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

Commit c6ac4dc9 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Add new power button behavior that asks keyguard to show the hub" into main

parents f309e40d e581b06f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ public abstract class DreamManagerInternal {
     */
    public abstract boolean canStartDreaming(boolean isScreenOn);

    /**
     * Whether or not the device is currently in the user's "when to dream" state, ex.
     * docked & charging.
     */
    public abstract boolean dreamConditionActive();

    /**
     * Register a {@link DreamManagerStateListener}, which will be called when there are changes to
     * dream state.
+3 −0
Original line number Diff line number Diff line
@@ -1214,6 +1214,9 @@
            3 - Really go to sleep and go home (don't doze)
            4 - Go to home
            5 - Dismiss IME if shown. Otherwise go to home
            6 - Lock if keyguard enabled or go to sleep (doze)
            7 - Dream if possible or go to sleep (doze)
            8 - Go to glanceable hub or dream if possible, or sleep if neither is available (doze)
    -->
    <integer name="config_shortPressOnPowerBehavior">1</integer>

+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public class GlobalSettingsValidators {
        VALIDATORS.put(Global.REQUIRE_PASSWORD_TO_DECRYPT, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.DEVICE_DEMO_MODE, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.AWARE_ALLOWED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.POWER_BUTTON_SHORT_PRESS, new InclusiveIntegerRangeValidator(0, 7));
        VALIDATORS.put(Global.POWER_BUTTON_SHORT_PRESS, new InclusiveIntegerRangeValidator(0, 8));
        VALIDATORS.put(Global.POWER_BUTTON_DOUBLE_PRESS, new InclusiveIntegerRangeValidator(0, 3));
        VALIDATORS.put(Global.POWER_BUTTON_TRIPLE_PRESS, new InclusiveIntegerRangeValidator(0, 3));
        VALIDATORS.put(Global.POWER_BUTTON_LONG_PRESS, new InclusiveIntegerRangeValidator(0, 5));
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class DreamViewModel
constructor(
    configurationInteractor: ConfigurationInteractor,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
    fromGlanceableHubTransitionInteractor: GlanceableHubToDreamingTransitionViewModel,
    fromGlanceableHubTransitionViewModel: GlanceableHubToDreamingTransitionViewModel,
    toGlanceableHubTransitionViewModel: DreamingToGlanceableHubTransitionViewModel,
    private val toLockscreenTransitionViewModel: DreamingToLockscreenTransitionViewModel,
    private val fromDreamingTransitionInteractor: FromDreamingTransitionInteractor,
@@ -74,7 +74,7 @@ constructor(
    val dreamOverlayTranslationX: Flow<Float> =
        merge(
                toGlanceableHubTransitionViewModel.dreamOverlayTranslationX,
                fromGlanceableHubTransitionInteractor.dreamOverlayTranslationX,
                fromGlanceableHubTransitionViewModel.dreamOverlayTranslationX,
            )
            .distinctUntilChanged()

@@ -97,7 +97,7 @@ constructor(
        merge(
                toLockscreenTransitionViewModel.dreamOverlayAlpha,
                toGlanceableHubTransitionViewModel.dreamOverlayAlpha,
                fromGlanceableHubTransitionInteractor.dreamOverlayAlpha,
                fromGlanceableHubTransitionViewModel.dreamOverlayAlpha,
            )
            .distinctUntilChanged()

+21 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import com.android.internal.jank.InteractionJankMonitor.Configuration;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.policy.IKeyguardStateCallback;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.statusbar.IStatusBarService;
@@ -139,6 +140,7 @@ import com.android.systemui.animation.ActivityTransitionAnimator;
import com.android.systemui.animation.TransitionAnimator;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor;
import com.android.systemui.communal.ui.viewmodel.CommunalTransitionViewModel;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
@@ -256,6 +258,15 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private static final String DELAYED_LOCK_PROFILE_ACTION =
            "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_LOCK";

    /**
     * String extra key passed in the bundle of {@link IKeyguardService#doKeyguardTimeout(Bundle)}
     * if the value is {@code true}, indicates to keyguard that the device should show the
     * glanceable hub upon locking. If the hub is already visible, the device should go to sleep.
     *
     * Mirrored from PhoneWindowManager which sends the extra.
     */
    public static final String EXTRA_TRIGGER_HUB = "extra_trigger_hub";

    private static final String SYSTEMUI_PERMISSION = "com.android.systemui.permission.SELF";

    // used for handler messages
@@ -354,6 +365,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private final ScreenOffAnimationController mScreenOffAnimationController;
    private final Lazy<NotificationShadeDepthController> mNotificationShadeDepthController;
    private final Lazy<ShadeController> mShadeController;
    private final Lazy<CommunalSceneInteractor> mCommunalSceneInteractor;
    /*
     * Records the user id on request to go away, for validation when WM calls back to start the
     * exit animation.
@@ -1556,6 +1568,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            SelectedUserInteractor selectedUserInteractor,
            KeyguardInteractor keyguardInteractor,
            KeyguardTransitionBootInteractor transitionBootInteractor,
            Lazy<CommunalSceneInteractor> communalSceneInteractor,
            WindowManagerOcclusionManager wmOcclusionManager) {
        mContext = context;
        mUserTracker = userTracker;
@@ -1597,6 +1610,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        mSelectedUserInteractor = selectedUserInteractor;
        mKeyguardInteractor = keyguardInteractor;
        mTransitionBootInteractor = transitionBootInteractor;
        mCommunalSceneInteractor = communalSceneInteractor;

        mStatusBarStateController = statusBarStateController;
        statusBarStateController.addCallback(this);
@@ -2411,6 +2425,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
     * Enable the keyguard if the settings are appropriate.
     */
    private void doKeyguardLocked(Bundle options) {
        // If the power button behavior requests to open the glanceable hub.
        if (options != null && options.getBoolean(EXTRA_TRIGGER_HUB)) {
            // Set the hub to show immediately when the SysUI window shows, then continue to lock
            // the device.
            mCommunalSceneInteractor.get().showHubFromPowerButton();
        }

        int currentUserId = mSelectedUserInteractor.getSelectedUserId();
        if (options != null && options.getBinder(LOCK_ON_USER_SWITCH_CALLBACK) != null) {
            LockNowCallback callback = new LockNowCallback(currentUserId,
Loading