Merge "Disable comparison in user release builds" into tm-dev

This commit is contained in:
Remi NGUYEN VAN
2022-06-21 08:58:23 +00:00
committed by Android (Google) Code Review
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,15 +2000,30 @@ 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)) {
doReturn(testValue).when(mResources)
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);
assertEquals(true, mService.shouldRunComparison());
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);
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) {
final NetworkStats.NonMonotonicObserver observer =