| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.os; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.RequiresPermission; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.annotation.SystemService; |
| 23 |
import android.annotation.TestApi; |
| 24 |
import android.content.Context; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@SystemApi |
| 33 |
@SystemService(Context.DEVICE_IDLE_CONTROLLER) |
| 34 |
public class DeviceIdleManager { |
| 35 |
private final Context mContext; |
| 36 |
private final IDeviceIdleController mService; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public DeviceIdleManager(@NonNull Context context, @NonNull IDeviceIdleController service) { |
| 42 |
mContext = context; |
| 43 |
mService = service; |
| 44 |
} |
| 45 |
|
| 46 |
IDeviceIdleController getService() { |
| 47 |
return mService; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
@RequiresPermission(android.Manifest.permission.DEVICE_POWER) |
| 56 |
public void endIdle(@NonNull String reason) { |
| 57 |
try { |
| 58 |
mService.exitIdle(reason); |
| 59 |
} catch (RemoteException e) { |
| 60 |
throw e.rethrowFromSystemServer(); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
@TestApi |
| 71 |
public @NonNull String[] getSystemPowerWhitelistExceptIdle() { |
| 72 |
try { |
| 73 |
return mService.getSystemPowerWhitelistExceptIdle(); |
| 74 |
} catch (RemoteException e) { |
| 75 |
throw e.rethrowFromSystemServer(); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
@TestApi |
| 86 |
public @NonNull String[] getSystemPowerWhitelist() { |
| 87 |
try { |
| 88 |
return mService.getSystemPowerWhitelist(); |
| 89 |
} catch (RemoteException e) { |
| 90 |
throw e.rethrowFromSystemServer(); |
| 91 |
} |
| 92 |
} |
| 93 |
} |