From bfe1b70fcd3f3688bd27be317ee0830e80cc00fc Mon Sep 17 00:00:00 2001 From: Chris Li Date: Tue, 17 Mar 2020 10:12:24 -0700 Subject: Report incorrect context usage in ViewConfiguration Before, the documentation said that the passed context is an application context, which is incorrect to get the density, window metrics, and window manager. We should use visual context to get these instead. Bug: 151474461 Test: StrictModeTest#testIncorrectContextUse_GetViewConfiguration Change-Id: Iea28d727cafbb3ec8536742c6a0e594f73fe5a51 --- core/java/android/app/ContextImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'core/java/android/app/ContextImpl.java') diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 17fd4efec9cc..d8757c36374a 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1920,7 +1920,9 @@ class ContextImpl extends Context { return SystemServiceRegistry.getSystemServiceName(serviceClass); } - private boolean isUiContext() { + /** @hide */ + @Override + public boolean isUiContext() { return mIsSystemOrSystemUiContext || mIsUiContext || isSystemOrSystemUI(); } -- cgit v1.2.3