1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.os; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemService; 21 import android.annotation.TestApi; 22 import android.content.Context; 23 24 /** 25 * Access to the service that keeps track of device idleness and drives low power mode based on 26 * that. 27 * 28 * @hide 29 */ 30 @TestApi 31 @SystemService(Context.DEVICE_IDLE_CONTROLLER) 32 public class DeviceIdleManager { 33 private final Context mContext; 34 private final IDeviceIdleController mService; 35 36 /** 37 * @hide 38 */ DeviceIdleManager(@onNull Context context, @NonNull IDeviceIdleController service)39 public DeviceIdleManager(@NonNull Context context, @NonNull IDeviceIdleController service) { 40 mContext = context; 41 mService = service; 42 } 43 44 /** 45 * @return package names the system has white-listed to opt out of power save restrictions, 46 * except for device idle mode. 47 */ getSystemPowerWhitelistExceptIdle()48 public @NonNull String[] getSystemPowerWhitelistExceptIdle() { 49 try { 50 return mService.getSystemPowerWhitelistExceptIdle(); 51 } catch (RemoteException e) { 52 e.rethrowFromSystemServer(); 53 return new String[0]; 54 } 55 } 56 57 /** 58 * @return package names the system has white-listed to opt out of power save restrictions for 59 * all modes. 60 */ getSystemPowerWhitelist()61 public @NonNull String[] getSystemPowerWhitelist() { 62 try { 63 return mService.getSystemPowerWhitelist(); 64 } catch (RemoteException e) { 65 e.rethrowFromSystemServer(); 66 return new String[0]; 67 } 68 } 69 } 70