diff options
author | Graciela Wissen Putri <gracielawputri@google.com> | 2023-05-02 15:32:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-06-16 16:14:04 +0000 |
commit | 78d22dcf5d0479b62b542d1892d88f2725b59174 (patch) | |
tree | 994ad0526a7f03df11ee6ef2317039e4d18071bc | |
parent | f8494143e3944e4d46eb1f8d651663989db1b8fb (diff) | |
download | base-78d22dcf5d0479b62b542d1892d88f2725b59174.tar.gz |
Send update config change when letterbox is moved
When letterbox is repositioned, window configuration bounds are changed.
Because we currently only report public config changes in
diffPublicOnly, the client doesn't report changes in window
configuration.
We should always report window configuration bounds change to notify
that the position of window has changed.
Bug: 262900133
Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest
Manual test with app in bug
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:70187af25ce3f56f85ddd703f982caa82f685605)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2d435949ef08a2219feb23dba035f5a78b038f3f)
Merged-In: I9fc10876c03933ac8aac05205d56ad6537df72a8
Change-Id: I9fc10876c03933ac8aac05205d56ad6537df72a8
-rw-r--r-- | core/java/android/app/ActivityThread.java | 6 | ||||
-rw-r--r-- | core/java/android/window/ConfigurationHelper.java | 2 | ||||
-rw-r--r-- | core/tests/coretests/src/android/app/activity/ActivityThreadTest.java | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 5985d6e93107..10ca8990f2ff 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -36,6 +36,7 @@ import static android.view.Display.INVALID_DISPLAY; import static android.window.ConfigurationHelper.freeTextLayoutCachesIfNeeded; import static android.window.ConfigurationHelper.isDifferentDisplay; import static android.window.ConfigurationHelper.shouldUpdateResources; +import static android.window.ConfigurationHelper.shouldUpdateWindowMetricsBounds; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; @@ -5987,6 +5988,11 @@ public final class ActivityThread extends ClientTransactionHandler public static boolean shouldReportChange(@Nullable Configuration currentConfig, @NonNull Configuration newConfig, @Nullable SizeConfigurationBuckets sizeBuckets, int handledConfigChanges) { + // Always report changes in window configuration bounds + if (shouldUpdateWindowMetricsBounds(currentConfig, newConfig)) { + return true; + } + final int publicDiff = currentConfig.diffPublicOnly(newConfig); // Don't report the change if there's no public diff between current and new config. if (publicDiff == 0) { diff --git a/core/java/android/window/ConfigurationHelper.java b/core/java/android/window/ConfigurationHelper.java index e32adcf23a3b..269ce083d205 100644 --- a/core/java/android/window/ConfigurationHelper.java +++ b/core/java/android/window/ConfigurationHelper.java @@ -106,7 +106,7 @@ public class ConfigurationHelper { * @see WindowManager#getCurrentWindowMetrics() * @see WindowManager#getMaximumWindowMetrics() */ - private static boolean shouldUpdateWindowMetricsBounds(@NonNull Configuration currentConfig, + public static boolean shouldUpdateWindowMetricsBounds(@NonNull Configuration currentConfig, @NonNull Configuration newConfig) { final Rect currentBounds = currentConfig.windowConfiguration.getBounds(); final Rect newBounds = newConfig.windowConfiguration.getBounds(); diff --git a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java index 984ba584953a..1e1fca1ed0f4 100644 --- a/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java +++ b/core/tests/coretests/src/android/app/activity/ActivityThreadTest.java @@ -351,10 +351,8 @@ public class ActivityThreadTest { final Rect bounds = activity.getWindowManager().getCurrentWindowMetrics().getBounds(); assertEquals(activityConfigPortrait.windowConfiguration.getBounds(), bounds); - // Ensure that Activity#onConfigurationChanged() not be called because the changes in - // WindowConfiguration shouldn't be reported, and we only apply the latest Configuration - // update in transaction. - assertEquals(numOfConfig, activity.mNumOfConfigChanges); + // Ensure changes in window configuration bounds are reported + assertEquals(numOfConfig + 1, activity.mNumOfConfigChanges); } @Test |