am 35cf42d0: Merge "Add control to disable suspend optimizations" into jb-mr1-dev
* commit '35cf42d0b65a70ba28cd7bb13ce538369497d89f': Add control to disable suspend optimizations
This commit is contained in:
@@ -3287,6 +3287,14 @@ public final class Settings {
|
|||||||
public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
|
public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED =
|
||||||
"wifi_watchdog_poor_network_test_enabled";
|
"wifi_watchdog_poor_network_test_enabled";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and
|
||||||
|
* needs to be set to 0 to disable it.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED =
|
||||||
|
"wifi_suspend_optimizations_enabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting to turn off walled garden test on Wi-Fi. Feature is enabled by default and
|
* Setting to turn off walled garden test on Wi-Fi. Feature is enabled by default and
|
||||||
* the setting needs to be set to 0 to disable it.
|
* the setting needs to be set to 0 to disable it.
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.ContentObserver;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.DhcpInfo;
|
import android.net.DhcpInfo;
|
||||||
import android.net.DhcpInfoInternal;
|
import android.net.DhcpInfoInternal;
|
||||||
@@ -138,6 +139,8 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
private boolean mSetScanActive = false;
|
private boolean mSetScanActive = false;
|
||||||
/* High perf mode is true if an app has held a high perf Wifi Lock */
|
/* High perf mode is true if an app has held a high perf Wifi Lock */
|
||||||
private boolean mHighPerfMode = false;
|
private boolean mHighPerfMode = false;
|
||||||
|
/* Tracks if user has disabled suspend optimizations through settings */
|
||||||
|
private AtomicBoolean mSuspendOptEnabled = new AtomicBoolean(true);
|
||||||
|
|
||||||
private boolean mBluetoothConnectionActive = false;
|
private boolean mBluetoothConnectionActive = false;
|
||||||
|
|
||||||
@@ -591,6 +594,9 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
mPrimaryDeviceType = mContext.getResources().getString(
|
mPrimaryDeviceType = mContext.getResources().getString(
|
||||||
com.android.internal.R.string.config_wifi_p2p_device_type);
|
com.android.internal.R.string.config_wifi_p2p_device_type);
|
||||||
|
|
||||||
|
mSuspendOptEnabled.set(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1);
|
||||||
|
|
||||||
mContext.registerReceiver(
|
mContext.registerReceiver(
|
||||||
new BroadcastReceiver() {
|
new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -626,18 +632,25 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
enableBackgroundScanCommand(false);
|
enableBackgroundScanCommand(false);
|
||||||
}
|
}
|
||||||
enableAllNetworks();
|
enableAllNetworks();
|
||||||
sendMessage(CMD_CLEAR_SUSPEND_OPTIMIZATIONS);
|
if (mSuspendOptEnabled.get()) {
|
||||||
|
if (DBG) log("Clear suspend optimizations");
|
||||||
|
sendMessage(CMD_CLEAR_SUSPEND_OPTIMIZATIONS);
|
||||||
|
}
|
||||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
enableRssiPolling(false);
|
enableRssiPolling(false);
|
||||||
if (mBackgroundScanSupported) {
|
if (mBackgroundScanSupported) {
|
||||||
enableBackgroundScanCommand(true);
|
enableBackgroundScanCommand(true);
|
||||||
}
|
}
|
||||||
//Allow 2s for suspend optimizations to be set
|
if (mSuspendOptEnabled.get()) {
|
||||||
mSuspendWakeLock.acquire(2000);
|
if (DBG) log("Enable suspend optimizations");
|
||||||
sendMessage(CMD_SET_SUSPEND_OPTIMIZATIONS);
|
//Allow 2s for suspend optimizations to be set
|
||||||
|
mSuspendWakeLock.acquire(2000);
|
||||||
|
sendMessage(CMD_SET_SUSPEND_OPTIMIZATIONS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mContext.registerReceiver(
|
mContext.registerReceiver(
|
||||||
new BroadcastReceiver() {
|
new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -648,6 +661,16 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
},
|
},
|
||||||
new IntentFilter(ACTION_DELAYED_DRIVER_STOP));
|
new IntentFilter(ACTION_DELAYED_DRIVER_STOP));
|
||||||
|
|
||||||
|
mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
|
||||||
|
Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED), false,
|
||||||
|
new ContentObserver(getHandler()) {
|
||||||
|
@Override
|
||||||
|
public void onChange(boolean selfChange) {
|
||||||
|
mSuspendOptEnabled.set(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mScanResultCache = new LruCache<String, ScanResult>(SCAN_RESULT_CACHE_SIZE);
|
mScanResultCache = new LruCache<String, ScanResult>(SCAN_RESULT_CACHE_SIZE);
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
@@ -1133,6 +1156,8 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
sb.append("mLastNetworkId ").append(mLastNetworkId).append(LS);
|
sb.append("mLastNetworkId ").append(mLastNetworkId).append(LS);
|
||||||
sb.append("mReconnectCount ").append(mReconnectCount).append(LS);
|
sb.append("mReconnectCount ").append(mReconnectCount).append(LS);
|
||||||
sb.append("mIsScanMode ").append(mIsScanMode).append(LS);
|
sb.append("mIsScanMode ").append(mIsScanMode).append(LS);
|
||||||
|
sb.append("mHighPerfMode").append(mHighPerfMode).append(LS);
|
||||||
|
sb.append("mSuspendOptEnabled").append(mSuspendOptEnabled).append(LS);
|
||||||
sb.append("Supplicant status").append(LS)
|
sb.append("Supplicant status").append(LS)
|
||||||
.append(mWifiNative.status()).append(LS).append(LS);
|
.append(mWifiNative.status()).append(LS).append(LS);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user