From d2905dd0868983ec293c50506a3af64f3ad91c99 Mon Sep 17 00:00:00 2001 From: Youkichi Hosoi Date: Wed, 8 Jul 2020 03:27:01 +0900 Subject: [PATCH] Add MOUNT_FLAG_VISIBLE to visible stub volumes The visibility setting of a removable device shared with Chrome OS is passed via Disk flags. When a device (stub volume) is marked as visible, we should set the MOUNT_FLAG_VISIBLE flag to it. Bug: 123377807 Bug: 142684891 Bug: 132796154 Test: Toggle the visibility setting of a removable device in the Chrome Test: OS Settings app > Confirm that the device is visible to Android Test: apps only when it is marked as visible. Test: Tested in R Change-Id: I19289596345690b1802738122fe274eeb41f9361 --- core/java/android/os/storage/DiskInfo.java | 6 ++++++ .../core/java/com/android/server/StorageManagerService.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/core/java/android/os/storage/DiskInfo.java b/core/java/android/os/storage/DiskInfo.java index df3c4d55d9797..51856d8bb723d 100644 --- a/core/java/android/os/storage/DiskInfo.java +++ b/core/java/android/os/storage/DiskInfo.java @@ -50,6 +50,8 @@ public class DiskInfo implements Parcelable { public static final int FLAG_DEFAULT_PRIMARY = 1 << 1; public static final int FLAG_SD = 1 << 2; public static final int FLAG_USB = 1 << 3; + /** The FLAG_STUB_VISIBLE is set from vold, which gets the flag from outside (e.g., ChromeOS) */ + public static final int FLAG_STUB_VISIBLE = 1 << 6; public final String id; @UnsupportedAppUsage @@ -152,6 +154,10 @@ public class DiskInfo implements Parcelable { return (flags & FLAG_USB) != 0; } + public boolean isStubVisible() { + return (flags & FLAG_STUB_VISIBLE) != 0; + } + @Override public String toString() { final CharArrayWriter writer = new CharArrayWriter(); diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index dd497a656fae8..8c67c1f3dc6ea 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -1537,6 +1537,9 @@ class StorageManagerService extends IStorageManager.Stub mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget(); } else if (vol.type == VolumeInfo.TYPE_STUB) { + if (vol.disk.isStubVisible()) { + vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE; + } vol.mountUserId = mCurrentUserId; mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget(); } else {