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
This commit is contained in:
@@ -157,7 +157,7 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
||||
* Scrub given IMSI on production builds.
|
||||
*/
|
||||
public static String scrubSubscriberId(String subscriberId) {
|
||||
if ("eng".equals(Build.TYPE)) {
|
||||
if (Build.IS_ENG) {
|
||||
return subscriberId;
|
||||
} else if (subscriberId != null) {
|
||||
// TODO: parse this as MCC+MNC instead of hard-coding
|
||||
|
||||
@@ -125,9 +125,6 @@ public final class StrictMode {
|
||||
private static final String TAG = "StrictMode";
|
||||
private static final boolean LOG_V = Log.isLoggable(TAG, Log.VERBOSE);
|
||||
|
||||
private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
|
||||
private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);
|
||||
|
||||
/**
|
||||
* Boolean system property to disable strict mode checks outright.
|
||||
* Set this to 'true' to force disable; 'false' has no effect on other
|
||||
@@ -1191,7 +1188,7 @@ public final class StrictMode {
|
||||
|
||||
// For debug builds, log event loop stalls to dropbox for analysis.
|
||||
// Similar logic also appears in ActivityThread.java for system apps.
|
||||
if (!doFlashes && (IS_USER_BUILD || suppress)) {
|
||||
if (!doFlashes && (Build.IS_USER || suppress)) {
|
||||
setCloseGuardEnabled(false);
|
||||
return false;
|
||||
}
|
||||
@@ -1199,7 +1196,7 @@ public final class StrictMode {
|
||||
// Eng builds have flashes on all the time. The suppression property
|
||||
// overrides this, so we force the behavior only after the short-circuit
|
||||
// check above.
|
||||
if (IS_ENG_BUILD) {
|
||||
if (Build.IS_ENG) {
|
||||
doFlashes = true;
|
||||
}
|
||||
|
||||
@@ -1208,7 +1205,7 @@ public final class StrictMode {
|
||||
StrictMode.DETECT_DISK_READ |
|
||||
StrictMode.DETECT_NETWORK;
|
||||
|
||||
if (!IS_USER_BUILD) {
|
||||
if (!Build.IS_USER) {
|
||||
threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
|
||||
}
|
||||
if (doFlashes) {
|
||||
@@ -1219,23 +1216,25 @@ public final class StrictMode {
|
||||
|
||||
// VM Policy controls CloseGuard, detection of Activity leaks,
|
||||
// and instance counting.
|
||||
if (IS_USER_BUILD) {
|
||||
if (Build.IS_USER) {
|
||||
setCloseGuardEnabled(false);
|
||||
} else {
|
||||
VmPolicy.Builder policyBuilder = new VmPolicy.Builder().detectAll();
|
||||
if (!IS_ENG_BUILD) {
|
||||
if (!Build.IS_ENG) {
|
||||
// Activity leak detection causes too much slowdown for userdebug because of the
|
||||
// GCs.
|
||||
policyBuilder = policyBuilder.disable(DETECT_VM_ACTIVITY_LEAKS);
|
||||
}
|
||||
policyBuilder = policyBuilder.penaltyDropBox();
|
||||
if (IS_ENG_BUILD) {
|
||||
if (Build.IS_ENG) {
|
||||
policyBuilder.penaltyLog();
|
||||
}
|
||||
// All core system components need to tag their sockets to aid
|
||||
// system health investigations
|
||||
if (android.os.Process.myUid() < android.os.Process.FIRST_APPLICATION_UID) {
|
||||
policyBuilder.detectUntaggedSockets();
|
||||
policyBuilder.enable(DETECT_VM_UNTAGGED_SOCKET);
|
||||
} else {
|
||||
policyBuilder.disable(DETECT_VM_UNTAGGED_SOCKET);
|
||||
}
|
||||
setVmPolicy(policyBuilder.build());
|
||||
setCloseGuardEnabled(vmClosableObjectLeaksEnabled());
|
||||
@@ -2294,7 +2293,7 @@ public final class StrictMode {
|
||||
* @hide
|
||||
*/
|
||||
public static Span enterCriticalSpan(String name) {
|
||||
if (IS_USER_BUILD) {
|
||||
if (Build.IS_USER) {
|
||||
return NO_OP_SPAN;
|
||||
}
|
||||
if (name == null || name.isEmpty()) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Deque;
|
||||
*/
|
||||
public class BootTimingsTraceLog {
|
||||
// Debug boot time for every step if it's non-user build.
|
||||
private static final boolean DEBUG_BOOT_TIME = !"user".equals(Build.TYPE);
|
||||
private static final boolean DEBUG_BOOT_TIME = !Build.IS_USER;
|
||||
private final Deque<Pair<String, Long>> mStartTimes
|
||||
= DEBUG_BOOT_TIME ? new ArrayDeque<>() : null;
|
||||
private final String mTag;
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.util.Log;
|
||||
* @hide
|
||||
*/
|
||||
public final class InputEventConsistencyVerifier {
|
||||
private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);
|
||||
private static final boolean IS_ENG_BUILD = Build.IS_ENG;
|
||||
|
||||
private static final String EVENT_TYPE_KEY = "KeyEvent";
|
||||
private static final String EVENT_TYPE_TRACKBALL = "TrackballEvent";
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class AccessibilityCache {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static final boolean CHECK_INTEGRITY = "eng".equals(Build.TYPE);
|
||||
private static final boolean CHECK_INTEGRITY = Build.IS_ENG;
|
||||
|
||||
/**
|
||||
* {@link AccessibilityEvent} types that are critical for the cache to stay up to date
|
||||
|
||||
@@ -646,7 +646,7 @@ public class SparseMappingTable {
|
||||
*/
|
||||
private static void logOrThrow(String message, Throwable th) {
|
||||
Slog.e(TAG, message, th);
|
||||
if (Build.TYPE.equals("eng")) {
|
||||
if (Build.IS_ENG) {
|
||||
throw new RuntimeException(message, th);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.concurrent.TimeoutException;
|
||||
|
||||
final class RemoteIntArray implements ServiceConnection, Closeable {
|
||||
private static final long BIND_REMOTE_SERVICE_TIMEOUT =
|
||||
("eng".equals(Build.TYPE)) ? 120000 : 10000;
|
||||
Build.IS_ENG ? 120000 : 10000;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class BugreportWarningActivity extends AlertActivity
|
||||
|
||||
final int state = getWarningState(this, STATE_UNKNOWN);
|
||||
final boolean checked;
|
||||
if (Build.TYPE.equals("user")) {
|
||||
if (Build.IS_USER) {
|
||||
checked = state == STATE_HIDE; // Only checks if specifically set to.
|
||||
} else {
|
||||
checked = state != STATE_SHOW; // Checks by default.
|
||||
|
||||
@@ -577,7 +577,7 @@ public class BugreportReceiverTest {
|
||||
mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm_dont_repeat));
|
||||
final boolean firstTime = propertyState == null || propertyState == STATE_UNKNOWN;
|
||||
if (firstTime) {
|
||||
if (Build.TYPE.equals("user")) {
|
||||
if (Build.IS_USER) {
|
||||
assertFalse("Checkbox should NOT be checked by default on user builds",
|
||||
dontShowAgain.isChecked());
|
||||
mUiBot.click(dontShowAgain, "dont-show-again");
|
||||
|
||||
@@ -207,7 +207,7 @@ public class Recents extends SystemUI
|
||||
mImpl = new RecentsImpl(mContext);
|
||||
|
||||
// Check if there is a recents override package
|
||||
if ("userdebug".equals(Build.TYPE) || "eng".equals(Build.TYPE)) {
|
||||
if (Build.IS_USERDEBUG || Build.IS_ENG) {
|
||||
String cnStr = SystemProperties.get(RECENTS_OVERRIDE_SYSPROP_KEY);
|
||||
if (!cnStr.isEmpty()) {
|
||||
mOverrideRecentsPackageName = cnStr;
|
||||
|
||||
@@ -507,8 +507,6 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
|
||||
static final String SYSTEM_DEBUGGABLE = "ro.debuggable";
|
||||
|
||||
static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
|
||||
|
||||
// Amount of time after a call to stopAppSwitches() during which we will
|
||||
// prevent further untrusted switches from happening.
|
||||
static final long APP_SWITCH_DELAY_TIME = 5*1000;
|
||||
@@ -5730,7 +5728,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
final void logAppTooSlow(ProcessRecord app, long startTime, String msg) {
|
||||
if (true || IS_USER_BUILD) {
|
||||
if (true || Build.IS_USER) {
|
||||
return;
|
||||
}
|
||||
String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
|
||||
@@ -14540,7 +14538,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
final ProcessRecord r = handleApplicationWtfInner(callingUid, callingPid, app, tag,
|
||||
crashInfo);
|
||||
|
||||
final boolean isFatal = "eng".equals(Build.TYPE) || Settings.Global
|
||||
final boolean isFatal = Build.IS_ENG || Settings.Global
|
||||
.getInt(mContext.getContentResolver(), Settings.Global.WTF_IS_FATAL, 0) != 0;
|
||||
final boolean isSystem = (r == null) || r.persistent;
|
||||
|
||||
@@ -20587,7 +20585,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
&& config.navigation == Configuration.NAVIGATION_NONAV);
|
||||
int modeType = config.uiMode & Configuration.UI_MODE_TYPE_MASK;
|
||||
final boolean uiModeSupportsDialogs = (modeType != Configuration.UI_MODE_TYPE_CAR
|
||||
&& !(modeType == Configuration.UI_MODE_TYPE_WATCH && "user".equals(Build.TYPE))
|
||||
&& !(modeType == Configuration.UI_MODE_TYPE_WATCH && Build.IS_USER)
|
||||
&& modeType != Configuration.UI_MODE_TYPE_TELEVISION
|
||||
&& modeType != Configuration.UI_MODE_TYPE_VR_HEADSET);
|
||||
return inputMethodExists && uiModeSupportsDialogs;
|
||||
|
||||
@@ -91,7 +91,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_THUMBNAIL
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILITY;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
|
||||
import static com.android.server.am.ActivityManagerService.IS_USER_BUILD;
|
||||
import static com.android.server.am.ActivityManagerService.TAKE_FULLSCREEN_SCREENSHOTS;
|
||||
import static com.android.server.am.ActivityStack.ActivityState.DESTROYED;
|
||||
import static com.android.server.am.ActivityStack.ActivityState.DESTROYING;
|
||||
@@ -1801,7 +1800,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
|
||||
}
|
||||
|
||||
void startLaunchTickingLocked() {
|
||||
if (IS_USER_BUILD) {
|
||||
if (Build.IS_USER) {
|
||||
return;
|
||||
}
|
||||
if (launchTickTime == 0) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -32,8 +33,6 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import static com.android.server.am.ActivityManagerService.IS_USER_BUILD;
|
||||
|
||||
final class AppErrorDialog extends BaseErrorDialog implements View.OnClickListener {
|
||||
|
||||
private final ActivityManagerService mService;
|
||||
@@ -124,7 +123,7 @@ final class AppErrorDialog extends BaseErrorDialog implements View.OnClickListen
|
||||
close.setVisibility(!hasRestart ? View.VISIBLE : View.GONE);
|
||||
close.setOnClickListener(this);
|
||||
|
||||
boolean showMute = !IS_USER_BUILD && Settings.Global.getInt(context.getContentResolver(),
|
||||
boolean showMute = !Build.IS_USER && Settings.Global.getInt(context.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||
final TextView mute = findViewById(com.android.internal.R.id.aerr_mute);
|
||||
mute.setOnClickListener(this);
|
||||
|
||||
@@ -35,8 +35,6 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import static com.android.server.am.ActivityManagerService.IS_USER_BUILD;
|
||||
|
||||
final class AppNotRespondingDialog extends BaseErrorDialog implements View.OnClickListener {
|
||||
private static final String TAG = "AppNotRespondingDialog";
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ final class HdmiLogger {
|
||||
private static final long ERROR_LOG_DURATTION_MILLIS = 20 * 1000; // 20s
|
||||
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
|
||||
|
||||
private static final ThreadLocal<HdmiLogger> sLogger = new ThreadLocal<>();
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ final class EphemeralResolverConnection implements DeathRecipient {
|
||||
private static final String TAG = "PackageManager";
|
||||
// This is running in a critical section and the timeout must be sufficiently low
|
||||
private static final long BIND_SERVICE_TIMEOUT_MS =
|
||||
("eng".equals(Build.TYPE)) ? 500 : 300;
|
||||
Build.IS_ENG ? 500 : 300;
|
||||
private static final long CALL_SERVICE_TIMEOUT_MS =
|
||||
("eng".equals(Build.TYPE)) ? 200 : 100;
|
||||
Build.IS_ENG ? 200 : 100;
|
||||
private static final boolean DEBUG_EPHEMERAL = Build.IS_DEBUGGABLE;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
@@ -3050,7 +3050,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
|
||||
// Disable package parsing on eng builds to allow for faster incremental development.
|
||||
if ("eng".equals(Build.TYPE)) {
|
||||
if (Build.IS_ENG) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3085,7 +3085,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// NOTE: When no BUILD_NUMBER is set by the build system, it defaults to a build
|
||||
// that starts with "eng." to signify that this is an engineering build and not
|
||||
// destined for release.
|
||||
if ("userdebug".equals(Build.TYPE) && Build.VERSION.INCREMENTAL.startsWith("eng.")) {
|
||||
if (Build.IS_USERDEBUG && Build.VERSION.INCREMENTAL.startsWith("eng.")) {
|
||||
Slog.w(TAG, "Wiping cache directory because the system partition changed.");
|
||||
|
||||
// Heuristic: If the /system directory has been modified recently due to an "adb sync"
|
||||
@@ -5533,7 +5533,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
if (eventIdIndex == -1) {
|
||||
if (AppOpsManager.permissionToOpCode(name) == AppOpsManager.OP_NONE
|
||||
|| "user".equals(Build.TYPE)) {
|
||||
|| Build.IS_USER) {
|
||||
Log.i(TAG, "Unknown permission " + name);
|
||||
|
||||
return MetricsEvent.ACTION_PERMISSION_REQUEST_UNKNOWN;
|
||||
|
||||
@@ -72,7 +72,7 @@ final class RemotePrintSpooler {
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static final long BIND_SPOOLER_SERVICE_TIMEOUT =
|
||||
("eng".equals(Build.TYPE)) ? 120000 : 10000;
|
||||
(Build.IS_ENG) ? 120000 : 10000;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Log {
|
||||
public static boolean ERROR = isLoggable(android.util.Log.ERROR);
|
||||
|
||||
private static final boolean FORCE_LOGGING = false; /* STOP SHIP if true */
|
||||
private static final boolean USER_BUILD = Build.TYPE.equals("user");
|
||||
private static final boolean USER_BUILD = Build.IS_USER;
|
||||
|
||||
// Used to synchronize singleton logging lazy initialization
|
||||
private static final Object sSingletonSync = new Object();
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
*/
|
||||
public final class Rlog {
|
||||
|
||||
private static final boolean USER_BUILD = Build.TYPE.equals("user");
|
||||
private static final boolean USER_BUILD = Build.IS_USER;
|
||||
|
||||
private Rlog() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user