OSDN Git Service

Enable Always On mode by default.
authorMichael Wright <michaelwr@google.com>
Wed, 10 May 2017 18:49:06 +0000 (19:49 +0100)
committerMichael Wright <michaelwr@google.com>
Wed, 10 May 2017 20:47:47 +0000 (21:47 +0100)
Also, add a config value for always on display availability.

Test: runtest -x tests/src/com/android/systemui/doze
Change-Id: Id5e0136a5bed0eac78ad48147b0bef8311b06986

core/java/com/android/internal/hardware/AmbientDisplayConfiguration.java
core/res/res/values/config.xml
core/res/res/values/symbols.xml
packages/SystemUI/res/xml/tuner_prefs.xml
packages/SystemUI/tests/src/com/android/systemui/doze/DozeConfigurationTest.java

index c6cb837..00fa711 100644 (file)
@@ -20,6 +20,7 @@ import com.android.internal.R;
 
 import android.content.Context;
 import android.os.Build;
+import android.os.SystemProperties;
 import android.provider.Settings;
 import android.text.TextUtils;
 
@@ -75,13 +76,13 @@ public class AmbientDisplayConfiguration {
     }
 
     public boolean alwaysOnEnabled(int user) {
-        return boolSettingDefaultOff(Settings.Secure.DOZE_ALWAYS_ON, user)
+        return boolSettingDefaultOn(Settings.Secure.DOZE_ALWAYS_ON, user)
                 && alwaysOnAvailable();
     }
 
     public boolean alwaysOnAvailable() {
-        // TODO: introduce config_dozeAlwaysOnAvailable. For now just debuggable builds.
-        return Build.IS_DEBUGGABLE && ambientDisplayAvailable();
+        return (alwaysOnDisplayDebuggingEnabled() || alwaysOnDisplayAvailable())
+                && ambientDisplayAvailable();
     }
 
     public String ambientDisplayComponent() {
@@ -92,6 +93,15 @@ public class AmbientDisplayConfiguration {
         return !TextUtils.isEmpty(ambientDisplayComponent());
     }
 
+    private boolean alwaysOnDisplayAvailable() {
+        return mContext.getResources().getBoolean(R.bool.config_dozeAlwaysOnDisplayAvailable);
+    }
+
+    private boolean alwaysOnDisplayDebuggingEnabled() {
+        return SystemProperties.getBoolean("debug.doze.aod", false) && Build.IS_DEBUGGABLE;
+    }
+
+
     private boolean boolSettingDefaultOn(String name, int user) {
         return boolSetting(name, user, 1);
     }
index 5abc47d..c76c666 100644 (file)
     <!-- Type of the double tap sensor. Empty if double tap is not supported. -->
     <string name="config_dozeDoubleTapSensorType" translatable="false"></string>
 
+    <!-- Control whether the always on display mode is available. This should only be enabled on
+         devices where the display has be tuned to be power efficient in DOZE and/or DOZE_SUSPEND
+         states. -->
+    <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool>
+
     <!-- Power Management: Specifies whether to decouple the auto-suspend state of the
          device from the display on/off state.
 
index c688414..3ee4325 100644 (file)
 
   <!-- ETWS primary messages -->
   <java-symbol type="string" name="etws_primary_default_message_earthquake" />
-
   <java-symbol type="string" name="etws_primary_default_message_tsunami" />
-
   <java-symbol type="string" name="etws_primary_default_message_earthquake_and_tsunami" />
-
   <java-symbol type="string" name="etws_primary_default_message_test" />
-
   <java-symbol type="string" name="etws_primary_default_message_others" />
 
   <java-symbol type="bool" name="config_quickSettingsSupported" />
   <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" />
 
   <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" />
+
+  <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />
 </resources>
index 24f29c8..0c92274 100644 (file)
         <com.android.systemui.tuner.TunerSwitch
           android:key="doze_always_on"
           android:title="@string/tuner_doze_always_on"
-          sysui:defValue="false" />
+          sysui:defValue="true" />
 
     </PreferenceScreen>
 
index bbe324d..64507be 100644 (file)
@@ -16,7 +16,7 @@
 
 package com.android.systemui.doze;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import android.os.UserHandle;
 import android.provider.Settings;
@@ -42,7 +42,7 @@ public class DozeConfigurationTest extends SysuiTestCase {
     }
 
     @Test
-    public void alwaysOn_offByDefault() throws Exception {
+    public void alwaysOn_onByDefault() throws Exception {
         if (!mDozeConfig.alwaysOnAvailable()) {
             return;
         }
@@ -50,6 +50,6 @@ public class DozeConfigurationTest extends SysuiTestCase {
         Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DOZE_ALWAYS_ON,
                 null);
 
-        assertFalse(mDozeConfig.alwaysOnEnabled(UserHandle.USER_CURRENT));
+        assertTrue(mDozeConfig.alwaysOnEnabled(UserHandle.USER_CURRENT));
     }
 }