diff options
author | 2025-03-20 16:34:00 -0700 | |
---|---|---|
committer | 2025-03-20 16:34:00 -0700 | |
commit | 03313eda7435b4caf8f18306853329cc03db9de1 (patch) | |
tree | 8033ff1fc5cd9037e48e9db2c3dec137bcfaf1ce | |
parent | ba81c5f7f57fbd319664bf225f12e2945e41cc8c (diff) | |
parent | 91a0bc648f55263ac504dcd8dfece062a053c092 (diff) |
Snap for 13248265 from 91a0bc648f55263ac504dcd8dfece062a053c092 to 25Q2-release
Change-Id: Icb69c7893197346e55213e951de675113bc35637
4 files changed, 56 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/SarManager.java b/service/java/com/android/server/wifi/SarManager.java index a454dfe96c..9d6a992f57 100644 --- a/service/java/com/android/server/wifi/SarManager.java +++ b/service/java/com/android/server/wifi/SarManager.java @@ -72,7 +72,7 @@ public class SarManager { private static final String TAG = "WifiSarManager"; private boolean mVerboseLoggingEnabled = true; - private SarInfo mSarInfo; + private final SarInfo mSarInfo; /* Configuration for SAR support */ private boolean mSupportSarTxPowerLimit; @@ -106,6 +106,7 @@ public class SarManager { mAudioManager = mContext.getSystemService(AudioManager.class); mHandler = new Handler(looper); mPhoneStateListener = new WifiPhoneStateListener(looper); + mSarInfo = new SarInfo(); wifiDeviceStateChangeManager.registerStateChangeCallback( new WifiDeviceStateChangeManager.StateChangeCallback() { @Override @@ -121,9 +122,9 @@ public class SarManager { public void handleBootCompleted() { readSarConfigs(); if (mSupportSarTxPowerLimit) { - mSarInfo = new SarInfo(); setSarConfigsInInfo(); registerListeners(); + updateSarScenario(); } } @@ -302,11 +303,6 @@ public class SarManager { */ public void setClientWifiState(int state) { boolean newIsEnabled; - /* No action is taken if SAR is not supported */ - if (!mSupportSarTxPowerLimit) { - return; - } - if (state == WifiManager.WIFI_STATE_DISABLED) { newIsEnabled = false; } else if (state == WifiManager.WIFI_STATE_ENABLED) { @@ -328,10 +324,6 @@ public class SarManager { */ public void setSapWifiState(int state) { boolean newIsEnabled; - /* No action is taken if SAR is not supported */ - if (!mSupportSarTxPowerLimit) { - return; - } if (state == WifiManager.WIFI_AP_STATE_DISABLED) { newIsEnabled = false; @@ -354,10 +346,6 @@ public class SarManager { */ public void setScanOnlyWifiState(int state) { boolean newIsEnabled; - /* No action is taken if SAR is not supported */ - if (!mSupportSarTxPowerLimit) { - return; - } if (state == WifiManager.WIFI_STATE_DISABLED) { newIsEnabled = false; @@ -459,6 +447,10 @@ public class SarManager { * Update HAL with the new SAR scenario if needed. */ private void updateSarScenario() { + /* No action is taken if SAR is not supported */ + if (!mSupportSarTxPowerLimit) { + return; + } if (!mSarInfo.shouldReport()) { return; } diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java index f29eb75cf6..ec4a5ca353 100644 --- a/service/java/com/android/server/wifi/WifiNetworkFactory.java +++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java @@ -1347,6 +1347,14 @@ public class WifiNetworkFactory extends NetworkFactory { // If there is no active request or if the user has already selected a network, // ignore screen state changes. if (mActiveSpecificNetworkRequest == null || !mIsPeriodicScanEnabled) return; + if (mSkipUserDialogue) { + // Allow App which bypass the user approval to fulfill the request during screen off. + return; + } + if (screenOn != mIsPeriodicScanPaused) { + // already at the expected state + return; + } // Pause periodic scans when the screen is off & resume when the screen is on. if (screenOn) { diff --git a/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java index 867396da1d..fe582e3521 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/SarManagerTest.java @@ -133,7 +133,6 @@ public class SarManagerTest extends WifiBaseTest { mWifiDeviceStateChangeManager); mSarMgr.handleBootCompleted(); - if (isSarEnabled) { /* Capture the PhoneStateListener */ ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor = @@ -573,4 +572,44 @@ public class SarManagerTest extends WifiBaseTest { assertTrue(mSarInfo.isWifiScanOnlyEnabled); assertFalse(mSarInfo.isWifiClientEnabled); } + + /** + * Test that for devices that support setting/resetting Tx Power limits, device sets wifi enable + * first then finish the boot up. Verify device will change the power scenario. + */ + @Test + public void testSarMgr_enabledTxPowerScenario_wifiOn_before_boot_completed_offHook() { + mResources.setBoolean( + R.bool.config_wifi_framework_enable_sar_tx_power_limit, true); + mResources.setBoolean( + R.bool.config_wifi_framework_enable_soft_ap_sar_tx_power_limit, + false); + + mSarMgr = new SarManager(mContext, mTelephonyManager, mLooper.getLooper(), mWifiNative, + mWifiDeviceStateChangeManager); + /* Enable logs from SarManager */ + enableDebugLogs(); + + InOrder inOrder = inOrder(mWifiNative); + // Enable wifi first, should be no change to the WifiNative + mSarMgr.setClientWifiState(WifiManager.WIFI_STATE_ENABLED); + inOrder.verify(mWifiNative, never()).selectTxPowerScenario(any()); + + mSarMgr.handleBootCompleted(); + ArgumentCaptor<PhoneStateListener> phoneStateListenerCaptor = + ArgumentCaptor.forClass(PhoneStateListener.class); + verify(mTelephonyManager).listen(phoneStateListenerCaptor.capture(), + eq(PhoneStateListener.LISTEN_CALL_STATE)); + mPhoneStateListener = phoneStateListenerCaptor.getValue(); + assertNotNull(mPhoneStateListener); + captureSarInfo(mWifiNative); + assertFalse(mSarInfo.isVoiceCall); + inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); + + /* Set phone state to OFFHOOK */ + mPhoneStateListener.onCallStateChanged(CALL_STATE_OFFHOOK, ""); + + inOrder.verify(mWifiNative).selectTxPowerScenario(eq(mSarInfo)); + assertTrue(mSarInfo.isVoiceCall); + } } diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java index 21aba31784..329a7a8ef0 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java @@ -3342,6 +3342,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { WifiConfigurationTestUtil.createPskNetwork(), TEST_UID_1, TEST_PACKAGE_NAME_1, new int[0]); mWifiNetworkFactory.needNetworkFor(mNetworkRequest); + setScreenState(false); // Verify we did not trigger the UI for the second request. verify(mContext, never()).startActivityAsUser(any(), any()); |