summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ActiveModeWarden.java12
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java16
2 files changed, 22 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/ActiveModeWarden.java b/service/java/com/android/server/wifi/ActiveModeWarden.java
index 457b68773..03334584b 100644
--- a/service/java/com/android/server/wifi/ActiveModeWarden.java
+++ b/service/java/com/android/server/wifi/ActiveModeWarden.java
@@ -79,6 +79,7 @@ public class ActiveModeWarden {
private boolean mCanRequestMoreClientModeManagers = false;
private boolean mCanRequestMoreSoftApManagers = false;
+ private boolean mIsShuttingdown = false;
/**
* Called from WifiServiceImpl to register a callback for notifications from SoftApManager
@@ -122,7 +123,7 @@ public class ActiveModeWarden {
mWifiController = new WifiController();
wifiNative.registerStatusListener(isReady -> {
- if (!isReady) {
+ if (!isReady && !mIsShuttingdown) {
mHandler.post(() -> {
Log.e(TAG, "One of the native daemons died. Triggering recovery");
wifiDiagnostics.captureBugReportData(
@@ -149,6 +150,15 @@ public class ActiveModeWarden {
}
/**
+ * Notify that device is shutting down
+ * Keep it simple and don't add collection access codes
+ * to avoid concurrentModificationException when it is directly called from a different thread
+ */
+ public void notifyShuttingDown() {
+ mIsShuttingdown = true;
+ }
+
+ /**
* @return Returns whether we can create more client mode managers or not.
*/
public boolean canRequestMoreClientModeManagers() {
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 436cb94f3..73fb306f9 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -571,11 +571,17 @@ public class WifiServiceImpl extends BaseWifiService {
}
private void handleShutDown() {
- // There is no explicit disconnection event in clientModeImpl during shutdown.
- // Call resetConnectionState() so that connection duration is calculated correctly
- // before memory store write triggered by mMemoryStoreImpl.stop().
- mWifiScoreCard.resetConnectionState();
- mMemoryStoreImpl.stop();
+ // Direct call to notify ActiveModeWarden as soon as possible with the assumption that
+ // notifyShuttingDown() doesn't have codes that may cause concurrentModificationException,
+ // e.g., access to a collection.
+ mActiveModeWarden.notifyShuttingDown();
+ mWifiThreadRunner.post(()-> {
+ // There is no explicit disconnection event in clientModeImpl during shutdown.
+ // Call resetConnectionState() so that connection duration is calculated
+ // before memory store write triggered by mMemoryStoreImpl.stop().
+ mWifiScoreCard.resetConnectionState();
+ mMemoryStoreImpl.stop();
+ });
}
private boolean checkNetworkSettingsPermission(int pid, int uid) {