summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2014-08-23 00:23:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-23 00:23:45 +0000
commita96a3c1b65acd2b54a15fe98964208fa00ded96a (patch)
tree1700b2d6dacb532a3c6ecea5bc176b55a1408fd1
parentd7761be23d30b5e9ca9c07998af27e704d2a7ae2 (diff)
parent1bfd0f463e279e3ac3f133c5e0ad11ccfd73eed5 (diff)
downloadframeworks_base-a96a3c1b65acd2b54a15fe98964208fa00ded96a.zip
frameworks_base-a96a3c1b65acd2b54a15fe98964208fa00ded96a.tar.gz
frameworks_base-a96a3c1b65acd2b54a15fe98964208fa00ded96a.tar.bz2
Merge changes I9bd3a235,I9c4dbdef into lmp-dev
* changes: Improve adaptive brightness in very dark rooms. Hide PowerManager methods that third-party apps can't use.
-rw-r--r--api/current.txt3
-rw-r--r--api/removed.txt10
-rw-r--r--core/java/android/os/PowerManager.java32
-rw-r--r--core/res/res/values/config.xml53
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java37
6 files changed, 103 insertions, 33 deletions
diff --git a/api/current.txt b/api/current.txt
index 62f3adb..fc39cba 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22465,15 +22465,12 @@ package android.os {
}
public final class PowerManager {
- method public void goToSleep(long);
method public boolean isInteractive();
method public boolean isPowerSaveMode();
method public deprecated boolean isScreenOn();
method public boolean isWakeLockLevelSupported(int);
method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
method public void reboot(java.lang.String);
- method public void userActivity(long, boolean);
- method public void wakeUp(long);
field public static final int ACQUIRE_CAUSES_WAKEUP = 268435456; // 0x10000000
field public static final java.lang.String ACTION_POWER_SAVE_MODE_CHANGED = "android.os.action.POWER_SAVE_MODE_CHANGED";
field public static final deprecated int FULL_WAKE_LOCK = 26; // 0x1a
diff --git a/api/removed.txt b/api/removed.txt
index 465a18d..93484de 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -6,6 +6,16 @@ package android.media {
}
+package android.os {
+
+ public final class PowerManager {
+ method public void goToSleep(long);
+ method public deprecated void userActivity(long, boolean);
+ method public void wakeUp(long);
+ }
+
+}
+
package android.view {
public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 4b206e3..f7b0ead 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -521,7 +521,11 @@ public final class PowerManager {
*
* @see #wakeUp
* @see #goToSleep
+ *
+ * @removed Requires signature or system permission.
+ * @deprecated Use {@link #userActivity(long, int, int)}.
*/
+ @Deprecated
public void userActivity(long when, boolean noChangeLights) {
userActivity(when, USER_ACTIVITY_EVENT_OTHER,
noChangeLights ? USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS : 0);
@@ -575,13 +579,33 @@ public final class PowerManager {
*
* @see #userActivity
* @see #wakeUp
+ *
+ * @removed Requires signature permission.
*/
public void goToSleep(long time) {
goToSleep(time, GO_TO_SLEEP_REASON_APPLICATION, 0);
}
/**
- * @hide
+ * Forces the device to go to sleep.
+ * <p>
+ * Overrides all the wake locks that are held.
+ * This is what happens when the power key is pressed to turn off the screen.
+ * </p><p>
+ * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
+ * </p>
+ *
+ * @param time The time when the request to go to sleep was issued, in the
+ * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
+ * order the go to sleep request with other power management functions. It should be set
+ * to the timestamp of the input event that caused the request to go to sleep.
+ * @param reason The reason the device is going to sleep.
+ * @param flags Optional flags to apply when going to sleep.
+ *
+ * @see #userActivity
+ * @see #wakeUp
+ *
+ * @hide Requires signature permission.
*/
public void goToSleep(long time, int reason, int flags) {
try {
@@ -606,6 +630,8 @@ public final class PowerManager {
*
* @see #userActivity
* @see #goToSleep
+ *
+ * @removed Requires signature permission.
*/
public void wakeUp(long time) {
try {
@@ -633,7 +659,7 @@ public final class PowerManager {
* @see #wakeUp
* @see #goToSleep
*
- * @hide
+ * @hide Requires signature permission.
*/
public void nap(long time) {
try {
@@ -650,7 +676,7 @@ public final class PowerManager {
*
* @param brightness The brightness value from 0 to 255.
*
- * {@hide}
+ * @hide Requires signature permission.
*/
public void setBacklightBrightness(int brightness) {
try {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index c6478ab..4f0757c 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -673,6 +673,37 @@
-->
<integer name="config_doubleTapOnHomeBehavior">0</integer>
+ <!-- Minimum screen brightness setting allowed by the power manager.
+ The user is forbidden from setting the brightness below this level. -->
+ <integer name="config_screenBrightnessSettingMinimum">10</integer>
+
+ <!-- Maximum screen brightness allowed by the power manager.
+ The user is forbidden from setting the brightness above this level. -->
+ <integer name="config_screenBrightnessSettingMaximum">255</integer>
+
+ <!-- Default screen brightness setting.
+ Must be in the range specified by minimum and maximum. -->
+ <integer name="config_screenBrightnessSettingDefault">102</integer>
+
+ <!-- Screen brightness used to dim the screen while dozing in a very low power state.
+ May be less than the minimum allowed brightness setting
+ that can be set by the user. -->
+ <integer name="config_screenBrightnessDoze">1</integer>
+
+ <!-- Screen brightness used to dim the screen when the user activity
+ timeout expires. May be less than the minimum allowed brightness setting
+ that can be set by the user. -->
+ <integer name="config_screenBrightnessDim">10</integer>
+
+ <!-- Minimum allowable screen brightness to use in a very dark room.
+ This value sets the floor for the darkest possible auto-brightness
+ adjustment. It is expected to be somewhat less than the first entry in
+ config_autoBrightnessLcdBacklightValues so as to allow the user to have
+ some range of adjustment to dim the screen further than usual in very
+ dark rooms. The contents of the screen must still be clearly visible
+ in darkness (although they may not be visible in a bright room). -->
+ <integer name="config_screenBrightnessDark">1</integer>
+
<!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
The N entries of this array define N + 1 control points as follows:
(1-based arrays)
@@ -696,28 +727,6 @@
<integer-array name="config_autoBrightnessLevels">
</integer-array>
- <!-- Minimum screen brightness setting allowed by the power manager.
- The user is forbidden from setting the brightness below this level. -->
- <integer name="config_screenBrightnessSettingMinimum">10</integer>
-
- <!-- Maximum screen brightness allowed by the power manager.
- The user is forbidden from setting the brightness above this level. -->
- <integer name="config_screenBrightnessSettingMaximum">255</integer>
-
- <!-- Default screen brightness setting.
- Must be in the range specified by minimum and maximum. -->
- <integer name="config_screenBrightnessSettingDefault">102</integer>
-
- <!-- Screen brightness used to dim the screen while dozing in a very low power state.
- May be less than the minimum allowed brightness setting
- that can be set by the user. -->
- <integer name="config_screenBrightnessDoze">1</integer>
-
- <!-- Screen brightness used to dim the screen when the user activity
- timeout expires. May be less than the minimum allowed brightness setting
- that can be set by the user. -->
- <integer name="config_screenBrightnessDim">10</integer>
-
<!-- Array of output values for LCD backlight corresponding to the LUX values
in the config_autoBrightnessLevels array. This array should have size one greater
than the size of the config_autoBrightnessLevels array.
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index cdaa887..3f373aa 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1565,6 +1565,7 @@
<java-symbol type="integer" name="config_screenBrightnessSettingMinimum" />
<java-symbol type="integer" name="config_screenBrightnessSettingMaximum" />
<java-symbol type="integer" name="config_screenBrightnessSettingDefault" />
+ <java-symbol type="integer" name="config_screenBrightnessDark" />
<java-symbol type="integer" name="config_screenBrightnessDim" />
<java-symbol type="integer" name="config_screenBrightnessDoze" />
<java-symbol type="integer" name="config_shutdownBatteryTemperature" />
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 2a1ceaa..38077eb 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -139,6 +139,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// The dim screen brightness.
private final int mScreenBrightnessDimConfig;
+ // The minimum screen brightness to use in a very dark room.
+ private final int mScreenBrightnessDarkConfig;
+
// The minimum allowed brightness.
private final int mScreenBrightnessRangeMinimum;
@@ -247,6 +250,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mContext = context;
final Resources resources = context.getResources();
+ final int screenBrightnessSettingMinimum = clampAbsoluteBrightness(resources.getInteger(
+ com.android.internal.R.integer.config_screenBrightnessSettingMinimum));
mScreenBrightnessDozeConfig = clampAbsoluteBrightness(resources.getInteger(
com.android.internal.R.integer.config_screenBrightnessDoze));
@@ -254,9 +259,23 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mScreenBrightnessDimConfig = clampAbsoluteBrightness(resources.getInteger(
com.android.internal.R.integer.config_screenBrightnessDim));
- int screenBrightnessRangeMinimum = clampAbsoluteBrightness(Math.min(resources.getInteger(
- com.android.internal.R.integer.config_screenBrightnessSettingMinimum),
- mScreenBrightnessDimConfig));
+ mScreenBrightnessDarkConfig = clampAbsoluteBrightness(resources.getInteger(
+ com.android.internal.R.integer.config_screenBrightnessDark));
+ if (mScreenBrightnessDarkConfig > mScreenBrightnessDimConfig) {
+ Slog.w(TAG, "Expected config_screenBrightnessDark ("
+ + mScreenBrightnessDarkConfig + ") to be less than or equal to "
+ + "config_screenBrightnessDim (" + mScreenBrightnessDimConfig + ").");
+ }
+ if (mScreenBrightnessDarkConfig > mScreenBrightnessDimConfig) {
+ Slog.w(TAG, "Expected config_screenBrightnessDark ("
+ + mScreenBrightnessDarkConfig + ") to be less than or equal to "
+ + "config_screenBrightnessSettingMinimum ("
+ + screenBrightnessSettingMinimum + ").");
+ }
+
+ int screenBrightnessRangeMinimum = Math.min(Math.min(
+ screenBrightnessSettingMinimum, mScreenBrightnessDimConfig),
+ mScreenBrightnessDarkConfig);
mScreenBrightnessRangeMaximum = PowerManager.BRIGHTNESS_ON;
@@ -280,8 +299,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
+ "Auto-brightness will be disabled.");
mUseSoftwareAutoBrightnessConfig = false;
} else {
- if (screenBrightness[0] < screenBrightnessRangeMinimum) {
- screenBrightnessRangeMinimum = clampAbsoluteBrightness(screenBrightness[0]);
+ int bottom = clampAbsoluteBrightness(screenBrightness[0]);
+ if (mScreenBrightnessDarkConfig > bottom) {
+ Slog.w(TAG, "config_screenBrightnessDark (" + mScreenBrightnessDarkConfig
+ + ") should be less than or equal to the first value of "
+ + "config_autoBrightnessLcdBacklightValues ("
+ + bottom + ").");
+ }
+ if (bottom < screenBrightnessRangeMinimum) {
+ screenBrightnessRangeMinimum = bottom;
}
mAutomaticBrightnessController = new AutomaticBrightnessController(this,
handler.getLooper(), sensorManager, screenAutoBrightnessSpline,
@@ -905,6 +931,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
pw.println("Display Power Controller Configuration:");
pw.println(" mScreenBrightnessDozeConfig=" + mScreenBrightnessDozeConfig);
pw.println(" mScreenBrightnessDimConfig=" + mScreenBrightnessDimConfig);
+ pw.println(" mScreenBrightnessDarkConfig=" + mScreenBrightnessDarkConfig);
pw.println(" mScreenBrightnessRangeMinimum=" + mScreenBrightnessRangeMinimum);
pw.println(" mScreenBrightnessRangeMaximum=" + mScreenBrightnessRangeMaximum);
pw.println(" mUseSoftwareAutoBrightnessConfig="