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

Commit b025d156 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Refactor KeygaurdController using state machine

Bug: 242545520
Test: refactoring CL, existing tests pass
Change-Id: I3c0f031adb0fc3d7fbe5c3fb418bbff56914c9d5
parent a428d82f
Loading
Loading
Loading
Loading
+108 −0
Original line number Diff line number Diff line
@@ -627,6 +627,114 @@ public interface WindowManager extends ViewManager {
    })
    @interface DisplayImePolicy {}

    /**
     * The root state of all the state. This is an abstract state, and the keyguard should be in
     * one of this sub state.
     *
     * @hide
     */
    int KEYGUARD_STATE_ROOT = 0x0;

    /**
     * Keyguard is off, so activity can be shown on the screen.
     *
     * @hide
     */
    int KEYGUARD_STATE_OFF = 0x1;

    /**
     * The keyguard is off, but lock screen is still rendered on the screen. Waiting for
     * starting unlock animation.
     *
     * @hide
     */
    int KEYGUARD_STATE_GOING_AWAY = 0x11;

    /**
     * They keyguard is on, so normal activities cannot be shown on the screen. This is an abstract
     * state, and the keyguard should be in one of ths sub state.
     *
     * @hide
     */
    int KEYGUARD_STATE_ON = 0x2;

    /**
     * The keyguard is on and not occluded.
     * @hide
     */
    int KEYGUARD_STATE_KEYGUARD_TOP = 0x21;

    /**
     * The keyguard is on, and the lock screen is shown.
     *
     * @hide
     */
    int KEYGUARD_STATE_LOCKSCREEN_SHOWN = 0x211;

    /**
     * The keyguard is on, and the AOD is shown.
     *
     * @hide
     */
    int KEYGUARD_STATE_AOD_SHOWN = 0x212;

    /**
     * The keyguard is on but it's occluded by a normal SHOW_WHEN_LOCKED activity (i.e. non
     * occluded by Dream activity).
     *
     * @hide
     */
    int KEYGUARD_STATE_OCCLUDED = 0x22;

    /**
     * The keyguard is on but it's occluded by a Dream activity.
     *
     * @hide
     */
    int KEYGUARD_STATE_DREAMING = 0x221;

    /** @hide */
    @IntDef(prefix = { "KEYGUARD_STATE_" }, value = {
            KEYGUARD_STATE_ROOT,
            KEYGUARD_STATE_OFF,
            KEYGUARD_STATE_GOING_AWAY,
            KEYGUARD_STATE_ON,
            KEYGUARD_STATE_KEYGUARD_TOP,
            KEYGUARD_STATE_LOCKSCREEN_SHOWN,
            KEYGUARD_STATE_AOD_SHOWN,
            KEYGUARD_STATE_OCCLUDED,
            KEYGUARD_STATE_DREAMING,
    })
    @interface KeyguardState {}

    /**
     * @hide
     */
    static String keyguardStateToString(@KeyguardState int type) {
        switch (type) {
            case KEYGUARD_STATE_ROOT:
                return "ROOT";
            case KEYGUARD_STATE_OFF:
                return "KEYGUARD_OFF";
            case KEYGUARD_STATE_GOING_AWAY:
                return "KEYGUARD_GOING_AWAY";
            case KEYGUARD_STATE_ON:
                return "KEYGUARD_ON";
            case KEYGUARD_STATE_KEYGUARD_TOP:
                return "KEYGUARD_TOP";
            case KEYGUARD_STATE_LOCKSCREEN_SHOWN:
                return "KEYGUARD_LOCKSCREEN_SHOWN";
            case KEYGUARD_STATE_AOD_SHOWN:
                return "KEYGUARD_AOD_SHOWN";
            case KEYGUARD_STATE_OCCLUDED:
                return "KEYGUARD_OCCLUDED";
            case KEYGUARD_STATE_DREAMING:
                return "KEYGUARD_DREAMING";
            default:
                return "KEYGUARD_STATE_UNKNOWN(" + Integer.toHexString(type) + ")";
        }
    }

    /**
     * Exception that is thrown when trying to add view whose
     * {@link LayoutParams} {@link LayoutParams#token}
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ message KeyguardControllerProto {
    repeated KeyguardOccludedProto keyguard_occluded_states = 2 [deprecated=true];
    optional bool aod_showing = 3;
    repeated KeyguardPerDisplayProto keyguard_per_display = 4;
    optional bool keyguard_going_away = 5;
    optional bool keyguard_going_away = 5 [deprecated=true];
}

message KeyguardOccludedProto {
@@ -134,7 +134,7 @@ message KeyguardPerDisplayProto {
    optional bool keyguard_showing = 2;
    optional bool aod_showing = 3;
    optional bool keyguard_occluded = 4;
    optional bool keyguard_going_away = 5;
    optional bool keyguard_going_away = 5 [deprecated=true];
}

/* represents PhoneWindowManager */
+0 −3
Original line number Diff line number Diff line
@@ -3768,9 +3768,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private boolean setKeyguardOccludedLw(boolean isOccluded, boolean notify) {
        if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded);
        mKeyguardOccludedChanged = false;
        if (isKeyguardOccluded() == isOccluded) {
            return false;
        }
        mKeyguardDelegate.setOccluded(isOccluded, notify);
        return mKeyguardDelegate.isShowing();
    }
+1145 −527

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ class TransitionController {

    void dispatchLegacyAppTransitionStarting(TransitionInfo info, long statusBarTransitionDelay) {
        for (int i = 0; i < mLegacyListeners.size(); ++i) {
            // TODO(shell-transitions): handle (un)occlude transition.
            mLegacyListeners.get(i).onAppTransitionStartingLocked(info);
            mLegacyListeners.get(i).onAppTransitionStartingLocked(
                    SystemClock.uptimeMillis() + statusBarTransitionDelay,
                    AnimationAdapter.STATUS_BAR_TRANSITION_DURATION);
Loading