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 
24 /**
25  * @hide
26  */
27 oneway interface IUwbRangingCallbacks {
28   /**
29    * Called when the ranging session has been opened
30    *
31    * @param sessionHandle the session the callback is being invoked for
32    */
onRangingOpened(in SessionHandle sessionHandle)33   void onRangingOpened(in SessionHandle sessionHandle);
34 
35   /**
36    * Called when a ranging session fails to start
37    *
38    * @param sessionHandle the session the callback is being invoked for
39    * @param reason the reason the session failed to start
40    * @param parameters protocol specific parameters
41    */
onRangingOpenFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)42   void onRangingOpenFailed(in SessionHandle sessionHandle,
43                            RangingChangeReason reason,
44                            in PersistableBundle parameters);
45 
46   /**
47    * Called when ranging has started
48    *
49    * May output parameters generated by the lower layers that must be sent to the
50    * remote device(s). The PersistableBundle must be constructed using the UWB
51    * support library.
52    *
53    * @param sessionHandle the session the callback is being invoked for
54    * @param rangingOutputParameters parameters generated by the lower layer that
55    *                                should be sent to the remote device.
56    */
onRangingStarted(in SessionHandle sessionHandle, in PersistableBundle parameters)57   void onRangingStarted(in SessionHandle sessionHandle,
58                         in PersistableBundle parameters);
59 
60   /**
61    * Called when a ranging session fails to start
62    *
63    * @param sessionHandle the session the callback is being invoked for
64    * @param reason the reason the session failed to start
65    * @param parameters protocol specific parameters
66    */
onRangingStartFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)67   void onRangingStartFailed(in SessionHandle sessionHandle,
68                             RangingChangeReason reason,
69                             in PersistableBundle parameters);
70 
71    /**
72    * Called when ranging has been reconfigured
73    *
74    * @param sessionHandle the session the callback is being invoked for
75    * @param parameters the updated ranging configuration
76    */
onRangingReconfigured(in SessionHandle sessionHandle, in PersistableBundle parameters)77   void onRangingReconfigured(in SessionHandle sessionHandle,
78                              in PersistableBundle parameters);
79 
80   /**
81    * Called when a ranging session fails to be reconfigured
82    *
83    * @param sessionHandle the session the callback is being invoked for
84    * @param reason the reason the session failed to reconfigure
85    * @param parameters protocol specific parameters
86    */
onRangingReconfigureFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)87   void onRangingReconfigureFailed(in SessionHandle sessionHandle,
88                                   RangingChangeReason reason,
89                                   in PersistableBundle parameters);
90 
91   /**
92    * Called when the ranging session has been stopped
93    *
94    * @param sessionHandle the session the callback is being invoked for
95    * @param reason the reason the session was stopped
96    * @param parameters protocol specific parameters
97    */
98 
onRangingStopped(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)99   void onRangingStopped(in SessionHandle sessionHandle,
100                         RangingChangeReason reason,
101                         in PersistableBundle parameters);
102 
103   /**
104    * Called when a ranging session fails to stop
105    *
106    * @param sessionHandle the session the callback is being invoked for
107    * @param reason the reason the session failed to stop
108    * @param parameters protocol specific parameters
109    */
onRangingStopFailed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)110   void onRangingStopFailed(in SessionHandle sessionHandle,
111                            RangingChangeReason reason,
112                            in PersistableBundle parameters);
113 
114   /**
115    * Called when a ranging session is closed
116    *
117    * @param sessionHandle the session the callback is being invoked for
118    * @param reason the reason the session was closed
119    * @param parameters protocol specific parameters
120    */
onRangingClosed(in SessionHandle sessionHandle, RangingChangeReason reason, in PersistableBundle parameters)121   void onRangingClosed(in SessionHandle sessionHandle,
122                        RangingChangeReason reason,
123                        in PersistableBundle parameters);
124 
125   /**
126    * Provides a new RangingResult to the framework
127    *
128    * The reported timestamp for a ranging measurement must be calculated as the
129    * time which the ranging round that generated this measurement concluded.
130    *
131    * @param sessionHandle an identifier to associate the ranging results with a
132    *                      session that is active
133    * @param result the ranging report
134    */
onRangingResult(in SessionHandle sessionHandle, in RangingReport result)135   void onRangingResult(in SessionHandle sessionHandle, in RangingReport result);
136 }
137