Avoid a few crashes around unmounting.
Also refresh UI when metadata changes. Bug: 19993667 Change-Id: Ib0ea9be68a3db5c71d15fae6809f31df43fd9af0
This commit is contained in:
@@ -122,6 +122,18 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
screen.addPreference(mGraph);
|
||||
screen.addPreference(mTotal);
|
||||
screen.addPreference(mAvailable);
|
||||
|
||||
final File file = mVolume.getPath();
|
||||
mTotalSize = file.getTotalSpace();
|
||||
mAvailSize = file.getFreeSpace();
|
||||
|
||||
mTotal.setSummary(Formatter.formatFileSize(context, mTotalSize));
|
||||
mAvailable.setSummary(Formatter.formatFileSize(context, mAvailSize));
|
||||
|
||||
mGraph.clear();
|
||||
mGraph.addEntry(0, (mTotalSize - mAvailSize) / (float) mTotalSize,
|
||||
android.graphics.Color.GRAY);
|
||||
mGraph.commit();
|
||||
}
|
||||
|
||||
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
|
||||
@@ -134,18 +146,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
if (mDisk.isAdoptable()) {
|
||||
screen.addPreference(mFormatInternal);
|
||||
}
|
||||
|
||||
final File file = mVolume.getPath();
|
||||
mTotalSize = file.getTotalSpace();
|
||||
mAvailSize = file.getFreeSpace();
|
||||
|
||||
mTotal.setSummary(Formatter.formatFileSize(context, mTotalSize));
|
||||
mAvailable.setSummary(Formatter.formatFileSize(context, mAvailSize));
|
||||
|
||||
mGraph.clear();
|
||||
mGraph.addEntry(0, (mTotalSize - mAvailSize) / (float) mTotalSize,
|
||||
android.graphics.Color.GRAY);
|
||||
mGraph.commit();
|
||||
}
|
||||
|
||||
private UsageBarPreference buildGraph() {
|
||||
@@ -215,5 +215,13 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVolumeMetadataChanged(VolumeInfo vol) {
|
||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||
mVolume = vol;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user