diff options
author | 2024-10-10 17:07:28 -0700 | |
---|---|---|
committer | 2024-10-23 20:25:23 +0000 | |
commit | a74027cfd78da5c2a25814178fc0c20db8e7dc93 (patch) | |
tree | 041c93a8bbe3e1218e71fc38df04f9b40ff078c5 | |
parent | 7fc8c112913570f0bd8d1ae88e7b4dd5921e0cae (diff) |
Add voip mode into wifi scorer stats
Flag: com.android.wifi.flags.wifi_scorer_new_stats_collection
Bug: 372769096
Test: Atest and on device test
Change-Id: I879753335927a2c39595b7cba35d53c6675896de
7 files changed, 53 insertions, 16 deletions
diff --git a/framework/java/android/net/wifi/WifiUsabilityStatsEntry.java b/framework/java/android/net/wifi/WifiUsabilityStatsEntry.java index 94fbe73621..9a9f16abd0 100644 --- a/framework/java/android/net/wifi/WifiUsabilityStatsEntry.java +++ b/framework/java/android/net/wifi/WifiUsabilityStatsEntry.java @@ -181,6 +181,8 @@ public final class WifiUsabilityStatsEntry implements Parcelable { private final int mMaxSupportedTxLinkSpeed; /** Maximum supported rx link speed in Mbps */ private final int mMaxSupportedRxLinkSpeed; + /** WiFi Voip mode state */ + private final int mVoipMode; /** {@hide} */ @Retention(RetentionPolicy.SOURCE) @@ -1188,7 +1190,7 @@ public final class WifiUsabilityStatsEntry implements Parcelable { int isThroughputPredictorDownstreamSufficient, int isThroughputPredictorUpstreamSufficient, boolean isBluetoothConnected, int uwbAdapterState, boolean isLowLatencyActivated, int maxSupportedTxLinkSpeed, - int maxSupportedRxLinkSpeed) { + int maxSupportedRxLinkSpeed, int voipMode) { mTimeStampMillis = timeStampMillis; mRssi = rssi; mLinkSpeedMbps = linkSpeedMbps; @@ -1240,6 +1242,7 @@ public final class WifiUsabilityStatsEntry implements Parcelable { mIsLowLatencyActivated = isLowLatencyActivated; mMaxSupportedTxLinkSpeed = maxSupportedTxLinkSpeed; mMaxSupportedRxLinkSpeed = maxSupportedRxLinkSpeed; + mVoipMode = voipMode; } /** Implement the Parcelable interface */ @@ -1300,6 +1303,7 @@ public final class WifiUsabilityStatsEntry implements Parcelable { dest.writeBoolean(mIsLowLatencyActivated); dest.writeInt(mMaxSupportedTxLinkSpeed); dest.writeInt(mMaxSupportedRxLinkSpeed); + dest.writeInt(mVoipMode); } /** Implement the Parcelable interface */ @@ -1324,7 +1328,7 @@ public final class WifiUsabilityStatsEntry implements Parcelable { in.readSparseArray(LinkStats.class.getClassLoader()), in.readInt(), in.readInt(), in.readLong(), in.readLong(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readInt(), in.readBoolean(), - in.readInt(), in.readBoolean(), in.readInt(), in.readInt() + in.readInt(), in.readBoolean(), in.readInt(), in.readInt(), in.readInt() ); } @@ -2117,4 +2121,9 @@ public final class WifiUsabilityStatsEntry implements Parcelable { public int getMaxSupportedRxLinkSpeed() { return mMaxSupportedRxLinkSpeed; } + + /** @hide */ + public int getVoipMode() { + return mVoipMode; + } } diff --git a/framework/tests/src/android/net/wifi/WifiManagerTest.java b/framework/tests/src/android/net/wifi/WifiManagerTest.java index 4a9e6b143e..bf1b0f2e9b 100644 --- a/framework/tests/src/android/net/wifi/WifiManagerTest.java +++ b/framework/tests/src/android/net/wifi/WifiManagerTest.java @@ -2541,7 +2541,7 @@ public class WifiManagerTest { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1, 100, 10, 100, 27, contentionTimeStats, rateStats, radioStats, 101, true, true, true, 0, 10, 10, true, linkStats, 1, 0, 10, 20, 1, 2, 1, 1, 1, 1, false, 0, - false, 100, 100)); + false, 100, 100, 1)); verify(mOnWifiUsabilityStatsListener).onWifiUsabilityStats(anyInt(), anyBoolean(), any(WifiUsabilityStatsEntry.class)); } diff --git a/framework/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java b/framework/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java index 3518c4b280..d8211978cf 100644 --- a/framework/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java +++ b/framework/tests/src/android/net/wifi/WifiUsabilityStatsEntryTest.java @@ -116,7 +116,7 @@ public class WifiUsabilityStatsEntryTest { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 32, contentionTimeStats, rateStats, radioStats, 100, true, true, true, 23, 24, 25, true, linkStats, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - false, 36, false, 37, 38); + false, 36, false, 37, 38, 39); assertEquals(32, usabilityStatsEntry.getTimeSliceDutyCycleInPercent()); WifiUsabilityStatsEntry usabilityStatsEntryWithInvalidDutyCycleValue = @@ -124,7 +124,7 @@ public class WifiUsabilityStatsEntryTest { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, contentionTimeStats, rateStats, radioStats, 101, true, true, true, 23, 24, 25, true, linkStats, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - true, 36, true, 37, 38); + true, 36, true, 37, 38, 39); try { usabilityStatsEntryWithInvalidDutyCycleValue.getTimeSliceDutyCycleInPercent(); fail(); @@ -182,7 +182,7 @@ public class WifiUsabilityStatsEntryTest { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 50, contentionTimeStats, rateStats, radioStats, 102, true, true, true, 23, 24, 25, true, linkStats, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - true, 36, false, 37, 38 + true, 36, false, 37, 38, 39 ); } @@ -673,7 +673,7 @@ public class WifiUsabilityStatsEntryTest { WifiUsabilityStatsEntry usabilityStatsEntry = new WifiUsabilityStatsEntry( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 32, null, null, null, 100, true, true, true, 23, 24, 25, true, linkStats, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, true, 36, true, 37, 38); + 28, 29, 30, 31, 32, 33, 34, 35, true, 36, true, 37, 38, 39); assertThrows("linkId is invalid - " + MloLink.INVALID_MLO_LINK_ID, NoSuchElementException.class, diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index b81aee139b..132790f6aa 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -347,6 +347,7 @@ public class WifiMetrics { private SpeedSufficient mSpeedSufficientThroughputPredictor = new SpeedSufficient(); private int mLastUwbState = -1; private boolean mIsLowLatencyActivated = false; + private int mVoipMode = -1; /** * Wi-Fi usability state per interface as predicted by the network scorer. @@ -5306,6 +5307,7 @@ public class WifiMetrics { line.append(",is_low_latency_activated=" + entry.isLowLatencyActivated); line.append(",max_supported_tx_linkspeed=" + entry.maxSupportedTxLinkspeed); line.append(",max_supported_rx_linkspeed=" + entry.maxSupportedRxLinkspeed); + line.append(",voip_mode=" + entry.voipMode); pw.println(line.toString()); } @@ -7401,6 +7403,7 @@ public class WifiMetrics { info.getMaxSupportedTxLinkSpeedMbps(); wifiUsabilityStatsEntry.maxSupportedRxLinkspeed = info.getMaxSupportedRxLinkSpeedMbps(); + wifiUsabilityStatsEntry.voipMode = getVoipMode(); } wifiUsabilityStatsEntry.timeStampMs = stats.timeStampInMs; @@ -7956,7 +7959,7 @@ public class WifiMetrics { s.isThroughputPredictorDownstreamSufficient, s.isThroughputPredictorUpstreamSufficient, s.isBluetoothConnected, s.uwbAdapterState, s.isLowLatencyActivated, s.maxSupportedTxLinkspeed, - s.maxSupportedRxLinkspeed + s.maxSupportedRxLinkspeed, s.voipMode ); } @@ -8170,6 +8173,7 @@ public class WifiMetrics { out.isLowLatencyActivated = s.isLowLatencyActivated; out.maxSupportedTxLinkspeed = s.maxSupportedTxLinkspeed; out.maxSupportedRxLinkspeed = s.maxSupportedRxLinkspeed; + out.voipMode = s.voipMode; return out; } @@ -10462,4 +10466,12 @@ public class WifiMetrics { public void setLowLatencyState(boolean state) { mIsLowLatencyActivated = state; } + + public int getVoipMode() { + return mVoipMode; + } + + public void setVoipMode(int mode) { + mVoipMode = mode; + } } diff --git a/service/java/com/android/server/wifi/WifiVoipDetector.java b/service/java/com/android/server/wifi/WifiVoipDetector.java index 5754bc3ef8..e8c274b410 100644 --- a/service/java/com/android/server/wifi/WifiVoipDetector.java +++ b/service/java/com/android/server/wifi/WifiVoipDetector.java @@ -181,6 +181,7 @@ public class WifiVoipDetector { log = "Failed to set Voip Mode to " + newMode + " (maybe not supported?)"; } else { mCurrentMode = newMode; + mWifiInjector.getWifiMetrics().setVoipMode(mCurrentMode); } mLocalLog.log(log); if (mVerboseLoggingEnabled) { diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 6808ac6347..1637fb7d5c 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -2768,6 +2768,9 @@ message WifiUsabilityStatsEntry { // Maximum supported rx link speed in Mbps optional int32 max_supported_rx_linkspeed = 60; + + // Wifi Voip mode state + optional int32 voip_mode = 61; } message ContentionTimeStats { diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java index 9741a2c8c2..1c8264a1f6 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/WifiVoipDetectorTest.java @@ -66,6 +66,7 @@ public class WifiVoipDetectorTest extends WifiBaseTest { @Mock private TelephonyManager mTelephonyManager; @Mock private WifiNative mWifiNative; @Mock private WifiCarrierInfoManager mWifiCarrierInfoManager; + @Mock private WifiMetrics mWifiMetrics; private WifiVoipDetector mWifiVoipDetector; private TestLooper mLooper; @@ -84,13 +85,15 @@ public class WifiVoipDetectorTest extends WifiBaseTest { when(mWifiInjector.makeTelephonyManager()).thenReturn(mTelephonyManager); when(mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager); when(mWifiInjector.getWifiNative()).thenReturn(mWifiNative); + when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics); when(mWifiNative.setVoipMode(anyInt())).thenReturn(true); mWifiVoipDetector = new WifiVoipDetector(mContext, new Handler(mLooper.getLooper()), mWifiInjector, mWifiCarrierInfoManager); } - private void resetWifiNativeAndReSetupforMock() { + private void resetWifiNativeAndWifiMetricsAndReSetupforMock() { reset(mWifiNative); + reset(mWifiMetrics); when(mWifiNative.setVoipMode(anyInt())).thenReturn(true); } @@ -111,38 +114,46 @@ public class WifiVoipDetectorTest extends WifiBaseTest { when(mWifiCarrierInfoManager.isWifiCallingAvailable()).thenReturn(true); mWifiVoipDetector.notifyWifiConnected(true, true, TEST_PRIMARY_INTERFACE_NAME); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); // Test VoWifi call off -> switch to VoLte mTelephonyCallbackCaptor.getValue().onCallAttributesChanged(TEST_LTE_CALL_ATT); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Test VoWifi Call mTelephonyCallbackCaptor.getValue().onCallAttributesChanged(TEST_VOWIFI_CALL_ATT); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Test VoWifi call off -> switch to VoLte mTelephonyCallbackCaptor.getValue().onCallAttributesChanged(TEST_LTE_CALL_ATT); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Test MODE_IN_COMMUNICATION to trigger voice mode mAudioModeChangedListeneCaptor.getValue().onModeChanged(AudioManager.MODE_IN_COMMUNICATION); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Test MODE_NORMAL off WifiChip.WIFI_VOIP_MODE_OFF mAudioModeChangedListeneCaptor.getValue().onModeChanged(AudioManager.MODE_NORMAL); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Test MODE_COMMUNICATION_REDIRECT to trigger voice mode mAudioModeChangedListeneCaptor.getValue().onModeChanged( AudioManager.MODE_COMMUNICATION_REDIRECT); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); - resetWifiNativeAndReSetupforMock(); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); // Do nothing when mode change between two OTT modes. mAudioModeChangedListeneCaptor.getValue().onModeChanged(AudioManager.MODE_IN_COMMUNICATION); verify(mWifiNative, never()).setVoipMode(anyInt()); mWifiVoipDetector.notifyWifiConnected(false, true, TEST_PRIMARY_INTERFACE_NAME); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_OFF); // Test OTT on when wifi is disconnected, should do nothing since it doesn't relate to wifi. - resetWifiNativeAndReSetupforMock(); + resetWifiNativeAndWifiMetricsAndReSetupforMock(); mAudioModeChangedListeneCaptor.getValue().onModeChanged( AudioManager.MODE_COMMUNICATION_REDIRECT); verify(mWifiNative, never()).setVoipMode(anyInt()); @@ -150,6 +161,7 @@ public class WifiVoipDetectorTest extends WifiBaseTest { when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_COMMUNICATION_REDIRECT); mWifiVoipDetector.notifyWifiConnected(true, true, TEST_PRIMARY_INTERFACE_NAME); verify(mWifiNative).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); + verify(mWifiInjector.getWifiMetrics()).setVoipMode(WifiChip.WIFI_VOIP_MODE_VOICE); } @Test |