Don't crash on opening ejecting USB.
This crash occurs because, even if you finish an Activity during onCreate, the other lifecycle methods occur. In this case, onActivityCreated assumes that onCreate ran properly. By exiting early from onActivityCreated, we can ensure the activity is finished properly. Change-Id: Ia354341bf82d295c7dd042668fb11d588ddfebc0 Fixes: 37334861 Test: Instrumentation test
This commit is contained in:
@@ -98,7 +98,9 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
mVolume = mStorageManager.findVolumeByUuid(fsUuid);
|
||||
} else {
|
||||
final String volId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||
mVolume = mStorageManager.findVolumeById(volId);
|
||||
if (volId != null) {
|
||||
mVolume = mStorageManager.findVolumeById(volId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isVolumeValid()) {
|
||||
@@ -129,6 +131,12 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
// If the volume isn't valid, we are not scaffolded to set up a view.
|
||||
if (!isVolumeValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Resources resources = getResources();
|
||||
final int padding = resources.getDimensionPixelSize(
|
||||
R.dimen.unmount_button_padding);
|
||||
|
Reference in New Issue
Block a user