1 /*
2  * Copyright (C) 2022 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 com.android.server.wifi.hal;
18 
19 import android.annotation.Nullable;
20 import android.net.MacAddress;
21 import android.net.wifi.rtt.RangingRequest;
22 
23 import java.io.PrintWriter;
24 import java.util.List;
25 
26 interface IWifiRttController {
27     /**
28      * Set up the IWifiRttController.
29      *
30      * @return true if successful, false otherwise.
31      */
setup()32     boolean setup();
33 
34     /**
35      * Enable/disable verbose logging.
36      */
enableVerboseLogging(boolean verbose)37     void enableVerboseLogging(boolean verbose);
38 
39     /**
40      * Register a callback to receive ranging results.
41      *
42      * @param callback Callback to register.
43      */
registerRangingResultsCallback( WifiRttController.RttControllerRangingResultsCallback callback)44     void registerRangingResultsCallback(
45             WifiRttController.RttControllerRangingResultsCallback callback);
46 
47     /**
48      * Check whether the RTT controller is valid.
49      *
50      * @return true if the RTT controller is valid, false otherwise or if an error occurred.
51      */
validate()52     boolean validate();
53 
54     /**
55      * Get the RTT capabilities.
56      *
57      * @return Capabilities, or null if they could not be retrieved.
58      */
59     @Nullable
getRttCapabilities()60     WifiRttController.Capabilities getRttCapabilities();
61 
62     /**
63      * Issue a range request to the HAL.
64      *
65      * @param cmdId Command ID for the request. Will be used in the corresponding response from
66      *              {@link HalDeviceManager.InterfaceRttControllerLifecycleCallback}
67      *              onRangingResults()
68      * @param request Range request.
69      * @return true if successful, false otherwise.
70      */
rangeRequest(int cmdId, RangingRequest request)71     boolean rangeRequest(int cmdId, RangingRequest request);
72 
73     /**
74      * Cancel an outstanding ranging request.
75      *
76      * Note: No guarantees of execution. Can ignore any results which are returned for the
77      * canceled request.
78      *
79      * @param cmdId The cmdId issued with the original rangeRequest command.
80      * @param macAddresses A list of MAC addresses for which to cancel the operation.
81      * @return true for success, false for failure.
82      */
rangeCancel(int cmdId, List<MacAddress> macAddresses)83     boolean rangeCancel(int cmdId, List<MacAddress> macAddresses);
84 
85     /**
86      * Dump the internal state of the class.
87      */
dump(PrintWriter pw)88     void dump(PrintWriter pw);
89 }
90