Disable comparison in user release builds
This CL disable the comparison mechanism introduced
in previous beta releases to stop receiving log.wtf signals
from beta users.
This CL only affects logging on user release builds.
Ignore-AOSP-First: Parent CLs are not in aosp yet
Test: 1. NetworkStatsServiceTest
2. manual test with script
Bug: 233752318
Change-Id: I7047106b1019c29460d6633b148f501ffa62f139
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index b37f93d..52d76fc 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -1117,9 +1117,7 @@
} 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();
}
/**
diff --git a/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
index 527dec3..c3c6df6 100644
--- a/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
+++ b/tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java
@@ -2000,15 +2000,30 @@
@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) {
final NetworkStats.NonMonotonicObserver observer =