am 474f987d: am f5d6d432: am cf9aebf1: Merge "Remove ExternalStorageFormatter" into mnc-dev

* commit '474f987dd783493967e9ea899398f6965a7d3515':
  Remove ExternalStorageFormatter
This commit is contained in:
Rubin Xu
2015-07-14 00:38:12 +00:00
committed by Android Git Automerger
4 changed files with 1 additions and 180 deletions

View File

@@ -1,146 +0,0 @@
package com.android.internal.os.storage;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.util.Slog;
import android.view.WindowManager;
import android.widget.Toast;
import com.android.internal.R;
/**
* Takes care of unmounting and formatting external storage.
*
* @deprecated Please use {@link Intent#ACTION_MASTER_CLEAR} broadcast with extra
* {@link Intent#EXTRA_WIPE_EXTERNAL_STORAGE} to wipe and factory reset, or call
* {@link StorageManager#wipeAdoptableDisks} directly to format external storages.
*/
public class ExternalStorageFormatter extends Service {
static final String TAG = "ExternalStorageFormatter";
public static final String FORMAT_ONLY = "com.android.internal.os.storage.FORMAT_ONLY";
public static final String FORMAT_AND_FACTORY_RESET = "com.android.internal.os.storage.FORMAT_AND_FACTORY_RESET";
public static final String EXTRA_ALWAYS_RESET = "always_reset";
public static final ComponentName COMPONENT_NAME
= new ComponentName("android", ExternalStorageFormatter.class.getName());
private StorageManager mStorageManager;
private PowerManager.WakeLock mWakeLock;
private ProgressDialog mProgressDialog = null;
private boolean mFactoryReset = false;
private boolean mAlwaysReset = false;
private String mReason = null;
@Override
public void onCreate() {
super.onCreate();
mStorageManager = getSystemService(StorageManager.class);
mWakeLock = ((PowerManager)getSystemService(Context.POWER_SERVICE))
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ExternalStorageFormatter");
mWakeLock.acquire();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (FORMAT_AND_FACTORY_RESET.equals(intent.getAction())) {
mFactoryReset = true;
}
if (intent.getBooleanExtra(EXTRA_ALWAYS_RESET, false)) {
mAlwaysReset = true;
}
mReason = intent.getStringExtra(Intent.EXTRA_REASON);
StorageVolume userVol = intent.getParcelableExtra(StorageVolume.EXTRA_STORAGE_VOLUME);
if (userVol == null) {
Slog.w(TAG, "Missing explicit storage volume; assuming default");
userVol = mStorageManager.getPrimaryVolume();
}
final String volumeId = userVol.getId();
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mProgressDialog.setMessage(getText(R.string.progress_unmounting));
mProgressDialog.show();
new FormatTask(volumeId).start();
return Service.START_REDELIVER_INTENT;
}
private class FormatTask extends Thread {
private final String mVolumeId;
public FormatTask(String volumeId) {
mVolumeId = volumeId;
}
@Override
public void run() {
boolean success = false;
try {
mStorageManager.format(mVolumeId);
success = true;
} catch (Exception e) {
Slog.w(TAG, "Failed to format", e);
Toast.makeText(ExternalStorageFormatter.this,
R.string.format_error, Toast.LENGTH_LONG).show();
}
if (success) {
if (mFactoryReset) {
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON, mReason);
sendBroadcast(intent);
// Intent handling is asynchronous -- assume it will happen soon.
stopSelf();
return;
}
}
// If we didn't succeed, or aren't doing a full factory
// reset, then it is time to remount the storage.
if (!success && mAlwaysReset) {
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON, mReason);
sendBroadcast(intent);
} else {
try {
mStorageManager.mount(mVolumeId);
} catch (Exception e) {
Slog.w(TAG, "Failed to mount", e);
}
}
stopSelf();
}
}
@Override
public void onDestroy() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
mWakeLock.release();
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View File

@@ -2784,10 +2784,6 @@
</intent-filter>
</receiver>
<service android:name="com.android.internal.os.storage.ExternalStorageFormatter"
android:permission="android.permission.MASTER_CLEAR"
android:exported="true" />
<service android:name="android.hardware.location.GeofenceHardwareService"
android:permission="android.permission.LOCATION_HARDWARE"
android:exported="false" />

