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

Commit 14a8c482 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Show the keyguard on fold if flag softSleep is set

Guarded behind the fold grace period flag.

Bug: 308417021
Flag: ACONFIG com.android.internal.foldables.flags.fold_grace_period_enabled DEVELOPMENT
Test: atest PowerManagerServiceTest
Test: manual (adb root && adb shell setprop persist.fold_grace_period_enabled true && adb reboot)
Change-Id: I7ed49ca96a57ebd9dfc1556b1728ad1463b8b0fe
parent 77df401b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -4211,6 +4211,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return redoLayout;
    }

    /**
     * Shows the keyguard without immediately locking the device.
     */
    @Override
    public void showDismissibleKeyguard() {
        mKeyguardDelegate.showDismissibleKeyguard();
    }

    // There are several different flavors of "assistant" that can be launched from
    // various parts of the UI.

+6 −0
Original line number Diff line number Diff line
@@ -177,6 +177,12 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     */
    int applyKeyguardOcclusionChange();

    /**
     * Shows the keyguard immediately if not already shown.
     * Does NOT immediately request the device to lock.
     */
    void showDismissibleKeyguard();

    /**
     * Interface to the Window Manager state associated with a particular
     * window. You can hold on to an instance of this interface from the call
+9 −0
Original line number Diff line number Diff line
@@ -410,6 +410,15 @@ public class KeyguardServiceDelegate {
        }
    }

    /**
     * Request to show the keyguard immediately without immediately locking the device.
     */
    public void showDismissibleKeyguard() {
        if (mKeyguardService != null) {
            mKeyguardService.showDismissibleKeyguard();
        }
    }

    public void setCurrentUser(int newUserId) {
        if (mKeyguardService != null) {
            mKeyguardService.setCurrentUser(newUserId);
+5 −0
Original line number Diff line number Diff line
@@ -411,6 +411,11 @@ public class Notifier {
        mWakeLockLog.onWakeLockReleased(tag, ownerUid);
    }

    /** Shows the keyguard without requesting the device to immediately lock. */
    public void showDismissibleKeyguard() {
        mPolicy.showDismissibleKeyguard();
    }

    private int getBatteryStatsWakeLockMonitorType(int flags) {
        switch (flags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
            case PowerManager.PARTIAL_WAKE_LOCK:
+16 −2
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IBatteryStats;
import com.android.internal.display.BrightnessSynchronizer;
import com.android.internal.foldables.FoldGracePeriodProvider;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FrameworkStatsLog;
@@ -308,6 +309,7 @@ public final class PowerManagerService extends SystemService
    private final Context mContext;
    private final ServiceThread mHandlerThread;
    private final Handler mHandler;
    private final FoldGracePeriodProvider mFoldGracePeriodProvider;
    private final AmbientDisplayConfiguration mAmbientDisplayConfiguration;
    @Nullable
    private final BatterySaverStateMachine mBatterySaverStateMachine;
@@ -1007,6 +1009,10 @@ public final class PowerManagerService extends SystemService
            return new InattentiveSleepWarningController();
        }

        FoldGracePeriodProvider createFoldGracePeriodProvider() {
            return new FoldGracePeriodProvider();
        }

        public SystemPropertiesWrapper createSystemPropertiesWrapper() {
            return new SystemPropertiesWrapper() {
                @Override
@@ -1147,6 +1153,7 @@ public final class PowerManagerService extends SystemService
        mHandler = injector.createHandler(mHandlerThread.getLooper(),
                new PowerManagerHandlerCallback());
        mConstants = new Constants(mHandler);
        mFoldGracePeriodProvider = injector.createFoldGracePeriodProvider();
        mAmbientDisplayConfiguration = mInjector.createAmbientDisplayConfiguration(context);
        mAmbientDisplaySuppressionController =
                mInjector.createAmbientDisplaySuppressionController(
@@ -6933,10 +6940,17 @@ public final class PowerManagerService extends SystemService
                                + ") doesn't exist");
                    }
                    if ((flags & PowerManager.GO_TO_SLEEP_FLAG_SOFT_SLEEP) != 0) {
                        if (mFoldGracePeriodProvider.isEnabled()) {
                            if (!powerGroup.hasWakeLockKeepingScreenOnLocked()) {
                                mNotifier.showDismissibleKeyguard();
                            }
                            continue; // never actually goes to sleep for SOFT_SLEEP
                        } else {
                            if (powerGroup.hasWakeLockKeepingScreenOnLocked()) {
                                continue;
                            }
                        }
                    }
                    if (isNoDoze) {
                        sleepPowerGroupLocked(powerGroup, eventTime, reason, uid);
                    } else {
Loading