diff options
| author | Charles Chen <charlesccchen@google.com> | 2021-08-16 21:37:56 +0800 |
|---|---|---|
| committer | Charles Chen <charlesccchen@google.com> | 2021-08-17 10:22:46 +0800 |
| commit | eff3dfe44341582e8eea7cc75b1c9c9fc34d55c6 (patch) | |
| tree | 6d8e3bd06e91b399a3390fb99c68d70317b48c45 /core/java/android | |
| parent | 103c305438fe8e508955b41e3a50bbf12784a8d6 (diff) | |
Fix NPE in testWindowContextAddMismatchedWindowType
fixes: 196781957
Test: atest WindowContextPolicyTests
Change-Id: If0f8e124f3ee7939bf1e121d6d73616ff07e0829
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 5 | ||||
| -rw-r--r-- | core/java/android/window/WindowProviderService.java | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 20ecaf599921..a2d3e3447354 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -24,7 +24,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; -import static android.window.WindowProvider.KEY_IS_WINDOW_PROVIDER_SERVICE; +import static android.window.WindowProviderService.isWindowProviderService; import android.annotation.CallbackExecutor; import android.annotation.NonNull; @@ -177,8 +177,7 @@ public final class WindowManagerImpl implements WindowManager { + " Please create another Window Context via" + " createWindowContext(getDisplay(), " + windowType + ", null)" + " to add window with type:" + windowType); - if (!windowProvider.getWindowContextOptions().getBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, - false)) { + if (!isWindowProviderService(windowProvider.getWindowContextOptions())) { throw exception; } // Throw IncorrectCorrectViolation if the Window Context is allowed to provide multiple diff --git a/core/java/android/window/WindowProviderService.java b/core/java/android/window/WindowProviderService.java index 033b9eda9da4..f8484d15344e 100644 --- a/core/java/android/window/WindowProviderService.java +++ b/core/java/android/window/WindowProviderService.java @@ -55,6 +55,19 @@ public abstract class WindowProviderService extends Service implements WindowPro private WindowManager mWindowManager; private boolean mInitialized; + /** + * Returns {@code true} if the {@code windowContextOptions} declares that it is a + * {@link WindowProviderService}. + * + * @hide + */ + public static boolean isWindowProviderService(@Nullable Bundle windowContextOptions) { + if (windowContextOptions == null) { + return false; + } + return (windowContextOptions.getBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, false)); + } + public WindowProviderService() { mOptions = new Bundle(); mOptions.putBoolean(KEY_IS_WINDOW_PROVIDER_SERVICE, true); |
