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.NonNull; 20 import android.annotation.Nullable; 21 import android.net.DhcpResultsParcelable; 22 import android.net.MacAddress; 23 import android.net.Network; 24 import android.net.wifi.IWifiConnectedNetworkScorer; 25 import android.net.wifi.WifiConfiguration; 26 import android.net.wifi.WifiInfo; 27 import android.net.wifi.WifiManager; 28 import android.net.wifi.WifiManager.DeviceMobilityState; 29 import android.net.wifi.hotspot2.IProvisioningCallback; 30 import android.net.wifi.hotspot2.OsuProvider; 31 import android.net.wifi.nl80211.DeviceWiphyCapabilities; 32 import android.os.IBinder; 33 import android.os.Message; 34 import android.os.WorkSource; 35 36 import com.android.server.wifi.util.ActionListenerWrapper; 37 38 import java.io.FileDescriptor; 39 import java.io.PrintWriter; 40 import java.util.ArrayList; 41 import java.util.List; 42 import java.util.Set; 43 44 /** 45 * Default implementations for {@link ClientMode} APIs. 46 */ 47 public interface ClientModeDefaults extends ClientMode { dump(FileDescriptor fd, PrintWriter pw, String[] args)48 default void dump(FileDescriptor fd, PrintWriter pw, String[] args) { } 49 connectNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid, @NonNull String packageName, @Nullable String attributionTag)50 default void connectNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, 51 int callingUid, @NonNull String packageName, @Nullable String attributionTag) { 52 // wifi off, can't connect. 53 wrapper.sendFailure(WifiManager.ActionListener.FAILURE_BUSY); 54 } 55 saveNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, int callingUid, @NonNull String packageName)56 default void saveNetwork(NetworkUpdateResult result, ActionListenerWrapper wrapper, 57 int callingUid, @NonNull String packageName) { 58 // wifi off, nothing more to do here. 59 wrapper.sendSuccess(); 60 } 61 disconnect()62 default void disconnect() { } 63 reconnect(WorkSource ws)64 default void reconnect(WorkSource ws) { } 65 reassociate()66 default void reassociate() { } 67 startConnectToNetwork(int networkId, int uid, String bssid)68 default void startConnectToNetwork(int networkId, int uid, String bssid) { } 69 startRoamToNetwork(int networkId, String bssid)70 default void startRoamToNetwork(int networkId, String bssid) { } 71 onDeviceMobilityStateUpdated(@eviceMobilityState int newState)72 default void onDeviceMobilityStateUpdated(@DeviceMobilityState int newState) { } 73 setLinkLayerStatsPollingInterval(int newIntervalMs)74 default void setLinkLayerStatsPollingInterval(int newIntervalMs) { } 75 setWifiConnectedNetworkScorer( IBinder binder, IWifiConnectedNetworkScorer scorer, int callerUid)76 default boolean setWifiConnectedNetworkScorer( 77 IBinder binder, IWifiConnectedNetworkScorer scorer, int callerUid) { 78 // don't fail the public API when wifi is off. 79 return true; 80 } 81 clearWifiConnectedNetworkScorer()82 default void clearWifiConnectedNetworkScorer() { } 83 84 /** 85 * Notify the connected network scorer of the user accepting a network switch. 86 */ onNetworkSwitchAccepted(int targetNetworkId, String targetBssid)87 default void onNetworkSwitchAccepted(int targetNetworkId, String targetBssid) { } 88 89 /** 90 * Notify the connected network scorer of the user rejecting a network switch. 91 */ onNetworkSwitchRejected(int targetNetworkId, String targetBssid)92 default void onNetworkSwitchRejected(int targetNetworkId, String targetBssid) { } 93 resetSimAuthNetworks(@lientModeImpl.ResetSimReason int resetReason)94 default void resetSimAuthNetworks(@ClientModeImpl.ResetSimReason int resetReason) { } 95 onBluetoothConnectionStateChanged()96 default void onBluetoothConnectionStateChanged() { } 97 getConnectionInfo()98 default WifiInfo getConnectionInfo() { 99 return new WifiInfo(); 100 } 101 syncQueryPasspointIcon(long bssid, String fileName)102 default boolean syncQueryPasspointIcon(long bssid, String fileName) { 103 return false; 104 } 105 getCurrentNetwork()106 default Network getCurrentNetwork() { 107 return null; 108 } 109 syncGetDhcpResultsParcelable()110 default DhcpResultsParcelable syncGetDhcpResultsParcelable() { 111 return new DhcpResultsParcelable(); 112 } 113 syncStartSubscriptionProvisioning(int callingUid, OsuProvider provider, IProvisioningCallback callback)114 default boolean syncStartSubscriptionProvisioning(int callingUid, OsuProvider provider, 115 IProvisioningCallback callback) { 116 return false; 117 } 118 119 /** Enable TDLS session with remote MAC address */ enableTdls(String remoteMacAddress, boolean enable)120 default boolean enableTdls(String remoteMacAddress, boolean enable) { 121 return false; 122 } 123 124 /** Enable TDLS session with remote IP address */ enableTdlsWithRemoteIpAddress(String remoteIpAddress, boolean enable)125 default boolean enableTdlsWithRemoteIpAddress(String remoteIpAddress, boolean enable) { 126 return false; 127 } 128 129 /** Check if a TDLS session can be established */ isTdlsOperationCurrentlyAvailable()130 default boolean isTdlsOperationCurrentlyAvailable() { 131 return false; 132 } 133 134 /** The maximum number of TDLS sessions supported by the device */ getMaxSupportedConcurrentTdlsSessions()135 default int getMaxSupportedConcurrentTdlsSessions() { 136 return -1; 137 } 138 139 /** The number of Peer mac addresses configured in the device for establishing a TDLS session */ getNumberOfEnabledTdlsSessions()140 default int getNumberOfEnabledTdlsSessions() { 141 return 0; 142 } 143 dumpIpClient(FileDescriptor fd, PrintWriter pw, String[] args)144 default void dumpIpClient(FileDescriptor fd, PrintWriter pw, String[] args) { } 145 dumpWifiScoreReport(FileDescriptor fd, PrintWriter pw, String[] args)146 default void dumpWifiScoreReport(FileDescriptor fd, PrintWriter pw, String[] args) { } 147 enableVerboseLogging(boolean verbose)148 default void enableVerboseLogging(boolean verbose) { } 149 getFactoryMacAddress()150 default String getFactoryMacAddress() { 151 return null; 152 } 153 getConnectedWifiConfiguration()154 default WifiConfiguration getConnectedWifiConfiguration() { 155 return null; 156 } 157 getConnectingWifiConfiguration()158 default WifiConfiguration getConnectingWifiConfiguration() { 159 return null; 160 } 161 getConnectedBssid()162 default String getConnectedBssid() { 163 return null; 164 } 165 getConnectingBssid()166 default String getConnectingBssid() { 167 return null; 168 } 169 getWifiLinkLayerStats()170 default WifiLinkLayerStats getWifiLinkLayerStats() { 171 return null; 172 } 173 setPowerSave(@owerSaveClientType int client, boolean ps)174 default boolean setPowerSave(@PowerSaveClientType int client, boolean ps) { 175 return false; 176 } 177 enablePowerSave()178 default boolean enablePowerSave() { 179 return false; 180 } 181 setLowLatencyMode(boolean enabled)182 default boolean setLowLatencyMode(boolean enabled) { 183 return false; 184 } 185 getMcastLockManagerFilterController()186 default WifiMulticastLockManager.FilterController getMcastLockManagerFilterController() { 187 return new WifiMulticastLockManager.FilterController() { 188 @Override 189 public void startFilteringMulticastPackets() { } 190 @Override 191 public void stopFilteringMulticastPackets() { } 192 }; 193 } 194 isConnected()195 default boolean isConnected() { 196 return false; 197 } 198 isConnecting()199 default boolean isConnecting() { 200 return false; 201 } 202 isRoaming()203 default boolean isRoaming() { 204 return false; 205 } 206 isDisconnected()207 default boolean isDisconnected() { 208 return true; 209 } 210 isIpProvisioningTimedOut()211 default boolean isIpProvisioningTimedOut() { 212 return false; 213 } 214 isSupplicantTransientState()215 default boolean isSupplicantTransientState() { 216 return false; 217 } 218 onCellularConnectivityChanged(@ifiDataStall.CellularDataStatusCode int status)219 default void onCellularConnectivityChanged(@WifiDataStall.CellularDataStatusCode int status) {} 220 probeLink(ClientMode.LinkProbeCallback callback, int mcs)221 default void probeLink(ClientMode.LinkProbeCallback callback, int mcs) { 222 callback.onFailure(ClientMode.LinkProbeCallback.LINK_PROBE_ERROR_NOT_CONNECTED); 223 } 224 sendMessageToClientModeImpl(Message msg)225 default void sendMessageToClientModeImpl(Message msg) { } 226 setMboCellularDataStatus(boolean available)227 default void setMboCellularDataStatus(boolean available) { } 228 getRoamingCapabilities()229 default WifiNative.RoamingCapabilities getRoamingCapabilities() { 230 return null; 231 } 232 configureRoaming(WifiNative.RoamingConfig config)233 default boolean configureRoaming(WifiNative.RoamingConfig config) { 234 return false; 235 } 236 enableRoaming(boolean enabled)237 default boolean enableRoaming(boolean enabled) { 238 return false; 239 } 240 setCountryCode(String countryCode)241 default boolean setCountryCode(String countryCode) { 242 return false; 243 } 244 getTxPktFates()245 default List<WifiNative.TxFateReport> getTxPktFates() { 246 return new ArrayList<>(); 247 } 248 getRxPktFates()249 default List<WifiNative.RxFateReport> getRxPktFates() { 250 return new ArrayList<>(); 251 } 252 getDeviceWiphyCapabilities()253 default DeviceWiphyCapabilities getDeviceWiphyCapabilities() { 254 return null; 255 } 256 requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes)257 default boolean requestAnqp(String bssid, Set<Integer> anqpIds, Set<Integer> hs20Subtypes) { 258 return false; 259 } 260 requestVenueUrlAnqp(String bssid)261 default boolean requestVenueUrlAnqp(String bssid) { 262 return false; 263 } 264 requestIcon(String bssid, String fileName)265 default boolean requestIcon(String bssid, String fileName) { 266 return false; 267 } 268 269 @Override setShouldReduceNetworkScore(boolean shouldReduceNetworkScore)270 default void setShouldReduceNetworkScore(boolean shouldReduceNetworkScore) { } 271 272 @Override updateCapabilities()273 default void updateCapabilities() { } 274 275 @Override isAffiliatedLinkBssid(MacAddress bssid)276 default boolean isAffiliatedLinkBssid(MacAddress bssid) { 277 return false; 278 } 279 280 @Override isMlo()281 default boolean isMlo() { 282 return false; 283 } 284 285 @Override onIdleModeChanged(boolean isIdle)286 default void onIdleModeChanged(boolean isIdle) { } 287 } 288