From 615928575a45e15d0583329bb99b39dc915b5e88 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Wed, 21 Sep 2022 08:48:40 +0000 Subject: [PATCH] Updating the cached resource configuration if ViewRoot is perserved When configuration changed, an Activity was relaunched because the new layout size is smaller than old layout size. However, the mLastConfigurationFromResources was not updated when relaunching Activity while the window is preserved. If the same Activity was resized to the previous bounds and the configuration changes are not cross the size buckets, the Activity won't be relaunched. Meanwhile, the View#onConfigurationChanged was not reported because `mLastConfigurationFromResources` was not update-to-date and was the same with the new configuration. Bug: 247013643 Test: resizing the app in split-screen Change-Id: I392417e1e6cc8bb5e8be0006b3b81385c3ef41aa --- core/java/android/view/ViewRootImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index e4caa385bc9b5..0e5016bbd3048 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1099,6 +1099,10 @@ public final class ViewRootImpl implements ViewParent, mInputQueueCallback.onInputQueueCreated(mInputQueue); } } + + // Update the last resource config in case the resource configuration was changed while + // activity relaunched. + mLastConfigurationFromResources.setTo(getConfiguration()); } private Configuration getConfiguration() {