diff options
| author | Chris Li <lihongyu@google.com> | 2020-03-17 10:12:24 -0700 |
|---|---|---|
| committer | Chris Li <lihongyu@google.com> | 2020-03-26 22:09:28 -0700 |
| commit | bfe1b70fcd3f3688bd27be317ee0830e80cc00fc (patch) | |
| tree | 5a62b351c6731fd8e3111693b73b42f218e9ff23 /core/java/android/content/Context.java | |
| parent | 2279fd5f469d16da8e458f3bec6a1a072fc296f3 (diff) | |
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
Diffstat (limited to 'core/java/android/content/Context.java')
| -rw-r--r-- | core/java/android/content/Context.java | 9 |
1 files changed, 9 insertions, 0 deletions
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."); + } } |
