summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorVishal Mahaveer <vishalm@ti.com>2012-05-24 14:03:36 -0500
committerIrfan Sheriff <isheriff@google.com>2012-05-24 22:49:58 -0700
commitf48fb85a8c4f72ec08b98f15ec3d9c70c247de7d (patch)
treefe5edf459a791eeea02d13c2dcd6f64c0a07ac62 /wifi
parentae14715284837aebe179f790e0456d2bdb367583 (diff)
downloadframeworks_base-f48fb85a8c4f72ec08b98f15ec3d9c70c247de7d.zip
frameworks_base-f48fb85a8c4f72ec08b98f15ec3d9c70c247de7d.tar.gz
frameworks_base-f48fb85a8c4f72ec08b98f15ec3d9c70c247de7d.tar.bz2
Fix delayed wifi shutdown
Use a wake up alarm to ensure delayed shut down message is sent Bug: 5926285 Change-Id: I26a3353ddabb17d55299d8b5f9faf4c7ef5b2448 Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 2903faa..c4519be 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -208,6 +208,8 @@ public class WifiStateMachine extends StateMachine {
private AlarmManager mAlarmManager;
private PendingIntent mScanIntent;
+ private PendingIntent mDriverStopIntent;
+
/* Tracks current frequency mode */
private AtomicInteger mFrequencyBand = new AtomicInteger(WifiManager.WIFI_FREQUENCY_BAND_AUTO);
@@ -520,6 +522,11 @@ public class WifiStateMachine extends StateMachine {
private static final String ACTION_START_SCAN =
"com.android.server.WifiManager.action.START_SCAN";
+ private static final String DELAYED_STOP_COUNTER = "DelayedStopCounter";
+ private static final int DRIVER_STOP_REQUEST = 0;
+ private static final String ACTION_DELAYED_DRIVER_STOP =
+ "com.android.server.WifiManager.action.DELAYED_DRIVER_STOP";
+
/**
* Keep track of whether WIFI is running.
*/
@@ -637,6 +644,15 @@ public class WifiStateMachine extends StateMachine {
}
}
};
+ mContext.registerReceiver(
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ int counter = intent.getIntExtra(DELAYED_STOP_COUNTER, 0);
+ sendMessage(obtainMessage(CMD_DELAYED_STOP_DRIVER, counter, 0));
+ }
+ },
+ new IntentFilter(ACTION_DELAYED_DRIVER_STOP));
mScanResultCache = new LruCache<String, ScanResult>(SCAN_RESULT_CACHE_SIZE);
@@ -2666,18 +2682,26 @@ public class WifiStateMachine extends StateMachine {
sendMessage(obtainMessage(CMD_DELAYED_STOP_DRIVER, mDelayedStopCounter, 0));
} else {
/* send regular delayed shut down */
- sendMessageDelayed(obtainMessage(CMD_DELAYED_STOP_DRIVER,
- mDelayedStopCounter, 0), mDriverStopDelayMs);
+ Intent driverStopIntent = new Intent(ACTION_DELAYED_DRIVER_STOP, null);
+ driverStopIntent.putExtra(DELAYED_STOP_COUNTER, mDelayedStopCounter);
+ mDriverStopIntent = PendingIntent.getBroadcast(mContext,
+ DRIVER_STOP_REQUEST, driverStopIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+
+ mAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ + mDriverStopDelayMs, mDriverStopIntent);
}
break;
case CMD_START_DRIVER:
if (mInDelayedStop) {
mInDelayedStop = false;
mDelayedStopCounter++;
+ mAlarmManager.cancel(mDriverStopIntent);
if (DBG) log("Delayed stop ignored due to start");
}
break;
case CMD_DELAYED_STOP_DRIVER:
+ if (DBG) log("delayed stop " + message.arg1 + " " + mDelayedStopCounter);
if (message.arg1 != mDelayedStopCounter) break;
if (getCurrentState() != mDisconnectedState) {
mWifiNative.disconnect();