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/content/Context.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/java/android/content/Context.java') diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 2fe935e35735..e21a31e5e185 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -6103,4 +6103,13 @@ public abstract class Context { + "get a UI context from ActivityThread#getSystemUiContext()"); } } + + /** + * Indicates if this context is a visual context such as {@link android.app.Activity} or + * a context created from {@link #createWindowContext(int, Bundle)}. + * @hide + */ + public boolean isUiContext() { + throw new RuntimeException("Not implemented. Must override in a subclass."); + } } -- cgit v1.2.3