Merge "Disable comparison in user release builds" into tm-dev am: 5409851f43

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18869740

Change-Id: I7c1150436b477a7f6d6dcb8e7132fddcabb2d9b1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Remi NGUYEN VAN
2022-06-21 09:03:29 +00:00
committed by Automerger Merge Worker
2 changed files with 21 additions and 8 deletions

View File

@@ -1126,9 +1126,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
} catch (Resources.NotFoundException e) {
// Overlay value is not defined.
}
// TODO(b/233752318): For now it is always true to collect signal from beta users.
// Should change to the default behavior (true if debuggable builds) before formal release.
return (overlayValue != null ? overlayValue : mDeps.isDebuggable()) || true;
return overlayValue != null ? overlayValue : mDeps.isDebuggable();
}
/**

View File

@@ -2000,14 +2000,29 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
@Test
public void testShouldRunComparison() {
// TODO(b/233752318): For now it should always true to collect signal from beta users.
// Should change to the default behavior (true if userdebug rom) before formal release.
for (int testValue : Set.of(-1, 0, 1, 2)) {
for (Boolean isDebuggable : Set.of(Boolean.TRUE, Boolean.FALSE)) {
mIsDebuggable = isDebuggable;
// Verify return false regardless of the device is debuggable.
doReturn(0).when(mResources)
.getInteger(R.integer.config_netstats_validate_import);
assertShouldRunComparison(false, isDebuggable);
// Verify return true regardless of the device is debuggable.
doReturn(1).when(mResources)
.getInteger(R.integer.config_netstats_validate_import);
assertShouldRunComparison(true, isDebuggable);
// Verify return true iff the device is debuggable.
for (int testValue : Set.of(-1, 2)) {
doReturn(testValue).when(mResources)
.getInteger(R.integer.config_netstats_validate_import);
assertEquals(true, mService.shouldRunComparison());
assertShouldRunComparison(isDebuggable, isDebuggable);
}
}
}
private void assertShouldRunComparison(boolean expected, boolean isDebuggable) {
assertEquals("shouldRunComparison (debuggable=" + isDebuggable + "): ",
expected, mService.shouldRunComparison());
}
private NetworkStatsRecorder makeTestRecorder(File directory, String prefix, Config config,
boolean includeTags, boolean wipeOnError) {