am 21b7e6de: am c831b978: Merge "Add isScreenBrightnessBoosted and a broadcast when underlying value changes." into lmp-mr1-modular-dev
* commit '21b7e6de94b1e4d0bbe2f1a13ac19f491ff466ed': Add isScreenBrightnessBoosted and a broadcast when underlying value changes.
This commit is contained in:
@@ -23738,6 +23738,7 @@ package android.os {
|
||||
public final class PowerManager {
|
||||
method public boolean isInteractive();
|
||||
method public boolean isPowerSaveMode();
|
||||
method public boolean isScreenBrightnessBoosted();
|
||||
method public deprecated boolean isScreenOn();
|
||||
method public boolean isWakeLockLevelSupported(int);
|
||||
method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
|
||||
@@ -23745,6 +23746,7 @@ package android.os {
|
||||
method public void userActivity(long, int, int);
|
||||
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 java.lang.String ACTION_SCREEN_BRIGHTNESS_BOOST_CHANGED = "android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED";
|
||||
field public static final deprecated int FULL_WAKE_LOCK = 26; // 0x1a
|
||||
field public static final int ON_AFTER_RELEASE = 536870912; // 0x20000000
|
||||
field public static final int PARTIAL_WAKE_LOCK = 1; // 0x1
|
||||
|
||||
@@ -50,6 +50,7 @@ interface IPowerManager
|
||||
|
||||
void setStayOnSetting(int val);
|
||||
void boostScreenBrightness(long time);
|
||||
boolean isScreenBrightnessBoosted();
|
||||
|
||||
// temporarily overrides the screen brightness settings to allow the user to
|
||||
// see the effect of a settings change without applying it immediately
|
||||
|
||||
@@ -711,6 +711,22 @@ public final class PowerManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the screen brightness is currently boosted to maximum, caused by a call
|
||||
* to {@link #boostScreenBrightness(long)}.
|
||||
* @return {@code True} if the screen brightness is currently boosted. {@code False} otherwise.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean isScreenBrightnessBoosted() {
|
||||
try {
|
||||
return mService.isScreenBrightnessBoosted();
|
||||
} catch (RemoteException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of the backlights (screen, keyboard, button).
|
||||
* <p>
|
||||
@@ -891,6 +907,16 @@ public final class PowerManager {
|
||||
/** @hide */
|
||||
public static final String EXTRA_POWER_SAVE_MODE = "mode";
|
||||
|
||||
/**
|
||||
* Intent that is broadcast when the state of {@link #isScreenBrightnessBoosted()} has changed.
|
||||
* This broadcast is only sent to registered receivers.
|
||||
*
|
||||
* @hide
|
||||
**/
|
||||
@SystemApi
|
||||
public static final String ACTION_SCREEN_BRIGHTNESS_BOOST_CHANGED
|
||||
= "android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED";
|
||||
|
||||
/**
|
||||
* A wake lock is a mechanism to indicate that your application needs
|
||||
* to have the device stay on.
|
||||
|
||||
@@ -77,6 +77,8 @@
|
||||
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGED" />
|
||||
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGING" />
|
||||
|
||||
<protected-broadcast android:name="android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED" />
|
||||
|
||||
<protected-broadcast android:name="android.app.action.ENTER_CAR_MODE" />
|
||||
<protected-broadcast android:name="android.app.action.EXIT_CAR_MODE" />
|
||||
<protected-broadcast android:name="android.app.action.ENTER_DESK_MODE" />
|
||||
|
||||
@@ -78,6 +78,7 @@ final class Notifier {
|
||||
private static final int MSG_USER_ACTIVITY = 1;
|
||||
private static final int MSG_BROADCAST = 2;
|
||||
private static final int MSG_WIRELESS_CHARGING_STARTED = 3;
|
||||
private static final int MSG_SCREEN_BRIGHTNESS_BOOST_CHANGED = 4;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
@@ -92,6 +93,7 @@ final class Notifier {
|
||||
private final NotifierHandler mHandler;
|
||||
private final Intent mScreenOnIntent;
|
||||
private final Intent mScreenOffIntent;
|
||||
private final Intent mScreenBrightnessBoostIntent;
|
||||
|
||||
// The current interactive state.
|
||||
private int mActualInteractiveState;
|
||||
@@ -128,6 +130,10 @@ final class Notifier {
|
||||
mScreenOffIntent = new Intent(Intent.ACTION_SCREEN_OFF);
|
||||
mScreenOffIntent.addFlags(
|
||||
Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
mScreenBrightnessBoostIntent =
|
||||
new Intent(PowerManager.ACTION_SCREEN_BRIGHTNESS_BOOST_CHANGED);
|
||||
mScreenBrightnessBoostIntent.addFlags(
|
||||
Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
|
||||
// Initialize interactive state for battery stats.
|
||||
try {
|
||||
@@ -348,6 +354,19 @@ final class Notifier {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when screen brightness boost begins or ends.
|
||||
*/
|
||||
public void onScreenBrightnessBoostChanged() {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onScreenBrightnessBoostChanged");
|
||||
}
|
||||
|
||||
mSuspendBlocker.acquire();
|
||||
Message msg = mHandler.obtainMessage(MSG_SCREEN_BRIGHTNESS_BOOST_CHANGED);
|
||||
msg.setAsynchronous(true);
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
/**
|
||||
* Called when there has been user activity.
|
||||
*/
|
||||
@@ -457,6 +476,22 @@ final class Notifier {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendBrightnessBoostChangedBroadcast() {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Sending brightness boost changed broadcast.");
|
||||
}
|
||||
|
||||
mContext.sendOrderedBroadcastAsUser(mScreenBrightnessBoostIntent, UserHandle.ALL, null,
|
||||
mScreeBrightnessBoostChangedDone, mHandler, 0, null, null);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mScreeBrightnessBoostChangedDone = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mSuspendBlocker.release();
|
||||
}
|
||||
};
|
||||
|
||||
private void sendWakeUpBroadcast() {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Sending wake up broadcast.");
|
||||
@@ -539,6 +574,9 @@ final class Notifier {
|
||||
case MSG_WIRELESS_CHARGING_STARTED:
|
||||
playWirelessChargingStartedSound();
|
||||
break;
|
||||
case MSG_SCREEN_BRIGHTNESS_BOOST_CHANGED:
|
||||
sendBrightnessBoostChangedBroadcast();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1900,6 +1900,7 @@ public final class PowerManagerService extends SystemService
|
||||
}
|
||||
}
|
||||
mScreenBrightnessBoostInProgress = false;
|
||||
mNotifier.onScreenBrightnessBoostChanged();
|
||||
userActivityNoUpdateLocked(now,
|
||||
PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
|
||||
}
|
||||
@@ -2275,7 +2276,10 @@ public final class PowerManagerService extends SystemService
|
||||
|
||||
Slog.i(TAG, "Brightness boost activated (uid " + uid +")...");
|
||||
mLastScreenBrightnessBoostTime = eventTime;
|
||||
mScreenBrightnessBoostInProgress = true;
|
||||
if (!mScreenBrightnessBoostInProgress) {
|
||||
mScreenBrightnessBoostInProgress = true;
|
||||
mNotifier.onScreenBrightnessBoostChanged();
|
||||
}
|
||||
mDirty |= DIRTY_SCREEN_BRIGHTNESS_BOOST;
|
||||
|
||||
userActivityNoUpdateLocked(eventTime,
|
||||
@@ -2284,6 +2288,12 @@ public final class PowerManagerService extends SystemService
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isScreenBrightnessBoostedInternal() {
|
||||
synchronized (mLock) {
|
||||
return mScreenBrightnessBoostInProgress;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a screen brightness boost timeout has occurred.
|
||||
*
|
||||
@@ -3217,6 +3227,16 @@ public final class PowerManagerService extends SystemService
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean isScreenBrightnessBoosted() {
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return isScreenBrightnessBoostedInternal();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
|
||||
|
||||
Reference in New Issue
Block a user