• 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 com.android.server.wifi;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.net.DhcpResultsParcelable;
23 import android.net.Network;
24 import android.net.wifi.IWifiConnectedNetworkScorer;
25 import android.net.wifi.WifiAnnotations;
26 import android.net.wifi.WifiConfiguration;
27 import android.net.wifi.WifiInfo;
28 import android.net.wifi.hotspot2.IProvisioningCallback;
29 import android.net.wifi.hotspot2.OsuProvider;
30 import android.net.wifi.nl80211.DeviceWiphyCapabilities;
31 import android.net.wifi.nl80211.WifiNl80211Manager;
32 import android.os.IBinder;
33 import android.os.Message;
34 import android.os.WorkSource;
35 
36 import com.android.server.wifi.WifiNative.RxFateReport;
37 import com.android.server.wifi.WifiNative.TxFateReport;
38 import com.android.server.wifi.util.ActionListenerWrapper;
39 
40 import java.io.FileDescriptor;
41 import java.io.PrintWriter;
42 import java.lang.annotation.Retention;
43 import java.lang.annotation.RetentionPolicy;
44 import java.util.List;
45 import java.util.Set;
46 
47 /**
48  * This interface is used to respond to calls independent of a STA's current mode.
49  * If the STA is in scan only mode, ClientMode is implemented using {@link ScanOnlyModeImpl}.
50  * If the STA is in client mode, ClientMode is implemented using {@link ClientModeImpl}.
51  */
52 public interface ClientMode {
53     @Retention(RetentionPolicy.SOURCE)
54     @IntDef(flag = true, prefix = {"POWER_SAVE_CLIENT_"},
55             value = {
56                     POWER_SAVE_CLIENT_DHCP,
57                     POWER_SAVE_CLIENT_WIFI_LOCK})
58     @interface PowerSaveClientType {}
59     int POWER_SAVE_CLIENT_DHCP = 0x1;
60     int POWER_SAVE_CLIENT_WIFI_LOCK = 0x2;
61 
dump(FileDescriptor fd, PrintWriter pw, String[] args)62     void dump(FileDescriptor fd, PrintWriter pw, String[] args);
63 
enableVerboseLogging(boolean verbose)64     void enableVerboseLogging(boolean verbose);
65 
connectNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid, @NonNull String packageName)66     void connectNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid,
67             @NonNull String packageName);
68 
saveNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid, @NonNull String packageName)69     void saveNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid,
70             @NonNull String packageName);
71 
disconnect()72     void disconnect();
73 
reconnect(WorkSource ws)74     void reconnect(WorkSource ws);
75 
reassociate()76     void reassociate();
77 
startConnectToNetwork(int networkId, int uid, String bssid)78     void startConnectToNetwork(int networkId, int uid, String bssid);
79 
startRoamToNetwork(int networkId, String bssid)80     void startRoamToNetwork(int networkId, String bssid);
81 
setWifiConnectedNetworkScorer(IBinder binder, IWifiConnectedNetworkScorer scorer)82     boolean setWifiConnectedNetworkScorer(IBinder binder, IWifiConnectedNetworkScorer scorer);
83 
clearWifiConnectedNetworkScorer()84     void clearWifiConnectedNetworkScorer();
85 
resetSimAuthNetworks(@lientModeImpl.ResetSimReason int resetReason)86     void resetSimAuthNetworks(@ClientModeImpl.ResetSimReason int resetReason);
87 
88     /**
89      * Notification that the Bluetooth connection state changed. The latest connection state can be
90      * fetched from {@link WifiGlobals#isBluetoothConnected()}.
91      */
onBluetoothConnectionStateChanged()92     void onBluetoothConnectionStateChanged();
93 
syncRequestConnectionInfo()94     WifiInfo syncRequestConnectionInfo();
95 
syncQueryPasspointIcon(long bssid, String fileName)96     boolean syncQueryPasspointIcon(long bssid, String fileName);
97 
syncGetCurrentNetwork()98     Network syncGetCurrentNetwork();
99 
syncGetDhcpResultsParcelable()100     DhcpResultsParcelable syncGetDhcpResultsParcelable();
101 
102     /** Get the supported feature set synchronously */
getSupportedFeatures()103     long getSupportedFeatures();
104 
syncStartSubscriptionProvisioning(int callingUid, OsuProvider provider, IProvisioningCallback callback)105     boolean syncStartSubscriptionProvisioning(int callingUid, OsuProvider provider,
106             IProvisioningCallback callback);
107 
isWifiStandardSupported(@ifiAnnotations.WifiStandard int standard)108     boolean isWifiStandardSupported(@WifiAnnotations.WifiStandard int standard);
109 
enableTdls(String remoteMacAddress, boolean enable)110     void enableTdls(String remoteMacAddress, boolean enable);
111 
dumpIpClient(FileDescriptor fd, PrintWriter pw, String[] args)112     void dumpIpClient(FileDescriptor fd, PrintWriter pw, String[] args);
113 
dumpWifiScoreReport(FileDescriptor fd, PrintWriter pw, String[] args)114     void dumpWifiScoreReport(FileDescriptor fd, PrintWriter pw, String[] args);
115 
getFactoryMacAddress()116     String getFactoryMacAddress();
117 
118     /**
119      * Returns WifiConfiguration object corresponding to the currently connected network, null if
120      * not connected.
121      */
122     @Nullable
getConnectedWifiConfiguration()123     WifiConfiguration getConnectedWifiConfiguration();
124 
125     /**
126      * Returns WifiConfiguration object corresponding to the currently connecting network, null if
127      * not connecting.
128      */
getConnectingWifiConfiguration()129     @Nullable WifiConfiguration getConnectingWifiConfiguration();
130 
131     /**
132      * Returns bssid corresponding to the currently connected network, null if not connected.
133      */
getConnectedBssid()134     @Nullable String getConnectedBssid();
135 
136     /**
137      * Returns bssid corresponding to the currently connecting network, null if not connecting.
138      */
getConnectingBssid()139     @Nullable String getConnectingBssid();
140 
getWifiLinkLayerStats()141     WifiLinkLayerStats getWifiLinkLayerStats();
142 
setPowerSave(@owerSaveClientType int client, boolean ps)143     boolean setPowerSave(@PowerSaveClientType int client, boolean ps);
enablePowerSave()144     boolean enablePowerSave();
145 
setLowLatencyMode(boolean enabled)146     boolean setLowLatencyMode(boolean enabled);
147 
getMcastLockManagerFilterController()148     WifiMulticastLockManager.FilterController getMcastLockManagerFilterController();
149 
isConnected()150     boolean isConnected();
151 
isConnecting()152     boolean isConnecting();
153 
isRoaming()154     boolean isRoaming();
155 
isDisconnected()156     boolean isDisconnected();
157 
isSupplicantTransientState()158     boolean isSupplicantTransientState();
159 
onCellularConnectivityChanged(@ifiDataStall.CellularDataStatusCode int status)160     void onCellularConnectivityChanged(@WifiDataStall.CellularDataStatusCode int status);
161 
162     /** Result callback for {@link #probeLink(LinkProbeCallback, int)} */
163     interface LinkProbeCallback extends WifiNl80211Manager.SendMgmtFrameCallback {
164 
165         @Retention(RetentionPolicy.SOURCE)
166         @IntDef(prefix = {"LINK_PROBE_ERROR_"},
167                 value = {LINK_PROBE_ERROR_NOT_CONNECTED})
168         @interface LinkProbeFailure {}
169 
170         /** Attempted to send a link probe when not connected to Wifi. */
171         // Note: this is a restriction in the Wifi framework since link probing is defined to be
172         // targeted at the currently connected AP. Driver/firmware has no problems with sending
173         // management frames to arbitrary APs whether connected or disconnected.
174         int LINK_PROBE_ERROR_NOT_CONNECTED = 1000;
175 
176         /**
177          * Called when the link probe failed.
178          * @param reason The error code for the failure. One of
179          * {@link WifiNl80211Manager.SendMgmtFrameError} or {@link LinkProbeFailure}.
180          */
onFailure(int reason)181         void onFailure(int reason);
182 
failureReasonToString(int reason)183         static String failureReasonToString(int reason) {
184             switch (reason) {
185                 case WifiNl80211Manager.SEND_MGMT_FRAME_ERROR_UNKNOWN:
186                     return "SEND_MGMT_FRAME_ERROR_UNKNOWN";
187                 case WifiNl80211Manager.SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED:
188                     return "SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED";
189                 case WifiNl80211Manager.SEND_MGMT_FRAME_ERROR_NO_ACK:
190                     return "SEND_MGMT_FRAME_ERROR_NO_ACK";
191                 case WifiNl80211Manager.SEND_MGMT_FRAME_ERROR_TIMEOUT:
192                     return "SEND_MGMT_FRAME_ERROR_TIMEOUT";
193                 case WifiNl80211Manager.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED:
194                     return "SEND_MGMT_FRAME_ERROR_ALREADY_STARTED";
195                 case LINK_PROBE_ERROR_NOT_CONNECTED:
196                     return "LINK_PROBE_ERROR_NOT_CONNECTED";
197                 default:
198                     return "Unrecognized error";
199             }
200         }
201     }
202 
203     /** Send a link probe */
probeLink(LinkProbeCallback callback, int mcs)204     void probeLink(LinkProbeCallback callback, int mcs);
205 
206     /** Send a {@link Message} to ClientModeImpl's StateMachine. */
sendMessageToClientModeImpl(Message msg)207     void sendMessageToClientModeImpl(Message msg);
208 
209     /** Unique ID for this ClientMode instance, used for debugging. */
getId()210     long getId();
211 
212     /**
213      * Set MBO cellular data status
214      * @param available cellular data status, true means cellular data available, false otherwise.
215      */
setMboCellularDataStatus(boolean available)216     void setMboCellularDataStatus(boolean available);
217 
218     /**
219      * Query the firmware roaming capabilities.
220      * @return Roaming Capabilities on success, null on failure.
221      */
222     @Nullable
getRoamingCapabilities()223     WifiNative.RoamingCapabilities getRoamingCapabilities();
224 
225     /** Set firmware roaming configurations. */
configureRoaming(WifiNative.RoamingConfig config)226     boolean configureRoaming(WifiNative.RoamingConfig config);
227 
228     /** Enable/Disable firmware roaming. */
enableRoaming(boolean enabled)229     boolean enableRoaming(boolean enabled);
230 
231     /**
232      * Set country code.
233      *
234      * @param countryCode 2 byte ASCII string. For ex: US, CA.
235      * @return true if request is sent successfully, false otherwise.
236      */
setCountryCode(String countryCode)237     boolean setCountryCode(String countryCode);
238 
239     /**
240      * Fetch the most recent TX packet fates from the HAL. Fails unless HAL is started.
241      * @return TxFateReport list on success, empty list on failure. Never returns null.
242      */
243     @NonNull
getTxPktFates()244     List<TxFateReport> getTxPktFates();
245 
246     /**
247      * Fetch the most recent RX packet fates from the HAL. Fails unless HAL is started.
248      * @return RxFateReport list on success, empty list on failure. Never returns null.
249      */
250     @NonNull
getRxPktFates()251     List<RxFateReport> getRxPktFates();
252 
253     /**
254      * Get the Wiphy capabilities of a device for a given interface
255      * If the interface is not associated with one,
256      * it will be read from the device through wificond
257      *
258      * @return the device capabilities for this interface, or null if not available
259      */
260     @Nullable
getDeviceWiphyCapabilities()261     DeviceWiphyCapabilities getDeviceWiphyCapabilities();
262 
263     /**
264      * Initiate ANQP query.
265      *
266      * @param bssid BSSID of the AP to be queried
267      * @param anqpIds Set of anqp IDs.
268      * @param hs20Subtypes Set of HS20 subtypes.
269      * @return true on success, false otherwise.
270      */
requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes)271     boolean requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes);
272 
273     /**
274      * Initiate Venue URL ANQP query.
275      *
276      * @param bssid BSSID of the AP to be queried
277      * @return true on success, false otherwise.
278      */
requestVenueUrlAnqp(String bssid)279     boolean requestVenueUrlAnqp(String bssid);
280 
281     /**
282      * Request a passpoint icon file |filename| from the specified AP |bssid|.
283      *
284      * @param bssid BSSID of the AP
285      * @param fileName name of the icon file
286      * @return true if request is sent successfully, false otherwise
287      */
requestIcon(String bssid, String fileName)288     boolean requestIcon(String  bssid, String fileName);
289 
290     /**
291      * If set to true, the NetworkAgent score for connections established on this ClientModeManager
292      * will be artificially reduced so that ConnectivityService will prefer any other connection.
293      */
setShouldReduceNetworkScore(boolean shouldReduceNetworkScore)294     void setShouldReduceNetworkScore(boolean shouldReduceNetworkScore);
295 
296 
297     /**
298      * update the capabilities
299      */
updateCapabilities()300     void updateCapabilities();
301 }
302