Merge "Gracefully handle the case where private volume may be unmountable" into qt-dev

This commit is contained in:
Fan Zhang
2019-04-10 19:29:58 +00:00
committed by Android (Google) Code Review

View File

@@ -150,8 +150,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
mInternalCategory.addPreference(mInternalSummary); mInternalCategory.addPreference(mInternalSummary);
int privateCount = 0;
final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(mStorageManager); final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(mStorageManager);
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(smvp); final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(smvp);
final long privateTotalBytes = info.totalBytes; final long privateTotalBytes = info.totalBytes;
@@ -162,10 +160,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
for (VolumeInfo vol : volumes) { for (VolumeInfo vol : volumes) {
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) { if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
sTotalInternalStorage); if (vol.getState() == VolumeInfo.STATE_UNMOUNTABLE) {
mInternalCategory.addPreference( mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, volumeTotalBytes)); new StorageVolumePreference(context, vol, 0));
} else {
final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
sTotalInternalStorage);
mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, volumeTotalBytes));
}
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC
|| vol.getType() == VolumeInfo.TYPE_STUB) { || vol.getType() == VolumeInfo.TYPE_STUB) {
mExternalCategory.addPreference( mExternalCategory.addPreference(