am c938a02b: am c1db1192: am d2a6f28f: Disable option to format SD card for secondary external storage
* commit 'c938a02bc69434840340dcebb8ac16b6dcfb8b60':
Disable option to format SD card for secondary external storage
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
index e326b2b..9dbff88 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
@@ -63,6 +63,8 @@
private StorageMeasurement mMeasurement;
+ private boolean mAllowFormat;
+
static class CategoryInfo {
final int mTitle;
final int mColor;
@@ -163,6 +165,12 @@
setTitle(storageVolume.getDescription());
mMeasurement = StorageMeasurement.getInstance(context, storageVolume, isPrimary);
mMeasurement.setReceiver(this);
+
+ // Cannot format emulated storage
+ mAllowFormat = !mStorageVolume.isEmulated();
+ // For now we are disabling reformatting secondary external storage
+ // until some interoperability problems with MTP are fixed
+ if (!isPrimary) mAllowFormat = false;
}
public void init() {
@@ -190,9 +198,11 @@
mMountTogglePreference.setTitle(R.string.sd_eject);
mMountTogglePreference.setSummary(R.string.sd_eject_summary);
- mFormatPreference = new Preference(getContext());
- mFormatPreference.setTitle(R.string.sd_format);
- mFormatPreference.setSummary(R.string.sd_format_summary);
+ if (mAllowFormat) {
+ mFormatPreference = new Preference(getContext());
+ mFormatPreference.setTitle(R.string.sd_format);
+ mFormatPreference.setSummary(R.string.sd_format_summary);
+ }
}
public StorageVolume getStorageVolume() {
@@ -211,14 +221,18 @@
removePreference(mPreferences[i]);
}
removePreference(mMountTogglePreference);
- removePreference(mFormatPreference);
+ if (mFormatPreference != null) {
+ removePreference(mFormatPreference);
+ }
addPreference(mUsageBarPreference);
for (int i = 0; i < numberOfCategories; i++) {
addPreference(mPreferences[i]);
}
addPreference(mMountTogglePreference);
- addPreference(mFormatPreference);
+ if (mFormatPreference != null) {
+ addPreference(mFormatPreference);
+ }
mMountTogglePreference.setEnabled(true);
}
@@ -232,10 +246,12 @@
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
state = Environment.MEDIA_MOUNTED;
readOnly = mResources.getString(R.string.read_only);
- removePreference(mFormatPreference);
+ if (mFormatPreference != null) {
+ removePreference(mFormatPreference);
+ }
}
- if (mStorageVolume.isEmulated()) {
+ if (mFormatPreference != null) {
removePreference(mFormatPreference);
}
@@ -266,7 +282,9 @@
removePreference(mUsageBarPreference);
removePreference(mPreferences[TOTAL_SIZE]);
removePreference(mPreferences[AVAILABLE]);
- removePreference(mFormatPreference);
+ if (mFormatPreference != null) {
+ removePreference(mFormatPreference);
+ }
}
}