1 /*
2  * Copyright 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.uwb;
18 
19 import android.os.PersistableBundle;
20 import android.uwb.RangingChangeReason;
21 import android.uwb.RangingReport;
22 import android.uwb.SessionHandle;
23 import android.uwb.UwbAddress;
24 
25 /**
26  * @hide
27  * TODO(b/211025367): Remove all the duplicate javadocs here.
28  */
29 oneway interface IUwbRangingCallbacks {
30   /**
31    * Called when the ranging session has been opened
32    *
33    * @param sessionHandle the session the callback is being invoked for
34    */
onRangingOpened(in SessionHandle sessionHandle)35   void onRangingOpened(in SessionHandle sessionHandle);
36 
37   /**
38    * Called when a ranging session fails to start
39    *
40    * @param sessionHandle the session the callback is being invoked for
41    * @param reason the reason the session failed to start
42    * @param parameters protocol specific parameters
43    */
onRangingOpenFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)44   void onRangingOpenFailed(in SessionHandle sessionHandle,
45                            RangingChangeReason reason,
46                            in PersistableBundle parameters);
47 
48   /**
49    * Called when ranging has started
50    *
51    * May output parameters generated by the lower layers that must be sent to the
52    * remote device(s). The PersistableBundle must be constructed using the UWB
53    * support library.
54    *
55    * @param sessionHandle the session the callback is being invoked for
56    * @param rangingOutputParameters parameters generated by the lower layer that
57    *                                should be sent to the remote device.
58    */
onRangingStarted(in SessionHandle sessionHandle, in PersistableBundle parameters)59   void onRangingStarted(in SessionHandle sessionHandle,
60                         in PersistableBundle parameters);
61 
62   /**
63    * Called when a ranging session fails to start
64    *
65    * @param sessionHandle the session the callback is being invoked for
66    * @param reason the reason the session failed to start
67    * @param parameters protocol specific parameters
68    */
onRangingStartFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)69   void onRangingStartFailed(in SessionHandle sessionHandle,
70                             RangingChangeReason reason,
71                             in PersistableBundle parameters);
72 
73    /**
74    * Called when ranging has been reconfigured
75    *
76    * @param sessionHandle the session the callback is being invoked for
77    * @param parameters the updated ranging configuration
78    */
onRangingReconfigured(in SessionHandle sessionHandle, in PersistableBundle parameters)79   void onRangingReconfigured(in SessionHandle sessionHandle,
80                              in PersistableBundle parameters);
81 
82   /**
83    * Called when a ranging session fails to be reconfigured
84    *
85    * @param sessionHandle the session the callback is being invoked for
86    * @param reason the reason the session failed to reconfigure
87    * @param parameters protocol specific parameters
88    */
onRangingReconfigureFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)89   void onRangingReconfigureFailed(in SessionHandle sessionHandle,
90                                   RangingChangeReason reason,
91                                   in PersistableBundle parameters);
92 
93   /**
94    * Called when the ranging session has been stopped
95    *
96    * @param sessionHandle the session the callback is being invoked for
97    * @param reason the reason the session was stopped
98    * @param parameters protocol specific parameters
99    */
100 
onRangingStopped(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)101   void onRangingStopped(in SessionHandle sessionHandle,
102                         RangingChangeReason reason,
103                         in PersistableBundle parameters);
104 
105   /**
106    * Called when a ranging session fails to stop
107    *
108    * @param sessionHandle the session the callback is being invoked for
109    * @param reason the reason the session failed to stop
110    * @param parameters protocol specific parameters
111    */
onRangingStopFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)112   void onRangingStopFailed(in SessionHandle sessionHandle,
113                            RangingChangeReason reason,
114                            in PersistableBundle parameters);
115 
116   /**
117    * Called when a ranging session is closed
118    *
119    * @param sessionHandle the session the callback is being invoked for
120    * @param reason the reason the session was closed
121    * @param parameters protocol specific parameters
122    */
onRangingClosed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)123   void onRangingClosed(in SessionHandle sessionHandle,
124                        RangingChangeReason reason,
125                        in PersistableBundle parameters);
126 
127   /**
128    * Provides a new RangingResult to the framework
129    *
130    * The reported timestamp for a ranging measurement must be calculated as the
131    * time which the ranging round that generated this measurement concluded.
132    *
133    * @param sessionHandle an identifier to associate the ranging results with a
134    *                      session that is active
135    * @param result the ranging report
136    */
onRangingResult(in SessionHandle sessionHandle, in RangingReport result)137   void onRangingResult(in SessionHandle sessionHandle, in RangingReport result);
138 
139   /**
140    * Invoked when a new controlee is added to an ongoing one-to many session.
141    *
142    * @param sessionHandle the session the callback is being invoked for
143    * @param parameters protocol specific parameters for the new controlee.
144    */
onControleeAdded(in SessionHandle sessionHandle, in PersistableBundle parameters)145   void onControleeAdded(in SessionHandle sessionHandle, in PersistableBundle parameters);
146 
147   /**
148    * Invoked when a new controlee is added to an ongoing one-to many session.
149    *
150    * @param sessionHandle the session the callback is being invoked for
151    * @param reason reason for the controlee add failure.
152    * @param parameters protocol specific parameters related to the failure.
153    */
onControleeAddFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)154   void onControleeAddFailed(in SessionHandle sessionHandle,
155           RangingChangeReason reason, in PersistableBundle parameters);
156 
157   /**
158    * Invoked when an existing controlee is removed from an ongoing one-to many session.
159    *
160    * @param sessionHandle the session the callback is being invoked for
161    * @param parameters protocol specific parameters for the existing controlee.
162    */
onControleeRemoved(in SessionHandle sessionHandle, in PersistableBundle parameters)163   void onControleeRemoved(in SessionHandle sessionHandle, in PersistableBundle parameters);
164 
165   /**
166    * Invoked when a new controlee is added to an ongoing one-to many session.
167    *
168    * @param sessionHandle the session the callback is being invoked for
169    * @param reason reason for the controlee remove failure.
170    * @param parameters protocol specific parameters related to the failure.
171    */
onControleeRemoveFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)172   void onControleeRemoveFailed(in SessionHandle sessionHandle,
173           RangingChangeReason reason, in PersistableBundle parameters);
174 
175   /**
176    * Invoked when an ongoing session is successfully suspended.
177    *
178    * @param sessionHandle the session the callback is being invoked for
179    * @param parameters protocol specific parameters sent for suspension.
180    */
onRangingPaused(in SessionHandle sessionHandle, in PersistableBundle parameters)181   void onRangingPaused(in SessionHandle sessionHandle, in PersistableBundle parameters);
182 
183   /**
184    * Invoked when an ongoing session suspension fails.
185    *
186    * @param sessionHandle the session the callback is being invoked for
187    * @param reason reason for the suspension failure.
188    * @param parameters protocol specific parameters for suspension failure.
189    */
onRangingPauseFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)190   void onRangingPauseFailed(in SessionHandle sessionHandle,
191           RangingChangeReason reason, in PersistableBundle parameters);
192 
193   /**
194    * Invoked when a suspended session is successfully resumed.
195    *
196    * @param parameters protocol specific parameters sent for suspension.
197    */
onRangingResumed(in SessionHandle sessionHandle, in PersistableBundle parameters)198   void onRangingResumed(in SessionHandle sessionHandle, in PersistableBundle parameters);
199 
200   /**
201    * Invoked when a suspended session resumption fails.
202    *
203    * @param sessionHandle the session the callback is being invoked for
204    * @param reason reason for the resumption failure.
205    * @param parameters protocol specific parameters for resumption failure.
206    */
onRangingResumeFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)207   void onRangingResumeFailed(in SessionHandle sessionHandle,
208           RangingChangeReason reason, in PersistableBundle parameters);
209 
210   /**
211    * Invoked when data is successfully sent via {@link RangingSession#sendData(UwbAddress,
212    * PersistableBundle, byte[])}.
213    *
214    * @param sessionHandle the session the callback is being invoked for
215    * @param remoteDeviceAddress remote device's address.
216    * @param parameters protocol specific parameters sent for suspension.
217    */
onDataSent(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress, in PersistableBundle parameters)218   void onDataSent(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress,
219           in PersistableBundle parameters);
220 
221   /**
222    * Invoked when data send to a remote device via {@link RangingSession#sendData(UwbAddress,
223    * PersistableBundle, byte[])} fails.
224    *
225    * @param sessionHandle the session the callback is being invoked for
226    * @param remoteDeviceAddress remote device's address.
227    * @param reason reason for the resumption failure.
228    * @param parameters protocol specific parameters for resumption failure.
229    */
onDataSendFailed(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress, RangingChangeReason reason, in PersistableBundle parameters)230   void onDataSendFailed(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress,
231           RangingChangeReason reason, in PersistableBundle parameters);
232 
233   /**
234    * Invoked when set data transfer phase config via {@link RangingSession#
235    * setDataTransferPhaseConfig(in SessionHandle sessionHandle, in PersistableBundle params)}
236    * succeeds.
237    *
238    * @param sessionHandle the session for which the callback is being invoked for
239    * @param parameters protocol specific parameters for set data transfer phase config success.
240    */
onDataTransferPhaseConfigured(in SessionHandle sessionHandle, in PersistableBundle parameters)241   void onDataTransferPhaseConfigured(in SessionHandle sessionHandle,
242         in PersistableBundle parameters);
243 
244   /**
245    * Invoked when set data transfer phase config via {@link RangingSession#
246    * setDataTransferPhaseConfig(in SessionHandle sessionHandle, in PersistableBundle params)} fails.
247    *
248    * @param sessionHandle the session for which the callback is being invoked for
249    * @param parameters protocol specific parameters for set data transfer phase config failure.
250    */
onDataTransferPhaseConfigFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)251   void onDataTransferPhaseConfigFailed(in SessionHandle sessionHandle,
252           RangingChangeReason reason, in PersistableBundle parameters);
253 
254   /**
255    * Invoked when data is received successfully from a remote device.
256    * The data is received piggybacked over RRM (initiator -> responder) or
257    * RIM (responder -> initiator).
258    * <p> This is only functional on a FIRA 2.0 compliant device.
259    *
260    * @param sessionHandle the session the callback is being invoked for
261    * @param remoteDeviceAddress remote device's address.
262    * @param data Raw data received.
263    * @param parameters protocol specific parameters for the received data.
264    */
onDataReceived(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress, in PersistableBundle parameters, in byte[] data)265   void onDataReceived(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress,
266           in PersistableBundle parameters, in byte[] data);
267 
268   /**
269    * Invoked when data receive from a remote device fails.
270    *
271    * @param sessionHandle the session the callback is being invoked for
272    * @param remoteDeviceAddress remote device's address.
273    * @param reason reason for the resumption failure.
274    * @param parameters protocol specific parameters for resumption failure.
275    */
onDataReceiveFailed(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress, RangingChangeReason reason, in PersistableBundle parameters)276   void onDataReceiveFailed(in SessionHandle sessionHandle, in UwbAddress remoteDeviceAddress,
277           RangingChangeReason reason, in PersistableBundle parameters);
278 
279   /**
280    * Invoked when set hybrid session controller configuration via {@link RangingSession#
281    * setHybridSessionControllerConfiguration(
282    * in SessionHandle sessionHandle, in PersistableBundle params)} succeeds.
283    *
284    * @param sessionHandle the session for which the callback is being invoked for.
285    * @param parameters protocol specific parameters for set hybrid session controller config
286    * success.
287    */
onHybridSessionControllerConfigured(in SessionHandle sessionHandle, in PersistableBundle parameters)288   void onHybridSessionControllerConfigured(in SessionHandle sessionHandle,
289           in PersistableBundle parameters);
290 
291   /**
292    * Invoked when set hybrid session controller configuration via {@link RangingSession#
293    * setHybridSessionControllerConfiguration(
294    * in SessionHandle sessionHandle, in PersistableBundle params)} fails.
295    *
296    * @param sessionHandle the session for which the callback is being invoked for.
297    * @param parameters protocol specific parameters for set hybrid session controller config
298    * failure.
299    */
onHybridSessionControllerConfigurationFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)300   void onHybridSessionControllerConfigurationFailed(in SessionHandle sessionHandle,
301           RangingChangeReason reason, in PersistableBundle parameters);
302 
303   /**
304    * Invoked when set hybrid session Controlee configuration via {@link RangingSession#
305    * setHybridSessionControleeConfiguration(
306    * in SessionHandle sessionHandle, in PersistableBundle params)} succeeds.
307    *
308    * @param sessionHandle the session for which the callback is being invoked for.
309    * @param parameters protocol specific parameters for set hybrid session Controlee config
310    * success.
311    */
onHybridSessionControleeConfigured(in SessionHandle sessionHandle, in PersistableBundle parameters)312   void onHybridSessionControleeConfigured(in SessionHandle sessionHandle,
313           in PersistableBundle parameters);
314 
315   /**
316    * Invoked when set hybrid session Controlee configuration via {@link RangingSession#
317    * setHybridSessionControleeConfiguration(
318    * in SessionHandle sessionHandle, in PersistableBundle params)} fails.
319    *
320    * @param sessionHandle the session for which the callback is being invoked for.
321    * @param parameters protocol specific parameters for set hybrid session Controlee config
322    * failure.
323    */
onHybridSessionControleeConfigurationFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)324   void onHybridSessionControleeConfigurationFailed(in SessionHandle sessionHandle,
325           RangingChangeReason reason, in PersistableBundle parameters);
326 
onServiceDiscovered(in SessionHandle sessionHandle, in PersistableBundle parameters)327   void onServiceDiscovered(in SessionHandle sessionHandle, in PersistableBundle parameters);
328 
onServiceConnected(in SessionHandle sessionHandle, in PersistableBundle parameters)329   void onServiceConnected(in SessionHandle sessionHandle, in PersistableBundle parameters);
330 
onRangingRoundsUpdateDtTagStatus(in SessionHandle sessionHandle, in PersistableBundle parameters)331   void onRangingRoundsUpdateDtTagStatus(in SessionHandle sessionHandle,
332             in PersistableBundle parameters);
333 }
334