diff options
| author | 2017-05-12 10:37:16 -0700 | |
|---|---|---|
| committer | 2017-05-12 10:41:59 -0700 | |
| commit | 027f4753bcdbef5a830ed877f974701727e98d19 (patch) | |
| tree | 436a6b2976c659f184e7798f06616a0c1fe6b46a | |
| parent | 34bc4af8109b1221305036a528324b8d754b501f (diff) | |
Fixed exceptions during test tearDown
- Acquire WM lock when tearing down test. Prevent the handler thread
from modifying state at the same time.
- Don't set surface boundaries on window states without a surface
control.
- Avoid exception if process can read screen-edge-insets for Pip.
Change-Id: If4a2438032866eaec84ed79c30c1d716e0f89758
Fixes: 38113905
Test: this is it!
3 files changed, 25 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java index 82416ec513c4..fc4ec2889523 100644 --- a/services/core/java/com/android/server/wm/PinnedStackController.java +++ b/services/core/java/com/android/server/wm/PinnedStackController.java @@ -158,19 +158,23 @@ class PinnedStackController { /** * Reloads all the resources for the current configuration. */ - void reloadResources() { + private void reloadResources() { final Resources res = mService.mContext.getResources(); mMinSize = res.getDimensionPixelSize( com.android.internal.R.dimen.default_minimal_size_pip_resizable_task); mDefaultAspectRatio = res.getFloat( com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio); - final Size screenEdgeInsetsDp = Size.parseSize(res.getString( - com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets)); + final String screenEdgeInsetsDpString = res.getString( + com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets); + final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty() + ? Size.parseSize(screenEdgeInsetsDpString) + : null; mDefaultStackGravity = res.getInteger( com.android.internal.R.integer.config_defaultPictureInPictureGravity); mDisplayContent.getDisplay().getRealMetrics(mTmpMetrics); - mScreenEdgeInsets = new Point(dpToPx(screenEdgeInsetsDp.getWidth(), mTmpMetrics), - dpToPx(screenEdgeInsetsDp.getHeight(), mTmpMetrics)); + mScreenEdgeInsets = screenEdgeInsetsDp == null ? new Point() + : new Point(dpToPx(screenEdgeInsetsDp.getWidth(), mTmpMetrics), + dpToPx(screenEdgeInsetsDp.getHeight(), mTmpMetrics)); mMinAspectRatio = res.getFloat( com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); mMaxAspectRatio = res.getFloat( diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index a6b95d635ba7..6cb4ddc14969 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1310,6 +1310,10 @@ class WindowStateAnimator { } void setSurfaceBoundariesLocked(final boolean recoveringMemory) { + if (mSurfaceController == null) { + return; + } + final WindowState w = mWin; final LayoutParams attrs = mWin.getAttrs(); final Task task = w.getTask(); diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java index 0167654d92b1..32eee84200ba 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java @@ -120,18 +120,21 @@ class WindowTestsBase { @After public void tearDown() throws Exception { final LinkedList<WindowState> nonCommonWindows = new LinkedList(); - sWm.mRoot.forAllWindows(w -> { - if (!mCommonWindows.contains(w)) { - nonCommonWindows.addLast(w); + + synchronized (sWm.mWindowMap) { + sWm.mRoot.forAllWindows(w -> { + if (!mCommonWindows.contains(w)) { + nonCommonWindows.addLast(w); + } + }, true /* traverseTopToBottom */); + + while (!nonCommonWindows.isEmpty()) { + nonCommonWindows.pollLast().removeImmediately(); } - }, true /* traverseTopToBottom */); - while (!nonCommonWindows.isEmpty()) { - nonCommonWindows.pollLast().removeImmediately(); + mDisplayContent.removeImmediately(); + sWm.mInputMethodTarget = null; } - - mDisplayContent.removeImmediately(); - sWm.mInputMethodTarget = null; } private WindowState createCommonWindow(WindowState parent, int type, String name) { |