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

Commit 3cc877a2 authored by Will Leshner's avatar Will Leshner
Browse files

Don't allow user to dream when not unlocked.

Bug: 262584382
Test: manually by rebooting device, docking, and then short pressing
power button. The device should be locked (which prevents dreaming), so
the screen should turn off rather than going to dream.

Change-Id: I6d194b6345d382991ae9d9016060df8edf5d48fe
parent ef1f84f5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.os.ShellCallback;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.dreams.DreamManagerInternal;
import android.service.dreams.DreamService;
@@ -113,6 +114,7 @@ public final class DreamManagerService extends SystemService {
    private final PowerManagerInternal mPowerManagerInternal;
    private final PowerManager.WakeLock mDozeWakeLock;
    private final ActivityTaskManagerInternal mAtmInternal;
    private final UserManager mUserManager;
    private final UiEventLogger mUiEventLogger;
    private final DreamUiEventLogger mDreamUiEventLogger;
    private final ComponentName mAmbientDisplayComponent;
@@ -212,6 +214,7 @@ public final class DreamManagerService extends SystemService {
        mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        mPowerManagerInternal = getLocalService(PowerManagerInternal.class);
        mAtmInternal = getLocalService(ActivityTaskManagerInternal.class);
        mUserManager = context.getSystemService(UserManager.class);
        mDozeWakeLock = mPowerManager.newWakeLock(PowerManager.DOZE_WAKE_LOCK, DOZE_WAKE_LOCK_TAG);
        mDozeConfig = new AmbientDisplayConfiguration(mContext);
        mUiEventLogger = new UiEventLoggerImpl();
@@ -383,6 +386,10 @@ public final class DreamManagerService extends SystemService {
                return false;
            }

            if (!mUserManager.isUserUnlocked()) {
                return false;
            }

            if ((mWhenToDream & DREAM_ON_CHARGE) == DREAM_ON_CHARGE) {
                return mIsCharging;
            }