summaryrefslogtreecommitdiff
path: root/test-mock
diff options
context:
space:
mode:
authorAndrii Kulian <akulian@google.com>2020-01-29 16:57:32 -0800
committerAndrii Kulian <akulian@google.com>2020-02-20 01:29:25 +0000
commit5877c7d6c083d1150f603e278229fd8a1d8dbb1b (patch)
tree92c6bd68369015b896b2766405aa861fefd06d93 /test-mock
parent5263c11a4c4ca45ab3fc9f5925218dcc760dec86 (diff)
Exempt-From-Owner-Approval: Report non-visual Context misuse
Make obtaining a visual service from non-visual Context instance report a strict mode violation and print the stacktrace. Make calling getDisplay() throw an exception if called on an instance that is not associated with a display. For existing usages introduce a new internal method that does not perform the verification until the usages are properly fixed. Bug: 128338354 Test: StrictModeTest#testIncorrectContextUse_GetSystemService Test: StrictModeTest#testIncorrectContextUse_GetDisplay Change-Id: Id25d590eca6e10066e55d7ed6436d3bc9e433beb
Diffstat (limited to 'test-mock')
-rw-r--r--test-mock/src/android/test/mock/MockContext.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/test-mock/src/android/test/mock/MockContext.java b/test-mock/src/android/test/mock/MockContext.java
index 359c44849634..2c6604759813 100644
--- a/test-mock/src/android/test/mock/MockContext.java
+++ b/test-mock/src/android/test/mock/MockContext.java
@@ -834,6 +834,12 @@ public class MockContext extends Context {
/** @hide */
@Override
+ public Display getDisplayNoVerify() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ @Override
public int getDisplayId() {
throw new UnsupportedOperationException();
}