OSDN Git Service

Build browse intents based on target user.
authorJeff Sharkey <jsharkey@android.com>
Tue, 22 May 2018 18:01:31 +0000 (12:01 -0600)
committerJeff Sharkey <jsharkey@android.com>
Tue, 22 May 2018 18:01:34 +0000 (12:01 -0600)
SystemUI runs under a single user (user 0), and needs to build
browse intents for secondary users.  To accommodate this, the safety
check recently added to buildBrowseIntent() needs to be relaxed
when building for a non-current user.

Bug: 79733193
Test: builds, boots
Change-Id: Icce014bf824d0a0ee15e3d84c34f1c2b73d213c1

core/java/android/os/storage/VolumeInfo.java
packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java

index 576ea52..8d4c3c3 100644 (file)
@@ -407,8 +407,12 @@ public class VolumeInfo implements Parcelable {
      * {@link #TYPE_EMULATED} or {@link #TYPE_PUBLIC}.
      */
     public @Nullable Intent buildBrowseIntent() {
+        return buildBrowseIntentForUser(UserHandle.myUserId());
+    }
+
+    public @Nullable Intent buildBrowseIntentForUser(int userId) {
         final Uri uri;
-        if (type == VolumeInfo.TYPE_PUBLIC && mountUserId == UserHandle.myUserId()) {
+        if (type == VolumeInfo.TYPE_PUBLIC && mountUserId == userId) {
             uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY, fsUuid);
         } else if (type == VolumeInfo.TYPE_EMULATED && isPrimary()) {
             uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY,
index d527465..2f8dfdc 100644 (file)
@@ -640,7 +640,7 @@ public class StorageNotification extends SystemUI {
     }
 
     private PendingIntent buildBrowsePendingIntent(VolumeInfo vol) {
-        final Intent intent = vol.buildBrowseIntent();
+        final Intent intent = vol.buildBrowseIntentForUser(vol.getMountUserId());
 
         final int requestKey = vol.getId().hashCode();
         return PendingIntent.getActivityAsUser(mContext, requestKey, intent,