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

Commit a4215ceb authored by John Spurlock's avatar John Spurlock
Browse files

Doze: Add a user opt-out setting.

When devices are configured with a doze component, the user
now has the option of disabling doze mode with a secure setting.

Bug:16703536
Change-Id: Ieab6ee8d2acf54580b86fb16e9d77b52080fb3b1
parent f6b0c2f3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4606,6 +4606,12 @@ public final class Settings {
         */
        public static final String WAKE_GESTURE_ENABLED = "wake_gesture_enabled";

        /**
         * Whether the device should doze if configured.
         * @hide
         */
        public static final String DOZE_ENABLED = "doze_enabled";

        /**
         * The current night mode that has been selected by the user.  Owned
         * and controlled by UiModeManagerService.  Constants are as per
+8 −2
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ public final class DreamManagerService extends SystemService {

    private ComponentName chooseDreamForUser(boolean doze, int userId) {
        if (doze) {
            ComponentName dozeComponent = getDozeComponent();
            ComponentName dozeComponent = getDozeComponent(userId);
            return validateDream(dozeComponent) ? dozeComponent : null;
        }
        ComponentName[] dreams = getDreamComponentsForUser(userId);
@@ -314,6 +314,10 @@ public final class DreamManagerService extends SystemService {
    }

    private ComponentName getDozeComponent() {
        return getDozeComponent(ActivityManager.getCurrentUser());
    }

    private ComponentName getDozeComponent(int userId) {
        // Read the component from a system property to facilitate debugging.
        // Note that for production devices, the dream should actually be declared in
        // a config.xml resource.
@@ -324,7 +328,9 @@ public final class DreamManagerService extends SystemService {
            name = mContext.getResources().getString(
                    com.android.internal.R.string.config_dozeComponent);
        }
        return TextUtils.isEmpty(name) ? null : ComponentName.unflattenFromString(name);
        boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.DOZE_ENABLED, 1, userId) != 0;
        return TextUtils.isEmpty(name) || !enabled ? null : ComponentName.unflattenFromString(name);
    }

    private ServiceInfo getServiceInfo(ComponentName name) {