diff options
| author | Kenneth Ford <kennethford@google.com> | 2021-08-21 03:00:21 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-08-21 03:00:21 +0000 |
| commit | c810e5c6dddc522fc41e306ee5bd2ada45c789d5 (patch) | |
| tree | 2503267e44ab10705706013f8ef7759eae3eace7 /core/java/android | |
| parent | a729265863d71b4cb8aa34ce2485fdd7c09638af (diff) | |
| parent | 1f70abe98d33f9e673dc2e4022fbb4dad8025ed8 (diff) | |
Merge changes from topic "top-focused-DevStMan" into sc-v2-dev
* changes:
Allow top focused activities to call requestState
Allow override requests to outlive the requesting process.
Refactor request lifecycle logic into OverrideRequestController.
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/hardware/devicestate/DeviceStateManager.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/java/android/hardware/devicestate/DeviceStateManager.java b/core/java/android/hardware/devicestate/DeviceStateManager.java index 52dad3efefb8..95892aa7af81 100644 --- a/core/java/android/hardware/devicestate/DeviceStateManager.java +++ b/core/java/android/hardware/devicestate/DeviceStateManager.java @@ -75,23 +75,24 @@ public final class DeviceStateManager { /** * Submits a {@link DeviceStateRequest request} to modify the device state. * <p> - * By default, the request is kept active until a call to - * {@link #cancelRequest(DeviceStateRequest)} or until one of the following occurs: + * By default, the request is kept active until one of the following occurs: * <ul> + * <li>The system deems the request can no longer be honored, for example if the requested + * state becomes unsupported. + * <li>A call to {@link #cancelRequest(DeviceStateRequest)}. * <li>Another processes submits a request succeeding this request in which case the request * will be suspended until the interrupting request is canceled. - * <li>The requested state has become unsupported. - * <li>The process submitting the request dies. * </ul> * However, this behavior can be changed by setting flags on the {@link DeviceStateRequest}. * * @throws IllegalArgumentException if the requested state is unsupported. - * @throws SecurityException if the {@link android.Manifest.permission#CONTROL_DEVICE_STATE} - * permission is not held. + * @throws SecurityException if the caller is neither the current top-focused activity nor if + * the {@link android.Manifest.permission#CONTROL_DEVICE_STATE} permission is held. * * @see DeviceStateRequest */ - @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) + @RequiresPermission(value = android.Manifest.permission.CONTROL_DEVICE_STATE, + conditional = true) public void requestState(@NonNull DeviceStateRequest request, @Nullable @CallbackExecutor Executor executor, @Nullable DeviceStateRequest.Callback callback) { @@ -105,10 +106,11 @@ public final class DeviceStateManager { * This method is noop if the {@code request} has not been submitted with a call to * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. * - * @throws SecurityException if the {@link android.Manifest.permission#CONTROL_DEVICE_STATE} - * permission is not held. + * @throws SecurityException if the caller is neither the current top-focused activity nor if + * the {@link android.Manifest.permission#CONTROL_DEVICE_STATE} permission is held. */ - @RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE) + @RequiresPermission(value = android.Manifest.permission.CONTROL_DEVICE_STATE, + conditional = true) public void cancelRequest(@NonNull DeviceStateRequest request) { mGlobal.cancelRequest(request); } |
