• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. */
getDeviceStateInfo()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      */
registerCallback(in IDeviceStateManagerCallback callback)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      * @param token the request token previously registered with
45      *        {@link #requestState(IBinder, int, int)}
46      *
47      * @throws IllegalStateException if a callback has not yet been registered for the calling
48      *         process.
49      * @throws IllegalStateException if the supplied {@code token} has already been registered.
50      * @throws IllegalArgumentException if the supplied {@code state} is not supported.
51      */
requestState(IBinder token, int state, int flags)52     void requestState(IBinder token, int state, int flags);
53 
54     /**
55      * Cancels a request previously submitted with a call to
56      * {@link #requestState(IBinder, int, int)}.
57      *
58      * @param token the request token previously registered with
59      *        {@link #requestState(IBinder, int, int)}
60      *
61      * @throws IllegalStateException if the supplied {@code token} has not been previously
62      *         requested.
63      */
cancelRequest(IBinder token)64     void cancelRequest(IBinder token);
65 }
66