| 1 |
/** |
| 2 |
* Copyright (c) 2020, 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.hardware.devicestate; |
| 18 |
|
| 19 |
import android.hardware.devicestate.DeviceStateInfo; |
| 20 |
import android.hardware.devicestate.IDeviceStateManagerCallback; |
| 21 |
|
| 22 |
/** @hide */ |
| 23 |
interface IDeviceStateManager { |
| 24 |
/** Returns the current device state info. */ |
| 25 |
DeviceStateInfo getDeviceStateInfo(); |
| 26 |
|
| 27 |
/** |
| 28 |
* Registers a callback to receive notifications from the device state manager. Only one |
| 29 |
* callback can be registered per-process. |
| 30 |
* <p> |
| 31 |
* As the callback mechanism is used to alert the caller of changes to request status a callback |
| 32 |
* <b>MUST</b> be registered before calling {@link #requestState(IBinder, int, int)} or |
| 33 |
* {@link #cancelRequest(IBinder)}, otherwise an exception will be thrown. |
| 34 |
* |
| 35 |
* @throws SecurityException if a callback is already registered for the calling process. |
| 36 |
*/ |
| 37 |
void registerCallback(in IDeviceStateManagerCallback callback); |
| 38 |
|
| 39 |
/** |
| 40 |
* Requests that the device enter the supplied {@code state}. A callback <b>MUST</b> have been |
| 41 |
* previously registered with {@link #registerCallback(IDeviceStateManagerCallback)} before a |
| 42 |
* call to this method. |
| 43 |
* |
| 44 |
* Requesting a state does not cancel a base state override made through |
| 45 |
* {@link #requestBaseStateOverride}, but will still attempt to put the device into the |
| 46 |
* supplied {@code state}. |
| 47 |
* |
| 48 |
* @param token the request token provided |
| 49 |
* @param state the state of device the request is asking for |
| 50 |
* @param flags any flags that correspond to the request |
| 51 |
* |
| 52 |
* @throws IllegalStateException if a callback has not yet been registered for the calling |
| 53 |
* process. |
| 54 |
* @throws IllegalStateException if the supplied {@code token} has already been registered. |
| 55 |
* @throws IllegalArgumentException if the supplied {@code state} is not supported. |
| 56 |
*/ |
| 57 |
@JavaPassthrough(annotation= |
| 58 |
"@android.annotation.RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true)") |
| 59 |
void requestState(IBinder token, int state, int flags); |
| 60 |
|
| 61 |
/** |
| 62 |
* Cancels the active request previously submitted with a call to |
| 63 |
* {@link #requestState(IBinder, int, int)}. Will have no effect on any base state override that |
| 64 |
* was previously requested with {@link #requestBaseStateOverride}. |
| 65 |
* |
| 66 |
* @throws IllegalStateException if a callback has not yet been registered for the calling |
| 67 |
* process. |
| 68 |
*/ |
| 69 |
@JavaPassthrough(annotation= |
| 70 |
"@android.annotation.RequiresPermission(value=android.Manifest.permission.CONTROL_DEVICE_STATE, conditional=true)") |
| 71 |
void cancelStateRequest(); |
| 72 |
|
| 73 |
/** |
| 74 |
* Requests that the device's base state be overridden to the supplied {@code state}. A callback |
| 75 |
* <b>MUST</b> have been previously registered with |
| 76 |
* {@link #registerCallback(IDeviceStateManagerCallback)} before a call to this method. |
| 77 |
* |
| 78 |
* This method should only be used for testing, when you want to simulate the device physically |
| 79 |
* changing states. If you are looking to change device state for a feature, where the system |
| 80 |
* should still be aware that the physical state is different than the emulated state, use |
| 81 |
* {@link #requestState}. |
| 82 |
* |
| 83 |
* @param token the request token provided |
| 84 |
* @param state the state of device the request is asking for |
| 85 |
* @param flags any flags that correspond to the request |
| 86 |
* |
| 87 |
* @throws IllegalStateException if a callback has not yet been registered for the calling |
| 88 |
* process. |
| 89 |
* @throws IllegalStateException if the supplied {@code token} has already been registered. |
| 90 |
* @throws IllegalArgumentException if the supplied {@code state} is not supported. |
| 91 |
*/ |
| 92 |
@JavaPassthrough(annotation= |
| 93 |
"@android.annotation.RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE)") |
| 94 |
void requestBaseStateOverride(IBinder token, int state, int flags); |
| 95 |
|
| 96 |
/** |
| 97 |
* Cancels the active base state request previously submitted with a call to |
| 98 |
* {@link #overrideBaseState(IBinder, int, int)}. |
| 99 |
* |
| 100 |
* @throws IllegalStateException if a callback has not yet been registered for the calling |
| 101 |
* process. |
| 102 |
*/ |
| 103 |
@JavaPassthrough(annotation= |
| 104 |
"@android.annotation.RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE)") |
| 105 |
void cancelBaseStateOverride(); |
| 106 |
|
| 107 |
/** |
| 108 |
* Notifies the system service that the educational overlay that was launched |
| 109 |
* before entering a requested state was dismissed or closed, and provides |
| 110 |
* the system information on if the pairing mode should be canceled or not. |
| 111 |
* |
| 112 |
* This should only be called from the overlay itself. |
| 113 |
*/ |
| 114 |
@JavaPassthrough(annotation= |
| 115 |
"@android.annotation.RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE)") |
| 116 |
void onStateRequestOverlayDismissed(boolean shouldCancelRequest); |
| 117 |
} |