From 95813a4921022aa3da77cdc3b6e0429beaf09dcb Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Sat, 27 May 2023 15:37:15 +0000 Subject: [PATCH] Use CounterRotator for wallpaper animation targets when unlocking To avoid seeing the portrait wallpaper being placed on the Landscape display bounds without fiting the screen when unlocking keyguard in phone devices from Portrait to Landscape mode, Using CounterRotator to ensure the closing wallpaper orientation unchanged during transition animation for fixing this flicker case. See: http://recall/-/bN53iXCwu0DIehsmJlTyWk/craq03f8iJXcaFXGWR8mBM Bug: 283963801 Test: atest WMShellFlickerTests:UnlockKeyguardToSplitScreen \ --rerun-until failure 10 Test: manual by issue steps: 1) Launch apps to enter split-screen mode 2) Turn off/on the screen with power key to show the lockscreen 3) Rotate the device in landscape 4) Swipe up to dismiss the lockscreen 5) Expect the split-tasks animates fade-in without seeing a weird cross-fade out animation on top of the split-tasks Change-Id: I50550fd2a7fc488d743794fb1044dfe9d126521a --- .../keyguard/KeyguardTransitionHandler.java | 3 ++ .../UnlockKeyguardToSplitScreen.kt | 3 -- .../systemui/keyguard/KeyguardService.java | 41 +++++++++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java index 25e9401290817..25ecbc5989857 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java @@ -185,6 +185,9 @@ public class KeyguardTransitionHandler implements Transitions.TransitionHandler @Override public void onTransitionFinished( WindowContainerTransaction wct, SurfaceControl.Transaction sct) { + if (sct != null) { + finishTransaction.merge(sct); + } mMainExecutor.execute(() -> { mStartedTransitions.remove(transition); finishCallback.onTransitionFinished(wct, null); diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt index e0dbfa3853cc2..676c150815add 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/UnlockKeyguardToSplitScreen.kt @@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.splitscreen import android.platform.test.annotations.Postsubmit import android.tools.common.NavBar -import android.tools.common.Rotation import android.tools.common.flicker.subject.region.RegionSubject import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder @@ -105,8 +104,6 @@ class UnlockKeyguardToSplitScreen(override val flicker: FlickerTest) : @JvmStatic fun getParams(): List { return FlickerTestFactory.nonRotationTests( - // TODO(b/283963801) address entireScreenCovered test faliure in landscape. - supportedRotations = listOf(Rotation.ROTATION_0), supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index a8d22c48e7094..5a8c2253b185b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -29,6 +29,7 @@ import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE; import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE_BY_DREAM; import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_OLD_NONE; +import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TransitionFlags; import static android.view.WindowManager.TransitionOldType; import static android.view.WindowManager.TransitionType; @@ -49,6 +50,7 @@ import android.os.RemoteException; import android.os.Trace; import android.util.ArrayMap; import android.util.Log; +import android.util.RotationUtils; import android.util.Slog; import android.view.IRemoteAnimationFinishedCallback; import android.view.IRemoteAnimationRunner; @@ -73,6 +75,7 @@ import com.android.systemui.SystemUIApplication; import com.android.systemui.settings.DisplayTracker; import com.android.wm.shell.transition.ShellTransitions; import com.android.wm.shell.transition.Transitions; +import com.android.wm.shell.util.CounterRotator; import com.android.wm.shell.util.TransitionUtil; import java.util.ArrayList; @@ -103,7 +106,8 @@ public class KeyguardService extends Service { } private static RemoteAnimationTarget[] wrap(TransitionInfo info, boolean wallpapers, - SurfaceControl.Transaction t, ArrayMap leashMap) { + SurfaceControl.Transaction t, ArrayMap leashMap, + CounterRotator counterWallpaper) { final ArrayList out = new ArrayList<>(); for (int i = 0; i < info.getChanges().size(); i++) { boolean changeIsWallpaper = @@ -133,6 +137,25 @@ public class KeyguardService extends Service { (change.getFlags() & TransitionInfo.FLAG_SHOW_WALLPAPER) != 0, info, t, leashMap); + if (changeIsWallpaper) { + int rotateDelta = RotationUtils.deltaRotation(change.getStartRotation(), + change.getEndRotation()); + if (rotateDelta != 0 && change.getParent() != null + && change.getMode() == TRANSIT_TO_BACK) { + final TransitionInfo.Change parent = info.getChange(change.getParent()); + if (parent != null) { + float displayW = parent.getEndAbsBounds().width(); + float displayH = parent.getEndAbsBounds().height(); + counterWallpaper.setup(t, parent.getLeash(), rotateDelta, displayW, + displayH); + } + if (counterWallpaper.getSurface() != null) { + t.setLayer(counterWallpaper.getSurface(), -1); + counterWallpaper.addChild(t, leashMap.get(change.getLeash())); + } + } + } + out.add(target); } return out.toArray(new RemoteAnimationTarget[out.size()]); @@ -163,6 +186,8 @@ public class KeyguardService extends Service { return new IRemoteTransition.Stub() { private final ArrayMap mLeashMap = new ArrayMap<>(); + private final CounterRotator mCounterRotator = new CounterRotator(); + @GuardedBy("mLeashMap") private IRemoteTransitionFinishedCallback mFinishCallback = null; @@ -175,9 +200,9 @@ public class KeyguardService extends Service { synchronized (mLeashMap) { final RemoteAnimationTarget[] apps = - wrap(info, false /* wallpapers */, t, mLeashMap); + wrap(info, false /* wallpapers */, t, mLeashMap, mCounterRotator); final RemoteAnimationTarget[] wallpapers = - wrap(info, true /* wallpapers */, t, mLeashMap); + wrap(info, true /* wallpapers */, t, mLeashMap, mCounterRotator); final RemoteAnimationTarget[] nonApps = new RemoteAnimationTarget[0]; // Set alpha back to 1 for the independent changes because we will be animating @@ -231,11 +256,19 @@ public class KeyguardService extends Service { @GuardedBy("mLeashMap") private void finish() throws RemoteException { + SurfaceControl.Transaction finishTransaction = null; + if (mCounterRotator.getSurface() != null + && mCounterRotator.getSurface().isValid()) { + finishTransaction = new SurfaceControl.Transaction(); + mCounterRotator.cleanUp(finishTransaction); + } mLeashMap.clear(); final IRemoteTransitionFinishedCallback finishCallback = mFinishCallback; if (finishCallback != null) { mFinishCallback = null; - finishCallback.onTransitionFinished(null /* wct */, null /* t */); + finishCallback.onTransitionFinished(null /* wct */, finishTransaction); + } else if (finishTransaction != null) { + finishTransaction.apply(); } } };