Actually gracefully finish this time around.
Also fix tinting on front-door icon. Bug: 21403958 Change-Id: I74f0372a41b92235abe10391f36d9f6a1e6a40c5
This commit is contained in:
@@ -53,7 +53,6 @@ import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings.StorageUseActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
@@ -110,6 +109,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
private Preference mExplore;
|
||||
|
||||
private boolean isVolumeValid() {
|
||||
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
|
||||
&& mVolume.isMountedReadable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||
@@ -127,22 +131,19 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
mVolumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||
|
||||
if (mVolume == null) {
|
||||
Log.d(TAG, "Leaving details fragment due to missing volume");
|
||||
finish();
|
||||
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
||||
mMeasure.setReceiver(mReceiver);
|
||||
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
|
||||
|
||||
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
||||
|
||||
// Find the emulated shared storage layered above this private volume
|
||||
mSharedVolume = mStorageManager.findEmulatedForPrivate(mVolume);
|
||||
|
||||
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
||||
mMeasure.setReceiver(mReceiver);
|
||||
|
||||
mSummary = new StorageSummaryPreference(context);
|
||||
|
||||
mApps = buildItem(R.string.storage_detail_apps);
|
||||
@@ -167,6 +168,11 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||
|
||||
// Valid options may have changed
|
||||
@@ -177,12 +183,6 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
screen.removeAll();
|
||||
|
||||
if (!mVolume.isMountedReadable()) {
|
||||
Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
screen.addPreference(mSummary);
|
||||
|
||||
final boolean showUsers = !mUsers.isEmpty();
|
||||
@@ -250,7 +250,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
// Refresh to verify that we haven't been formatted away
|
||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||
if (mVolume == null) {
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
@@ -268,7 +268,9 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMeasure.onDestroy();
|
||||
if (mMeasure != null) {
|
||||
mMeasure.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,6 +280,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
if (!isVolumeValid()) return;
|
||||
|
||||
final MenuItem rename = menu.findItem(R.id.storage_rename);
|
||||
final MenuItem mount = menu.findItem(R.id.storage_mount);
|
||||
final MenuItem unmount = menu.findItem(R.id.storage_unmount);
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -33,7 +31,6 @@ import android.provider.DocumentsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.text.format.Formatter.BytesResult;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.util.Preconditions;
|
||||
@@ -67,6 +64,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
private Preference mFormatPublic;
|
||||
private Preference mFormatPrivate;
|
||||
|
||||
private boolean isVolumeValid() {
|
||||
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC)
|
||||
&& mVolume.isMountedReadable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsLogger.DEVICEINFO_STORAGE;
|
||||
@@ -90,14 +92,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
mVolume = mStorageManager.findVolumeById(volId);
|
||||
}
|
||||
|
||||
if (mVolume == null) {
|
||||
Log.d(TAG, "Leaving details fragment due to missing volume");
|
||||
finish();
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PUBLIC);
|
||||
|
||||
mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
|
||||
Preconditions.checkNotNull(mDisk);
|
||||
|
||||
@@ -114,6 +113,11 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
|
||||
|
||||
final Context context = getActivity();
|
||||
@@ -121,12 +125,6 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
screen.removeAll();
|
||||
|
||||
if (!mVolume.isMountedReadable()) {
|
||||
Log.d(TAG, "Leaving details fragment due to state " + mVolume.getState());
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mVolume.isMountedReadable()) {
|
||||
screen.addPreference(mSummary);
|
||||
|
||||
@@ -168,7 +166,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
||||
|
||||
// Refresh to verify that we haven't been formatted away
|
||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||
if (mVolume == null) {
|
||||
if (!isVolumeValid()) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.DiskInfo;
|
||||
@@ -165,11 +166,16 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
for (VolumeRecord rec : recs) {
|
||||
if (rec.getType() == VolumeInfo.TYPE_PRIVATE
|
||||
&& mStorageManager.findVolumeByUuid(rec.getFsUuid()) == null) {
|
||||
// TODO: add actual storage type to record
|
||||
final Drawable icon = context.getDrawable(R.drawable.ic_sim_sd);
|
||||
icon.mutate();
|
||||
icon.setTint(COLOR_PUBLIC);
|
||||
|
||||
final Preference pref = new Preference(context);
|
||||
pref.setKey(rec.getFsUuid());
|
||||
pref.setTitle(rec.getNickname());
|
||||
pref.setSummary(com.android.internal.R.string.ext_media_status_missing);
|
||||
pref.setIcon(R.drawable.ic_settings_storage);
|
||||
pref.setIcon(icon);
|
||||
mInternalCategory.addPreference(pref);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user