diff options
author | Ahmed ElArabawy <arabawy@google.com> | 2018-05-01 09:11:13 -0700 |
---|---|---|
committer | Ahmed ElArabawy <arabawy@google.com> | 2018-06-08 09:54:52 -0700 |
commit | 26744a15cfead946e7a4ca8b028fe4ea9bf96efe (patch) | |
tree | 381c057744f38d690ef2d1055d9200a834794fac /service | |
parent | 1b8216207b5ab9c5cc64932c9c731843fe819539 (diff) |
WiFi: Extend SAR to support sap/scan-only modes
This commit is part of the feature of extending SAR Support in WiFi.
It adds support for both AP and Scan-Only modes.
This commit also adds some more general tests for SarManager class.
Bug: 65174506
Test: Run Wifi unit test suite
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I04b61aaf69308600919c5f6e9ea61be130be9750
Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
Diffstat (limited to 'service')
4 files changed, 73 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java index f157ac41e..d38eab981 100644 --- a/service/java/com/android/server/wifi/SarManager.java +++ b/service/java/com/android/server/wifi/SarManager.java @@ -42,6 +42,8 @@ import java.util.List; * This class provides the Support for SAR to control WiFi TX power limits. * It deals with the following: * - Tracking the STA state through calls from the ClientModeManager. + * - Tracking the SAP state through calls from SoftApManager + * - Tracking the Scan-Only state through ScanOnlyModeManager * - Tracking the state of the Cellular calls or data. * - Tracking the sensor indicating proximity to user head/hand/body. * - It constructs the sar info and send it towards the HAL @@ -182,6 +184,58 @@ public class SarManager { } /** + * Update Wifi SoftAP State + */ + public void setSapWifiState(int state) { + boolean newIsEnabled; + /* No action is taken if SAR is not enabled */ + if (!mEnableSarTxPowerLimit) { + return; + } + + if (state == WifiManager.WIFI_AP_STATE_DISABLED) { + newIsEnabled = false; + } else if (state == WifiManager.WIFI_AP_STATE_ENABLED) { + newIsEnabled = true; + } else { + /* No change so exiting with no action */ + return; + } + + /* Report change to HAL if needed */ + if (mSarInfo.mIsWifiSapEnabled != newIsEnabled) { + mSarInfo.mIsWifiSapEnabled = newIsEnabled; + updateSarScenario(); + } + } + + /** + * Update Wifi ScanOnly State + */ + public void setScanOnlyWifiState(int state) { + boolean newIsEnabled; + /* No action is taken if SAR is not enabled */ + if (!mEnableSarTxPowerLimit) { + return; + } + + if (state == WifiManager.WIFI_STATE_DISABLED) { + newIsEnabled = false; + } else if (state == WifiManager.WIFI_STATE_ENABLED) { + newIsEnabled = true; + } else { + /* No change so exiting with no action */ + return; + } + + /* Report change to HAL if needed */ + if (mSarInfo.mIsWifiScanOnlyEnabled != newIsEnabled) { + mSarInfo.mIsWifiScanOnlyEnabled = newIsEnabled; + updateSarScenario(); + } + } + + /** * Report Cell state event */ private void onCellStateChangeEvent(int state) { @@ -238,7 +292,6 @@ public class SarManager { * Enable/disable verbose logging. */ public void enableVerboseLogging(int verbose) { - Log.d(TAG, "Inside enableVerboseLogging: " + verbose); if (verbose > 0) { mVerboseLoggingEnabled = true; } else { diff --git a/service/java/com/android/server/wifi/ScanOnlyModeManager.java b/service/java/com/android/server/wifi/ScanOnlyModeManager.java index 346d2ca67..991657929 100644 --- a/service/java/com/android/server/wifi/ScanOnlyModeManager.java +++ b/service/java/com/android/server/wifi/ScanOnlyModeManager.java @@ -48,6 +48,7 @@ public class ScanOnlyModeManager implements ActiveModeManager { private final Listener mListener; private final ScanRequestProxy mScanRequestProxy; private final WakeupController mWakeupController; + private final SarManager mSarManager; private String mClientInterfaceName; private boolean mIfaceIsUp = false; @@ -58,13 +59,15 @@ public class ScanOnlyModeManager implements ActiveModeManager { @NonNull WifiNative wifiNative, @NonNull Listener listener, @NonNull WifiMetrics wifiMetrics, @NonNull ScanRequestProxy scanRequestProxy, - @NonNull WakeupController wakeupController) { + @NonNull WakeupController wakeupController, + @NonNull SarManager sarManager) { mContext = context; mWifiNative = wifiNative; mListener = listener; mWifiMetrics = wifiMetrics; mScanRequestProxy = scanRequestProxy; mWakeupController = wakeupController; + mSarManager = sarManager; mStateMachine = new ScanOnlyModeStateMachine(looper); } @@ -242,6 +245,7 @@ public class ScanOnlyModeManager implements ActiveModeManager { mIfaceIsUp = false; onUpChanged(mWifiNative.isInterfaceUp(mClientInterfaceName)); + mSarManager.setScanOnlyWifiState(WifiManager.WIFI_STATE_ENABLED); } @Override @@ -281,6 +285,7 @@ public class ScanOnlyModeManager implements ActiveModeManager { mClientInterfaceName = null; } updateWifiState(WifiManager.WIFI_STATE_DISABLED); + mSarManager.setScanOnlyWifiState(WifiManager.WIFI_STATE_DISABLED); // once we leave started, nothing else to do... stop the state machine mStateMachine.quitNow(); diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index 6c52918a5..1afe9ed9d 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -93,6 +93,8 @@ public class SoftApManager implements ActiveModeManager { private int mNumAssociatedStations = 0; private boolean mTimeoutEnabled = false; + private final SarManager mSarManager; + /** * Listener for soft AP events. */ @@ -118,7 +120,8 @@ public class SoftApManager implements ActiveModeManager { @NonNull WifiManager.SoftApCallback callback, @NonNull WifiApConfigStore wifiApConfigStore, @NonNull SoftApModeConfiguration apConfig, - @NonNull WifiMetrics wifiMetrics) { + @NonNull WifiMetrics wifiMetrics, + @NonNull SarManager sarManager) { mContext = context; mFrameworkFacade = framework; mWifiNative = wifiNative; @@ -133,6 +136,7 @@ public class SoftApManager implements ActiveModeManager { mApConfig = config; } mWifiMetrics = wifiMetrics; + mSarManager = sarManager; mStateMachine = new SoftApStateMachine(looper); } @@ -491,6 +495,9 @@ public class SoftApManager implements ActiveModeManager { if (mSettingObserver != null) { mSettingObserver.register(); } + + mSarManager.setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED); + Log.d(TAG, "Resetting num stations on start"); mNumAssociatedStations = 0; scheduleTimeoutMessage(); @@ -512,6 +519,8 @@ public class SoftApManager implements ActiveModeManager { mWifiMetrics.addSoftApUpChangedEvent(false, mMode); updateApState(WifiManager.WIFI_AP_STATE_DISABLED, WifiManager.WIFI_AP_STATE_DISABLING, 0); + + mSarManager.setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED); mApInterfaceName = null; mIfaceIsUp = false; mStateMachine.quitNow(); diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 5a4fe570b..199548090 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -465,7 +465,7 @@ public class WifiInjector { @NonNull SoftApModeConfiguration config) { return new SoftApManager(mContext, mWifiStateMachineHandlerThread.getLooper(), mFrameworkFacade, mWifiNative, mCountryCode.getCountryCode(), callback, - mWifiApConfigStore, config, mWifiMetrics); + mWifiApConfigStore, config, mWifiMetrics, mSarManager); } /** @@ -477,7 +477,8 @@ public class WifiInjector { public ScanOnlyModeManager makeScanOnlyModeManager( @NonNull ScanOnlyModeManager.Listener listener) { return new ScanOnlyModeManager(mContext, mWifiStateMachineHandlerThread.getLooper(), - mWifiNative, listener, mWifiMetrics, mScanRequestProxy, mWakeupController); + mWifiNative, listener, mWifiMetrics, mScanRequestProxy, mWakeupController, + mSarManager); } /** |