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

Commit 4e1aba61 authored by Selim Cinek's avatar Selim Cinek Committed by Automerger Merge Worker
Browse files

Merge "Adds the ScreenOffAnimationController, which fixes multiple issues with...

Merge "Adds the ScreenOffAnimationController, which fixes multiple issues with unlocked screen off." into sc-dev am: df773665 am: 4cee06e8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14737509

Change-Id: I19497216d13bf18529074ebf46d289b3e8e91b0c
parents dbe3811e 4cee06e8
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -63,8 +63,10 @@ oneway interface IKeyguardService {


     * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the reason we're waking up,
     * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the reason we're waking up,
     * such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE.
     * such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE.
     * @param cameraGestureTriggered Whether we're waking up due to a power button double tap
     * gesture.
     */
     */
    void onStartedWakingUp(int pmWakeReason);
    void onStartedWakingUp(int pmWakeReason,  boolean cameraGestureTriggered);


    /**
    /**
     * Called when the device has finished waking up.
     * Called when the device has finished waking up.
+21 −18
Original line number Original line Diff line number Diff line
@@ -107,6 +107,21 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
        }
        }
    };
    };


    private final StatusBarStateController.StateListener mStatusBarStatePersistentListener =
            new StatusBarStateController.StateListener() {
                @Override
                public void onDozeAmountChanged(float linear, float eased) {
                    boolean noAnimation = (mDozeAmount == 0f && linear == 1f)
                            || (mDozeAmount == 1f && linear == 0f);
                    boolean isDozing = linear > mDozeAmount;
                    mDozeAmount = linear;
                    if (mIsDozing != isDozing) {
                        mIsDozing = isDozing;
                        mView.animateDoze(mIsDozing, !noAnimation);
                    }
                }
            };

    private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
    private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
            new KeyguardUpdateMonitorCallback() {
        @Override
        @Override
@@ -133,14 +148,15 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
        updateLocale();
        updateLocale();
        mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver,
        mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver,
                new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
                new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
        mStatusBarStateController.addCallback(mStatusBarStateListener);

        mIsDozing = mStatusBarStateController.isDozing();
        mIsDozing = mStatusBarStateController.isDozing();
        mDozeAmount = mStatusBarStateController.getDozeAmount();
        mDozeAmount = mStatusBarStateController.getDozeAmount();
        mBatteryController.addCallback(mBatteryCallback);
        mBatteryController.addCallback(mBatteryCallback);
        mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback);
        mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback);
        mKeyguardShowing = true;
        mKeyguardShowing = true;


        mStatusBarStateController.removeCallback(mStatusBarStatePersistentListener);
        mStatusBarStateController.addCallback(mStatusBarStatePersistentListener);

        refreshTime();
        refreshTime();
        initColors();
        initColors();
        mView.animateDoze(mIsDozing, false);
        mView.animateDoze(mIsDozing, false);
@@ -149,9 +165,11 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
    @Override
    @Override
    protected void onViewDetached() {
    protected void onViewDetached() {
        mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver);
        mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver);
        mStatusBarStateController.removeCallback(mStatusBarStateListener);
        mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
        mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
        mBatteryController.removeCallback(mBatteryCallback);
        mBatteryController.removeCallback(mBatteryCallback);
        if (!mView.isAttachedToWindow()) {
            mStatusBarStateController.removeCallback(mStatusBarStatePersistentListener);
        }
    }
    }


    /** Animate the clock appearance */
    /** Animate the clock appearance */
@@ -199,19 +217,4 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
        mView.setColors(mDozingColor, mLockScreenColor);
        mView.setColors(mDozingColor, mLockScreenColor);
        mView.animateDoze(mIsDozing, false);
        mView.animateDoze(mIsDozing, false);
    }
    }

    private final StatusBarStateController.StateListener mStatusBarStateListener =
            new StatusBarStateController.StateListener() {
                @Override
                public void onDozeAmountChanged(float linear, float eased) {
                    boolean noAnimation = (mDozeAmount == 0f && linear == 1f)
                            || (mDozeAmount == 1f && linear == 0f);
                    boolean isDozing = linear > mDozeAmount;
                    mDozeAmount = linear;
                    if (mIsDozing != isDozing) {
                        mIsDozing = isDozing;
                        mView.animateDoze(mIsDozing, !noAnimation);
                    }
                }
            };
}
}
+4 −9
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.ViewController;
@@ -66,7 +67,8 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
            ConfigurationController configurationController,
            ConfigurationController configurationController,
            DozeParameters dozeParameters,
            DozeParameters dozeParameters,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            SmartspaceTransitionController smartspaceTransitionController) {
            SmartspaceTransitionController smartspaceTransitionController,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
        super(keyguardStatusView);
        super(keyguardStatusView);
        mKeyguardSliceViewController = keyguardSliceViewController;
        mKeyguardSliceViewController = keyguardSliceViewController;
        mKeyguardClockSwitchController = keyguardClockSwitchController;
        mKeyguardClockSwitchController = keyguardClockSwitchController;
@@ -75,7 +77,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
        mDozeParameters = dozeParameters;
        mDozeParameters = dozeParameters;
        mKeyguardStateController = keyguardStateController;
        mKeyguardStateController = keyguardStateController;
        mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController,
        mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController,
                dozeParameters);
                dozeParameters, unlockedScreenOffAnimationController);
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mSmartspaceTransitionController = smartspaceTransitionController;
        mSmartspaceTransitionController = smartspaceTransitionController;


