diff --git a/core/api/test-current.txt b/core/api/test-current.txt index c39394bb1e4fa..15148a93cbe72 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1104,7 +1104,7 @@ package android.hardware.camera2 { package android.hardware.devicestate { public final class DeviceStateManager { - method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void cancelRequest(@NonNull android.hardware.devicestate.DeviceStateRequest); + method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void cancelStateRequest(); method @NonNull public int[] getSupportedStates(); method public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.hardware.devicestate.DeviceStateManager.DeviceStateCallback); method @RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true) public void requestState(@NonNull android.hardware.devicestate.DeviceStateRequest, @Nullable java.util.concurrent.Executor, @Nullable android.hardware.devicestate.DeviceStateRequest.Callback); diff --git a/core/java/android/hardware/devicestate/DeviceStateManager.java b/core/java/android/hardware/devicestate/DeviceStateManager.java index b06d076fe08eb..30aa4db938da1 100644 --- a/core/java/android/hardware/devicestate/DeviceStateManager.java +++ b/core/java/android/hardware/devicestate/DeviceStateManager.java @@ -79,9 +79,9 @@ public final class DeviceStateManager { * * However, this behavior can be changed by setting flags on the {@link DeviceStateRequest}. * @@ -100,19 +100,18 @@ public final class DeviceStateManager { } /** - * Cancels a {@link DeviceStateRequest request} previously submitted with a call to + * Cancels the active {@link DeviceStateRequest} previously submitted with a call to * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. *

- * This method is noop if the {@code request} has not been submitted with a call to - * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. + * This method is noop if there is no request currently active. * * @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(value = android.Manifest.permission.CONTROL_DEVICE_STATE, conditional = true) - public void cancelRequest(@NonNull DeviceStateRequest request) { - mGlobal.cancelRequest(request); + public void cancelStateRequest() { + mGlobal.cancelStateRequest(); } /** diff --git a/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java b/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java index 85e70b0fb3e95..aba538f510433 100644 --- a/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java +++ b/core/java/android/hardware/devicestate/DeviceStateManagerGlobal.java @@ -151,20 +151,14 @@ public final class DeviceStateManagerGlobal { * Cancels a {@link DeviceStateRequest request} previously submitted with a call to * {@link #requestState(DeviceStateRequest, Executor, DeviceStateRequest.Callback)}. * - * @see DeviceStateManager#cancelRequest(DeviceStateRequest) + * @see DeviceStateManager#cancelStateRequest */ - public void cancelRequest(@NonNull DeviceStateRequest request) { + public void cancelStateRequest() { synchronized (mLock) { registerCallbackIfNeededLocked(); - final IBinder token = findRequestTokenLocked(request); - if (token == null) { - // This request has not been submitted. - return; - } - try { - mDeviceStateManager.cancelRequest(token); + mDeviceStateManager.cancelStateRequest(); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } @@ -297,20 +291,6 @@ public final class DeviceStateManagerGlobal { } } - /** - * Handles a call from the server that a request for the supplied {@code token} has become - * suspended. - */ - private void handleRequestSuspended(IBinder token) { - DeviceStateRequestWrapper request; - synchronized (mLock) { - request = mRequests.get(token); - } - if (request != null) { - request.notifyRequestSuspended(); - } - } - /** * Handles a call from the server that a request for the supplied {@code token} has become * canceled. @@ -336,11 +316,6 @@ public final class DeviceStateManagerGlobal { handleRequestActive(token); } - @Override - public void onRequestSuspended(IBinder token) { - handleRequestSuspended(token); - } - @Override public void onRequestCanceled(IBinder token) { handleRequestCanceled(token); @@ -395,14 +370,6 @@ public final class DeviceStateManagerGlobal { mExecutor.execute(() -> mCallback.onRequestActivated(mRequest)); } - void notifyRequestSuspended() { - if (mCallback == null) { - return; - } - - mExecutor.execute(() -> mCallback.onRequestSuspended(mRequest)); - } - void notifyRequestCanceled() { if (mCallback == null) { return; diff --git a/core/java/android/hardware/devicestate/DeviceStateRequest.java b/core/java/android/hardware/devicestate/DeviceStateRequest.java index df488d2f6df1a..893d765e48dad 100644 --- a/core/java/android/hardware/devicestate/DeviceStateRequest.java +++ b/core/java/android/hardware/devicestate/DeviceStateRequest.java @@ -32,8 +32,7 @@ import java.util.concurrent.Executor; * DeviceStateRequest.Callback)}. *

* By default, the request is kept active until a call to - * {@link DeviceStateManager#cancelRequest(DeviceStateRequest)} or until one of the following - * occurs: + * {@link DeviceStateManager#cancelStateRequest} or until one of the following occurs: *