View File

@@ -3168,33 +3168,11 @@
<!-- Label for the "Done" button on the far left of action mode toolbars. -->
<string name="action_mode_done">Done</string>
<!-- Strings for ExternalStorageFormatter service. -->
<!-- Text for progress dialog while unmounting USB storage volume [CHAR LIMIT=NONE] -->
<string name="progress_unmounting" product="nosdcard">Unmounting USB storage\u2026</string>
<!-- Text for progress dialog while unmounting SD card [CHAR LIMIT=NONE] -->
<string name="progress_unmounting" product="default">Unmounting SD card\u2026</string>
<!-- Strings for MasterClearReceiver. -->
<!-- Text for progress dialog while erasing USB storage volume [CHAR LIMIT=NONE] -->
<string name="progress_erasing" product="nosdcard">Erasing USB storage\u2026</string>
<!-- Text for progress dialog while erasing SD card [CHAR LIMIT=NONE] -->
<string name="progress_erasing" product="default">Erasing SD card\u2026</string>
<!-- Text for message to user that an error happened when formatting USB storage [CHAR LIMIT=NONE] -->
<string name="format_error" product="nosdcard">Couldn\'t erase USB storage.</string>
<!-- Text for message to user that an error happened when formatting SD card [CHAR LIMIT=NONE] -->
<string name="format_error" product="default">Couldn\'t erase SD card.</string>
<!-- Text for message to user that SD card has been removed while in use [CHAR LIMIT=NONE] -->
<string name="media_bad_removal">SD card was removed before being unmounted.</string>
<!-- Text for message to user USB storage is currently being checked [CHAR LIMIT=NONE] -->
<string name="media_checking" product="nosdcard">USB storage is currently being checked.</string>
<!-- Text for message to user SD card is currently being checked [CHAR LIMIT=NONE] -->
<string name="media_checking" product="default">SD card is currently being checked.</string>
<!-- Text for message to user SD card has been removed [CHAR LIMIT=NONE] -->
<string name="media_removed">SD card has been removed.</string>
<!-- Text for message to user USB storage is currently mounted on a computer [CHAR LIMIT=NONE] -->
<string name="media_shared" product="nosdcard">USB storage is currently in use by a computer.</string>
<!-- Text for message to user SD card is currently mounted on a computer [CHAR LIMIT=NONE] -->
<string name="media_shared" product="default">SD card is currently in use by a computer.</string>
<!-- Text for message for an unknown external media state [CHAR LIMIT=NONE] -->
<string name="media_unknown_state">External media in unknown state.</string>
<!-- Text for WebView's text selection Action Mode -->
<!-- ActionBar action to share the current selection [CHAR LIMIT=10] -->

View File

@@ -627,7 +627,6 @@
<java-symbol type="string" name="eventTypeOther" />
<java-symbol type="string" name="fileSizeSuffix" />
<java-symbol type="string" name="force_close" />
<java-symbol type="string" name="format_error" />
<java-symbol type="string" name="gadget_host_error_inflating" />
<java-symbol type="string" name="gigabyteShort" />
<java-symbol type="string" name="gpsNotifMessage" />
@@ -711,11 +710,6 @@
<java-symbol type="string" name="lockscreen_emergency_call" />
<java-symbol type="string" name="lockscreen_return_to_call" />
<java-symbol type="string" name="low_memory" />
<java-symbol type="string" name="media_bad_removal" />
<java-symbol type="string" name="media_checking" />
<java-symbol type="string" name="media_removed" />
<java-symbol type="string" name="media_shared" />
<java-symbol type="string" name="media_unknown_state" />
<java-symbol type="string" name="megabyteShort" />
<java-symbol type="string" name="midnight" />
<java-symbol type="string" name="mismatchPin" />
@@ -814,7 +808,6 @@
<java-symbol type="string" name="print_service_installed_title" />
<java-symbol type="string" name="print_service_installed_message" />
<java-symbol type="string" name="progress_erasing" />
<java-symbol type="string" name="progress_unmounting" />
<java-symbol type="string" name="mobile_provisioning_apn" />
<java-symbol type="string" name="mobile_provisioning_url" />
<java-symbol type="string" name="quick_contacts_not_available" />