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

Commit 1d545216 authored by Julia Tuttle's avatar Julia Tuttle Committed by Android (Google) Code Review
Browse files

Merge "StatusBarRemoteInputCallback: simplify onStateChanged" into main

parents 747ee9cc 3ab73e99
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -728,20 +728,23 @@ public class StatusBarStateControllerImpl implements
        // doesn't work well for clients of this class (like remote input) that expect the device to
        // be fully and properly unlocked when the state changes to SHADE.
        //
        // Therefore, we calculate the device to be in a locked-ish state (KEYGUARD or SHADE_LOCKED,
        // Therefore, we consider the device to be in a keyguardish state (KEYGUARD or SHADE_LOCKED,
        // but not SHADE) if *any* of these are still true:
        // 1. deviceUnlockStatus.isUnlocked is false.
        // 2. We are on (currentScene equals) a locked-ish scene (Lockscreen, Bouncer, or Communal).
        // 3. We are over (backStack contains) a locked-ish scene (Lockscreen or Communal).
        // 2. currentScene is a keyguardish scene (Lockscreen, Bouncer, or Communal).
        // 3. backStack contains a keyguardish scene (Lockscreen or Communal).

        final boolean onKeyguardish = onLockscreen || onBouncer || onCommunal;
        final boolean overKeyguardish = overLockscreen || overCommunal;

        if (isOccluded) {
            // Occlusion is special; even though the device is still technically on the lockscreen,
            // the UI behaves as if it is unlocked.
            newState = StatusBarState.SHADE;
        } else if (onLockscreen || onBouncer || onCommunal || overLockscreen || overCommunal) {
            // We get here if we are on or over a locked-ish scene, even if isUnlocked is true; we
        } else if (onKeyguardish || overKeyguardish) {
            // We get here if we are on or over a keyguardish scene, even if isUnlocked is true; we
            // want to return SHADE_LOCKED or KEYGUARD until we are also neither on nor over a
            // locked-ish scene.
            // keyguardish scene.
            if (onShade || onQuickSettings || overShade || overlaidShade || overlaidQuickSettings) {
                newState = StatusBarState.SHADE_LOCKED;
            } else {
@@ -751,7 +754,7 @@ public class StatusBarStateControllerImpl implements
            newState = StatusBarState.SHADE;
        } else if (onShade || onQuickSettings) {
            // We get here if deviceUnlockStatus.isUnlocked is false but we are no longer on or over
            // a locked-ish scene; we want to return SHADE_LOCKED until isUnlocked is also true.
            // a keyguardish scene; we want to return SHADE_LOCKED until isUnlocked is also true.
            newState = StatusBarState.SHADE_LOCKED;
        } else {
            throw new IllegalArgumentException(
+15 −10
Original line number Diff line number Diff line
@@ -117,18 +117,15 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks,

    @Override
    public void onStateChanged(int state) {
        boolean hasPendingRemoteInput = mPendingRemoteInputView != null;
        if (state == StatusBarState.SHADE
                && (mStatusBarStateController.leaveOpenOnKeyguardHide() || hasPendingRemoteInput)) {
            if (!mStatusBarStateController.isKeyguardRequested()
                    && mKeyguardStateController.isUnlocked()) {
                if (hasPendingRemoteInput) {
                    mExecutor.execute(mPendingRemoteInputView::callOnClick);
        if (mPendingRemoteInputView == null) {
            return;
        }

        if (state == StatusBarState.SHADE && canRetryPendingRemoteInput()) {
            mExecutor.execute(mPendingRemoteInputView::callOnClick);
            mPendingRemoteInputView = null;
        }
    }
    }

    @Override
    public void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
@@ -320,6 +317,14 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks,
        }
    }

    /**
     * Returns {@code true} if it is safe to retry a pending remote input.
     */
    private boolean canRetryPendingRemoteInput() {
        return mKeyguardStateController.isUnlocked()
                && !mStatusBarStateController.isKeyguardRequested();
    }

    protected class ChallengeReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {