Merge "Fixed exceptions during test tearDown" into oc-dev
diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java
index 82416ec..fc4ec28 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 @@
/**
* 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 a6b95d6..6cb4ddc 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 @@
}
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 0167654..32eee84 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 @@
@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) {