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

Commit 34b064a1 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Clean up TypedArray docs & formatting, remove coercion warnings"

parents 349c504c 6bbb47b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -22548,6 +22548,7 @@ package android.os {
    method public android.os.StrictMode.ThreadPolicy.Builder detectDiskReads();
    method public android.os.StrictMode.ThreadPolicy.Builder detectDiskReads();
    method public android.os.StrictMode.ThreadPolicy.Builder detectDiskWrites();
    method public android.os.StrictMode.ThreadPolicy.Builder detectDiskWrites();
    method public android.os.StrictMode.ThreadPolicy.Builder detectNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder detectNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder detectResourceMismatches();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDeath();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDeath();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDeathOnNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDeathOnNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDialog();
    method public android.os.StrictMode.ThreadPolicy.Builder penaltyDialog();
@@ -22559,6 +22560,7 @@ package android.os {
    method public android.os.StrictMode.ThreadPolicy.Builder permitDiskReads();
    method public android.os.StrictMode.ThreadPolicy.Builder permitDiskReads();
    method public android.os.StrictMode.ThreadPolicy.Builder permitDiskWrites();
    method public android.os.StrictMode.ThreadPolicy.Builder permitDiskWrites();
    method public android.os.StrictMode.ThreadPolicy.Builder permitNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder permitNetwork();
    method public android.os.StrictMode.ThreadPolicy.Builder permitResourceMismatches();
  }
  }
  public static final class StrictMode.VmPolicy {
  public static final class StrictMode.VmPolicy {
+2 −2
Original line number Original line Diff line number Diff line
@@ -2696,8 +2696,8 @@ public class Resources {


    private ColorStateList loadColorStateListForCookie(TypedValue value, int id, Theme theme) {
    private ColorStateList loadColorStateListForCookie(TypedValue value, int id, Theme theme) {
        if (value.string == null) {
        if (value.string == null) {
            throw new NotFoundException("Resource \"" + getResourceName(id) + "\" ("
            throw new UnsupportedOperationException(
                    + Integer.toHexString(id) + ") is not a ColorStateList: " + value);
                    "Can't convert to color state list: type=0x" + value.type);
        }
        }


        final String file = value.string.toString();
        final String file = value.string.toString();
+229 −101

File changed.

Preview size limit exceeded, changes collapsed.

+68 −1
Original line number Original line Diff line number Diff line
@@ -174,8 +174,16 @@ public final class StrictMode {
     */
     */
    public static final int DETECT_CUSTOM = 0x08;  // for ThreadPolicy
    public static final int DETECT_CUSTOM = 0x08;  // for ThreadPolicy


    /**
     * For StrictMode.noteResourceMismatch()
     *
     * @hide
     */
    public static final int DETECT_RESOURCE_MISMATCH = 0x10;  // for ThreadPolicy

    private static final int ALL_THREAD_DETECT_BITS =
    private static final int ALL_THREAD_DETECT_BITS =
            DETECT_DISK_WRITE | DETECT_DISK_READ | DETECT_NETWORK | DETECT_CUSTOM;
            DETECT_DISK_WRITE | DETECT_DISK_READ | DETECT_NETWORK | DETECT_CUSTOM |
            DETECT_RESOURCE_MISMATCH;


    // Process-policy:
    // Process-policy:


@@ -429,6 +437,22 @@ public final class StrictMode {
                return disable(DETECT_CUSTOM);
                return disable(DETECT_CUSTOM);
            }
            }


            /**
             * Disable detection of mismatches between defined resource types
             * and getter calls.
             */
            public Builder permitResourceMismatches() {
                return disable(DETECT_RESOURCE_MISMATCH);
            }

            /**
             * Enable detection of mismatches between defined resource types
             * and getter calls.
             */
            public Builder detectResourceMismatches() {
                return enable(DETECT_RESOURCE_MISMATCH);
            }

            /**
            /**
             * Enable detection of disk writes.
             * Enable detection of disk writes.
             */
             */
@@ -850,6 +874,15 @@ public final class StrictMode {
        }
        }
    }
    }


    /**
     * @hide
     */
    private static class StrictModeResourceMismatchViolation extends StrictModeViolation {
        public StrictModeResourceMismatchViolation(int policyMask, Object tag) {
            super(policyMask, DETECT_RESOURCE_MISMATCH, tag != null ? tag.toString() : null);
        }
    }

    /**
    /**
     * Returns the bitmask of the current thread's policy.
     * Returns the bitmask of the current thread's policy.
     *
     *
@@ -1125,6 +1158,20 @@ public final class StrictMode {
            startHandlingViolationException(e);
            startHandlingViolationException(e);
        }
        }


        // Not part of BlockGuard.Policy; just part of StrictMode:
        void onResourceMismatch(Object tag) {
            if ((mPolicyMask & DETECT_RESOURCE_MISMATCH) == 0) {
                return;
            }
            if (tooManyViolationsThisLoop()) {
                return;
            }
            BlockGuard.BlockGuardPolicyException e =
                    new StrictModeResourceMismatchViolation(mPolicyMask, tag);
            e.fillInStackTrace();
            startHandlingViolationException(e);
        }

        // Part of BlockGuard.Policy interface:
        // Part of BlockGuard.Policy interface:
        public void onReadFromDisk() {
        public void onReadFromDisk() {
            if ((mPolicyMask & DETECT_DISK_READ) == 0) {
            if ((mPolicyMask & DETECT_DISK_READ) == 0) {
@@ -1942,6 +1989,26 @@ public final class StrictMode {
        ((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name);
        ((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name);
    }
    }


    /**
     * For code to note that a resource was obtained using a type other than
     * its defined type. This is a no-op unless the current thread's
     * {@link android.os.StrictMode.ThreadPolicy} has
     * {@link android.os.StrictMode.ThreadPolicy.Builder#detectResourceMismatches()}
     * enabled.
     *
     * @param tag an object for the exception stack trace that's
     *            built if when this fires.
     * @hide
     */
    public static void noteResourceMismatch(Object tag) {
        BlockGuard.Policy policy = BlockGuard.getThreadPolicy();
        if (!(policy instanceof AndroidBlockGuardPolicy)) {
            // StrictMode not enabled.
            return;
        }
        ((AndroidBlockGuardPolicy) policy).onResourceMismatch(tag);
    }

    /**
    /**
     * @hide
     * @hide
     */
     */