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