Pass keyguard occluded status in onAnimationCancelled.

Test: No visible changes yet. Pass existing tests.
Bug: 235463625
Change-Id: Iabee71bc76e19f20702f8a2739f565aa915f9b52
Merged-In: Iabee71bc76e19f20702f8a2739f565aa915f9b52
This commit is contained in:
Issei Suzuki
2022-06-16 15:24:40 +00:00
parent 41bcf6803e
commit c77d9bda04
19 changed files with 44 additions and 34 deletions

View File

@@ -46,5 +46,5 @@ oneway interface IRemoteAnimationRunner {
* won't have any effect anymore. * won't have any effect anymore.
*/ */
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
void onAnimationCancelled(); void onAnimationCancelled(boolean isKeyguardOccluded);
} }

View File

@@ -83,9 +83,9 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
if (TaskFragmentAnimationController.DEBUG) { if (TaskFragmentAnimationController.DEBUG) {
Log.v(TAG, "onAnimationCancelled"); Log.v(TAG, "onAnimationCancelled: isKeyguardOccluded=" + isKeyguardOccluded);
} }
mHandler.post(this::cancelAnimation); mHandler.post(this::cancelAnimation);
} }

View File

@@ -456,10 +456,10 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
onRemoteAnimationFinishedOrCancelled(evictWct); onRemoteAnimationFinishedOrCancelled(evictWct);
try { try {
adapter.getRunner().onAnimationCancelled(); adapter.getRunner().onAnimationCancelled(isKeyguardOccluded);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Error starting remote animation", e); Slog.e(TAG, "Error starting remote animation", e);
} }

View File

@@ -345,9 +345,9 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
try { try {
adapter.getRunner().onAnimationCancelled(); adapter.getRunner().onAnimationCancelled(isKeyguardOccluded);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Error starting remote animation", e); Slog.e(TAG, "Error starting remote animation", e);
} }

View File

@@ -107,7 +107,7 @@ public class LegacyTransitions {
} }
@Override @Override
public void onAnimationCancelled() throws RemoteException { public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
mCancelled = true; mCancelled = true;
mApps = mWallpapers = mNonApps = null; mApps = mWallpapers = mNonApps = null;
checkApply(); checkApply();

View File

@@ -596,7 +596,7 @@ class ActivityLaunchAnimator(
controller.onLaunchAnimationCancelled() controller.onLaunchAnimationCancelled()
} }
override fun onAnimationCancelled() { override fun onAnimationCancelled(isKeyguardOccluded: Boolean) {
if (timedOut) { if (timedOut) {
return return
} }

View File

@@ -105,7 +105,7 @@ public class RemoteAnimationAdapterCompat {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
remoteAnimationAdapter.onAnimationCancelled(); remoteAnimationAdapter.onAnimationCancelled();
} }
}; };

View File

@@ -220,7 +220,6 @@ public class KeyguardService extends Service {
public void mergeAnimation(IBinder transition, TransitionInfo info, public void mergeAnimation(IBinder transition, TransitionInfo info,
SurfaceControl.Transaction t, IBinder mergeTarget, SurfaceControl.Transaction t, IBinder mergeTarget,
IRemoteTransitionFinishedCallback finishCallback) { IRemoteTransitionFinishedCallback finishCallback) {
} }
}; };
} }
@@ -349,7 +348,7 @@ public class KeyguardService extends Service {
} }
@Override // Binder interface @Override // Binder interface
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
mKeyguardViewMediator.cancelKeyguardExitAnimation(); mKeyguardViewMediator.cancelKeyguardExitAnimation();
} }
}; };

View File

@@ -910,12 +910,12 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
private final Matrix mUnoccludeMatrix = new Matrix(); private final Matrix mUnoccludeMatrix = new Matrix();
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
if (mUnoccludeAnimator != null) { if (mUnoccludeAnimator != null) {
mUnoccludeAnimator.cancel(); mUnoccludeAnimator.cancel();
} }
setOccluded(false /* isOccluded */, false /* animate */); setOccluded(isKeyguardOccluded, false /* animate */);
Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: " Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: "
+ mOccluded); + mOccluded);
} }
@@ -3150,9 +3150,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
} }
@Override @Override
public void onAnimationCancelled() throws RemoteException { public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
if (mRunner != null) { if (mRunner != null) {
mRunner.onAnimationCancelled(); mRunner.onAnimationCancelled(isKeyguardOccluded);
} }
} }
@@ -3193,8 +3193,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
} }
@Override @Override
public void onAnimationCancelled() throws RemoteException { public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
super.onAnimationCancelled(); super.onAnimationCancelled(isKeyguardOccluded);
Log.d(TAG, "Occlude launch animation cancelled. Occluded state is now: " + mOccluded); Log.d(TAG, "Occlude launch animation cancelled. Occluded state is now: " + mOccluded);
} }
} }

View File

@@ -142,7 +142,7 @@ public class ScreenshotController {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
} }
}; };

View File

