Merge "Disable comparison in user release builds" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5409851f43
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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 =
|
||||||
|
|||||||
Reference in New Issue
Block a user