From c6c6ef3a58941d2150cf11ee55188386036f51e8 Mon Sep 17 00:00:00 2001 From: Les Lee Date: Tue, 2 Aug 2022 11:14:14 +0800 Subject: [PATCH] wifi: Handle wifi ap initial state before register intent The intent WIFI_AP_STATE_CHANGED_ACTION is not sticky intent after SC-V2, query wifi ap state and run intent handling after registering intent. Bug: 231214355 Test: make RunSettingsRoboTests ROBOTEST_FILTER=Hotspot Test: make RunSettingsRoboTests ROBOTEST_FILTER=Tether Test: Manual test, the state shows correctly even if resume hotspot settings page from recent app. Change-Id: Iab6b2b8628d725b003d5e5c4086420a329611745 --- src/com/android/settings/AllInOneTetherSettings.java | 3 +++ .../conditional/HotspotConditionController.java | 3 +++ src/com/android/settings/wifi/tether/WifiTetherSettings.java | 3 +++ .../settings/wifi/tether/WifiTetherSwitchBarController.java | 1 + 4 files changed, 10 insertions(+) diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java index d41c07bb6a3..f98fdc1d234 100644 --- a/src/com/android/settings/AllInOneTetherSettings.java +++ b/src/com/android/settings/AllInOneTetherSettings.java @@ -251,6 +251,9 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment } final Context context = getContext(); if (context != null) { + // The intent WIFI_AP_STATE_CHANGED_ACTION is not sticky intent after SC-V2 + // But ACTION_TETHER_STATE_CHANGED is still sticky intent. So no need to handle + // initial state for WIFI_AP_STATE_CHANGED_ACTION IntentFilter filter = new IntentFilter(ACTION_TETHER_STATE_CHANGED); filter.addAction(WIFI_AP_STATE_CHANGED_ACTION); context.registerReceiver(mTetherChangeReceiver, filter); diff --git a/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionController.java index b59fda48bbc..dd788074313 100644 --- a/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionController.java +++ b/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionController.java @@ -106,6 +106,9 @@ public class HotspotConditionController implements ConditionalCardController { @Override public void startMonitoringStateChange() { mAppContext.registerReceiver(mReceiver, WIFI_AP_STATE_FILTER); + // The intent WIFI_AP_STATE_CHANGED_ACTION is not sticky intent anymore after SC-V2 + // Handle the initial state after register the receiver. + mConditionManager.onConditionChanged(); } @Override diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java index aea7078f144..e6b4bd6e67a 100644 --- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java +++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java @@ -159,6 +159,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment if (context != null) { context.registerReceiver(mTetherChangeReceiver, TETHER_STATE_CHANGE_FILTER, Context.RECEIVER_EXPORTED_UNAUDITED); + // The intent WIFI_AP_STATE_CHANGED_ACTION is not sticky intent anymore after SC-V2 + // Handle the initial state after register the receiver. + updateDisplayWithNewConfig(); } } diff --git a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java index e88931cceff..d6ca524f61f 100644 --- a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java +++ b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java @@ -93,6 +93,7 @@ public class WifiTetherSwitchBarController implements mSwitchBar.addOnSwitchChangeListener(this); mContext.registerReceiver(mReceiver, WIFI_INTENT_FILTER, Context.RECEIVER_EXPORTED_UNAUDITED); + handleWifiApStateChanged(mWifiManager.getWifiApState()); } @Override