@@ -159,7 +159,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
@Test @Test
fun doesNotStartIfAnimationIsCancelled() { fun doesNotStartIfAnimationIsCancelled() {
val runner = activityLaunchAnimator.createRunner(controller) val runner = activityLaunchAnimator.createRunner(controller)
runner.onAnimationCancelled() runner.onAnimationCancelled(false /* isKeyguardOccluded */)
runner.onAnimationStart(0, emptyArray(), emptyArray(), emptyArray(), iCallback) runner.onAnimationStart(0, emptyArray(), emptyArray(), emptyArray(), iCallback)
waitForIdleSync() waitForIdleSync()

View File

@@ -6175,6 +6175,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
.getKeyguardController().isAodShowing(mDisplayId); .getKeyguardController().isAodShowing(mDisplayId);
} }
/**
* @return whether the keyguard is occluded on this display
*/
boolean isKeyguardOccluded() {
return mRootWindowContainer.mTaskSupervisor
.getKeyguardController().isDisplayOccluded(mDisplayId);
}
@VisibleForTesting @VisibleForTesting
void removeAllTasks() { void removeAllTasks() {
forAllTasks((t) -> { t.getRootTask().removeChild(t, "removeAllTasks"); }); forAllTasks((t) -> { t.getRootTask().removeChild(t, "removeAllTasks"); });

View File

@@ -316,8 +316,10 @@ class RemoteAnimationController implements DeathRecipient {
private void invokeAnimationCancelled(String reason) { private void invokeAnimationCancelled(String reason) {
ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "cancelAnimation(): reason=%s", reason); ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "cancelAnimation(): reason=%s", reason);
final boolean isKeyguardOccluded = mDisplayContent.isKeyguardOccluded();
try { try {
mRemoteAnimationAdapter.getRunner().onAnimationCancelled(); mRemoteAnimationAdapter.getRunner().onAnimationCancelled(isKeyguardOccluded);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Failed to notify cancel", e); Slog.e(TAG, "Failed to notify cancel", e);
} }

View File

@@ -779,7 +779,7 @@ public class ActivityRecordTests extends WindowTestsBase {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
} }
}, 0, 0)); }, 0, 0));
activity.updateOptionsLocked(opts); activity.updateOptionsLocked(opts);

View File

@@ -87,7 +87,7 @@ public class AppChangeTransitionTests extends WindowTestsBase {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
} }
@Override @Override

View File

@@ -777,7 +777,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
} }
@Override @Override
public void onAnimationCancelled() throws RemoteException { public void onAnimationCancelled(boolean isKeyguardOccluded) throws RemoteException {
mFinishedCallback = null; mFinishedCallback = null;
} }

View File

@@ -522,7 +522,7 @@ public class AppTransitionTests extends WindowTestsBase {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
mCancelled = true; mCancelled = true;
} }

View File

@@ -43,6 +43,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
@@ -168,7 +169,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN);
adapter.onAnimationCancelled(mMockLeash); adapter.onAnimationCancelled(mMockLeash);
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
} }
@Test @Test
@@ -183,7 +184,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mClock.fastForward(10500); mClock.fastForward(10500);
mHandler.timeAdvance(); mHandler.timeAdvance();
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION),
eq(adapter)); eq(adapter));
} }
@@ -204,12 +205,12 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
mClock.fastForward(10500); mClock.fastForward(10500);
mHandler.timeAdvance(); mHandler.timeAdvance();
verify(mMockRunner, never()).onAnimationCancelled(); verify(mMockRunner, never()).onAnimationCancelled(anyBoolean());
mClock.fastForward(52500); mClock.fastForward(52500);
mHandler.timeAdvance(); mHandler.timeAdvance();
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION),
eq(adapter)); eq(adapter));
} finally { } finally {
@@ -221,7 +222,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
public void testZeroAnimations() throws Exception { public void testZeroAnimations() throws Exception {
mController.goodToGo(TRANSIT_OLD_NONE); mController.goodToGo(TRANSIT_OLD_NONE);
verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any());
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
} }
@Test @Test
@@ -231,7 +232,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
new Point(50, 100), null, new Rect(50, 100, 150, 150), null); new Point(50, 100), null, new Rect(50, 100, 150, 150), null);
mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN);
verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any());
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
} }
@Test @Test
@@ -271,7 +272,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
win.mActivityRecord.removeImmediately(); win.mActivityRecord.removeImmediately();
mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN);
verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any());
verify(mMockRunner).onAnimationCancelled(); verify(mMockRunner).onAnimationCancelled(anyBoolean());
verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION),
eq(adapter)); eq(adapter));
} }
@@ -527,7 +528,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
// Cancel the wallpaper window animator and ensure the runner is not canceled // Cancel the wallpaper window animator and ensure the runner is not canceled
wallpaperWindowToken.cancelAnimation(); wallpaperWindowToken.cancelAnimation();
verify(mMockRunner, never()).onAnimationCancelled(); verify(mMockRunner, never()).onAnimationCancelled(anyBoolean());
} finally { } finally {
mDisplayContent.mOpeningApps.clear(); mDisplayContent.mOpeningApps.clear();
} }

View File

@@ -979,7 +979,7 @@ public class WindowContainerTests extends WindowTestsBase {
} }
@Override @Override
public void onAnimationCancelled() { public void onAnimationCancelled(boolean isKeyguardOccluded) {
} }
}, 0, 0, false); }, 0, 0, false);
adapter.setCallingPidUid(123, 456); adapter.setCallingPidUid(123, 456);