Fields Summary |
---|
private static final String | TAG |
public static final int | ERROR_AUTHENTICATINGThe error code if there was a problem authenticating. |
public static final String | WIFI_SCAN_AVAILABLEBroadcast intent action indicating whether Wi-Fi scanning is allowed currently |
public static final String | EXTRA_SCAN_AVAILABLEExtra int indicating scan availability, WIFI_STATE_ENABLED and WIFI_STATE_DISABLED |
public static final String | WIFI_STATE_CHANGED_ACTIONBroadcast intent action indicating that Wi-Fi has been enabled, disabled,
enabling, disabling, or unknown. One extra provides this state as an int.
Another extra provides the previous state, if available. |
public static final String | EXTRA_WIFI_STATEThe lookup key for an int that indicates whether Wi-Fi is enabled,
disabled, enabling, disabling, or unknown. Retrieve it with
{@link android.content.Intent#getIntExtra(String,int)}. |
public static final String | EXTRA_PREVIOUS_WIFI_STATEThe previous Wi-Fi state. |
public static final int | WIFI_STATE_DISABLINGWi-Fi is currently being disabled. The state will change to {@link #WIFI_STATE_DISABLED} if
it finishes successfully. |
public static final int | WIFI_STATE_DISABLEDWi-Fi is disabled. |
public static final int | WIFI_STATE_ENABLINGWi-Fi is currently being enabled. The state will change to {@link #WIFI_STATE_ENABLED} if
it finishes successfully. |
public static final int | WIFI_STATE_ENABLEDWi-Fi is enabled. |
public static final int | WIFI_STATE_UNKNOWNWi-Fi is in an unknown state. This state will occur when an error happens while enabling
or disabling. |
public static final String | WIFI_AP_STATE_CHANGED_ACTIONBroadcast intent action indicating that Wi-Fi AP has been enabled, disabled,
enabling, disabling, or failed. |
public static final String | EXTRA_WIFI_AP_STATEThe lookup key for an int that indicates whether Wi-Fi AP is enabled,
disabled, enabling, disabling, or failed. Retrieve it with
{@link android.content.Intent#getIntExtra(String,int)}. |
public static final String | EXTRA_PREVIOUS_WIFI_AP_STATEThe previous Wi-Fi state. |
public static final int | WIFI_AP_STATE_DISABLINGWi-Fi AP is currently being disabled. The state will change to
{@link #WIFI_AP_STATE_DISABLED} if it finishes successfully. |
public static final int | WIFI_AP_STATE_DISABLEDWi-Fi AP is disabled. |
public static final int | WIFI_AP_STATE_ENABLINGWi-Fi AP is currently being enabled. The state will change to
{@link #WIFI_AP_STATE_ENABLED} if it finishes successfully. |
public static final int | WIFI_AP_STATE_ENABLEDWi-Fi AP is enabled. |
public static final int | WIFI_AP_STATE_FAILEDWi-Fi AP is in a failed state. This state will occur when an error occurs during
enabling or disabling |
public static final String | SUPPLICANT_CONNECTION_CHANGE_ACTIONBroadcast intent action indicating that a connection to the supplicant has
been established (and it is now possible
to perform Wi-Fi operations) or the connection to the supplicant has been
lost. One extra provides the connection state as a boolean, where {@code true}
means CONNECTED. |
public static final String | EXTRA_SUPPLICANT_CONNECTEDThe lookup key for a boolean that indicates whether a connection to
the supplicant daemon has been gained or lost. {@code true} means
a connection now exists.
Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
public static final String | NETWORK_STATE_CHANGED_ACTIONBroadcast intent action indicating that the state of Wi-Fi connectivity
has changed. One extra provides the new state
in the form of a {@link android.net.NetworkInfo} object. If the new
state is CONNECTED, additional extras may provide the BSSID and WifiInfo of
the access point.
as a {@code String}. |
public static final String | EXTRA_NETWORK_INFOThe lookup key for a {@link android.net.NetworkInfo} object associated with the
Wi-Fi network. Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | EXTRA_BSSIDThe lookup key for a String giving the BSSID of the access point to which
we are connected. Only present when the new state is CONNECTED.
Retrieve with
{@link android.content.Intent#getStringExtra(String)}. |
public static final String | EXTRA_WIFI_INFOThe lookup key for a {@link android.net.wifi.WifiInfo} object giving the
information about the access point to which we are connected. Only present
when the new state is CONNECTED. Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | SUPPLICANT_STATE_CHANGED_ACTIONBroadcast intent action indicating that the state of establishing a connection to
an access point has changed.One extra provides the new
{@link SupplicantState}. Note that the supplicant state is Wi-Fi specific, and
is not generally the most useful thing to look at if you are just interested in
the overall state of connectivity. |
public static final String | EXTRA_NEW_STATEThe lookup key for a {@link SupplicantState} describing the new state
Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | EXTRA_SUPPLICANT_ERRORThe lookup key for a {@link SupplicantState} describing the supplicant
error code if any
Retrieve with
{@link android.content.Intent#getIntExtra(String, int)}. |
public static final String | CONFIGURED_NETWORKS_CHANGED_ACTIONBroadcast intent action indicating that the configured networks changed.
This can be as a result of adding/updating/deleting a network. If
{@link #EXTRA_MULTIPLE_NETWORKS_CHANGED} is set to true the new configuration
can be retreived with the {@link #EXTRA_WIFI_CONFIGURATION} extra. If multiple
Wi-Fi configurations changed, {@link #EXTRA_WIFI_CONFIGURATION} will not be present. |
public static final String | EXTRA_WIFI_CONFIGURATIONThe lookup key for a (@link android.net.wifi.WifiConfiguration} object representing
the changed Wi-Fi configuration when the {@link #CONFIGURED_NETWORKS_CHANGED_ACTION}
broadcast is sent. |
public static final String | EXTRA_MULTIPLE_NETWORKS_CHANGEDMultiple network configurations have changed. |
public static final String | EXTRA_CHANGE_REASONThe lookup key for an integer indicating the reason a Wi-Fi network configuration
has changed. Only present if {@link #EXTRA_MULTIPLE_NETWORKS_CHANGED} is {@code false} |
public static final int | CHANGE_REASON_ADDEDThe configuration is new and was added. |
public static final int | CHANGE_REASON_REMOVEDThe configuration was removed and is no longer present in the system's list of
configured networks. |
public static final int | CHANGE_REASON_CONFIG_CHANGEThe configuration has changed as a result of explicit action or because the system
took an automated action such as disabling a malfunctioning configuration. |
public static final String | SCAN_RESULTS_AVAILABLE_ACTIONAn access point scan has completed, and results are available from the supplicant.
Call {@link #getScanResults()} to obtain the results. |
public static final String | BATCHED_SCAN_RESULTS_AVAILABLE_ACTIONA batch of access point scans has been completed and the results areavailable.
Call {@link #getBatchedScanResults()} to obtain the results. |
public static final String | RSSI_CHANGED_ACTIONThe RSSI (signal strength) has changed. |
public static final String | EXTRA_NEW_RSSIThe lookup key for an {@code int} giving the new RSSI in dBm. |
public static final String | LINK_CONFIGURATION_CHANGED_ACTIONBroadcast intent action indicating that the link configuration
changed on wifi. |
public static final String | EXTRA_LINK_PROPERTIESThe lookup key for a {@link android.net.LinkProperties} object associated with the
Wi-Fi network. Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | EXTRA_NETWORK_CAPABILITIESThe lookup key for a {@link android.net.NetworkCapabilities} object associated with the
Wi-Fi network. Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | NETWORK_IDS_CHANGED_ACTIONThe network IDs of the configured networks could have changed. |
public static final String | ACTION_REQUEST_SCAN_ALWAYS_AVAILABLEActivity Action: Show a system activity that allows the user to enable
scans to be available even with Wi-Fi turned off.
Notification of the result of this activity is posted using the
{@link android.app.Activity#onActivityResult} callback. The
resultCode
will be {@link android.app.Activity#RESULT_OK} if scan always mode has
been turned on or {@link android.app.Activity#RESULT_CANCELED} if the user
has rejected the request or an error has occurred. |
public static final String | ACTION_PICK_WIFI_NETWORKActivity Action: Pick a Wi-Fi network to connect to.
Input: Nothing.
Output: Nothing. |
public static final int | WIFI_MODE_FULLIn this Wi-Fi lock mode, Wi-Fi will be kept active,
and will behave normally, i.e., it will attempt to automatically
establish a connection to a remembered access point that is
within range, and will do periodic scans if there are remembered
access points but none are in range. |
public static final int | WIFI_MODE_SCAN_ONLYIn this Wi-Fi lock mode, Wi-Fi will be kept active,
but the only operation that will be supported is initiation of
scans, and the subsequent reporting of scan results. No attempts
will be made to automatically connect to remembered access points,
nor will periodic scans be automatically performed looking for
remembered access points. Scans must be explicitly requested by
an application in this mode. |
public static final int | WIFI_MODE_FULL_HIGH_PERFIn this Wi-Fi lock mode, Wi-Fi will be kept active as in mode
{@link #WIFI_MODE_FULL} but it operates at high performance
with minimum packet loss and low packet latency even when
the device screen is off. This mode will consume more power
and hence should be used only when there is a need for such
an active connection.
An example use case is when a voice connection needs to be
kept active even after the device screen goes off. Holding the
regular {@link #WIFI_MODE_FULL} lock will keep the wifi
connection active, but the connection can be lossy.
Holding a {@link #WIFI_MODE_FULL_HIGH_PERF} lock for the
duration of the voice call will improve the call quality.
When there is no support from the hardware, this lock mode
will have the same behavior as {@link #WIFI_MODE_FULL} |
private static final int | MIN_RSSIAnything worse than or equal to this will show 0 bars. |
private static final int | MAX_RSSIAnything better than or equal to this will show the max bars. |
public static final int | RSSI_LEVELSNumber of RSSI levels used in the framework to initiate
{@link #RSSI_CHANGED_ACTION} broadcast |
public static final int | WIFI_FREQUENCY_BAND_AUTOAuto settings in the driver. The driver could choose to operate on both
2.4 GHz and 5 GHz or make a dynamic decision on selecting the band. |
public static final int | WIFI_FREQUENCY_BAND_5GHZOperation on 5 GHz alone |
public static final int | WIFI_FREQUENCY_BAND_2GHZOperation on 2.4 GHz alone |
public static final int | DATA_ACTIVITY_NOTIFICATIONList of asyncronous notifications |
public static final int | DATA_ACTIVITY_NONE |
public static final int | DATA_ACTIVITY_IN |
public static final int | DATA_ACTIVITY_OUT |
public static final int | DATA_ACTIVITY_INOUT |
public static final boolean | DEFAULT_POOR_NETWORK_AVOIDANCE_ENABLED |
private static final int | MAX_ACTIVE_LOCKS |
private int | mActiveLockCount |
private android.content.Context | mContext |
IWifiManager | mService |
private static final int | INVALID_KEY |
private static int | sListenerKey |
private static final android.util.SparseArray | sListenerMap |
private static final Object | sListenerMapLock |
private static com.android.internal.util.AsyncChannel | sAsyncChannel |
private static CountDownLatch | sConnected |
private static final Object | sThreadRefLock |
private static int | sThreadRefCount |
private static android.os.HandlerThread | sHandlerThread |
public static final int | WIFI_FEATURE_INFRA |
public static final int | WIFI_FEATURE_INFRA_5G |
public static final int | WIFI_FEATURE_PASSPOINT |
public static final int | WIFI_FEATURE_P2P |
public static final int | WIFI_FEATURE_MOBILE_HOTSPOT |
public static final int | WIFI_FEATURE_SCANNER |
public static final int | WIFI_FEATURE_NAN |
public static final int | WIFI_FEATURE_D2D_RTT |
public static final int | WIFI_FEATURE_D2AP_RTT |
public static final int | WIFI_FEATURE_BATCH_SCAN |
public static final int | WIFI_FEATURE_PNO |
public static final int | WIFI_FEATURE_ADDITIONAL_STA |
public static final int | WIFI_FEATURE_TDLS |
public static final int | WIFI_FEATURE_TDLS_OFFCHANNEL |
public static final int | WIFI_FEATURE_EPR |
private static final int | BASE |
public static final int | CONNECT_NETWORK |
public static final int | CONNECT_NETWORK_FAILED |
public static final int | CONNECT_NETWORK_SUCCEEDED |
public static final int | FORGET_NETWORK |
public static final int | FORGET_NETWORK_FAILED |
public static final int | FORGET_NETWORK_SUCCEEDED |
public static final int | SAVE_NETWORK |
public static final int | SAVE_NETWORK_FAILED |
public static final int | SAVE_NETWORK_SUCCEEDED |
public static final int | START_WPS |
public static final int | START_WPS_SUCCEEDED |
public static final int | WPS_FAILED |
public static final int | WPS_COMPLETED |
public static final int | CANCEL_WPS |
public static final int | CANCEL_WPS_FAILED |
public static final int | CANCEL_WPS_SUCCEDED |
public static final int | DISABLE_NETWORK |
public static final int | DISABLE_NETWORK_FAILED |
public static final int | DISABLE_NETWORK_SUCCEEDED |
public static final int | RSSI_PKTCNT_FETCH |
public static final int | RSSI_PKTCNT_FETCH_SUCCEEDED |
public static final int | RSSI_PKTCNT_FETCH_FAILED |
public static final int | ERRORPassed with {@link ActionListener#onFailure}.
Indicates that the operation failed due to an internal error. |
public static final int | IN_PROGRESSPassed with {@link ActionListener#onFailure}.
Indicates that the operation is already in progress |
public static final int | BUSYPassed with {@link ActionListener#onFailure}.
Indicates that the operation failed because the framework is busy and
unable to service the request |
public static final int | WPS_OVERLAP_ERRORWPS overlap detected |
public static final int | WPS_WEP_PROHIBITEDWEP on WPS is prohibited |
public static final int | WPS_TKIP_ONLY_PROHIBITEDTKIP only prohibited |
public static final int | WPS_AUTH_FAILUREAuthentication failure on WPS |
public static final int | WPS_TIMED_OUTWPS timed out |
public static final int | INVALID_ARGSPassed with {@link ActionListener#onFailure}.
Indicates that the operation failed due to invalid inputs |
public static final int | NOT_AUTHORIZEDPassed with {@link ActionListener#onFailure}.
Indicates that the operation failed due to user permissions. |
Methods Summary |
---|
public int | addNetwork(WifiConfiguration config)Add a new network description to the set of configured networks.
The {@code networkId} field of the supplied configuration object
is ignored.
The new network will be marked DISABLED by default. To enable it,
called {@link #enableNetwork}.
if (config == null) {
return -1;
}
config.networkId = -1;
return addOrUpdateNetwork(config);
|
private int | addOrUpdateNetwork(WifiConfiguration config)Internal method for doing the RPC that creates a new network description
or updates an existing one.
try {
return mService.addOrUpdateNetwork(config);
} catch (RemoteException e) {
return -1;
}
|
public boolean | addToBlacklist(java.lang.String bssid)Add a bssid to the supplicant blacklist
This API is used by WifiWatchdogService
try {
mService.addToBlacklist(bssid);
return true;
} catch (RemoteException e) {
return false;
}
|
public static int | calculateSignalLevel(int rssi, int numLevels)Calculates the level of the signal. This should be used any time a signal
is being shown.
if (rssi <= MIN_RSSI) {
return 0;
} else if (rssi >= MAX_RSSI) {
return numLevels - 1;
} else {
float inputRange = (MAX_RSSI - MIN_RSSI);
float outputRange = (numLevels - 1);
return (int)((float)(rssi - MIN_RSSI) * outputRange / inputRange);
}
|
public void | cancelWps(android.net.wifi.WifiManager$WpsCallback listener)Cancel any ongoing Wi-fi Protected Setup
validateChannel();
sAsyncChannel.sendMessage(CANCEL_WPS, 0, putListener(listener));
|
public boolean | clearBlacklist()Clear the supplicant blacklist
This API is used by WifiWatchdogService
try {
mService.clearBlacklist();
return true;
} catch (RemoteException e) {
return false;
}
|
public static int | compareSignalLevel(int rssiA, int rssiB)Compares two signal strengths.
return rssiA - rssiB;
|
public void | connect(WifiConfiguration config, android.net.wifi.WifiManager$ActionListener listener)Connect to a network with the given configuration. The network also
gets added to the supplicant configuration.
For a new network, this function is used instead of a
sequence of addNetwork(), enableNetwork(), saveConfiguration() and
reconnect()
if (config == null) throw new IllegalArgumentException("config cannot be null");
validateChannel();
// Use INVALID_NETWORK_ID for arg1 when passing a config object
// arg1 is used to pass network id when the network already exists
sAsyncChannel.sendMessage(CONNECT_NETWORK, WifiConfiguration.INVALID_NETWORK_ID,
putListener(listener), config);
|
public void | connect(int networkId, android.net.wifi.WifiManager$ActionListener listener)Connect to a network with the given networkId.
This function is used instead of a enableNetwork(), saveConfiguration() and
reconnect()
if (networkId < 0) throw new IllegalArgumentException("Network id cannot be negative");
validateChannel();
sAsyncChannel.sendMessage(CONNECT_NETWORK, networkId, putListener(listener));
|
public android.net.wifi.WifiManager$MulticastLock | createMulticastLock(java.lang.String tag)Create a new MulticastLock
return new MulticastLock(tag);
|
public android.net.wifi.WifiManager$WifiLock | createWifiLock(int lockType, java.lang.String tag)Creates a new WifiLock.
return new WifiLock(lockType, tag);
|
public android.net.wifi.WifiManager$WifiLock | createWifiLock(java.lang.String tag)Creates a new WifiLock.
return new WifiLock(WIFI_MODE_FULL, tag);
|
public void | disable(int netId, android.net.wifi.WifiManager$ActionListener listener)Disable network
if (netId < 0) throw new IllegalArgumentException("Network id cannot be negative");
validateChannel();
sAsyncChannel.sendMessage(DISABLE_NETWORK, netId, putListener(listener));
|
public void | disableEphemeralNetwork(java.lang.String SSID)Disable ephemeral Network
if (SSID == null) throw new IllegalArgumentException("SSID cannot be null");
try {
mService.disableEphemeralNetwork(SSID);
} catch (RemoteException e) {
}
|
public boolean | disableNetwork(int netId)Disable a configured network. The specified network will not be
a candidate for associating. This may result in the asynchronous
delivery of state change events.
try {
return mService.disableNetwork(netId);
} catch (RemoteException e) {
return false;
}
|
public boolean | disconnect()Disassociate from the currently active access point. This may result
in the asynchronous delivery of state change events.
try {
mService.disconnect();
return true;
} catch (RemoteException e) {
return false;
}
|
public void | enableAggressiveHandover(int enabled)Set wifi Aggressive Handover. Called from developer settings.
try {
mService.enableAggressiveHandover(enabled);
} catch (RemoteException e) {
}
|
public boolean | enableNetwork(int netId, boolean disableOthers)Allow a previously configured network to be associated with. If
disableOthers is true, then all other configured
networks are disabled, and an attempt to connect to the selected
network is initiated. This may result in the asynchronous delivery
of state change events.
try {
return mService.enableNetwork(netId, disableOthers);
} catch (RemoteException e) {
return false;
}
|
public void | enableVerboseLogging(int verbose)Set wifi verbose log. Called from developer settings.
try {
mService.enableVerboseLogging(verbose);
} catch (Exception e) {
//ignore any failure here
Log.e(TAG, "enableVerboseLogging " + e.toString());
}
|
protected void | finalize()
try {
synchronized (sThreadRefLock) {
if (--sThreadRefCount == 0 && sAsyncChannel != null) {
sAsyncChannel.disconnect();
}
}
} finally {
super.finalize();
}
|
public void | forget(int netId, android.net.wifi.WifiManager$ActionListener listener)Delete the network in the supplicant config.
This function is used instead of a sequence of removeNetwork()
and saveConfiguration().
if (netId < 0) throw new IllegalArgumentException("Network id cannot be negative");
validateChannel();
sAsyncChannel.sendMessage(FORGET_NETWORK, netId, putListener(listener));
|
public int | getAggressiveHandover()Get the WiFi Handover aggressiveness.This is used by settings
to decide what to show within the picker.
try {
return mService.getAggressiveHandover();
} catch (RemoteException e) {
return 0;
}
|
public int | getAllowScansWithTraffic()Get setting for allowing Scans when traffic is ongoing.
try {
return mService.getAllowScansWithTraffic();
} catch (RemoteException e) {
return 0;
}
|
public java.util.List | getBatchedScanResults()Retrieve the latest batched scan result. This should be called immediately after
{@link BATCHED_SCAN_RESULTS_AVAILABLE_ACTION} is received.
try {
return mService.getBatchedScanResults(mContext.getOpPackageName());
} catch (RemoteException e) {
return null;
}
|
public java.util.List | getChannelList()Get a list of available channels for customized scan.
try {
return mService.getChannelList();
} catch (RemoteException e) {
return null;
}
|
public java.lang.String | getConfigFile()Returns the file in which IP and proxy configuration data is stored
try {
return mService.getConfigFile();
} catch (RemoteException e) {
return null;
}
|
public java.util.List | getConfiguredNetworks()Return a list of all the networks configured in the supplicant.
Not all fields of WifiConfiguration are returned. Only the following
fields are filled in:
- networkId
- SSID
- BSSID
- priority
- allowedProtocols
- allowedKeyManagement
- allowedAuthAlgorithms
- allowedPairwiseCiphers
- allowedGroupCiphers
try {
return mService.getConfiguredNetworks();
} catch (RemoteException e) {
return null;
}
|
public WifiInfo | getConnectionInfo()Return dynamic information about the current Wi-Fi connection, if any is active.
try {
return mService.getConnectionInfo();
} catch (RemoteException e) {
return null;
}
|
public WifiConnectionStatistics | getConnectionStatistics()
try {
return mService.getConnectionStatistics();
} catch (RemoteException e) {
return null;
}
|
public WifiActivityEnergyInfo | getControllerActivityEnergyInfo(int updateType)Return the record of {@link WifiActivityEnergyInfo} object that
has the activity and energy info. This can be used to ascertain what
the controller has been up to, since the last sample.
if (mService == null) return null;
try {
WifiActivityEnergyInfo record;
if (!isEnhancedPowerReportingSupported()) {
return null;
}
synchronized(this) {
record = mService.reportActivityInfo();
if (record.isValid()) {
return record;
} else {
return null;
}
}
} catch (RemoteException e) {
Log.e(TAG, "getControllerActivityEnergyInfo: " + e);
}
return null;
|
public android.net.DhcpInfo | getDhcpInfo()Return the DHCP-assigned addresses from the last successful DHCP request,
if any.
try {
return mService.getDhcpInfo();
} catch (RemoteException e) {
return null;
}
|
public int | getFrequencyBand()Get the operational frequency band.
try {
return mService.getFrequencyBand();
} catch (RemoteException e) {
return -1;
}
|
public java.util.List | getPrivilegedConfiguredNetworks()
try {
return mService.getPrivilegedConfiguredNetworks();
} catch (RemoteException e) {
return null;
}
|
public java.util.List | getScanResults()Return the results of the latest access point scan.
try {
return mService.getScanResults(mContext.getOpPackageName());
} catch (RemoteException e) {
return null;
}
|
private int | getSupportedFeatures() // Enhanced power reporting
try {
return mService.getSupportedFeatures();
} catch (RemoteException e) {
return 0;
}
|
public void | getTxPacketCount(android.net.wifi.WifiManager$TxPacketCountListener listener)Return TX packet counter, for CTS test of WiFi watchdog.
validateChannel();
sAsyncChannel.sendMessage(RSSI_PKTCNT_FETCH, 0, putListener(listener));
|
public int | getVerboseLoggingLevel()Get the WiFi verbose logging level.This is used by settings
to decide what to show within the picker.
try {
return mService.getVerboseLoggingLevel();
} catch (RemoteException e) {
return 0;
}
|
public WifiConfiguration | getWifiApConfiguration()Gets the Wi-Fi AP Configuration.
try {
return mService.getWifiApConfiguration();
} catch (RemoteException e) {
return null;
}
|
public int | getWifiApState()Gets the Wi-Fi enabled state.
try {
return mService.getWifiApEnabledState();
} catch (RemoteException e) {
return WIFI_AP_STATE_FAILED;
}
|
public android.os.Messenger | getWifiServiceMessenger()Get a reference to WifiService handler. This is used by a client to establish
an AsyncChannel communication with WifiService
try {
return mService.getWifiServiceMessenger();
} catch (RemoteException e) {
return null;
} catch (SecurityException e) {
return null;
}
|
public int | getWifiState()Gets the Wi-Fi enabled state.
try {
return mService.getWifiEnabledState();
} catch (RemoteException e) {
return WIFI_STATE_UNKNOWN;
}
|
public java.lang.String | getWpsNfcConfigurationToken(int netId)Creates a configuration token describing the network referenced by {@code netId}
of MIME type application/vnd.wfa.wsc. Can be used to configure WiFi networks via NFC.
try {
return mService.getWpsNfcConfigurationToken(netId);
} catch (RemoteException e) {
return null;
}
|
private void | init()
synchronized (sThreadRefLock) {
if (++sThreadRefCount == 1) {
Messenger messenger = getWifiServiceMessenger();
if (messenger == null) {
sAsyncChannel = null;
return;
}
sHandlerThread = new HandlerThread("WifiManager");
sAsyncChannel = new AsyncChannel();
sConnected = new CountDownLatch(1);
sHandlerThread.start();
Handler handler = new ServiceHandler(sHandlerThread.getLooper());
sAsyncChannel.connect(mContext, handler, messenger);
try {
sConnected.await();
} catch (InterruptedException e) {
Log.e(TAG, "interrupted wait at init");
}
}
}
|
public boolean | initializeMulticastFiltering()Initialize the multicast filtering to 'on'
try {
mService.initializeMulticastFiltering();
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | is5GHzBandSupported()
return isFeatureSupported(WIFI_FEATURE_INFRA_5G);
|
public boolean | isAdditionalStaSupported()
return isFeatureSupported(WIFI_FEATURE_ADDITIONAL_STA);
|
public boolean | isBatchedScanSupported()Check if the Batched Scan feature is supported.
try {
return mService.isBatchedScanSupported();
} catch (RemoteException e) { return false; }
|
public boolean | isDeviceToApRttSupported()
return isFeatureSupported(WIFI_FEATURE_D2AP_RTT);
|
public boolean | isDeviceToDeviceRttSupported()
return isFeatureSupported(WIFI_FEATURE_D2D_RTT);
|
public boolean | isDualBandSupported()Check if the chipset supports dual frequency band (2.4 GHz and 5 GHz)
try {
return mService.isDualBandSupported();
} catch (RemoteException e) {
return false;
}
|
public boolean | isEnhancedPowerReportingSupported()
return isFeatureSupported(WIFI_FEATURE_EPR);
|
private boolean | isFeatureSupported(int feature)
return (getSupportedFeatures() & feature) == feature;
|
public boolean | isMulticastEnabled()Check multicast filter status.
try {
return mService.isMulticastEnabled();
} catch (RemoteException e) {
return false;
}
|
public boolean | isNanSupported()
return isFeatureSupported(WIFI_FEATURE_NAN);
|
public boolean | isOffChannelTdlsSupported()
return isFeatureSupported(WIFI_FEATURE_TDLS_OFFCHANNEL);
|
public boolean | isP2pSupported()
return isFeatureSupported(WIFI_FEATURE_P2P);
|
public boolean | isPasspointSupported()
return isFeatureSupported(WIFI_FEATURE_PASSPOINT);
|
public boolean | isPortableHotspotSupported()
return isFeatureSupported(WIFI_FEATURE_MOBILE_HOTSPOT);
|
public boolean | isPreferredNetworkOffloadSupported()
return isFeatureSupported(WIFI_FEATURE_PNO);
|
public boolean | isScanAlwaysAvailable()Check if scanning is always available.
If this return {@code true}, apps can issue {@link #startScan} and fetch scan results
even when Wi-Fi is turned off.
To change this setting, see {@link #ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE}.
try {
return mService.isScanAlwaysAvailable();
} catch (RemoteException e) {
return false;
}
|
public boolean | isTdlsSupported()
return isFeatureSupported(WIFI_FEATURE_TDLS);
|
public boolean | isWifiApEnabled()Return whether Wi-Fi AP is enabled or disabled.
return getWifiApState() == WIFI_AP_STATE_ENABLED;
|
public boolean | isWifiEnabled()Return whether Wi-Fi is enabled or disabled.
return getWifiState() == WIFI_STATE_ENABLED;
|
public boolean | isWifiScannerSupported()
return isFeatureSupported(WIFI_FEATURE_SCANNER);
|
public boolean | pingSupplicant()Check that the supplicant daemon is responding to requests.
if (mService == null)
return false;
try {
return mService.pingSupplicant();
} catch (RemoteException e) {
return false;
}
|
public void | pollBatchedScan()Force a re-reading of batched scan results. This will attempt
to read more information from the chip, but will do so at the expense
of previous data. Rate limited to the current scan frequency.
pollBatchedScan will always wait 1 period from the start of the batch
before trying to read from the chip, so if your #scans/batch == 1 this will
have no effect.
If you had already waited 1 period before calling, this should have
immediate (though async) effect.
If you call before that 1 period is up this will set up a timer and fetch
results when the 1 period is up.
Servicing a pollBatchedScan request (immediate or after timed delay) starts a
new batch, so if you were doing 10 scans/batch and called in the 4th scan, you
would get data in the 4th and then again 10 scans later.
try {
mService.pollBatchedScan();
} catch (RemoteException e) { }
|
private static int | putListener(java.lang.Object listener)
if (listener == null) return INVALID_KEY;
int key;
synchronized (sListenerMapLock) {
do {
key = sListenerKey++;
} while (key == INVALID_KEY);
sListenerMap.put(key, listener);
}
return key;
|
public boolean | reassociate()Reconnect to the currently active access point, even if we are already
connected. This may result in the asynchronous delivery of state
change events.
try {
mService.reassociate();
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | reconnect()Reconnect to the currently active access point, if we are currently
disconnected. This may result in the asynchronous delivery of state
change events.
try {
mService.reconnect();
return true;
} catch (RemoteException e) {
return false;
}
|
private static java.lang.Object | removeListener(int key)
if (key == INVALID_KEY) return null;
synchronized (sListenerMapLock) {
Object listener = sListenerMap.get(key);
sListenerMap.remove(key);
return listener;
}
|
public boolean | removeNetwork(int netId)Remove the specified network from the list of configured networks.
This may result in the asynchronous delivery of state change
events.
try {
return mService.removeNetwork(netId);
} catch (RemoteException e) {
return false;
}
|
public boolean | requestBatchedScan(BatchedScanSettings requested)Request a batched scan for access points. To end your requested batched scan,
call stopBatchedScan with the same Settings.
If there are mulitple requests for batched scans, the more demanding settings will
take precidence.
try {
return mService.requestBatchedScan(requested, new Binder(), null);
} catch (RemoteException e) { return false; }
|
public boolean | requestBatchedScan(BatchedScanSettings requested, android.os.WorkSource workSource)
try {
return mService.requestBatchedScan(requested, new Binder(), workSource);
} catch (RemoteException e) { return false; }
|
public void | save(WifiConfiguration config, android.net.wifi.WifiManager$ActionListener listener)Save the given network in the supplicant config. If the network already
exists, the configuration is updated. A new network is enabled
by default.
For a new network, this function is used instead of a
sequence of addNetwork(), enableNetwork() and saveConfiguration().
For an existing network, it accomplishes the task of updateNetwork()
and saveConfiguration()
if (config == null) throw new IllegalArgumentException("config cannot be null");
validateChannel();
sAsyncChannel.sendMessage(SAVE_NETWORK, 0, putListener(listener), config);
|
public boolean | saveConfiguration()Tell the supplicant to persist the current list of configured networks.
Note: It is possible for this method to change the network IDs of
existing networks. You should assume the network IDs can be different
after calling this method.
try {
return mService.saveConfiguration();
} catch (RemoteException e) {
return false;
}
|
public void | setAllowScansWithTraffic(int enabled)Set setting for allowing Scans when traffic is ongoing.
try {
mService.setAllowScansWithTraffic(enabled);
} catch (RemoteException e) {
}
|
public void | setCountryCode(java.lang.String country, boolean persist)Set the country code.
try {
mService.setCountryCode(country, persist);
} catch (RemoteException e) { }
|
public void | setFrequencyBand(int band, boolean persist)Set the operational frequency band.
try {
mService.setFrequencyBand(band, persist);
} catch (RemoteException e) { }
|
public void | setTdlsEnabled(java.net.InetAddress remoteIPAddress, boolean enable)Enable/Disable TDLS on a specific local route.
TDLS enables two wireless endpoints to talk to each other directly
without going through the access point that is managing the local
network. It saves bandwidth and improves quality of the link.
This API enables/disables the option of using TDLS. If enabled, the
underlying hardware is free to use TDLS or a hop through the access
point. If disabled, existing TDLS session is torn down and
hardware is restricted to use access point for transferring wireless
packets. Default value for all routes is 'disabled', meaning restricted
to use access point for transferring packets.
try {
mService.enableTdls(remoteIPAddress.getHostAddress(), enable);
} catch (RemoteException e) {
// Just ignore the exception
}
|
public void | setTdlsEnabledWithMacAddress(java.lang.String remoteMacAddress, boolean enable)Similar to {@link #setTdlsEnabled(InetAddress, boolean) }, except
this version allows you to specify remote endpoint with a MAC address.
try {
mService.enableTdlsWithMacAddress(remoteMacAddress, enable);
} catch (RemoteException e) {
// Just ignore the exception
}
|
public boolean | setWifiApConfiguration(WifiConfiguration wifiConfig)Sets the Wi-Fi AP Configuration.
try {
mService.setWifiApConfiguration(wifiConfig);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled)Start AccessPoint mode with the specified
configuration. If the radio is already running in
AP mode, update the new configuration
Note that starting in access point mode disables station
mode operation
try {
mService.setWifiApEnabled(wifiConfig, enabled);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | setWifiEnabled(boolean enabled)Enable or disable Wi-Fi.
try {
return mService.setWifiEnabled(enabled);
} catch (RemoteException e) {
return false;
}
|
public boolean | startCustomizedScan(android.net.wifi.ScanSettings requested)Request a scan for access points in specified channel list. Each channel is specified by its
frequency in MHz, e.g. "5500" (do NOT include "DFS" even though it is). The availability of
the results is made known later in the same way as {@link #startScan}.
Note:
1. Customized scan is for non-connection purposes, i.e. it won't trigger a wifi connection
even though it finds some known networks.
2. Customized scan result may include access points that is not specified in the channel
list. An app will need to do frequency filtering if it wants to get pure results for the
channel list it specified.
try {
mService.startScan(requested, null);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | startCustomizedScan(android.net.wifi.ScanSettings requested, android.os.WorkSource workSource)
try {
mService.startScan(requested, workSource);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | startLocationRestrictedScan(android.os.WorkSource workSource)startLocationRestrictedScan()
Trigger a scan which will not make use of DFS channels and is thus not suitable for
establishing wifi connection.
try {
mService.startLocationRestrictedScan(workSource);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | startScan()Request a scan for access points. Returns immediately. The availability
of the results is made known later by means of an asynchronous event sent
on completion of the scan.
try {
mService.startScan(null, null);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | startScan(android.os.WorkSource workSource)
try {
mService.startScan(null, workSource);
return true;
} catch (RemoteException e) {
return false;
}
|
public boolean | startWifi()Start the driver and connect to network.
This function will over-ride WifiLock and device idle status. For example,
even if the device is idle or there is only a scan-only lock held,
a start wifi would mean that wifi connection is kept active until
a stopWifi() is sent.
This API is used by WifiStateTracker
try {
mService.startWifi();
return true;
} catch (RemoteException e) {
return false;
}
|
public void | startWps(WpsInfo config, android.net.wifi.WifiManager$WpsCallback listener)Start Wi-fi Protected Setup
if (config == null) throw new IllegalArgumentException("config cannot be null");
validateChannel();
sAsyncChannel.sendMessage(START_WPS, 0, putListener(listener), config);
|
public void | stopBatchedScan(BatchedScanSettings requested)End a requested batch scan for this applicaiton. Note that batched scan may
still occur if other apps are using them.
try {
mService.stopBatchedScan(requested);
} catch (RemoteException e) {}
|
public boolean | stopWifi()Disconnect from a network (if any) and stop the driver.
This function will over-ride WifiLock and device idle status. Wi-Fi
stays inactive until a startWifi() is issued.
This API is used by WifiStateTracker
try {
mService.stopWifi();
return true;
} catch (RemoteException e) {
return false;
}
|
public int | updateNetwork(WifiConfiguration config)Update the network description of an existing configured network.
if (config == null || config.networkId < 0) {
return -1;
}
return addOrUpdateNetwork(config);
|
private void | validateChannel()
if (sAsyncChannel == null) throw new IllegalStateException(
"No permission to access and change wifi or a bad initialization");
|