Skip to content

Commit 5ab0243

Browse files
committed
Only require that system UIDs tag their sockets.
Apps with a normal UID are typically isolated enough to not require socket tagging; we're mostly interested in tracking down internal UIDs that have lots of code sharing the same UID. Also fix up everyone doing manual string checks of Build.TYPE, since we now have first-class fields for those. Bug: 38126076 Test: builds, boots Change-Id: I3a40348196bd8459289f2b9355d9783a07f1e7dd
1 parent 2789536 commit 5ab0243

20 files changed

Lines changed: 33 additions & 41 deletions

File tree

core/java/android/net/NetworkIdentity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public boolean getMetered() {
157157
* Scrub given IMSI on production builds.
158158
*/
159159
public static String scrubSubscriberId(String subscriberId) {
160-
if ("eng".equals(Build.TYPE)) {
160+
if (Build.IS_ENG) {
161161
return subscriberId;
162162
} else if (subscriberId != null) {
163163
// TODO: parse this as MCC+MNC instead of hard-coding

core/java/android/os/StrictMode.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ public final class StrictMode {
125125
private static final String TAG = "StrictMode";
126126
private static final boolean LOG_V = Log.isLoggable(TAG, Log.VERBOSE);
127127

128-
private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
129-
private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);
130-
131128
/**
132129
* Boolean system property to disable strict mode checks outright.
133130
* Set this to 'true' to force disable; 'false' has no effect on other
@@ -1191,15 +1188,15 @@ public static boolean conditionallyEnableDebugLogging() {
11911188

11921189
// For debug builds, log event loop stalls to dropbox for analysis.
11931190
// Similar logic also appears in ActivityThread.java for system apps.
1194-
if (!doFlashes && (IS_USER_BUILD || suppress)) {
1191+
if (!doFlashes && (Build.IS_USER || suppress)) {
11951192
setCloseGuardEnabled(false);
11961193
return false;
11971194
}
11981195

11991196
// Eng builds have flashes on all the time. The suppression property
12001197
// overrides this, so we force the behavior only after the short-circuit
12011198
// check above.
1202-
if (IS_ENG_BUILD) {
1199+
if (Build.IS_ENG) {
12031200
doFlashes = true;
12041201
}
12051202

@@ -1208,7 +1205,7 @@ public static boolean conditionallyEnableDebugLogging() {
12081205
StrictMode.DETECT_DISK_READ |
12091206
StrictMode.DETECT_NETWORK;
12101207

1211-
if (!IS_USER_BUILD) {
1208+
if (!Build.IS_USER) {
12121209
threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
12131210
}
12141211
if (doFlashes) {
@@ -1219,23 +1216,25 @@ public static boolean conditionallyEnableDebugLogging() {
12191216

12201217
// VM Policy controls CloseGuard, detection of Activity leaks,
12211218
// and instance counting.
1222-
if (IS_USER_BUILD) {
1219+
if (Build.IS_USER) {
12231220
setCloseGuardEnabled(false);
12241221
} else {
12251222
VmPolicy.Builder policyBuilder = new VmPolicy.Builder().detectAll();
1226-
if (!IS_ENG_BUILD) {
1223+
if (!Build.IS_ENG) {
12271224
// Activity leak detection causes too much slowdown for userdebug because of the
12281225
// GCs.
12291226
policyBuilder = policyBuilder.disable(DETECT_VM_ACTIVITY_LEAKS);
12301227
}
12311228
policyBuilder = policyBuilder.penaltyDropBox();
1232-
if (IS_ENG_BUILD) {
1229+
if (Build.IS_ENG) {
12331230
policyBuilder.penaltyLog();
12341231
}
12351232
// All core system components need to tag their sockets to aid
12361233
// system health investigations
12371234
if (android.os.Process.myUid() < android.os.Process.FIRST_APPLICATION_UID) {
1238-
policyBuilder.detectUntaggedSockets();
1235+
policyBuilder.enable(DETECT_VM_UNTAGGED_SOCKET);
1236+
} else {
1237+
policyBuilder.disable(DETECT_VM_UNTAGGED_SOCKET);
12391238
}
12401239
setVmPolicy(policyBuilder.build());
12411240
setCloseGuardEnabled(vmClosableObjectLeaksEnabled());
@@ -2294,7 +2293,7 @@ protected IWindowManager create() {
22942293
* @hide
22952294
*/
22962295
public static Span enterCriticalSpan(String name) {
2297-
if (IS_USER_BUILD) {
2296+
if (Build.IS_USER) {
22982297
return NO_OP_SPAN;
22992298
}
23002299
if (name == null || name.isEmpty()) {

core/java/android/util/BootTimingsTraceLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
public class BootTimingsTraceLog {
3131
// Debug boot time for every step if it's non-user build.
32-
private static final boolean DEBUG_BOOT_TIME = !"user".equals(Build.TYPE);
32+
private static final boolean DEBUG_BOOT_TIME = !Build.IS_USER;
3333
private final Deque<Pair<String, Long>> mStartTimes
3434
= DEBUG_BOOT_TIME ? new ArrayDeque<>() : null;
3535
private final String mTag;

core/java/android/view/InputEventConsistencyVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @hide
3131
*/
3232
public final class InputEventConsistencyVerifier {
33-
private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);
33+
private static final boolean IS_ENG_BUILD = Build.IS_ENG;
3434

3535
private static final String EVENT_TYPE_KEY = "KeyEvent";
3636
private static final String EVENT_TYPE_TRACKBALL = "TrackballEvent";

core/java/android/view/accessibility/AccessibilityCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class AccessibilityCache {
4040

4141
private static final boolean DEBUG = false;
4242

43-
private static final boolean CHECK_INTEGRITY = "eng".equals(Build.TYPE);
43+
private static final boolean CHECK_INTEGRITY = Build.IS_ENG;
4444

4545
/**
4646
* {@link AccessibilityEvent} types that are critical for the cache to stay up to date

core/java/com/android/internal/app/procstats/SparseMappingTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private static void logOrThrow(String message) {
646646
*/
647647
private static void logOrThrow(String message, Throwable th) {
648648
Slog.e(TAG, message, th);
649-
if (Build.TYPE.equals("eng")) {
649+
if (Build.IS_ENG) {
650650
throw new RuntimeException(message, th);
651651
}
652652
}

core/tests/utiltests/src/android/util/RemoteIntArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
final class RemoteIntArray implements ServiceConnection, Closeable {
3434
private static final long BIND_REMOTE_SERVICE_TIMEOUT =
35-
("eng".equals(Build.TYPE)) ? 120000 : 10000;
35+
Build.IS_ENG ? 120000 : 10000;
3636

3737
private final Object mLock = new Object();
3838

packages/Shell/src/com/android/shell/BugreportWarningActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void onCreate(Bundle icicle) {
6464

6565
final int state = getWarningState(this, STATE_UNKNOWN);
6666
final boolean checked;
67-
if (Build.TYPE.equals("user")) {
67+
if (Build.IS_USER) {
6868
checked = state == STATE_HIDE; // Only checks if specifically set to.
6969
} else {
7070
checked = state != STATE_SHOW; // Checks by default.

packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ private void bugreportFinishedWithWarningTest(Integer propertyState) throws Exce
577577
mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm_dont_repeat));
578578
final boolean firstTime = propertyState == null || propertyState == STATE_UNKNOWN;
579579
if (firstTime) {
580-
if (Build.TYPE.equals("user")) {
580+
if (Build.IS_USER) {
581581
assertFalse("Checkbox should NOT be checked by default on user builds",
582582
dontShowAgain.isChecked());
583583
mUiBot.click(dontShowAgain, "dont-show-again");

packages/SystemUI/src/com/android/systemui/recents/Recents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void start() {
207207
mImpl = new RecentsImpl(mContext);
208208

209209
// Check if there is a recents override package
210-
if ("userdebug".equals(Build.TYPE) || "eng".equals(Build.TYPE)) {
210+
if (Build.IS_USERDEBUG || Build.IS_ENG) {
211211
String cnStr = SystemProperties.get(RECENTS_OVERRIDE_SYSPROP_KEY);
212212
if (!cnStr.isEmpty()) {
213213
mOverrideRecentsPackageName = cnStr;

0 commit comments

Comments
 (0)