Allow StubVolume to be browseable in Settings

Test: Unit test + manual test: Mount and unmount stubvolume in ARC++,
check settings show the device correctly and could browse it using
DocumentsUI.
Bug: 110380403

Change-Id: I96fc82e731225776ac7070ef035687f83da94245
This commit is contained in:
Risan
2018-10-29 08:59:06 +09:00
parent bd57f94a4c
commit 9deece9086
2 changed files with 27 additions and 1 deletions

View File

@@ -144,6 +144,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
switch (vol.getType()) {
case VolumeInfo.TYPE_PRIVATE:
case VolumeInfo.TYPE_PUBLIC:
case VolumeInfo.TYPE_STUB:
return true;
default:
return false;
@@ -176,7 +177,8 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, color, volumeTotalBytes));
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC
|| vol.getType() == VolumeInfo.TYPE_STUB) {
mExternalCategory.addPreference(
new StorageVolumePreference(context, vol, COLOR_PUBLIC, 0));
}
@@ -304,6 +306,8 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
return handlePublicVolumeClick(getContext(), vol);
} else if (vol.getType() == VolumeInfo.TYPE_STUB) {
return handleStubVolumeClick(getContext(), vol);
}
} else if (key.startsWith("disk:")) {
@@ -327,6 +331,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
return false;
}
@VisibleForTesting
static boolean handleStubVolumeClick(Context context, VolumeInfo vol) {
final Intent intent = vol.buildBrowseIntent();
if (vol.isMountedReadable() && intent != null) {
context.startActivity(intent);
return true;
}
return false;
}
@VisibleForTesting
static boolean handlePublicVolumeClick(Context context, VolumeInfo vol) {
final Intent intent = vol.buildBrowseIntent();