diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-05-21 06:05:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-21 06:05:13 +0000 |
commit | 25ada1ff4b9782d3175a1d5fd93e97a1559bcb84 (patch) | |
tree | c207a33f9d6040b79554fa3ae226a350247fef6b /tests | |
parent | 3280ce7359f081628980661afc46890bd90a71c9 (diff) | |
parent | 7f871799e7233c9cf16def8be78e1926bbc544d5 (diff) |
Merge changes I7f95fec0,I81810626 into rvc-dev
* changes:
WifiDumpsysMetricsTest: ensure that only DUMP permission is needed
Fix Wifi Metrics not uploading
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mts/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | tests/mts/src/android/net/wifi/mts/WifiDumpsysMetricsTest.java | 14 |
2 files changed, 12 insertions, 5 deletions
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); |