diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-06-03 19:29:04 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-06-03 19:29:04 +0000 |
commit | dace99306a5ab16fb556ff3287139f95843bebb3 (patch) | |
tree | 5077dbd03193971b7b4e497d21ed625ea3f2c292 /service | |
parent | edd8833275a5b7b750b2a58fa7c323b45b86b961 (diff) | |
parent | 4a8e0a5fa8f70140be5d9191c9f872fe99a6cf9a (diff) |
Merge "ActiveModeWarden: Defer APM toggle if handling a previous toggle" into rvc-dev
Diffstat (limited to 'service')
5 files changed, 45 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/ActiveModeManager.java b/service/java/com/android/server/wifi/ActiveModeManager.java index aa0bf9f6b..0983e9b93 100644 --- a/service/java/com/android/server/wifi/ActiveModeManager.java +++ b/service/java/com/android/server/wifi/ActiveModeManager.java @@ -59,6 +59,11 @@ public interface ActiveModeManager { */ void stop(); + /** + * Method used to indicate if the mode manager is still stopping. + */ + boolean isStopping(); + /** Roles assigned to each mode manager. */ int ROLE_UNSPECIFIED = -1; // SoftApManager - Tethering, will respond to public APIs. diff --git a/service/java/com/android/server/wifi/ActiveModeWarden.java b/service/java/com/android/server/wifi/ActiveModeWarden.java index 03334584b..e0a0a3d29 100644 --- a/service/java/com/android/server/wifi/ActiveModeWarden.java +++ b/service/java/com/android/server/wifi/ActiveModeWarden.java @@ -282,6 +282,16 @@ public class ActiveModeWarden { } /** + * @return true if any mode manager is stopping + */ + private boolean hasAnyModeManagerStopping() { + for (ActiveModeManager manager : mActiveModeManagers) { + if (manager.isStopping()) return true; + } + return false; + } + + /** * @return true if all the client mode managers are in scan only role, * false if there are no client mode managers present or if any of them are not in scan only * role. @@ -886,8 +896,16 @@ public class ActiveModeWarden { if (mSettingsStore.isAirplaneModeOn()) { return NOT_HANDLED; } else { - // when airplane mode is toggled off, but wifi is on, we can keep it on - log("airplane mode toggled - and airplane mode is off. return handled"); + if (hasAnyModeManagerStopping()) { + // previous airplane mode toggle on is being processed, defer the + // message toggle off until previous processing is completed. + deferMessage(msg); + } else { + // when airplane mode is toggled off, but wifi is on, we can keep it + // on + log("airplane mode toggled - and airplane mode is off. return " + + "handled"); + } return HANDLED; } case CMD_AP_STOPPED: diff --git a/service/java/com/android/server/wifi/ClientModeManager.java b/service/java/com/android/server/wifi/ClientModeManager.java index 61df5191b..abb6f625d 100644 --- a/service/java/com/android/server/wifi/ClientModeManager.java +++ b/service/java/com/android/server/wifi/ClientModeManager.java @@ -76,9 +76,9 @@ public class ClientModeManager implements ActiveModeManager { private String mClientInterfaceName; private boolean mIfaceIsUp = false; - private @Role int mRole = ROLE_UNSPECIFIED; private DeferStopHandler mDeferStopHandler; - private int mTargetRole = ROLE_UNSPECIFIED; + private @Role int mRole = ROLE_UNSPECIFIED; + private @Role int mTargetRole = ROLE_UNSPECIFIED; private int mActiveSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; ClientModeManager(Context context, @NonNull Looper looper, Clock clock, WifiNative wifiNative, @@ -122,6 +122,11 @@ public class ClientModeManager implements ActiveModeManager { mDeferStopHandler.start(getWifiOffDeferringTimeMs()); } + @Override + public boolean isStopping() { + return mTargetRole == ROLE_UNSPECIFIED && mRole != ROLE_UNSPECIFIED; + } + private class DeferStopHandler extends WifiHandler { private boolean mIsDeferring = false; private ImsMmTelManager mImsMmTelManager = null; diff --git a/service/java/com/android/server/wifi/DefaultModeManager.java b/service/java/com/android/server/wifi/DefaultModeManager.java index cda4978b8..00b2117a8 100644 --- a/service/java/com/android/server/wifi/DefaultModeManager.java +++ b/service/java/com/android/server/wifi/DefaultModeManager.java @@ -45,6 +45,11 @@ public class DefaultModeManager implements ActiveModeManager { @Override public void stop() { }; + @Override + public boolean isStopping() { + return false; + } + /** * No role specified in default mode. */ diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index 3bf12ca34..f9720477b 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -122,6 +122,7 @@ public class SoftApManager implements ActiveModeManager { private BaseWifiDiagnostics mWifiDiagnostics; private @Role int mRole = ROLE_UNSPECIFIED; + private @Role int mTargetRole = ROLE_UNSPECIFIED; private boolean mEverReportMetricsForMaxClient = false; @@ -219,6 +220,7 @@ public class SoftApManager implements ActiveModeManager { @Override public void stop() { Log.d(TAG, " currentstate: " + getCurrentStateName()); + mTargetRole = ROLE_UNSPECIFIED; if (mApInterfaceName != null) { if (mIfaceIsUp) { updateApState(WifiManager.WIFI_AP_STATE_DISABLING, @@ -232,6 +234,11 @@ public class SoftApManager implements ActiveModeManager { } @Override + public boolean isStopping() { + return mTargetRole == ROLE_UNSPECIFIED && mRole != ROLE_UNSPECIFIED; + } + + @Override public @Role int getRole() { return mRole; } @@ -241,6 +248,7 @@ public class SoftApManager implements ActiveModeManager { // softap does not allow in-place switching of roles. Preconditions.checkState(mRole == ROLE_UNSPECIFIED); Preconditions.checkState(SOFTAP_ROLES.contains(role)); + mTargetRole = role; mRole = role; } |