summaryrefslogtreecommitdiff
path: root/wifi/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl8
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java60
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java4
-rw-r--r--wifi/java/android/net/wifi/WifiStateTracker.java217
4 files changed, 252 insertions, 37 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 5fd44b1df6c8..0ee559e7c228 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -21,6 +21,8 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.ScanResult;
import android.net.DhcpInfo;
+import android.os.WorkSource;
+
/**
* Interface that allows controlling and querying Wi-Fi connectivity.
*
@@ -66,7 +68,9 @@ interface IWifiManager
DhcpInfo getDhcpInfo();
- boolean acquireWifiLock(IBinder lock, int lockType, String tag);
+ boolean acquireWifiLock(IBinder lock, int lockType, String tag, in WorkSource ws);
+
+ void updateWifiLockWorkSource(IBinder lock, in WorkSource ws);
boolean releaseWifiLock(IBinder lock);
@@ -83,5 +87,7 @@ interface IWifiManager
int getWifiApEnabledState();
WifiConfiguration getWifiApConfiguration();
+
+ void setWifiApConfiguration(in WifiConfiguration wifiConfig);
}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 970d5fc18f25..dd162f212cbd 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -23,6 +23,7 @@ import android.os.Binder;
import android.os.IBinder;
import android.os.Handler;
import android.os.RemoteException;
+import android.os.WorkSource;
import java.util.List;
@@ -307,6 +308,16 @@ public class WifiManager {
public static final String ACTION_PICK_WIFI_NETWORK = "android.net.wifi.PICK_WIFI_NETWORK";
/**
+ * In this Wi-Fi lock mode, Wi-Fi will behave as in the mode
+ * {@link #WIFI_MODE_FULL} but it operates at high performance
+ * at the expense of power. This mode should be used
+ * only when the wifi connection needs to have minimum loss and low
+ * latency as it can impact the battery life.
+ * @hide
+ */
+ public static final int WIFI_MODE_FULL_HIGH_PERF = 3;
+
+ /**
* 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
@@ -824,6 +835,21 @@ public class WifiManager {
}
/**
+ * Sets the Wi-Fi AP Configuration.
+ * @return {@code true} if the operation succeeded, {@code false} otherwise
+ *
+ * @hide Dont open yet
+ */
+ public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
+ try {
+ mService.setWifiApConfiguration(wifiConfig);
+ return true;
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
* Allows an application to keep the Wi-Fi radio awake.
* Normally the Wi-Fi radio may turn off when the user has not used the device in a while.
* Acquiring a WifiLock will keep the radio on until the lock is released. Multiple
@@ -847,6 +873,7 @@ public class WifiManager {
int mLockType;
private boolean mRefCounted;
private boolean mHeld;
+ private WorkSource mWorkSource;
private WifiLock(int lockType, String tag) {
mTag = tag;
@@ -872,7 +899,7 @@ public class WifiManager {
synchronized (mBinder) {
if (mRefCounted ? (++mRefCount > 0) : (!mHeld)) {
try {
- mService.acquireWifiLock(mBinder, mLockType, mTag);
+ mService.acquireWifiLock(mBinder, mLockType, mTag, mWorkSource);
synchronized (WifiManager.this) {
if (mActiveLockCount >= MAX_ACTIVE_LOCKS) {
mService.releaseWifiLock(mBinder);
@@ -944,6 +971,32 @@ public class WifiManager {
}
}
+ public void setWorkSource(WorkSource ws) {
+ synchronized (mBinder) {
+ if (ws != null && ws.size() == 0) {
+ ws = null;
+ }
+ boolean changed = true;
+ if (ws == null) {
+ mWorkSource = null;
+ } else if (mWorkSource == null) {
+ changed = mWorkSource != null;
+ mWorkSource = new WorkSource(ws);
+ } else {
+ changed = mWorkSource.diff(ws);
+ if (changed) {
+ mWorkSource.set(ws);
+ }
+ }
+ if (changed && mHeld) {
+ try {
+ mService.updateWifiLockWorkSource(mBinder, mWorkSource);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ }
+
public String toString() {
String s1, s2, s3;
synchronized (mBinder) {
@@ -978,8 +1031,9 @@ public class WifiManager {
/**
* Creates a new WifiLock.
*
- * @param lockType the type of lock to create. See {@link #WIFI_MODE_FULL} and
- * {@link #WIFI_MODE_SCAN_ONLY} for descriptions of the types of Wi-Fi locks.
+ * @param lockType the type of lock to create. See {@link #WIFI_MODE_FULL},
+ * and {@link #WIFI_MODE_SCAN_ONLY} for descriptions of the types of Wi-Fi locks.
+ *
* @param tag a tag for the WifiLock to identify it in debugging messages. This string is
* never shown to the user under normal conditions, but should be descriptive
* enough to identify your application and the specific WifiLock within it, if it
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index f98cd2875a7b..25f05c01f964 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -109,6 +109,8 @@ public class WifiNative {
public native static boolean setPowerModeCommand(int mode);
+ public native static int getPowerModeCommand();
+
public native static boolean setNumAllowedChannelsCommand(int numChannels);
public native static int getNumAllowedChannelsCommand();
@@ -147,6 +149,8 @@ public class WifiNative {
public native static String getDhcpError();
+ public native static boolean setSuspendOptimizationsCommand(boolean enabled);
+
/**
* Wait for the supplicant to send an event, returning the event string.
* @return the event string sent by the supplicant.
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 38130152d210..22dbda3bc7ea 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -59,6 +59,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* Track the state of Wifi connectivity. All event handling is done here,
@@ -216,6 +217,9 @@ public class WifiStateTracker extends NetworkStateTracker {
private boolean mUseStaticIp = false;
private int mReconnectCount;
+ /* Tracks if any network in the configuration is disabled */
+ private AtomicBoolean mIsAnyNetworkDisabled = new AtomicBoolean(false);
+
// used to store the (non-persisted) num determined during device boot
// (from mcc or other phone info) before the driver is started.
private int mNumAllowedChannels = 0;
@@ -276,6 +280,9 @@ public class WifiStateTracker extends NetworkStateTracker {
private boolean mIsScanModeActive;
private boolean mEnableRssiPolling;
+ private boolean mIsHighPerfEnabled;
+ private int mPowerModeRefCount = 0;
+ private int mOptimizationsDisabledRefCount = 0;
/**
* One of {@link WifiManager#WIFI_STATE_DISABLED},
@@ -659,6 +666,67 @@ public class WifiStateTracker extends NetworkStateTracker {
}
}
+ /**
+ * Set suspend mode optimizations. These include:
+ * - packet filtering
+ * - turn off roaming
+ * - DTIM settings
+ *
+ * Uses reference counting to keep the suspend optimizations disabled
+ * as long as one entity wants optimizations disabled.
+ *
+ * For example, WifiLock can keep suspend optimizations disabled
+ * or the user setting (wifi never sleeps) can keep suspend optimizations
+ * disabled. As long as one entity wants it disabled, it should stay
+ * that way
+ *
+ * @param enabled true if optimizations need enabled, false otherwise
+ */
+ public synchronized void setSuspendModeOptimizations(boolean enabled) {
+
+ /* It is good to plumb suspend optimization enable
+ * or disable even if ref count indicates already done
+ * since we could have a case of previous failure.
+ */
+ if (!enabled) {
+ mOptimizationsDisabledRefCount++;
+ } else {
+ mOptimizationsDisabledRefCount--;
+ if (mOptimizationsDisabledRefCount > 0) {
+ return;
+ } else {
+ /* Keep refcount from becoming negative */
+ mOptimizationsDisabledRefCount = 0;
+ }
+ }
+
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
+ return;
+ }
+
+ WifiNative.setSuspendOptimizationsCommand(enabled);
+ }
+
+
+ /**
+ * Set high performance mode of operation. This would mean
+ * use active power mode and disable suspend optimizations
+ * @param enabled true if enabled, false otherwise
+ */
+ public synchronized void setHighPerfMode(boolean enabled) {
+ if (mIsHighPerfEnabled != enabled) {
+ if (enabled) {
+ setPowerMode(DRIVER_POWER_MODE_ACTIVE);
+ setSuspendModeOptimizations(false);
+ } else {
+ setPowerMode(DRIVER_POWER_MODE_AUTO);
+ setSuspendModeOptimizations(true);
+ }
+ mIsHighPerfEnabled = enabled;
+ Log.d(TAG,"high performance mode: " + enabled);
+ }
+ }
+
private void checkIsBluetoothPlaying() {
boolean isBluetoothPlaying = false;
@@ -744,9 +812,13 @@ public class WifiStateTracker extends NetworkStateTracker {
dhcpThread.start();
mDhcpTarget = new DhcpHandler(dhcpThread.getLooper(), this);
mIsScanModeActive = true;
+ mIsHighPerfEnabled = false;
+ mOptimizationsDisabledRefCount = 0;
+ mPowerModeRefCount = 0;
mTornDownByConnMgr = false;
mLastBssid = null;
mLastSsid = null;
+ mIsAnyNetworkDisabled.set(false);
requestConnectionInfo();
SupplicantState supplState = mWifiInfo.getSupplicantState();
/**
@@ -1132,7 +1204,8 @@ public class WifiStateTracker extends NetworkStateTracker {
setDetailedState(DetailedState.CONNECTED);
sendNetworkStateChangeBroadcast(mWifiInfo.getBSSID());
} else {
- mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED);
+ msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
+ msg.sendToTarget();
}
if (LOCAL_LOGD) Log.v(TAG, "IP configuration: " + mDhcpInfo);
// Wi-Fi interface configuration state changed:
@@ -1483,18 +1556,19 @@ public class WifiStateTracker extends NetworkStateTracker {
* disconnect or stop command was initiated.
*/
public synchronized boolean disconnectAndStop() {
+ boolean ret = true;;
if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
// Take down any open network notifications
setNotificationVisible(false, 0, false, 0);
- mRunState = RUN_STATE_STOPPING;
if (mWifiInfo.getSupplicantState() == SupplicantState.DORMANT) {
- return stopDriver();
+ ret = stopDriver();
} else {
- return disconnect();
+ ret = disconnect();
}
+ mRunState = RUN_STATE_STOPPING;
}
- return true;
+ return ret;
}
public synchronized boolean restart() {
@@ -1516,6 +1590,10 @@ public class WifiStateTracker extends NetworkStateTracker {
mWifiState.set(wifiState);
}
+ public boolean isAnyNetworkDisabled() {
+ return mIsAnyNetworkDisabled.get();
+ }
+
/**
* The WifiNative interface functions are listed below.
* The only native call that is not synchronized on
@@ -1605,7 +1683,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean scan(boolean forceActive) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.scanCommand(forceActive);
@@ -1621,7 +1699,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setScanResultHandling(int mode) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED) {
return false;
}
return WifiNative.setScanResultHandlingCommand(mode);
@@ -1635,7 +1713,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* 00:bb:cc:dd:cc:ff 2412 165 [WPA-EAP-TKIP][WPA2-EAP-CCMP] Net2
*/
public synchronized String scanResults() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return null;
}
return WifiNative.scanResultsCommand();
@@ -1647,7 +1725,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setScanMode(boolean isScanModeActive) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
if (mIsScanModeActive != isScanModeActive) {
@@ -1662,7 +1740,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean disconnect() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.disconnectCommand();
@@ -1674,7 +1752,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean reconnectCommand() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.reconnectCommand();
@@ -1716,10 +1794,28 @@ public class WifiStateTracker extends NetworkStateTracker {
if (mWifiState.get() != WIFI_STATE_ENABLED) {
return false;
}
+ if (disableOthers) mIsAnyNetworkDisabled.set(true);
return WifiNative.enableNetworkCommand(netId, disableOthers);
}
/**
+ * Enable all networks
+ *
+ * @param networks list of configured networks
+ */
+ public synchronized void enableAllNetworks(List<WifiConfiguration> networks) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED) {
+ return;
+ }
+ mIsAnyNetworkDisabled.set(false);
+ for (WifiConfiguration config : networks) {
+ if (config.status == WifiConfiguration.Status.DISABLED) {
+ WifiNative.enableNetworkCommand(config.networkId, false);
+ }
+ }
+ }
+
+ /**
* Disable a network
*
* @param netId network id of the network
@@ -1729,6 +1825,7 @@ public class WifiStateTracker extends NetworkStateTracker {
if (mWifiState.get() != WIFI_STATE_ENABLED) {
return false;
}
+ mIsAnyNetworkDisabled.set(true);
return WifiNative.disableNetworkCommand(netId);
}
@@ -1738,7 +1835,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean reassociate() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.reassociateCommand();
@@ -1837,7 +1934,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return RSSI value, -1 on failure
*/
public synchronized int getRssi() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getRssiApproxCommand();
@@ -1849,7 +1946,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return RSSI value, -1 on failure
*/
public synchronized int getRssiApprox() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getRssiApproxCommand();
@@ -1861,7 +1958,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return link speed, -1 on failure
*/
public synchronized int getLinkSpeed() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getLinkSpeedCommand();
@@ -1873,7 +1970,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return MAC address, null on failure
*/
public synchronized String getMacAddress() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return null;
}
return WifiNative.getMacAddressCommand();
@@ -1897,7 +1994,9 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean stopDriver() {
- if (mWifiState.get() != WIFI_STATE_ENABLED) {
+ /* Driver stop should not happen only when supplicant event
+ * DRIVER_STOPPED has already been handled */
+ if (mWifiState.get() != WIFI_STATE_ENABLED || mRunState == RUN_STATE_STOPPED) {
return false;
}
return WifiNative.stopDriverCommand();
@@ -1909,7 +2008,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean startPacketFiltering() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.startPacketFiltering();
@@ -1921,24 +2020,63 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean stopPacketFiltering() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.stopPacketFiltering();
}
/**
+ * Get power mode
+ * @return power mode
+ */
+ public synchronized int getPowerMode() {
+ if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ return -1;
+ }
+ return WifiNative.getPowerModeCommand();
+ }
+
+ /**
* Set power mode
* @param mode
* DRIVER_POWER_MODE_AUTO
* DRIVER_POWER_MODE_ACTIVE
- * @return {@code true} if the operation succeeds, {@code false} otherwise
+ *
+ * Uses reference counting to keep power mode active
+ * as long as one entity wants power mode to be active.
+ *
+ * For example, WifiLock high perf mode can keep power mode active
+ * or a DHCP session can keep it active. As long as one entity wants
+ * it enabled, it should stay that way
+ *
*/
- public synchronized boolean setPowerMode(int mode) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
- return false;
+ private synchronized void setPowerMode(int mode) {
+
+ /* It is good to plumb power mode change
+ * even if ref count indicates already done
+ * since we could have a case of previous failure.
+ */
+ switch(mode) {
+ case DRIVER_POWER_MODE_ACTIVE:
+ mPowerModeRefCount++;
+ break;
+ case DRIVER_POWER_MODE_AUTO:
+ mPowerModeRefCount--;
+ if (mPowerModeRefCount > 0) {
+ return;
+ } else {
+ /* Keep refcount from becoming negative */
+ mPowerModeRefCount = 0;
+ }
+ break;
+ }
+
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
+ return;
}
- return WifiNative.setPowerModeCommand(mode);
+
+ WifiNative.setPowerModeCommand(mode);
}
/**
@@ -1948,7 +2086,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* the number of channels is invalid.
*/
public synchronized boolean setNumAllowedChannels() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
try {
@@ -1973,7 +2111,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* {@code numChannels} is outside the valid range.
*/
public synchronized boolean setNumAllowedChannels(int numChannels) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
mNumAllowedChannels = numChannels;
@@ -1986,7 +2124,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return channel count, -1 on failure
*/
public synchronized int getNumAllowedChannels() {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return -1;
}
return WifiNative.getNumAllowedChannelsCommand();
@@ -2002,7 +2140,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return {@code true} if the operation succeeds, {@code false} otherwise
*/
public synchronized boolean setBluetoothCoexistenceMode(int mode) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return false;
}
return WifiNative.setBluetoothCoexistenceModeCommand(mode);
@@ -2016,7 +2154,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @param isBluetoothPlaying whether to enable or disable this mode
*/
public synchronized void setBluetoothScanMode(boolean isBluetoothPlaying) {
- if (mWifiState.get() != WIFI_STATE_ENABLED && !isDriverStopped()) {
+ if (mWifiState.get() != WIFI_STATE_ENABLED || isDriverStopped()) {
return;
}
WifiNative.setBluetoothCoexistenceScanModeCommand(isBluetoothPlaying);
@@ -2252,6 +2390,8 @@ public class WifiStateTracker extends NetworkStateTracker {
case EVENT_DHCP_START:
boolean modifiedBluetoothCoexistenceMode = false;
+ int powerMode = DRIVER_POWER_MODE_AUTO;
+
if (shouldDisableCoexistenceMode()) {
/*
* There are problems setting the Wi-Fi driver's power
@@ -2276,7 +2416,15 @@ public class WifiStateTracker extends NetworkStateTracker {
WifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED);
}
- setPowerMode(DRIVER_POWER_MODE_ACTIVE);
+ powerMode = getPowerMode();
+ if (powerMode < 0) {
+ // Handle the case where supplicant driver does not support
+ // getPowerModeCommand.
+ powerMode = DRIVER_POWER_MODE_AUTO;
+ }
+ if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
+ setPowerMode(DRIVER_POWER_MODE_ACTIVE);
+ }
synchronized (this) {
// A new request is being made, so assume we will callback
@@ -2292,7 +2440,9 @@ public class WifiStateTracker extends NetworkStateTracker {
NetworkUtils.getDhcpError());
}
- setPowerMode(DRIVER_POWER_MODE_AUTO);
+ if (powerMode != DRIVER_POWER_MODE_ACTIVE) {
+ setPowerMode(powerMode);
+ }
if (modifiedBluetoothCoexistenceMode) {
// Set the coexistence mode back to its default value
@@ -2323,7 +2473,7 @@ public class WifiStateTracker extends NetworkStateTracker {
* @return Whether to disable coexistence mode.
*/
private boolean shouldDisableCoexistenceMode() {
- int state = mBluetoothHeadset.getState();
+ int state = mBluetoothHeadset.getState(mBluetoothHeadset.getCurrentHeadset());
return state == BluetoothHeadset.STATE_DISCONNECTED;
}
}
@@ -2450,7 +2600,8 @@ public class WifiStateTracker extends NetworkStateTracker {
resetConnections(true);
configureInterface();
if (mUseStaticIp) {
- mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED);
+ Message msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
+ msg.sendToTarget();
}
}
}