Fix wrong request_count in connectivityStateSample and add tests

This CL updates CSTest to use mocked appOpsManager to bypass
checkPackage enforcement so that test can file network request as
SYSTEM_UID

Bug: 314627716
Test: atest ConnectivitySampleMetricsTest
Change-Id: I0a5f3b1bf2c343644e6f5e2a4ec1b0460e2645c4
This commit is contained in:
Motomu Utsumi 2024-02-28 15:58:42 +09:00
commit e08de4d322

View file

@ -2607,7 +2607,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Not the system, so it's an app requesting on its own behalf.
type = RequestType.RT_APP.getNumber();
}
countPerType.put(type, countPerType.get(type, 0));
countPerType.put(type, countPerType.get(type, 0) + 1);
}
for (int i = countPerType.size() - 1; i >= 0; --i) {
final RequestCountForType.Builder r = RequestCountForType.newBuilder();