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

Commit 285cb414 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #21813831: Need API for asking to be added to power whitelist" into mnc-dev

parents 2d4dc8db 1958e5e7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23419,6 +23419,7 @@ package android.os {
  public final class PowerManager {
    method public boolean isDeviceIdleMode();
    method public boolean isIgnoringBatteryOptimizations(java.lang.String);
    method public boolean isInteractive();
    method public boolean isPowerSaveMode();
    method public deprecated boolean isScreenOn();
+1 −0
Original line number Diff line number Diff line
@@ -25341,6 +25341,7 @@ package android.os {
  public final class PowerManager {
    method public boolean isDeviceIdleMode();
    method public boolean isIgnoringBatteryOptimizations(java.lang.String);
    method public boolean isInteractive();
    method public boolean isPowerSaveMode();
    method public boolean isScreenBrightnessBoosted();
+8 −0
Original line number Diff line number Diff line
@@ -2248,6 +2248,7 @@ public abstract class Context {
            //@hide: VOICE_INTERACTION_MANAGER_SERVICE,
            //@hide: BACKUP_SERVICE,
            DROPBOX_SERVICE,
            //@hide: DEVICE_IDLE_CONTROLLER,
            DEVICE_POLICY_SERVICE,
            UI_MODE_SERVICE,
            DOWNLOAD_SERVICE,
@@ -2873,6 +2874,13 @@ public abstract class Context {
     */
    public static final String DROPBOX_SERVICE = "dropbox";

    /**
     * System service name for the DeviceIdleController.  There is no Java API for this.
     * @see #getSystemService
     * @hide
     */
    public static final String DEVICE_IDLE_CONTROLLER = "deviceidle";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.app.admin.DevicePolicyManager} for working with global
+21 −0
Original line number Diff line number Diff line
@@ -392,6 +392,8 @@ public final class PowerManager {
    final IPowerManager mService;
    final Handler mHandler;

    IDeviceIdleController mIDeviceIdleController;

    /**
     * {@hide}
     */
@@ -891,6 +893,25 @@ public final class PowerManager {
        }
    }

    /**
     * Return whether the given application package name is on the device's power whitelist.
     * Apps can be placed on the whitelist through the settings UI invoked by
     * {@link android.provider.Settings#ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}.
     */
    public boolean isIgnoringBatteryOptimizations(String packageName) {
        synchronized (this) {
            if (mIDeviceIdleController == null) {
                mIDeviceIdleController = IDeviceIdleController.Stub.asInterface(
                        ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
            }
        }
        try {
            return mIDeviceIdleController.isPowerSaveWhitelistApp(packageName);
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * Turn off the device.
     *
+5 −4
Original line number Diff line number Diff line
@@ -579,13 +579,14 @@ public final class Settings {
    /**
     * Activity Action: Show screen for controlling which apps can ignore battery optimizations.
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * <p>
     * Input: The Intent's data URI specifies the application package name
     * Input: Optionally, the Intent's data URI specifies the application package name
     * to be shown, with the "package" scheme.  That is "package:com.my.app".
     * <p>
     * Output: Nothing.
     * <p>
     * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
     * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
     * already ignoring optimizations.
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS =
Loading