diff --git a/apex/jobscheduler/framework/java/android/app/job/JobSchedulerFrameworkInitializer.java b/apex/jobscheduler/framework/java/android/app/job/JobSchedulerFrameworkInitializer.java index f3ec5e5752a0f..3835d93ebeb92 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobSchedulerFrameworkInitializer.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobSchedulerFrameworkInitializer.java @@ -21,6 +21,7 @@ import android.app.SystemServiceRegistry; import android.content.Context; import android.os.DeviceIdleManager; import android.os.IDeviceIdleController; +import android.os.PowerWhitelistManager; /** * Class holding initialization code for the job scheduler module. @@ -48,5 +49,8 @@ public class JobSchedulerFrameworkInitializer { Context.DEVICE_IDLE_CONTROLLER, DeviceIdleManager.class, (context, b) -> new DeviceIdleManager( context, IDeviceIdleController.Stub.asInterface(b))); + SystemServiceRegistry.registerContextAwareService( + Context.POWER_WHITELIST_MANAGER, PowerWhitelistManager.class, + PowerWhitelistManager::new); } } diff --git a/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java b/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java new file mode 100644 index 0000000000000..06ed52d7f5869 --- /dev/null +++ b/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.os; + +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.annotation.SystemService; +import android.annotation.TestApi; +import android.content.Context; + +/** + * Interface to access and modify the power save whitelist. + * + * @hide + */ +@SystemApi +@TestApi +@SystemService(Context.POWER_WHITELIST_MANAGER) +public class PowerWhitelistManager { + private final Context mContext; + + /** + * @hide + */ + public PowerWhitelistManager(@NonNull Context context) { + mContext = context; + } +} diff --git a/api/system-current.txt b/api/system-current.txt index fd6afea8a91b4..bb60107139b06 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5626,6 +5626,9 @@ package android.os { field public static final int USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS = 1; // 0x1 } + public class PowerWhitelistManager { + } + public class RecoverySystem { method @RequiresPermission(android.Manifest.permission.RECOVERY) public static void cancelScheduledUpdate(android.content.Context) throws java.io.IOException; method @RequiresPermission(android.Manifest.permission.RECOVERY) public static void installPackage(android.content.Context, java.io.File, boolean) throws java.io.IOException; diff --git a/api/test-current.txt b/api/test-current.txt index c6b02b9e649b1..80432d0f9faae 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -706,6 +706,7 @@ package android.content { field public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture"; field public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; field public static final String PERMISSION_SERVICE = "permission"; + field public static final String POWER_WHITELIST_MANAGER = "power_whitelist"; field public static final String ROLLBACK_SERVICE = "rollback"; field public static final String STATUS_BAR_SERVICE = "statusbar"; field public static final String TEST_NETWORK_SERVICE = "test_network"; @@ -2025,6 +2026,9 @@ package android.os { field public static final int POWER_SAVE_MODE_TRIGGER_PERCENTAGE = 0; // 0x0 } + public class PowerWhitelistManager { + } + public class Process { method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException; field public static final int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000; // 0x15f90 diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 03b49136bde4f..af0959d875bf1 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -3308,6 +3308,7 @@ public abstract class Context { ROLLBACK_SERVICE, DROPBOX_SERVICE, //@hide: DEVICE_IDLE_CONTROLLER, + //@hide: POWER_WHITELIST_MANAGER, DEVICE_POLICY_SERVICE, UI_MODE_SERVICE, DOWNLOAD_SERVICE, @@ -4292,6 +4293,15 @@ public abstract class Context { @TestApi public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; + /** + * System service name for the PowerWhitelistManager. + * + * @see #getSystemService(String) + * @hide + */ + @TestApi + public static final String POWER_WHITELIST_MANAGER = "power_whitelist"; + /** * Use with {@link #getSystemService(String)} to retrieve a * {@link android.app.admin.DevicePolicyManager} for working with global