Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ceb0988 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Extend property to enable remote animation for keyguard.

There are two types of keyguard invovlved app transitions. Instead of
enabling / disabling remote animation for all such transitions, we can
now enable remote animation one by one.

Disable remote animation for all keyguard transitions.
% adb shell setprop persist.wm.enable_remote_keyguard_animation 0

Enable remote animation only for keyguard going away transition
(default).
% adb shell setprop persist.wm.enable_remote_keyguard_animation 1

Enable remote animation for both keyguard going away and (un)occlude
transition.
% adb shell setprop persist.wm.enable_remote_keyguard_animation 2

After setting the property, you need to restart shell and sysui, or reboot
the device.

Test: No-op chaneg. Pass existing tests.
Bug: 166736690
Change-Id: I81cf31fe60583f0fe0d9f46c3189fc0309e8374f
parent 271c6006
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.systemui.SystemUIApplication;
import com.android.wm.shell.transition.Transitions;

import javax.inject.Inject;

@@ -62,16 +63,29 @@ public class KeyguardService extends Service {
     * Run Keyguard animation as remote animation in System UI instead of local animation in
     * the server process.
     *
     * 0: Runs all keyguard animation as local animation
     * 1: Only runs keyguard going away animation as remote animation
     * 2: Runs all keyguard animation as remote animation
     *
     * Note: Must be consistent with WindowManagerService.
     */
    private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY =
            "persist.wm.enable_remote_keyguard_animation";

    private static final int sEnableRemoteKeyguardAnimation =
            SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 0);

    /**
     * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
     */
    public static boolean sEnableRemoteKeyguardAnimation =
            SystemProperties.getBoolean(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, false);
    public static boolean sEnableRemoteKeyguardGoingAwayAnimation =
            !Transitions.ENABLE_SHELL_TRANSITIONS && sEnableRemoteKeyguardAnimation >= 1;

    /**
     * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY
     */
    public static boolean sEnableRemoteKeyguardOccludeAnimation =
            !Transitions.ENABLE_SHELL_TRANSITIONS && sEnableRemoteKeyguardAnimation >= 2;

    private final KeyguardViewMediator mKeyguardViewMediator;
    private final KeyguardLifecyclesDispatcher mKeyguardLifecyclesDispatcher;
@@ -83,21 +97,23 @@ public class KeyguardService extends Service {
        mKeyguardViewMediator = keyguardViewMediator;
        mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher;

        if (sEnableRemoteKeyguardAnimation) {
        RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
        if (sEnableRemoteKeyguardGoingAwayAnimation) {
            final RemoteAnimationAdapter exitAnimationAdapter =
                    new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0);
            definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, exitAnimationAdapter);
            definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
                    exitAnimationAdapter);
        }
        if (sEnableRemoteKeyguardOccludeAnimation) {
            final RemoteAnimationAdapter occludeAnimationAdapter =
                    new RemoteAnimationAdapter(mOccludeAnimationRunner, 0, 0);
            definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE, occludeAnimationAdapter);
            definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE, occludeAnimationAdapter);
        }
        ActivityTaskManager.getInstance().registerRemoteAnimationsForDisplay(
                DEFAULT_DISPLAY, definition);
    }
    }

    @Override
    public void onCreate() {
+1 −1
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ class KeyguardUnlockAnimationController @Inject constructor(
    }

    override fun onKeyguardDismissAmountChanged() {
        if (!KeyguardService.sEnableRemoteKeyguardAnimation) {
        if (!KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation) {
            return
        }

+2 −2
Original line number Diff line number Diff line
@@ -2180,7 +2180,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
            IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner;
            mKeyguardExitAnimationRunner = null;

            if (KeyguardService.sEnableRemoteKeyguardAnimation && runner != null
            if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation && runner != null
                    && finishedCallback != null) {
                // Wrap finishedCallback to clean up the keyguard state once the animation is done.
                IRemoteAnimationFinishedCallback callback =
@@ -2211,7 +2211,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,

            // When remaining on the shade, there's no need to do a fancy remote animation,
            // it will dismiss the panel in that case.
            } else if (KeyguardService.sEnableRemoteKeyguardAnimation
            } else if (KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
                    && !mStatusBarStateController.leaveOpenOnKeyguardHide()
                    && apps != null && apps.length > 0) {
                mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback;
+1 −1
Original line number Diff line number Diff line
@@ -2101,7 +2101,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        // launches as they can break the animation.
        // TODO(b/184121838): Support non activity launches on the lockscreen.
        return isActivityIntent
                && KeyguardService.sEnableRemoteKeyguardAnimation
                && KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
                && mKeyguardStateController.canDismissLockScreen();
    }

+1 −1
Original line number Diff line number Diff line
@@ -3044,7 +3044,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private int handleStartTransitionForKeyguardLw(boolean keyguardGoingAway, long duration) {
        final int res = applyKeyguardOcclusionChange();
        if (res != 0) return res;
        if (!WindowManagerService.sEnableRemoteKeyguardAnimation && keyguardGoingAway) {
        if (!WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation && keyguardGoingAway) {
            if (DEBUG_KEYGUARD) Slog.d(TAG, "Starting keyguard exit animation");
            startKeyguardExitAnimation(SystemClock.uptimeMillis(), duration);
        }
Loading