Loading api/current.xml +24 −2 Original line number Diff line number Diff line Loading @@ -136369,7 +136369,7 @@ deprecated="not deprecated" visibility="public" > <method name="getThreadBlockingPolicy" <method name="allowThreadDiskReads" return="int" abstract="false" native="false" Loading @@ -136380,7 +136380,29 @@ visibility="public" > </method> <method name="setThreadBlockingPolicy" <method name="allowThreadDiskWrites" return="int" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getThreadPolicy" return="int" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="setThreadPolicy" return="void" abstract="false" native="false" core/java/android/app/ActivityThread.java +1 −1 Original line number Diff line number Diff line Loading @@ -3151,7 +3151,7 @@ public final class ActivityThread { (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0 && !"user".equals(Build.TYPE)) { StrictMode.setThreadBlockingPolicy( StrictMode.setThreadPolicy( StrictMode.DISALLOW_DISK_WRITE | StrictMode.DISALLOW_DISK_READ | StrictMode.DISALLOW_NETWORK | Loading core/java/android/os/StrictMode.java +38 −6 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public final class StrictMode { * * @param policyMask a bitmask of DISALLOW_* and PENALTY_* values. */ public static void setThreadBlockingPolicy(final int policyMask) { public static void setThreadPolicy(final int policyMask) { // In addition to the Java-level thread-local in Dalvik's // BlockGuard, we also need to keep a native thread-local in // Binder in order to propagate the value across Binder calls, Loading Loading @@ -164,10 +164,42 @@ public final class StrictMode { * * @return the bitmask of all the DISALLOW_* and PENALTY_* bits currently enabled */ public static int getThreadBlockingPolicy() { public static int getThreadPolicy() { return BlockGuard.getThreadPolicy().getPolicyMask(); } /** * Updates the current thread's policy mask to allow reading & * writing to disk. * * @return the old policy mask, to be passed to setThreadPolicy to * restore the policy. */ public static int allowThreadDiskWrites() { int oldPolicy = getThreadPolicy(); int newPolicy = oldPolicy & ~(DISALLOW_DISK_WRITE | DISALLOW_DISK_READ); if (newPolicy != oldPolicy) { setThreadPolicy(newPolicy); } return oldPolicy; } /** * Updates the current thread's policy mask to allow reading from * disk. * * @return the old policy mask, to be passed to setThreadPolicy to * restore the policy. */ public static int allowThreadDiskReads() { int oldPolicy = getThreadPolicy(); int newPolicy = oldPolicy & ~(DISALLOW_DISK_READ); if (newPolicy != oldPolicy) { setThreadPolicy(newPolicy); } return oldPolicy; } /** * Parses the BlockGuard policy mask out from the Exception's * getMessage() String value. Kinda gross, but least Loading Loading @@ -413,13 +445,13 @@ public final class StrictMode { if (violationMaskSubset != 0) { int violationBit = parseViolationFromMessage(info.crashInfo.exceptionMessage); violationMaskSubset |= violationBit; final int savedPolicy = getThreadBlockingPolicy(); final int savedPolicy = getThreadPolicy(); try { // First, remove any policy before we call into the Activity Manager, // otherwise we'll infinite recurse as we try to log policy violations // to disk, thus violating policy, thus requiring logging, etc... // We restore the current policy below, in the finally block. setThreadBlockingPolicy(0); setThreadPolicy(0); ActivityManagerNative.getDefault().handleApplicationStrictModeViolation( RuntimeInit.getApplicationObject(), Loading @@ -429,7 +461,7 @@ public final class StrictMode { Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); } finally { // Restore the policy. setThreadBlockingPolicy(savedPolicy); setThreadPolicy(savedPolicy); } } Loading Loading @@ -487,7 +519,7 @@ public final class StrictMode { new LogStackTrace().printStackTrace(new PrintWriter(sw)); String ourStack = sw.toString(); int policyMask = getThreadBlockingPolicy(); int policyMask = getThreadPolicy(); boolean currentlyGathering = (policyMask & PENALTY_GATHER) != 0; int numViolations = p.readInt(); Loading Loading
api/current.xml +24 −2 Original line number Diff line number Diff line Loading @@ -136369,7 +136369,7 @@ deprecated="not deprecated" visibility="public" > <method name="getThreadBlockingPolicy" <method name="allowThreadDiskReads" return="int" abstract="false" native="false" Loading @@ -136380,7 +136380,29 @@ visibility="public" > </method> <method name="setThreadBlockingPolicy" <method name="allowThreadDiskWrites" return="int" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getThreadPolicy" return="int" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="setThreadPolicy" return="void" abstract="false" native="false"
core/java/android/app/ActivityThread.java +1 −1 Original line number Diff line number Diff line Loading @@ -3151,7 +3151,7 @@ public final class ActivityThread { (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0 && !"user".equals(Build.TYPE)) { StrictMode.setThreadBlockingPolicy( StrictMode.setThreadPolicy( StrictMode.DISALLOW_DISK_WRITE | StrictMode.DISALLOW_DISK_READ | StrictMode.DISALLOW_NETWORK | Loading
core/java/android/os/StrictMode.java +38 −6 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public final class StrictMode { * * @param policyMask a bitmask of DISALLOW_* and PENALTY_* values. */ public static void setThreadBlockingPolicy(final int policyMask) { public static void setThreadPolicy(final int policyMask) { // In addition to the Java-level thread-local in Dalvik's // BlockGuard, we also need to keep a native thread-local in // Binder in order to propagate the value across Binder calls, Loading Loading @@ -164,10 +164,42 @@ public final class StrictMode { * * @return the bitmask of all the DISALLOW_* and PENALTY_* bits currently enabled */ public static int getThreadBlockingPolicy() { public static int getThreadPolicy() { return BlockGuard.getThreadPolicy().getPolicyMask(); } /** * Updates the current thread's policy mask to allow reading & * writing to disk. * * @return the old policy mask, to be passed to setThreadPolicy to * restore the policy. */ public static int allowThreadDiskWrites() { int oldPolicy = getThreadPolicy(); int newPolicy = oldPolicy & ~(DISALLOW_DISK_WRITE | DISALLOW_DISK_READ); if (newPolicy != oldPolicy) { setThreadPolicy(newPolicy); } return oldPolicy; } /** * Updates the current thread's policy mask to allow reading from * disk. * * @return the old policy mask, to be passed to setThreadPolicy to * restore the policy. */ public static int allowThreadDiskReads() { int oldPolicy = getThreadPolicy(); int newPolicy = oldPolicy & ~(DISALLOW_DISK_READ); if (newPolicy != oldPolicy) { setThreadPolicy(newPolicy); } return oldPolicy; } /** * Parses the BlockGuard policy mask out from the Exception's * getMessage() String value. Kinda gross, but least Loading Loading @@ -413,13 +445,13 @@ public final class StrictMode { if (violationMaskSubset != 0) { int violationBit = parseViolationFromMessage(info.crashInfo.exceptionMessage); violationMaskSubset |= violationBit; final int savedPolicy = getThreadBlockingPolicy(); final int savedPolicy = getThreadPolicy(); try { // First, remove any policy before we call into the Activity Manager, // otherwise we'll infinite recurse as we try to log policy violations // to disk, thus violating policy, thus requiring logging, etc... // We restore the current policy below, in the finally block. setThreadBlockingPolicy(0); setThreadPolicy(0); ActivityManagerNative.getDefault().handleApplicationStrictModeViolation( RuntimeInit.getApplicationObject(), Loading @@ -429,7 +461,7 @@ public final class StrictMode { Log.e(TAG, "RemoteException trying to handle StrictMode violation", e); } finally { // Restore the policy. setThreadBlockingPolicy(savedPolicy); setThreadPolicy(savedPolicy); } } Loading Loading @@ -487,7 +519,7 @@ public final class StrictMode { new LogStackTrace().printStackTrace(new PrintWriter(sw)); String ourStack = sw.toString(); int policyMask = getThreadBlockingPolicy(); int policyMask = getThreadPolicy(); boolean currentlyGathering = (policyMask & PENALTY_GATHER) != 0; int numViolations = p.readInt(); Loading