am a39077c9
: am 67832cc3
: am 74c7f1fc
: Merge "Actually gracefully finish this time around." into mnc-dev
* commit 'a39077c95bb51102e77e55a2d4e352f8027d5c24': Actually gracefully finish this time around.
This commit is contained in:
21
res/drawable/ic_settings_sim.xml
Normal file
21
res/drawable/ic_settings_sim.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/ic_sim_sd"
|
||||
android:tint="?android:attr/colorAccent" />
|
||||
|
@@ -44,7 +44,7 @@
|
||||
android:id="@+id/sim_settings"
|
||||
android:title="@string/sim_settings_title"
|
||||
android:fragment="com.android.settings.sim.SimSettings"
|
||||
android:icon="@drawable/ic_sim_sd"
|
||||
android:icon="@drawable/ic_settings_sim"
|
||||
/>
|
||||
|
||||
<!-- Data Usage -->
|
||||
|
@@ -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,8 +268,10 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMeasure != null) {
|
||||
mMeasure.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
@@ -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