Fix a bug where Settings would crash from search into storage.

If the user entered the StorageDashboardFragment from search,
it would crash due to a precondition check added to the Storage
Manager. Because no volume id was set in the bundle for it to
check, it hits an assert that the volume id is not null causing
Settings to crash.

This sets a sensible default instead of null.

Bug: 34633464
Test: Manual. Entering through search does not crash now.
Change-Id: Ia6cd82929a0813eefcdad279436b9c2fe30b0146
This commit is contained in:
Daniel Nishi
2017-01-24 09:29:38 -08:00
parent d9d463be8b
commit 4d4142b6aa

View File

@@ -21,9 +21,6 @@ import android.os.Bundle;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo; import android.os.storage.VolumeInfo;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.logging.nano.MetricsProto; import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R; import com.android.settings.R;
@@ -62,7 +59,8 @@ public class StorageDashboardFragment extends DashboardFragment {
// Initialize the storage sizes that we can quickly calc. // Initialize the storage sizes that we can quickly calc.
StorageManager sm = context.getSystemService(StorageManager.class); StorageManager sm = context.getSystemService(StorageManager.class);
String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID); String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID,
VolumeInfo.ID_PRIVATE_INTERNAL);
mVolume = sm.findVolumeById(volumeId); mVolume = sm.findVolumeById(volumeId);
if (!isVolumeValid()) { if (!isVolumeValid()) {
getActivity().finish(); getActivity().finish();