Skip to content

Commit

Permalink
Merge "Settings: fix storage measurement for device without emulated …
Browse files Browse the repository at this point in the history
…sdcard"
  • Loading branch information
jsharkey authored and diclusial committed Dec 2, 2012
1 parent 79bf08d commit 0f3aae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ private void measureExactStorage(IMediaContainerService imcs) {
}

// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ public void init() {
}

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);
Expand Down Expand Up @@ -240,12 +241,12 @@ private void updatePreferencesFromState() {
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)
Expand Down Expand Up @@ -310,7 +311,9 @@ public void updateApproximate(long totalSize, long availSize) {
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;
}
Expand Down

0 comments on commit 0f3aae1

Please sign in to comment.