Format as public/private; follow refactoring.

Offer to format an empty disk as public/private.

Bug: 19993667
Change-Id: I69fafaed524f3ef5e65d04a9e3a94789fcfc3087
This commit is contained in:
Jeff Sharkey
2015-04-28 13:41:01 -07:00
parent 02c89944d1
commit a16257dbd5
15 changed files with 236 additions and 97 deletions

View File

@@ -273,43 +273,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
}
}
public static class FormatTask extends AsyncTask<Void, Void, Exception> {
private final Context mContext;
private final StorageManager mStorageManager;
private final String mVolumeId;
private final String mDescription;
public FormatTask(Context context, VolumeInfo volume) {
mContext = context.getApplicationContext();
mStorageManager = mContext.getSystemService(StorageManager.class);
mVolumeId = volume.getId();
mDescription = mStorageManager.getBestVolumeDescription(volume);
}
@Override
protected Exception doInBackground(Void... params) {
try {
mStorageManager.format(mVolumeId);
mStorageManager.mount(mVolumeId);
return null;
} catch (Exception e) {
return e;
}
}
@Override
protected void onPostExecute(Exception e) {
if (e == null) {
Toast.makeText(mContext, mContext.getString(R.string.storage_format_success,
mDescription), Toast.LENGTH_SHORT).show();
} else {
Log.e(TAG, "Failed to format " + mVolumeId, e);
Toast.makeText(mContext, mContext.getString(R.string.storage_format_failure,
mDescription), Toast.LENGTH_SHORT).show();
}
}
}
/**
* Enable indexing of searchable data
*/