Merge "Allow StubVolume to be browseable in Settings"
This commit is contained in:
@@ -144,6 +144,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
switch (vol.getType()) {
|
switch (vol.getType()) {
|
||||||
case VolumeInfo.TYPE_PRIVATE:
|
case VolumeInfo.TYPE_PRIVATE:
|
||||||
case VolumeInfo.TYPE_PUBLIC:
|
case VolumeInfo.TYPE_PUBLIC:
|
||||||
|
case VolumeInfo.TYPE_STUB:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -176,7 +177,8 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
|
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
|
||||||
mInternalCategory.addPreference(
|
mInternalCategory.addPreference(
|
||||||
new StorageVolumePreference(context, vol, color, volumeTotalBytes));
|
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(
|
mExternalCategory.addPreference(
|
||||||
new StorageVolumePreference(context, vol, COLOR_PUBLIC, 0));
|
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) {
|
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
|
||||||
return handlePublicVolumeClick(getContext(), vol);
|
return handlePublicVolumeClick(getContext(), vol);
|
||||||
|
} else if (vol.getType() == VolumeInfo.TYPE_STUB) {
|
||||||
|
return handleStubVolumeClick(getContext(), vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (key.startsWith("disk:")) {
|
} else if (key.startsWith("disk:")) {
|
||||||
@@ -327,6 +331,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
return false;
|
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
|
@VisibleForTesting
|
||||||
static boolean handlePublicVolumeClick(Context context, VolumeInfo vol) {
|
static boolean handlePublicVolumeClick(Context context, VolumeInfo vol) {
|
||||||
final Intent intent = vol.buildBrowseIntent();
|
final Intent intent = vol.buildBrowseIntent();
|
||||||
|
@@ -102,4 +102,16 @@ public class StorageSettingsTest {
|
|||||||
verify(mActivity, never()).startActivity(null);
|
verify(mActivity, never()).startActivity(null);
|
||||||
verify(mActivity).startActivity(any(Intent.class));
|
verify(mActivity).startActivity(any(Intent.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void handleStubVolumeClick_startsANonNullActivityWhenVolumeHasNoBrowse() {
|
||||||
|
VolumeInfo volumeInfo = mock(VolumeInfo.class, RETURNS_DEEP_STUBS);
|
||||||
|
when(volumeInfo.isMountedReadable()).thenReturn(true);
|
||||||
|
|
||||||
|
StorageSettings.handleStubVolumeClick(mActivity, volumeInfo);
|
||||||
|
|
||||||
|
verify(mActivity, never()).startActivity(null);
|
||||||
|
verify(mActivity).startActivity(any(Intent.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user