Merge changes Iba4e52c2,I81160755 into pi-dev

* changes:
  Public volumes only browsable by mounting user.
  Public volumes are only visible to mounted user.
This commit is contained in:
TreeHugger Robot
2018-03-27 20:28:31 +00:00
committed by Android (Google) Code Review

View File

@@ -269,22 +269,7 @@ public class VolumeInfo implements Parcelable {
return (mountFlags & MOUNT_FLAG_VISIBLE) != 0;
}
public boolean isVisibleForRead(int userId) {
if (type == TYPE_PUBLIC) {
if (isPrimary() && mountUserId != userId) {
// Primary physical is only visible to single user
return false;
} else {
return isVisible();
}
} else if (type == TYPE_EMULATED) {
return isVisible();
} else {
return false;
}
}
public boolean isVisibleForWrite(int userId) {
public boolean isVisibleForUser(int userId) {
if (type == TYPE_PUBLIC && mountUserId == userId) {
return isVisible();
} else if (type == TYPE_EMULATED) {
@@ -294,6 +279,14 @@ public class VolumeInfo implements Parcelable {
}
}
public boolean isVisibleForRead(int userId) {
return isVisibleForUser(userId);
}
public boolean isVisibleForWrite(int userId) {
return isVisibleForUser(userId);
}
public File getPath() {
return (path != null) ? new File(path) : null;
}
@@ -409,9 +402,9 @@ public class VolumeInfo implements Parcelable {
* Build an intent to browse the contents of this volume. Only valid for
* {@link #TYPE_EMULATED} or {@link #TYPE_PUBLIC}.
*/
public Intent buildBrowseIntent() {
public @Nullable Intent buildBrowseIntent() {
final Uri uri;
if (type == VolumeInfo.TYPE_PUBLIC) {
if (type == VolumeInfo.TYPE_PUBLIC && mountUserId == UserHandle.myUserId()) {
uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY, fsUuid);
} else if (type == VolumeInfo.TYPE_EMULATED && isPrimary()) {
uri = DocumentsContract.buildRootUri(DOCUMENT_AUTHORITY,