/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.content.Context; import android.net.ConnectivityManager; import android.net.DhcpInfo; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.os.Binder; import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.os.WorkSource; import android.util.Log; import android.util.SparseArray; import com.android.internal.util.AsyncChannel; import com.android.internal.util.Protocol; import com.android.server.net.NetworkPinner; import java.net.InetAddress; import java.util.List; import java.util.concurrent.CountDownLatch; /** * This class provides the primary API for managing all aspects of Wi-Fi * connectivity. Get an instance of this class by calling * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.WIFI_SERVICE)}. * On releases before NYC, it should only be obtained from an application context, and not from * any other derived context to avoid memory leaks within the calling process. * It deals with several categories of items: *
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.
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE =
"android.net.wifi.action.REQUEST_SCAN_ALWAYS_AVAILABLE";
/**
* Activity Action: Pick a Wi-Fi network to connect to.
*
Input: Nothing. *
Output: Nothing. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_PICK_WIFI_NETWORK = "android.net.wifi.PICK_WIFI_NETWORK"; /** * Internally used Wi-Fi lock mode representing the case were no locks are held. * @hide */ public static final int WIFI_MODE_NO_LOCKS_HELD = 0; /** * In 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_FULL = 1; /** * In 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_SCAN_ONLY = 2; /** * In 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} */ public static final int WIFI_MODE_FULL_HIGH_PERF = 3; /** Anything worse than or equal to this will show 0 bars. */ private static final int MIN_RSSI = -100; /** Anything better than or equal to this will show the max bars. */ private static final int MAX_RSSI = -55; /** * Number of RSSI levels used in the framework to initiate * {@link #RSSI_CHANGED_ACTION} broadcast * @hide */ public static final int RSSI_LEVELS = 5; /** * Auto 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. * @hide */ public static final int WIFI_FREQUENCY_BAND_AUTO = 0; /** * Operation on 5 GHz alone * @hide */ public static final int WIFI_FREQUENCY_BAND_5GHZ = 1; /** * Operation on 2.4 GHz alone * @hide */ public static final int WIFI_FREQUENCY_BAND_2GHZ = 2; /** List of asyncronous notifications * @hide */ public static final int DATA_ACTIVITY_NOTIFICATION = 1; //Lowest bit indicates data reception and the second lowest //bit indicates data transmitted /** @hide */ public static final int DATA_ACTIVITY_NONE = 0x00; /** @hide */ public static final int DATA_ACTIVITY_IN = 0x01; /** @hide */ public static final int DATA_ACTIVITY_OUT = 0x02; /** @hide */ public static final int DATA_ACTIVITY_INOUT = 0x03; /** @hide */ public static final boolean DEFAULT_POOR_NETWORK_AVOIDANCE_ENABLED = false; /* Maximum number of active locks we allow. * This limit was added to prevent apps from creating a ridiculous number * of locks and crashing the system by overflowing the global ref table. */ private static final int MAX_ACTIVE_LOCKS = 50; /* Number of currently active WifiLocks and MulticastLocks */ private int mActiveLockCount; private Context mContext; IWifiManager mService; private final int mTargetSdkVersion; private static final int INVALID_KEY = 0; private int mListenerKey = 1; private final SparseArray mListenerMap = new SparseArray(); private final Object mListenerMapLock = new Object(); private AsyncChannel mAsyncChannel; private CountDownLatch mConnected; private Looper mLooper; /** * Create a new WifiManager instance. * Applications will almost always want to use * {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve * the standard {@link android.content.Context#WIFI_SERVICE Context.WIFI_SERVICE}. * @param context the application context * @param service the Binder interface * @hide - hide this because it takes in a parameter of type IWifiManager, which * is a system private class. */ public WifiManager(Context context, IWifiManager service, Looper looper) { mContext = context; mService = service; mLooper = looper; mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion; } /** * 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: *
null
. The {@code networkId} field
* must be set to the ID of the existing network being updated.
* @return Returns the {@code networkId} of the supplied
* {@code WifiConfiguration} on success.
* 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.
*
* Note: If an application's target SDK version is
* {@link android.os.Build.VERSION_CODES#LOLLIPOP} or newer, network
* communication may not use Wi-Fi even if Wi-Fi is connected; traffic may
* instead be sent through another network, such as cellular data,
* Bluetooth tethering, or Ethernet. For example, traffic will never use a
* Wi-Fi network that does not provide Internet access (e.g. a wireless
* printer), if another network that does offer Internet access (e.g.
* cellular data) is available. Applications that need to ensure that their
* network traffic uses Wi-Fi should use APIs such as
* {@link Network#bindSocket(java.net.Socket)},
* {@link Network#openConnection(java.net.URL)}, or
* {@link ConnectivityManager#bindProcessToNetwork} to do so.
*
* @param netId the ID of the network in the list of configured networks
* @param disableOthers if true, disable all other networks. The way to
* select a particular network to connect to is specify {@code true}
* for this parameter.
* @return {@code true} if the operation succeeded
*/
public boolean enableNetwork(int netId, boolean disableOthers) {
final boolean pin = disableOthers && mTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP;
if (pin) {
NetworkRequest request = new NetworkRequest.Builder()
.clearCapabilities()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.build();
NetworkPinner.pin(mContext, request);
}
boolean success;
try {
success = mService.enableNetwork(netId, disableOthers);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
if (pin && !success) {
NetworkPinner.unpin();
}
return success;
}
/**
* 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.
* @param netId the ID of the network as returned by {@link #addNetwork}.
* @return {@code true} if the operation succeeded
*/
public boolean disableNetwork(int netId) {
try {
return mService.disableNetwork(netId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Disassociate from the currently active access point. This may result
* in the asynchronous delivery of state change events.
* @return {@code true} if the operation succeeded
*/
public boolean disconnect() {
try {
mService.disconnect();
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Reconnect to the currently active access point, if we are currently
* disconnected. This may result in the asynchronous delivery of state
* change events.
* @return {@code true} if the operation succeeded
*/
public boolean reconnect() {
try {
mService.reconnect();
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Reconnect to the currently active access point, even if we are already
* connected. This may result in the asynchronous delivery of state
* change events.
* @return {@code true} if the operation succeeded
*/
public boolean reassociate() {
try {
mService.reassociate();
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Check that the supplicant daemon is responding to requests.
* @return {@code true} if we were able to communicate with the supplicant and
* it returned the expected response to the PING message.
*/
public boolean pingSupplicant() {
if (mService == null)
return false;
try {
return mService.pingSupplicant();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/* Keep this list in sync with wifi_hal.h */
/** @hide */
public static final int WIFI_FEATURE_INFRA = 0x0001; // Basic infrastructure mode
/** @hide */
public static final int WIFI_FEATURE_INFRA_5G = 0x0002; // Support for 5 GHz Band
/** @hide */
public static final int WIFI_FEATURE_PASSPOINT = 0x0004; // Support for GAS/ANQP
/** @hide */
public static final int WIFI_FEATURE_P2P = 0x0008; // Wifi-Direct
/** @hide */
public static final int WIFI_FEATURE_MOBILE_HOTSPOT = 0x0010; // Soft AP
/** @hide */
public static final int WIFI_FEATURE_SCANNER = 0x0020; // WifiScanner APIs
/** @hide */
public static final int WIFI_FEATURE_NAN = 0x0040; // Neighbor Awareness Networking
/** @hide */
public static final int WIFI_FEATURE_D2D_RTT = 0x0080; // Device-to-device RTT
/** @hide */
public static final int WIFI_FEATURE_D2AP_RTT = 0x0100; // Device-to-AP RTT
/** @hide */
public static final int WIFI_FEATURE_BATCH_SCAN = 0x0200; // Batched Scan (deprecated)
/** @hide */
public static final int WIFI_FEATURE_PNO = 0x0400; // Preferred network offload
/** @hide */
public static final int WIFI_FEATURE_ADDITIONAL_STA = 0x0800; // Support for two STAs
/** @hide */
public static final int WIFI_FEATURE_TDLS = 0x1000; // Tunnel directed link setup
/** @hide */
public static final int WIFI_FEATURE_TDLS_OFFCHANNEL = 0x2000; // Support for TDLS off channel
/** @hide */
public static final int WIFI_FEATURE_EPR = 0x4000; // Enhanced power reporting
/** @hide */
public static final int WIFI_FEATURE_AP_STA = 0x8000; // Support for AP STA Concurrency
/** @hide */
public static final int WIFI_FEATURE_LINK_LAYER_STATS = 0x10000; // Link layer stats collection
/** @hide */
public static final int WIFI_FEATURE_LOGGER = 0x20000; // WiFi Logger
/** @hide */
public static final int WIFI_FEATURE_HAL_EPNO = 0x40000; // WiFi PNO enhanced
private int getSupportedFeatures() {
try {
return mService.getSupportedFeatures();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
private boolean isFeatureSupported(int feature) {
return (getSupportedFeatures() & feature) == feature;
}
/**
* @return true if this adapter supports 5 GHz band
*/
public boolean is5GHzBandSupported() {
return isFeatureSupported(WIFI_FEATURE_INFRA_5G);
}
/**
* @return true if this adapter supports passpoint
* @hide
*/
public boolean isPasspointSupported() {
return isFeatureSupported(WIFI_FEATURE_PASSPOINT);
}
/**
* @return true if this adapter supports WifiP2pManager (Wi-Fi Direct)
*/
public boolean isP2pSupported() {
return isFeatureSupported(WIFI_FEATURE_P2P);
}
/**
* @return true if this adapter supports portable Wi-Fi hotspot
* @hide
*/
@SystemApi
public boolean isPortableHotspotSupported() {
return isFeatureSupported(WIFI_FEATURE_MOBILE_HOTSPOT);
}
/**
* @return true if this adapter supports WifiScanner APIs
* @hide
*/
@SystemApi
public boolean isWifiScannerSupported() {
return isFeatureSupported(WIFI_FEATURE_SCANNER);
}
/**
* @return true if this adapter supports Neighbour Awareness Network APIs
* @hide PROPOSED_NAN_API
*/
public boolean isNanSupported() {
return isFeatureSupported(WIFI_FEATURE_NAN);
}
/**
* @return true if this adapter supports Device-to-device RTT
* @hide
*/
@SystemApi
public boolean isDeviceToDeviceRttSupported() {
return isFeatureSupported(WIFI_FEATURE_D2D_RTT);
}
/**
* @return true if this adapter supports Device-to-AP RTT
*/
@SystemApi
public boolean isDeviceToApRttSupported() {
return isFeatureSupported(WIFI_FEATURE_D2AP_RTT);
}
/**
* @return true if this adapter supports offloaded connectivity scan
*/
public boolean isPreferredNetworkOffloadSupported() {
return isFeatureSupported(WIFI_FEATURE_PNO);
}
/**
* @return true if this adapter supports multiple simultaneous connections
* @hide
*/
public boolean isAdditionalStaSupported() {
return isFeatureSupported(WIFI_FEATURE_ADDITIONAL_STA);
}
/**
* @return true if this adapter supports Tunnel Directed Link Setup
*/
public boolean isTdlsSupported() {
return isFeatureSupported(WIFI_FEATURE_TDLS);
}
/**
* @return true if this adapter supports Off Channel Tunnel Directed Link Setup
* @hide
*/
public boolean isOffChannelTdlsSupported() {
return isFeatureSupported(WIFI_FEATURE_TDLS_OFFCHANNEL);
}
/**
* @return true if this adapter supports advanced power/performance counters
*/
public boolean isEnhancedPowerReportingSupported() {
return isFeatureSupported(WIFI_FEATURE_LINK_LAYER_STATS);
}
/**
* 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.
* @param updateType Type of info, cached vs refreshed.
*
* @return a record with {@link WifiActivityEnergyInfo} or null if
* report is unavailable or unsupported
* @hide
*/
public WifiActivityEnergyInfo getControllerActivityEnergyInfo(int updateType) {
if (mService == null) return null;
try {
synchronized(this) {
return mService.reportActivityInfo();
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* 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.
* @return {@code true} if the operation succeeded, i.e., the scan was initiated
*/
public boolean startScan() {
try {
mService.startScan(null, null);
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/** @hide */
@SystemApi
public boolean startScan(WorkSource workSource) {
try {
mService.startScan(null, workSource);
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* startLocationRestrictedScan()
* Trigger a scan which will not make use of DFS channels and is thus not suitable for
* establishing wifi connection.
* @deprecated This API is nolonger supported.
* Use {@link android.net.wifi.WifiScanner} API
* @hide
*/
@Deprecated
@SystemApi
public boolean startLocationRestrictedScan(WorkSource workSource) {
return false;
}
/**
* Check if the Batched Scan feature is supported.
*
* @return false if not supported.
* @deprecated This API is nolonger supported.
* Use {@link android.net.wifi.WifiScanner} API
* @hide
*/
@Deprecated
@SystemApi
public boolean isBatchedScanSupported() {
return false;
}
/**
* Retrieve the latest batched scan result. This should be called immediately after
* {@link BATCHED_SCAN_RESULTS_AVAILABLE_ACTION} is received.
* @deprecated This API is nolonger supported.
* Use {@link android.net.wifi.WifiScanner} API
* @hide
*/
@Deprecated
@SystemApi
public List
* 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.
*
* @return {@code true} if the operation succeeded
*/
public boolean saveConfiguration() {
try {
return mService.saveConfiguration();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Set the country code.
* @param countryCode country code in ISO 3166 format.
* @param persist {@code true} if this needs to be remembered
*
* @hide
*/
public void setCountryCode(String country, boolean persist) {
try {
mService.setCountryCode(country, persist);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* get the country code.
* @return the country code in ISO 3166 format.
*
* @hide
*/
public String getCountryCode() {
try {
String country = mService.getCountryCode();
return country;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Set the operational frequency band.
* @param band One of
* {@link #WIFI_FREQUENCY_BAND_AUTO},
* {@link #WIFI_FREQUENCY_BAND_5GHZ},
* {@link #WIFI_FREQUENCY_BAND_2GHZ},
* @param persist {@code true} if this needs to be remembered
* @hide
*/
public void setFrequencyBand(int band, boolean persist) {
try {
mService.setFrequencyBand(band, persist);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Get the operational frequency band.
* @return One of
* {@link #WIFI_FREQUENCY_BAND_AUTO},
* {@link #WIFI_FREQUENCY_BAND_5GHZ},
* {@link #WIFI_FREQUENCY_BAND_2GHZ} or
* {@code -1} on failure.
* @hide
*/
public int getFrequencyBand() {
try {
return mService.getFrequencyBand();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Check if the chipset supports dual frequency band (2.4 GHz and 5 GHz)
* @return {@code true} if supported, {@code false} otherwise.
* @hide
*/
public boolean isDualBandSupported() {
try {
return mService.isDualBandSupported();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Return the DHCP-assigned addresses from the last successful DHCP request,
* if any.
* @return the DHCP information
*/
public DhcpInfo getDhcpInfo() {
try {
return mService.getDhcpInfo();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Enable or disable Wi-Fi.
* @param enabled {@code true} to enable, {@code false} to disable.
* @return {@code true} if the operation succeeds (or if the existing state
* is the same as the requested state).
*/
public boolean setWifiEnabled(boolean enabled) {
try {
return mService.setWifiEnabled(enabled);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Gets the Wi-Fi enabled state.
* @return One of {@link #WIFI_STATE_DISABLED},
* {@link #WIFI_STATE_DISABLING}, {@link #WIFI_STATE_ENABLED},
* {@link #WIFI_STATE_ENABLING}, {@link #WIFI_STATE_UNKNOWN}
* @see #isWifiEnabled()
*/
public int getWifiState() {
try {
return mService.getWifiEnabledState();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Return whether Wi-Fi is enabled or disabled.
* @return {@code true} if Wi-Fi is enabled
* @see #getWifiState()
*/
public boolean isWifiEnabled() {
return getWifiState() == WIFI_STATE_ENABLED;
}
/**
* Return TX packet counter, for CTS test of WiFi watchdog.
* @param listener is the interface to receive result
*
* @hide for CTS test only
*/
public void getTxPacketCount(TxPacketCountListener listener) {
getChannel().sendMessage(RSSI_PKTCNT_FETCH, 0, putListener(listener));
}
/**
* Calculates the level of the signal. This should be used any time a signal
* is being shown.
*
* @param rssi The power of the signal measured in RSSI.
* @param numLevels The number of levels to consider in the calculated
* level.
* @return A level of the signal, given in the range of 0 to numLevels-1
* (both inclusive).
*/
public static int calculateSignalLevel(int rssi, int numLevels) {
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);
}
}
/**
* Compares two signal strengths.
*
* @param rssiA The power of the first signal measured in RSSI.
* @param rssiB The power of the second signal measured in RSSI.
* @return Returns <0 if the first signal is weaker than the second signal,
* 0 if the two signals have the same strength, and >0 if the first
* signal is stronger than the second signal.
*/
public static int compareSignalLevel(int rssiA, int rssiB) {
return rssiA - rssiB;
}
/**
* 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
* @param wifiConfig SSID, security and channel details as
* part of WifiConfiguration
* @return {@code true} if the operation succeeds, {@code false} otherwise
*
* @hide
*/
@SystemApi
public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
try {
mService.setWifiApEnabled(wifiConfig, enabled);
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Gets the Wi-Fi enabled state.
* @return One of {@link #WIFI_AP_STATE_DISABLED},
* {@link #WIFI_AP_STATE_DISABLING}, {@link #WIFI_AP_STATE_ENABLED},
* {@link #WIFI_AP_STATE_ENABLING}, {@link #WIFI_AP_STATE_FAILED}
* @see #isWifiApEnabled()
*
* @hide
*/
@SystemApi
public int getWifiApState() {
try {
return mService.getWifiApEnabledState();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Return whether Wi-Fi AP is enabled or disabled.
* @return {@code true} if Wi-Fi AP is enabled
* @see #getWifiApState()
*
* @hide
*/
@SystemApi
public boolean isWifiApEnabled() {
return getWifiApState() == WIFI_AP_STATE_ENABLED;
}
/**
* Gets the Wi-Fi AP Configuration.
* @return AP details in WifiConfiguration
*
* @hide
*/
@SystemApi
public WifiConfiguration getWifiApConfiguration() {
try {
return mService.getWifiApConfiguration();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Builds a WifiConfiguration from Hotspot 2.0 MIME file.
* @return AP details in WifiConfiguration
*
* @hide Dont open yet
*/
public WifiConfiguration buildWifiConfig(String uriString, String mimeType, byte[] data) {
try {
return mService.buildWifiConfig(uriString, mimeType, data);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Sets the Wi-Fi AP Configuration.
* @return {@code true} if the operation succeeded, {@code false} otherwise
*
* @hide
*/
@SystemApi
public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
try {
mService.setWifiApConfiguration(wifiConfig);
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Add a bssid to the supplicant blacklist
*
* This API is used by WifiWatchdogService
*
* @return {@code true} if the operation succeeds else {@code false}
* @hide
*/
public boolean addToBlacklist(String bssid) {
try {
mService.addToBlacklist(bssid);
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Clear the supplicant blacklist
*
* This API is used by WifiWatchdogService
*
* @return {@code true} if the operation succeeds else {@code false}
* @hide
*/
public boolean clearBlacklist() {
try {
mService.clearBlacklist();
return true;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* 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.
*
* Before using a WifiLock, consider carefully if your application requires Wi-Fi access, or
* could function over a mobile network, if available. A program that needs to download large
* files should hold a WifiLock to ensure that the download will complete, but a program whose
* network usage is occasional or low-bandwidth should not hold a WifiLock to avoid adversely
* affecting battery life.
*
* Note that WifiLocks cannot override the user-level "Wi-Fi Enabled" setting, nor Airplane
* Mode. They simply keep the radio from turning off when Wi-Fi is already on but the device
* is idle.
*
* Any application using a WifiLock must request the {@code android.permission.WAKE_LOCK}
* permission in an {@code