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

Commit 1aba5d25 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move add-to-whitelist APIs."

parents 5bfa0bf0 891e56d3
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -17,13 +17,10 @@
package android.os;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;

import java.util.List;

/**
 * Access to the service that keeps track of device idleness and drives low power mode based on
 * that.
@@ -74,21 +71,6 @@ public class DeviceIdleManager {
        }
    }

    /**
     * Add the specified packages to the power save whitelist.
     *
     * @return the number of packages that were successfully added to the whitelist
     */
    @RequiresPermission(android.Manifest.permission.DEVICE_POWER)
    public int addPowerSaveWhitelistApps(@NonNull List<String> packageNames) {
        try {
            return mService.addPowerSaveWhitelistApps(packageNames);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            return 0;
        }
    }

    /**
     * Return whether a given package is in the power-save whitelist or not.
     * @hide
+27 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.content.Context;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.List;

/**
 * Interface to access and modify the power save whitelist.
@@ -77,6 +79,31 @@ public class PowerWhitelistManager {
        mService = context.getSystemService(DeviceIdleManager.class).getService();
    }

    /**
     * Add the specified package to the power save whitelist.
     *
     * @return true if the package was successfully added to the whitelist
     */
    @RequiresPermission(android.Manifest.permission.DEVICE_POWER)
    public boolean addToWhitelist(@NonNull String packageName) {
        return addToWhitelist(Collections.singletonList(packageName)) == 1;
    }

    /**
     * Add the specified packages to the power save whitelist.
     *
     * @return the number of packages that were successfully added to the whitelist
     */
    @RequiresPermission(android.Manifest.permission.DEVICE_POWER)
    public int addToWhitelist(@NonNull List<String> packageNames) {
        try {
            return mService.addPowerSaveWhitelistApps(packageNames);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            return 0;
        }
    }

    /**
     * Add an app to the temporary whitelist for a short amount of time.
     *
+2 −0
Original line number Diff line number Diff line
@@ -6379,6 +6379,8 @@ package android.os {
  }
  public class PowerWhitelistManager {
    method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public boolean addToWhitelist(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public int addToWhitelist(@NonNull java.util.List<java.lang.String>);
    method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void whitelistAppTemporarily(@NonNull String, long);
    method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public long whitelistAppTemporarilyForEvent(@NonNull String, int, @NonNull String);
    field public static final int EVENT_MMS = 2; // 0x2
+2 −1
Original line number Diff line number Diff line
@@ -1796,7 +1796,6 @@ package android.os {
  }

  public class DeviceIdleManager {
    method @RequiresPermission("android.permission.DEVICE_POWER") public int addPowerSaveWhitelistApps(@NonNull java.util.List<java.lang.String>);
    method @NonNull public String[] getSystemPowerWhitelist();
    method @NonNull public String[] getSystemPowerWhitelistExceptIdle();
  }
@@ -2045,6 +2044,8 @@ package android.os {
  }

  public class PowerWhitelistManager {
    method @RequiresPermission("android.permission.DEVICE_POWER") public boolean addToWhitelist(@NonNull String);
    method @RequiresPermission("android.permission.DEVICE_POWER") public int addToWhitelist(@NonNull java.util.List<java.lang.String>);
    method @RequiresPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") public void whitelistAppTemporarily(@NonNull String, long);
    method @RequiresPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") public long whitelistAppTemporarilyForEvent(@NonNull String, int, @NonNull String);
    field public static final int EVENT_MMS = 2; // 0x2