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 getService()44 IDeviceIdleController getService() { 45 return mService; 46 } 47 48 /** 49 * @return package names the system has white-listed to opt out of power save restrictions, 50 * except for device idle mode. 51 */ getSystemPowerWhitelistExceptIdle()52 public @NonNull String[] getSystemPowerWhitelistExceptIdle() { 53 try { 54 return mService.getSystemPowerWhitelistExceptIdle(); 55 } catch (RemoteException e) { 56 throw e.rethrowFromSystemServer(); 57 } 58 } 59 60 /** 61 * @return package names the system has white-listed to opt out of power save restrictions for 62 * all modes. 63 */ getSystemPowerWhitelist()64 public @NonNull String[] getSystemPowerWhitelist() { 65 try { 66 return mService.getSystemPowerWhitelist(); 67 } catch (RemoteException e) { 68 throw e.rethrowFromSystemServer(); 69 } 70 } 71 } 72