am 24de44a1: Merge "ExternalStorageFormatter takes an optional StorageVolume target." into honeycomb-mr2
* commit '24de44a1877be3e5d63697f90c98a87a4d88b1fb': ExternalStorageFormatter takes an optional StorageVolume target.
This commit is contained in:
@@ -16,16 +16,6 @@
|
||||
|
||||
package android.content;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -37,6 +27,15 @@ import android.util.Printer;
|
||||
|
||||
import com.android.internal.util.XmlUtils;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Structured description of Intent values to be matched. An IntentFilter can
|
||||
* match against actions, categories, and data (either via its type, scheme,
|
||||
@@ -755,7 +754,7 @@ public class IntentFilter implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Intent data oath to match against. The filter must
|
||||
* Add a new Intent data path to match against. The filter must
|
||||
* include one or more schemes (via {@link #addDataScheme}) <em>and</em>
|
||||
* one or more authorities (via {@link #addDataAuthority}) for the
|
||||
* path to be considered. If any paths are
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -100,10 +99,11 @@ public class StorageManager
|
||||
private final ObbActionListener mObbActionListener = new ObbActionListener();
|
||||
|
||||
private class ObbActionListener extends IObbActionListener.Stub {
|
||||
@SuppressWarnings("hiding")
|
||||
private SparseArray<ObbListenerDelegate> mListeners = new SparseArray<ObbListenerDelegate>();
|
||||
|
||||
@Override
|
||||
public void onObbResult(String filename, int nonce, int status) throws RemoteException {
|
||||
public void onObbResult(String filename, int nonce, int status) {
|
||||
final ObbListenerDelegate delegate;
|
||||
synchronized (mListeners) {
|
||||
delegate = mListeners.get(nonce);
|
||||
@@ -147,8 +147,8 @@ public class StorageManager
|
||||
mHandler = new Handler(mTgtLooper) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
final OnObbStateChangeListener listener = getListener();
|
||||
if (listener == null) {
|
||||
final OnObbStateChangeListener changeListener = getListener();
|
||||
if (changeListener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class StorageManager
|
||||
|
||||
if (msg.what == StorageEvent.EVENT_OBB_STATE_CHANGED) {
|
||||
ObbStateChangedStorageEvent ev = (ObbStateChangedStorageEvent) e;
|
||||
listener.onObbStateChange(ev.path, ev.state);
|
||||
changeListener.onObbStateChange(ev.path, ev.state);
|
||||
} else {
|
||||
Log.e(TAG, "Unsupported event " + msg.what);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package android.os.storage;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* A class representing a storage volume
|
||||
@@ -27,7 +25,7 @@ import android.util.Log;
|
||||
*/
|
||||
public class StorageVolume implements Parcelable {
|
||||
|
||||
private static final String TAG = "StorageVolume";
|
||||
//private static final String TAG = "StorageVolume";
|
||||
|
||||
private final String mPath;
|
||||
private final String mDescription;
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.os.ServiceManager;
|
||||
import android.os.storage.IMountService;
|
||||
import android.os.storage.StorageEventListener;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.StorageVolume;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
@@ -32,6 +33,9 @@ public class ExternalStorageFormatter extends Service
|
||||
|
||||
public static final String EXTRA_ALWAYS_RESET = "always_reset";
|
||||
|
||||
// If non-null, the volume to format. Otherwise, will use the default external storage directory
|
||||
private StorageVolume mStorageVolume;
|
||||
|
||||
public static final ComponentName COMPONENT_NAME
|
||||
= new ComponentName("android", ExternalStorageFormatter.class.getName());
|
||||
|
||||
@@ -80,6 +84,8 @@ public class ExternalStorageFormatter extends Service
|
||||
mAlwaysReset = true;
|
||||
}
|
||||
|
||||
mStorageVolume = intent.getParcelableExtra(StorageVolume.EXTRA_STORAGE_VOLUME);
|
||||
|
||||
if (mProgressDialog == null) {
|
||||
mProgressDialog = new ProgressDialog(this);
|
||||
mProgressDialog.setIndeterminate(true);
|
||||
@@ -115,7 +121,9 @@ public class ExternalStorageFormatter extends Service
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
IMountService mountService = getMountService();
|
||||
String extStoragePath = Environment.getExternalStorageDirectory().toString();
|
||||
String extStoragePath = mStorageVolume == null ?
|
||||
Environment.getExternalStorageDirectory().toString() :
|
||||
mStorageVolume.getPath();
|
||||
try {
|
||||
mountService.mountVolume(extStoragePath);
|
||||
} catch (RemoteException e) {
|
||||
@@ -133,12 +141,16 @@ public class ExternalStorageFormatter extends Service
|
||||
}
|
||||
|
||||
void updateProgressState() {
|
||||
String status = Environment.getExternalStorageState();
|
||||
String status = mStorageVolume == null ?
|
||||
Environment.getExternalStorageState() :
|
||||
mStorageManager.getVolumeState(mStorageVolume.getPath());
|
||||
if (Environment.MEDIA_MOUNTED.equals(status)
|
||||
|| Environment.MEDIA_MOUNTED_READ_ONLY.equals(status)) {
|
||||
updateProgressDialog(R.string.progress_unmounting);
|
||||
IMountService mountService = getMountService();
|
||||
String extStoragePath = Environment.getExternalStorageDirectory().toString();
|
||||
final String extStoragePath = mStorageVolume == null ?
|
||||
Environment.getExternalStorageDirectory().toString() :
|
||||
mStorageVolume.getPath();
|
||||
try {
|
||||
mountService.unmountVolume(extStoragePath, true);
|
||||
} catch (RemoteException e) {
|
||||
@@ -149,9 +161,12 @@ public class ExternalStorageFormatter extends Service
|
||||
|| Environment.MEDIA_UNMOUNTABLE.equals(status)) {
|
||||
updateProgressDialog(R.string.progress_erasing);
|
||||
final IMountService mountService = getMountService();
|
||||
final String extStoragePath = Environment.getExternalStorageDirectory().toString();
|
||||
final String extStoragePath = mStorageVolume == null ?
|
||||
Environment.getExternalStorageDirectory().toString() :
|
||||
mStorageVolume.getPath();
|
||||
if (mountService != null) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean success = false;
|
||||
try {
|
||||
@@ -185,7 +200,7 @@ public class ExternalStorageFormatter extends Service
|
||||
}
|
||||
}.start();
|
||||
} else {
|
||||
Log.w("MediaFormat", "Unable to locate IMountService");
|
||||
Log.w(TAG, "Unable to locate IMountService");
|
||||
}
|
||||
} else if (Environment.MEDIA_BAD_REMOVAL.equals(status)) {
|
||||
fail(R.string.media_bad_removal);
|
||||
|
||||
Reference in New Issue
Block a user