Gracefully handle null volumes after forgetting.
If a user tells a device to forget a storage volume and then goes back to the PrivateVolumeForget activity from their Recents, it attempts to re-initialize itself with a volume that it forgot. And this makes Settings crash. By gracefully killing the activity when we try to open PrivateVolumeForget for a forgotten volume, we avoid this crash. Change-Id: Ib4e881c10f0c872ce6b268b16a573960230ef99b Fixes: 34856304 Test: Settings unit test
This commit is contained in:
@@ -53,8 +53,18 @@ public class PrivateVolumeForget extends SettingsPreferenceFragment {
|
||||
Bundle savedInstanceState) {
|
||||
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||
final String fsUuid = getArguments().getString(VolumeRecord.EXTRA_FS_UUID);
|
||||
// Passing null will crash the StorageManager, so let's early exit.
|
||||
if (fsUuid == null) {
|
||||
getActivity().finish();
|
||||
return null;
|
||||
}
|
||||
mRecord = storage.findRecordByUuid(fsUuid);
|
||||
|
||||
if (mRecord == null) {
|
||||
getActivity().finish();
|
||||
return null;
|
||||
}
|
||||
|
||||
final View view = inflater.inflate(R.layout.storage_internal_forget, container, false);
|
||||
final TextView body = (TextView) view.findViewById(R.id.body);
|
||||
final Button confirm = (Button) view.findViewById(R.id.confirm);
|
||||
|
Reference in New Issue
Block a user