Merge "Allow StubVolume to be browseable in Settings" am: 8f516adef7 am: e613923d66

am: 1670c69b7c

Change-Id: Id567d995f6f25a46225a2080609048051cca2337
This commit is contained in:
Risan
2018-11-13 12:13:14 -08:00
committed by android-build-merger
2 changed files with 27 additions and 1 deletions

View File

@@ -146,6 +146,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;
@@ -178,7 +179,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));
}
@@ -306,6 +308,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:")) {
@@ -329,6 +333,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();