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

Commit 5dbd4aad authored by Jason Monk's avatar Jason Monk
Browse files

SysUI Tuner: Night mode v3

TwilightService:
 - Add support for locking on/off twilight globally
 - Change twilight state to have float amount rather than
   having clients calculate it using the sunrise/set values
 - State controlled through secure setting
 - Override mode which locks to a state for a couple hours then
   resets
 - Add broadcast for SysUI to listen to

Brightness/Power:
 - Updates to handle TwilightService changes
 - Added secure setting to control whether or not to use
   twilight when calculating brightness.

Tuner:
 - UI Overhall
 - NightModeController will set the values of the custom color matrix
   taking into account the current twilight service state and any
   custom calibration set by the user.
 - Probably other stuff.

Change-Id: I213f1f76a143e711c507b2ba7d784f581bfc32b4
parent 0f900c02
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@ public abstract class DisplayManagerInternal {
        public int dozeScreenBrightness;
        public int dozeScreenState;

        // If true, use twilight to affect the brightness.
        public boolean useTwilight;

        public DisplayPowerRequest() {
            policy = POLICY_BRIGHT;
            useProximitySensor = false;
@@ -242,6 +245,7 @@ public abstract class DisplayManagerInternal {
            boostScreenBrightness = other.boostScreenBrightness;
            dozeScreenBrightness = other.dozeScreenBrightness;
            dozeScreenState = other.dozeScreenState;
            useTwilight = other.useTwilight;
        }

        @Override
@@ -262,7 +266,8 @@ public abstract class DisplayManagerInternal {
                    && lowPowerMode == other.lowPowerMode
                    && boostScreenBrightness == other.boostScreenBrightness
                    && dozeScreenBrightness == other.dozeScreenBrightness
                    && dozeScreenState == other.dozeScreenState;
                    && dozeScreenState == other.dozeScreenState
                    && useTwilight == other.useTwilight;
        }

        @Override
@@ -282,7 +287,8 @@ public abstract class DisplayManagerInternal {
                    + ", lowPowerMode=" + lowPowerMode
                    + ", boostScreenBrightness=" + boostScreenBrightness
                    + ", dozeScreenBrightness=" + dozeScreenBrightness
                    + ", dozeScreenState=" + Display.stateToString(dozeScreenState);
                    + ", dozeScreenState=" + Display.stateToString(dozeScreenState)
                    + ", useTwilight=" + useTwilight;
        }

        public static String policyToString(int policy) {
+46 −0
Original line number Diff line number Diff line
@@ -5921,6 +5921,52 @@ public final class Settings {
        public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
                "camera_double_tap_power_gesture_disabled";

        /**

        /**
         * Behavior of twilight on the device.
         * One of {@link #TWILIGHT_MODE_LOCKED_OFF}, {@link #TWILIGHT_MODE_LOCKED_ON}
         * or {@link #TWILIGHT_MODE_AUTO}.
         * @hide
         */
        public static final String TWILIGHT_MODE = "twilight_mode";

        /**
         * Twilight mode always off.
         * @hide
         */
        public static final int TWILIGHT_MODE_LOCKED_OFF = 0;

        /**
         * Twilight mode always on.
         * @hide
         */
        public static final int TWILIGHT_MODE_LOCKED_ON = 1;

        /**
         * Twilight mode auto.
         * @hide
         */
        public static final int TWILIGHT_MODE_AUTO = 2;

        /**
         * Twilight mode auto, temporarily overriden to on.
         * @hide
         */
        public static final int TWILIGHT_MODE_AUTO_OVERRIDE_OFF = 3;

        /**
         * Twilight mode auto, temporarily overriden to off.
         * @hide
         */
        public static final int TWILIGHT_MODE_AUTO_OVERRIDE_ON = 4;

        /**
         * Whether brightness should automatically adjust based on twilight state.
         * @hide
         */
        public static final String BRIGHTNESS_USE_TWILIGHT = "brightness_use_twilight";

        /**
         * This are the settings to be backed up.
         *
+2 −0
Original line number Diff line number Diff line
@@ -452,6 +452,8 @@
    <protected-broadcast android:name="android.bluetooth.input.profile.action.HANDSHAKE" />
    <protected-broadcast android:name="android.bluetooth.input.profile.action.REPORT" />

    <protected-broadcast android:name="android.intent.action.TWILIGHT_CHANGED" />

    <!-- ====================================================================== -->
    <!--                          RUNTIME PERMISSIONS                           -->
    <!-- ====================================================================== -->
+1 −1
Original line number Diff line number Diff line
<!--
    Copyright (C) 2015 The Android Open Source Project
    Copyright (C) 2016 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
+24 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2016 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24.0dp"
        android:height="24.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#4DFFFFFF"
        android:pathData="M20.71,5.63l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0.0l-3.12,3.12 -1.93,-1.91 -1.41,1.41 1.42,1.42L3.0,16.25L3.0,21.0l4.75,0.0l8.92,-8.92 1.42,1.42 1.41,-1.41 -1.92,-1.92 3.12,-3.12c0.4,0.0 0.4,-1.0 0.01,-1.42zM6.92,19.0L5.0,17.08l8.06,-8.06 1.92,1.92L6.92,19.0z"/>
</vector>
Loading