Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ac2a434 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Give StrictMode more bits to work with.

We're almost out of bits, and we don't really need to smash both
thread and VM policy into the same 32-bit value, so use the lower
16-bits for each policy type and the upper 16-bits for penalty.

ActivityManager is only consulting the penalty bits, so we can
remove getViolationBit() and switch CTS over to doing instanceof
checks.

Bug: 110413274
Test: atest cts/tests/tests/os/src/android/os/cts/StrictModeTest.java
Change-Id: I760e6a28f56da66dc75b7df9daf2167ff5bdff50
parent c59a5e7e
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -683,23 +683,6 @@ package android.os {

  public final class StrictMode {
    method public static void setViolationLogger(android.os.StrictMode.ViolationLogger);
    field public static final int DETECT_CUSTOM = 8; // 0x8
    field public static final int DETECT_DISK_READ = 2; // 0x2
    field public static final int DETECT_DISK_WRITE = 1; // 0x1
    field public static final int DETECT_NETWORK = 4; // 0x4
    field public static final int DETECT_RESOURCE_MISMATCH = 16; // 0x10
    field public static final int DETECT_UNBUFFERED_IO = 32; // 0x20
    field public static final int DETECT_VM_ACTIVITY_LEAKS = 1024; // 0x400
    field public static final int DETECT_VM_CLEARTEXT_NETWORK = 16384; // 0x4000
    field public static final int DETECT_VM_CLOSABLE_LEAKS = 512; // 0x200
    field public static final int DETECT_VM_CONTENT_URI_WITHOUT_PERMISSION = 32768; // 0x8000
    field public static final int DETECT_VM_CURSOR_LEAKS = 256; // 0x100
    field public static final int DETECT_VM_FILE_URI_EXPOSURE = 8192; // 0x2000
    field public static final int DETECT_VM_IMPLICIT_DIRECT_BOOT = 536870912; // 0x20000000
    field public static final int DETECT_VM_INSTANCE_LEAKS = 2048; // 0x800
    field public static final int DETECT_VM_NON_SDK_API_USAGE = 1073741824; // 0x40000000
    field public static final int DETECT_VM_REGISTRATION_LEAKS = 4096; // 0x1000
    field public static final int DETECT_VM_UNTAGGED_SOCKET = -2147483648; // 0x80000000
  }

  public static final class StrictMode.ViolationInfo implements android.os.Parcelable {
@@ -707,9 +690,8 @@ package android.os {
    ctor public StrictMode.ViolationInfo(android.os.Parcel, boolean);
    method public int describeContents();
    method public void dump(android.util.Printer, java.lang.String);
    method public int getPolicyMask();
    method public java.lang.String getStackTrace();
    method public int getViolationBit();
    method public java.lang.Class<? extends android.os.strictmode.Violation> getViolationClass();
    method public java.lang.String getViolationDetails();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.os.StrictMode.ViolationInfo> CREATOR;
+2 −5
Original line number Diff line number Diff line
@@ -237,11 +237,8 @@ interface IActivityManager {
    // running.
    List<ApplicationInfo> getRunningExternalApplications();
    void finishHeavyWeightApp();
    // A StrictMode violation to be handled.  The violationMask is a
    // subset of the original StrictMode policy bitmask, with only the
    // bit violated and penalty bits to be executed by the
    // ActivityManagerService remaining set.
    void handleApplicationStrictModeViolation(in IBinder app, int violationMask,
    // A StrictMode violation to be handled.
    void handleApplicationStrictModeViolation(in IBinder app, int penaltyMask,
            in StrictMode.ViolationInfo crashInfo);
    boolean isTopActivityImmersive();
    void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message);
+212 −319

File changed.

Preview size limit exceeded, changes collapsed.

+3 −4
Original line number Diff line number Diff line
@@ -12042,13 +12042,13 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void handleApplicationStrictModeViolation(
            IBinder app,
            int violationMask,
            int penaltyMask,
            StrictMode.ViolationInfo info) {
        // We're okay if the ProcessRecord is missing; it probably means that
        // we're reporting a violation from the system process itself.
        final ProcessRecord r = findAppProcess(app, "StrictMode");
        if ((violationMask & StrictMode.PENALTY_DROPBOX) != 0) {
        if ((penaltyMask & StrictMode.PENALTY_DROPBOX) != 0) {
            Integer stackFingerprint = info.hashCode();
            boolean logIt = true;
            synchronized (mAlreadyLoggedViolatedStacks) {
@@ -12072,7 +12072,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if ((violationMask & StrictMode.PENALTY_DIALOG) != 0) {
        if ((penaltyMask & StrictMode.PENALTY_DIALOG) != 0) {
            AppErrorResult result = new AppErrorResult();
            synchronized (this) {
                final long origId = Binder.clearCallingIdentity();
@@ -12082,7 +12082,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                HashMap<String, Object> data = new HashMap<String, Object>();
                data.put("result", result);
                data.put("app", r);
                data.put("violationMask", violationMask);
                data.put("info", info);
                msg.obj = data;
                mUiHandler.sendMessage(msg);