From 401f78e822898f8cec9f9cbf50e570e9972c006e Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 16 Jun 2017 10:52:40 -0700 Subject: [PATCH 1/2] Fixing issue with PiP aspect ratio being clobbered. - We should only initialize the initial aspect ratio to the default aspect ratio once, instead of when the resources are reloaded. Otherwise, they will be clobbered when the configuration changes. This is a regression from ag/2295004. Bug: 62702553 Test: Set PiP aspect ratio from landscape-locked activity, ensure that it stays in that aspect ratio after the pip menu dismisses. Change-Id: Id82f9081c25c7d6482cf7bcf0268fedb9068eabe --- .../java/com/android/server/wm/PinnedStackController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java index 9a9e29a7eb888..6d33ce2941bc0 100644 --- a/services/core/java/com/android/server/wm/PinnedStackController.java +++ b/services/core/java/com/android/server/wm/PinnedStackController.java @@ -155,6 +155,10 @@ class PinnedStackController { mSnapAlgorithm = new PipSnapAlgorithm(service.mContext); mDisplayInfo.copyFrom(mDisplayContent.getDisplayInfo()); reloadResources(); + // Initialize the aspect ratio to the default aspect ratio. Don't do this in reload + // resources as it would clobber mAspectRatio when entering PiP from fullscreen which + // triggers a configuration change and the resources to be reloaded. + mAspectRatio = mDefaultAspectRatio; } void onConfigurationChanged() { @@ -171,7 +175,6 @@ class PinnedStackController { mCurrentMinSize = mDefaultMinSize; mDefaultAspectRatio = res.getFloat( com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio); - mAspectRatio = mDefaultAspectRatio; final String screenEdgeInsetsDpString = res.getString( com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets); final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty() From 06b50ab4b9d8b5ea9076ae71a08bfe8d90c4cdfc Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 16 Jun 2017 11:07:29 -0700 Subject: [PATCH 2/2] Fix backwards flag causing crash. Bug: 62692677 Test: Use an activity options that requires the bitmap copy, ensure that it does not crash. Change-Id: I20bdab1b91dfe47f7fe134fd17fe104eb4b27ec1 --- core/java/android/app/ActivityOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index cbb93a059613f..6dead3e6c0dc2 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -1244,7 +1244,7 @@ public class ActivityOptions { // Once we parcel the thumbnail for transfering over to the system, create a copy of // the bitmap to a hardware bitmap and pass through the GraphicBuffer if (mThumbnail != null) { - final Bitmap hwBitmap = mThumbnail.copy(Config.HARDWARE, true /* immutable */); + final Bitmap hwBitmap = mThumbnail.copy(Config.HARDWARE, false /* isMutable */); if (hwBitmap != null) { b.putParcelable(KEY_ANIM_THUMBNAIL, hwBitmap.createGraphicBufferHandle()); } else {