From f8494143e3944e4d46eb1f8d651663989db1b8fb Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Fri, 31 Mar 2023 00:09:56 +0000 Subject: Cancel current animation instead of candidate Otherwise everything along the way confidently ignores this and Keyguard doesn't even see the timeout and force-abort coming when it hits. This leaves an animation timer running for 950ms which sets occlude status on finish callback and causes unpleasant race conditions. Test: atest android.server.wm.KeyguardTests Test: specific case to be added in b/274003805 Bug: 275650364 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8ffedf11e398f9a6aa8b30cff5f06b102fd54536) Merged-In: I7b3dcd06e7483fde745a1d56dfee7c4efc262ed7 Change-Id: I7b3dcd06e7483fde745a1d56dfee7c4efc262ed7 --- .../com/android/systemui/keyguard/KeyguardService.java | 18 ++++++++---------- .../systemui/keyguard/KeyguardViewMediator.java | 13 +++++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index 4d40db0a0cfd..f1a8c95469f6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -260,22 +260,20 @@ public class KeyguardService extends Service { ); } - public void mergeAnimation(IBinder transition, TransitionInfo info, - SurfaceControl.Transaction t, IBinder mergeTarget, - IRemoteTransitionFinishedCallback finishCallback) { + public void mergeAnimation(IBinder candidateTransition, TransitionInfo candidateInfo, + SurfaceControl.Transaction candidateT, IBinder currentTransition, + IRemoteTransitionFinishedCallback candidateFinishCallback) { try { - final IRemoteTransitionFinishedCallback origFinishCB; + final IRemoteTransitionFinishedCallback currentFinishCB; synchronized (mFinishCallbacks) { - origFinishCB = mFinishCallbacks.remove(transition); + currentFinishCB = mFinishCallbacks.remove(currentTransition); } - info.releaseAllSurfaces(); - t.close(); - if (origFinishCB == null) { - // already finished (or not started yet), so do nothing. + if (currentFinishCB == null) { + Slog.e(TAG, "Called mergeAnimation, but finish callback is missing"); return; } runner.onAnimationCancelled(false /* isKeyguardOccluded */); - origFinishCB.onTransitionFinished(null /* wct */, null /* t */); + currentFinishCB.onTransitionFinished(null /* wct */, null /* t */); } catch (RemoteException e) { // nothing, we'll just let it finish on its own I guess. } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 82189763def6..d608abc3b008 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -958,10 +958,15 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, @Override public void onAnimationCancelled(boolean isKeyguardOccluded) { - if (mOccludeByDreamAnimator != null) { - mOccludeByDreamAnimator.cancel(); - } - setOccluded(isKeyguardOccluded /* isOccluded */, false /* animate */); + mContext.getMainExecutor().execute(() -> { + if (mOccludeByDreamAnimator != null) { + mOccludeByDreamAnimator.cancel(); + } + }); + // The value of isKeyguardOccluded here may come from mergeAnimation, which + // isn't reliable. In all cases, after running or cancelling this animation, + // keyguard should be occluded. + setOccluded(true /* isOccluded */, false /* animate */); if (DEBUG) { Log.d(TAG, "Occlude by Dream animation cancelled. Occluded state is now: " + mOccluded); -- cgit v1.2.3 From 78d22dcf5d0479b62b542d1892d88f2725b59174 Mon Sep 17 00:00:00 2001 From: Graciela Wissen Putri Date: Tue, 2 May 2023 15:32:24 +0000 Subject: 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 --- core/java/android/app/ActivityThread.java | 6 ++++++ core/java/android/window/ConfigurationHelper.java | 2 +- .../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 -- cgit v1.2.3 From 763420908229eabf49f66acac059fdd3b23c8972 Mon Sep 17 00:00:00 2001 From: Diego Vela Date: Fri, 5 May 2023 17:53:52 +0000 Subject: Report folding features to letterboxed apps. Folding features were filtered out from letterboxed apps because we assumed that letterboxed apps did not want to optimize. We have found apps do want to support folding features but may also request fixed orientation for their experience. We are removing the filter so that letterboxed apps will get folding feature information. Bug: 262900133 Test: Manual - open the samples and check if folding features report. (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3e428597423552cd806a9658c763ed3f7ffcbc2c) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:58855b37c9ba3cdf6e4885fd1ece41ffb4626a03) Merged-In: I427f0bc23f00d245c5093c75f13c9e533209362e Change-Id: I427f0bc23f00d245c5093c75f13c9e533209362e --- .../window/extensions/layout/WindowLayoutComponentImpl.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java index 8386131b177d..dd2d0ec57d54 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java @@ -381,24 +381,15 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { final Rect taskBounds = taskConfig.windowConfiguration.getBounds(); final WindowManager windowManager = Objects.requireNonNull( context.getSystemService(WindowManager.class)); - final Rect currentBounds = windowManager.getCurrentWindowMetrics().getBounds(); final Rect maxBounds = windowManager.getMaximumWindowMetrics().getBounds(); boolean isTaskExpanded = maxBounds.equals(taskBounds); - boolean isActivityExpanded = maxBounds.equals(currentBounds); /* * We need to proxy being in full screen because when a user enters PiP and exits PiP * the task windowingMode will report multi-window/pinned until the transition is * finished in WM Shell. * maxBounds == taskWindowBounds is a proxy check to verify the window is full screen - * For tasks that are letterboxed, we use currentBounds == maxBounds to filter these - * out. */ - // TODO(b/262900133) remove currentBounds check when letterboxed apps report bounds. - // currently we don't want to report to letterboxed apps since they do not update the - // window bounds when the Activity is moved. An inaccurate fold will be reported so - // we skip. - return isTaskExpanded && (isActivityExpanded - || mTaskFragmentOrganizer.isActivityEmbedded(activityToken)); + return isTaskExpanded; } else { // TODO(b/242674941): use task windowing mode for window context that associates with // activity. -- cgit v1.2.3