@@ -237,13 +239,6 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
                animate);
                animate);
    }
    }


    /**
     * @return {@code true} if we are currently animating the screen off from unlock
     */
    public boolean isAnimatingScreenOffFromUnlocked() {
        return mKeyguardVisibilityHelper.isAnimatingScreenOffFromUnlocked();
    }

    /**
    /**
     * Set the visibility of the keyguard status view based on some new state.
     * Set the visibility of the keyguard status view based on some new state.
     */
     */
+13 −35
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.KeyguardStateController;


/**
/**
@@ -38,16 +39,19 @@ public class KeyguardVisibilityHelper {
    private View mView;
    private View mView;
    private final KeyguardStateController mKeyguardStateController;
    private final KeyguardStateController mKeyguardStateController;
    private final DozeParameters mDozeParameters;
    private final DozeParameters mDozeParameters;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private boolean mKeyguardViewVisibilityAnimating;
    private boolean mKeyguardViewVisibilityAnimating;
    private boolean mLastOccludedState = false;
    private boolean mLastOccludedState = false;
    private boolean mAnimatingScreenOff;
    private final AnimationProperties mAnimationProperties = new AnimationProperties();
    private final AnimationProperties mAnimationProperties = new AnimationProperties();


    public KeyguardVisibilityHelper(View view, KeyguardStateController keyguardStateController,
    public KeyguardVisibilityHelper(View view,
            DozeParameters dozeParameters) {
            KeyguardStateController keyguardStateController,
            DozeParameters dozeParameters,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
        mView = view;
        mView = view;
        mKeyguardStateController = keyguardStateController;
        mKeyguardStateController = keyguardStateController;
        mDozeParameters = dozeParameters;
        mDozeParameters = dozeParameters;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
    }
    }


    public boolean isVisibilityAnimating() {
    public boolean isVisibilityAnimating() {
@@ -122,32 +126,14 @@ public class KeyguardVisibilityHelper {
                        .alpha(1f)
                        .alpha(1f)
                        .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable)
                        .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable)
                        .start();
                        .start();
            } else if (mDozeParameters.shouldControlUnlockedScreenOff()) {
            } else if (mUnlockedScreenOffAnimationController
                        .isScreenOffLightRevealAnimationPlaying()) {
                mKeyguardViewVisibilityAnimating = true;
                mKeyguardViewVisibilityAnimating = true;
                mAnimatingScreenOff = true;

                mView.setVisibility(View.VISIBLE);
                mView.setAlpha(0f);
                float currentY = mView.getY();
                mView.setY(currentY - mView.getHeight() * 0.1f);
                int duration = StackStateAnimator.ANIMATION_DURATION_WAKEUP;
                int delay = (int) (duration * .6f);
                // We animate the Y properly separately using the PropertyAnimator, as the panel
                // view als needs to update the end position.
                mAnimationProperties.setDuration(duration).setDelay(delay);
                PropertyAnimator.cancelAnimation(mView, AnimatableProperty.Y);
                PropertyAnimator.setProperty(mView, AnimatableProperty.Y, currentY,
                        mAnimationProperties,
                        true /* animate */);

                mView.animate()
                        .setStartDelay(delay)
                        .setDuration(duration)
                        .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                        .alpha(1f)
                        .withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable)
                        .start();


                // Ask the screen off animation controller to animate the keyguard visibility for us
                // since it may need to be cancelled due to keyguard lifecycle events.
                mUnlockedScreenOffAnimationController.animateInKeyguard(
                        mView, mAnimateKeyguardStatusViewVisibleEndRunnable);
            } else {
            } else {
                mView.setVisibility(View.VISIBLE);
                mView.setVisibility(View.VISIBLE);
                mView.setAlpha(1f);
                mView.setAlpha(1f);
@@ -172,13 +158,5 @@ public class KeyguardVisibilityHelper {


    private final Runnable mAnimateKeyguardStatusViewVisibleEndRunnable = () -> {
    private final Runnable mAnimateKeyguardStatusViewVisibleEndRunnable = () -> {
        mKeyguardViewVisibilityAnimating = false;
        mKeyguardViewVisibilityAnimating = false;
        mAnimatingScreenOff = false;
    };
    };

    /**
     * @return {@code true} if we are currently animating the screen off from unlock
     */
    public boolean isAnimatingScreenOffFromUnlocked() {
        return mAnimatingScreenOff;
    }
}
}
+3 −2
Original line number Original line Diff line number Diff line
@@ -232,10 +232,11 @@ public class KeyguardService extends Service {
        }
        }


        @Override // Binder interface
        @Override // Binder interface
        public void onStartedWakingUp(@PowerManager.WakeReason int pmWakeReason) {
        public void onStartedWakingUp(
                @PowerManager.WakeReason int pmWakeReason, boolean cameraGestureTriggered) {
            Trace.beginSection("KeyguardService.mBinder#onStartedWakingUp");
            Trace.beginSection("KeyguardService.mBinder#onStartedWakingUp");
            checkPermission();
            checkPermission();
            mKeyguardViewMediator.onStartedWakingUp();
            mKeyguardViewMediator.onStartedWakingUp(cameraGestureTriggered);
            mKeyguardLifecyclesDispatcher.dispatch(
            mKeyguardLifecyclesDispatcher.dispatch(
                    KeyguardLifecyclesDispatcher.STARTED_WAKING_UP, pmWakeReason);
                    KeyguardLifecyclesDispatcher.STARTED_WAKING_UP, pmWakeReason);
            Trace.endSection();
            Trace.endSection();
Loading