@@ -305,13 +305,11 @@ public class WifiStateMachine extends StateMachine {
305305 static final int CMD_RECONNECT = BASE + 75 ;
306306 /* Reassociate to a network */
307307 static final int CMD_REASSOCIATE = BASE + 76 ;
308- /* Controls power mode and suspend mode optimizations
308+ /* Controls suspend mode optimizations
309309 *
310- * When high perf mode is enabled, power mode is set to
311- * POWER_MODE_ACTIVE and suspend mode optimizations are disabled
310+ * When high perf mode is enabled, suspend mode optimizations are disabled
312311 *
313- * When high perf mode is disabled, power mode is set to
314- * POWER_MODE_AUTO and suspend mode optimizations are enabled
312+ * When high perf mode is disabled, suspend mode optimizations are enabled
315313 *
316314 * Suspend mode optimizations include:
317315 * - packet filtering
@@ -374,11 +372,8 @@ public class WifiStateMachine extends StateMachine {
374372 */
375373 private static final int DEFAULT_MAX_DHCP_RETRIES = 9 ;
376374
377- static final int POWER_MODE_ACTIVE = 1 ;
378- static final int POWER_MODE_AUTO = 0 ;
379-
380- /* Tracks the power mode for restoration after a DHCP request/renewal goes through */
381- private int mPowerMode = POWER_MODE_AUTO ;
375+ /* Tracks if power save is enabled in driver */
376+ private boolean mPowerSaveEnabled = true ;;
382377
383378 /**
384379 * Default framework scan interval in milliseconds. This is used in the scenario in which
@@ -1683,21 +1678,18 @@ void handlePreDhcpSetup() {
16831678 mWifiNative .BLUETOOTH_COEXISTENCE_MODE_DISABLED );
16841679 }
16851680
1686- mPowerMode = mWifiNative .getPowerMode ();
1687- if (mPowerMode < 0 ) {
1688- // Handle the case where supplicant driver does not support
1689- // getPowerModeCommand.
1690- mPowerMode = WifiStateMachine .POWER_MODE_AUTO ;
1691- }
1692- if (mPowerMode != WifiStateMachine .POWER_MODE_ACTIVE ) {
1693- mWifiNative .setPowerMode (WifiStateMachine .POWER_MODE_ACTIVE );
1681+ /* Disable power save during DHCP */
1682+ if (mPowerSaveEnabled ) {
1683+ mPowerSaveEnabled = false ;
1684+ mWifiNative .setPowerSave (mPowerSaveEnabled );
16941685 }
16951686 }
16961687
16971688
16981689 void handlePostDhcpSetup () {
1699- /* restore power mode */
1700- mWifiNative .setPowerMode (mPowerMode );
1690+ /* Restore power save */
1691+ mPowerSaveEnabled = true ;
1692+ mWifiNative .setPowerSave (mPowerSaveEnabled );
17011693
17021694 // Set the coexistence mode back to its default value
17031695 mWifiNative .setBluetoothCoexistenceMode (
@@ -2549,6 +2541,8 @@ public void enter() {
25492541 mWifiNative .stopFilteringMulticastV4Packets ();
25502542 }
25512543
2544+ mWifiNative .setPowerSave (mPowerSaveEnabled );
2545+
25522546 if (mIsScanMode ) {
25532547 mWifiNative .setScanResultHandling (SCAN_ONLY_MODE );
25542548 mWifiNative .disconnect ();
0 commit comments