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) { } catch (Resources.NotFoundException e) {
// Overlay value is not defined. // Overlay value is not defined.
} }
// TODO(b/233752318): For now it is always true to collect signal from beta users. return overlayValue != null ? overlayValue : mDeps.isDebuggable();
// Should change to the default behavior (true if debuggable builds) before formal release.
return (overlayValue != null ? overlayValue : mDeps.isDebuggable()) || true;
} }
/** /**

View File

@@ -2000,15 +2000,30 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
@Test @Test
public void testShouldRunComparison() { public void testShouldRunComparison() {
// TODO(b/233752318): For now it should always true to collect signal from beta users. for (Boolean isDebuggable : Set.of(Boolean.TRUE, Boolean.FALSE)) {
// Should change to the default behavior (true if userdebug rom) before formal release. mIsDebuggable = isDebuggable;
for (int testValue : Set.of(-1, 0, 1, 2)) { // Verify return false regardless of the device is debuggable.
doReturn(testValue).when(mResources) doReturn(0).when(mResources)
.getInteger(R.integer.config_netstats_validate_import); .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, private NetworkStatsRecorder makeTestRecorder(File directory, String prefix, Config config,
boolean includeTags, boolean wipeOnError) { boolean includeTags, boolean wipeOnError) {
final NetworkStats.NonMonotonicObserver observer = final NetworkStats.NonMonotonicObserver observer =