summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2019-04-28 17:04:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-04-28 17:04:03 +0000
commit8eccead1be0aec61ea83b32ec180b72a286e1ae7 (patch)
tree6ab2a6e8006bbf3f20db6a0b59d6936e4718b6c9
parent0107bbb1ef528a786dd92999a0d6d3daa1c6c4df (diff)
parente3644411a0ddb754bfba98c80f0b6c9505eb0283 (diff)
Merge "Avoid triggering StrictMode for storage notifs." into qt-dev
-rw-r--r--core/java/android/os/StrictMode.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java14
2 files changed, 14 insertions, 6 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 94cca30d9e6c..c707ba839336 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -1284,13 +1284,15 @@ public final class StrictMode {
return oldPolicyMask;
}
- private static ThreadPolicy allowThreadViolations() {
+ /** @hide */
+ public static ThreadPolicy allowThreadViolations() {
ThreadPolicy oldPolicy = getThreadPolicy();
setThreadPolicyMask(0);
return oldPolicy;
}
- private static VmPolicy allowVmViolations() {
+ /** @hide */
+ public static VmPolicy allowVmViolations() {
VmPolicy oldPolicy = getVmPolicy();
sVmPolicy = VmPolicy.LAX;
return oldPolicy;
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 329d02959435..de86f3d8cfb4 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -29,6 +29,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.MoveCallback;
import android.os.Bundle;
import android.os.Handler;
+import android.os.StrictMode;
import android.os.UserHandle;
import android.os.storage.DiskInfo;
import android.os.storage.StorageEventListener;
@@ -639,11 +640,16 @@ public class StorageNotification extends SystemUI {
}
private PendingIntent buildBrowsePendingIntent(VolumeInfo vol) {
- final Intent intent = vol.buildBrowseIntentForUser(vol.getMountUserId());
+ final StrictMode.VmPolicy oldPolicy = StrictMode.allowVmViolations();
+ try {
+ final Intent intent = vol.buildBrowseIntentForUser(vol.getMountUserId());
- final int requestKey = vol.getId().hashCode();
- return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
- PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
+ final int requestKey = vol.getId().hashCode();
+ return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
+ PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
+ } finally {
+ StrictMode.setVmPolicy(oldPolicy);
+ }
}
private PendingIntent buildVolumeSettingsPendingIntent(VolumeInfo vol) {