diff options
| author | 2023-12-14 21:29:33 +0000 | |
|---|---|---|
| committer | 2023-12-14 21:29:33 +0000 | |
| commit | b0e0c87d0a2208678e222e87cd11ca8f14affe04 (patch) | |
| tree | 5d37ec2bb09cc7929d539f82c279af64b36c099c | |
| parent | 490b996c590b28f5f149976758ca92509101f8de (diff) | |
| parent | 4569f000fb3955da083e6c0c864317c948b03d32 (diff) | |
Merge "StrictMode: fix race condition in onVmPolicyViolation" into main am: c49b89ef02 am: 4569f000fb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2796661
Change-Id: Iec58b5e013394ba4e39f925e8951aa41962e7f46
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | core/java/android/os/StrictMode.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java index d12e3b2431d5..4205b2c63563 100644 --- a/core/java/android/os/StrictMode.java +++ b/core/java/android/os/StrictMode.java @@ -2440,11 +2440,12 @@ public final class StrictMode { /** @hide */ public static void onVmPolicyViolation(Violation violation, boolean forceDeath) { - final boolean penaltyDropbox = (sVmPolicy.mask & PENALTY_DROPBOX) != 0; - final boolean penaltyDeath = ((sVmPolicy.mask & PENALTY_DEATH) != 0) || forceDeath; - final boolean penaltyLog = (sVmPolicy.mask & PENALTY_LOG) != 0; + final VmPolicy vmPolicy = getVmPolicy(); + final boolean penaltyDropbox = (vmPolicy.mask & PENALTY_DROPBOX) != 0; + final boolean penaltyDeath = ((vmPolicy.mask & PENALTY_DEATH) != 0) || forceDeath; + final boolean penaltyLog = (vmPolicy.mask & PENALTY_LOG) != 0; - final int penaltyMask = (sVmPolicy.mask & PENALTY_ALL); + final int penaltyMask = (vmPolicy.mask & PENALTY_ALL); final ViolationInfo info = new ViolationInfo(violation, penaltyMask); // Erase stuff not relevant for process-wide violations @@ -2497,10 +2498,10 @@ public final class StrictMode { // If penaltyDeath, we can't guarantee this callback finishes before the process dies for // all executors. penaltyDeath supersedes penaltyCallback. - if (sVmPolicy.mListener != null && sVmPolicy.mCallbackExecutor != null) { - final OnVmViolationListener listener = sVmPolicy.mListener; + if (vmPolicy.mListener != null && vmPolicy.mCallbackExecutor != null) { + final OnVmViolationListener listener = vmPolicy.mListener; try { - sVmPolicy.mCallbackExecutor.execute( + vmPolicy.mCallbackExecutor.execute( () -> { // Lift violated policy to prevent infinite recursion. VmPolicy oldPolicy = allowVmViolations(); |