Avoid a few crashes around unmounting.
Also refresh UI when metadata changes. Bug: 19993667 Change-Id: Ib0ea9be68a3db5c71d15fae6809f31df43fd9af0
This commit is contained in:
@@ -433,6 +433,14 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVolumeMetadataChanged(VolumeInfo vol) {
|
||||
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||
mVolume = vol;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -48,7 +48,7 @@ public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
|
||||
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||
final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||
mVolume = storage.findVolumeById(volumeId);
|
||||
mDisk = storage.findDiskById(mVolume.getId());
|
||||
mDisk = storage.findDiskById(mVolume.getDiskId());
|
||||
|
||||
final View view = inflater.inflate(R.layout.storage_internal_unmount, container, false);
|
||||
final TextView body = (TextView) view.findViewById(R.id.body);
|
||||
|
@@ -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