Merge "Settings: fix storage measurement for device without emulated sdcard"
This commit is contained in:
@@ -422,7 +422,7 @@ public class StorageMeasurement {
|
||||
}
|
||||
|
||||
// Measure misc files not counted under media
|
||||
if (mIsInternal || mIsPrimary) {
|
||||
if (measureMedia) {
|
||||
final File path = mIsInternal ? currentEnv.getExternalStorageDirectory()
|
||||
: mVolume.getPathFile();
|
||||
details.miscSize = measureMisc(imcs, path);
|
||||
|
@@ -194,8 +194,9 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory {
|
||||
}
|
||||
|
||||
final boolean isRemovable = mVolume != null ? mVolume.isRemovable() : false;
|
||||
// Always create the preference since many code rely on it existing
|
||||
mMountTogglePreference = new Preference(context);
|
||||
if (isRemovable) {
|
||||
mMountTogglePreference = new Preference(context);
|
||||
mMountTogglePreference.setTitle(R.string.sd_eject);
|
||||
mMountTogglePreference.setSummary(R.string.sd_eject_summary);
|
||||
addPreference(mMountTogglePreference);
|
||||
@@ -240,12 +241,12 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory {
|
||||
final String state = mStorageManager.getVolumeState(mVolume.getPath());
|
||||
|
||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
|
||||
mItemAvailable.setSummary(R.string.memory_available_read_only);
|
||||
mItemAvailable.setTitle(R.string.memory_available_read_only);
|
||||
if (mFormatPreference != null) {
|
||||
removePreference(mFormatPreference);
|
||||
}
|
||||
} else {
|
||||
mItemAvailable.setSummary(R.string.memory_available);
|
||||
mItemAvailable.setTitle(R.string.memory_available);
|
||||
}
|
||||
|
||||
if (Environment.MEDIA_MOUNTED.equals(state)
|
||||
@@ -310,7 +311,9 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory {
|
||||
private static long totalValues(HashMap<String, Long> map, String... keys) {
|
||||
long total = 0;
|
||||
for (String key : keys) {
|
||||
total += map.get(key);
|
||||
if (map.containsKey(key)) {
|
||||
total += map.get(key);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
Reference in New Issue
Block a user