summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java2
-rw-r--r--tests/mts/AndroidManifest.xml3
-rw-r--r--tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java14
3 files changed, 13 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index b03d24b3e..0772b4c80 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -3199,7 +3199,7 @@ public class WifiServiceImpl extends BaseWifiService {
WifiConfigManager.ENHANCED_MAC_RANDOMIZATION_FEATURE_FORCE_ENABLE_FLAG, 0) == 1
? true : false;
mWifiMetrics.setEnhancedMacRandomizationForceEnabled(isEnhancedMacRandEnabled);
- mWifiMetrics.setIsScanningAlwaysEnabled(isScanAlwaysAvailable());
+ mWifiMetrics.setIsScanningAlwaysEnabled(mSettingsStore.isScanAlwaysAvailable());
mWifiMetrics.setVerboseLoggingEnabled(mVerboseLoggingEnabled);
mWifiMetrics.setWifiWakeEnabled(mWifiInjector.getWakeupController().isEnabled());
}
diff --git a/tests/mts/AndroidManifest.xml b/tests/mts/AndroidManifest.xml
index 7130e6d89..b8b025dc2 100644
--- a/tests/mts/AndroidManifest.xml
+++ b/tests/mts/AndroidManifest.xml
@@ -19,6 +19,9 @@
package="android.net.wifi.mts"
android:targetSandboxVersion="2">
+ <!-- Need DUMP permission to call `dumpsys wifi wifiMetricsProto` -->
+ <uses-permission android:name="android.permission.DUMP" />
+
<application android:usesCleartextTraffic="true">
<uses-library android:name="android.test.runner" />
<uses-library android:name="org.apache.http.legacy" android:required="false" />
diff --git a/tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java b/tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java
index c548b852c..7fc10ec84 100644
--- a/tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java
+++ b/tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java
@@ -17,6 +17,7 @@
package android.net.wifi.mts;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assume.assumeTrue;
@@ -26,7 +27,6 @@ import android.util.Base64;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
-import com.android.compatibility.common.util.ShellIdentityUtils;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLog;
import org.junit.Before;
@@ -55,16 +55,20 @@ public class WifiDumpsysMetricsTest {
*/
@Test
public void testWifiDumpMetrics() throws Exception {
- String rawDumpOutput = ShellIdentityUtils.invokeWithShellPermissions(
- () -> StreamReader.runProcessCommand(WIFI_DUMP_PROTO_CMD));
+ // DO NOT run under shell identity. Shell has a lot more permissions.
+ // `dumpsys wifi wifiMetricsProto` should ONLY need `android.permission.DUMP`
+ String rawDumpOutput = StreamReader.runProcessCommand(WIFI_DUMP_PROTO_CMD);
assertThat(rawDumpOutput).isNotNull();
int protoStart = rawDumpOutput.indexOf(START_TAG);
int protoEnd = rawDumpOutput.indexOf(END_TAG);
- assertThat(protoStart).isAtLeast(0);
- assertThat(protoEnd).isAtLeast(protoStart);
+ assertWithMessage("Expected to find \"WifiMetrics:\", but instead found: " + rawDumpOutput)
+ .that(protoStart).isAtLeast(0);
+ assertWithMessage(
+ "Expected to find \"EndWifiMetrics\", but instead found: " + rawDumpOutput)
+ .that(protoEnd).isAtLeast(protoStart);
String protoString = rawDumpOutput.substring(protoStart + START_TAG.length(), protoEnd);
byte[] protoBytes = Base64.decode(protoString, Base64.DEFAULT);