diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-08-12 22:12:17 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-08-12 20:07:20 +0000 |
commit | 2013cb1f917b3d29df9a6f0caf34e17632bd240f (patch) | |
tree | 53aefa80f73827ffa611ea3a621a987de9eecd76 | |
parent | 67fe6d1f76a740147cc9c85487e8e70b53c744f8 (diff) | |
parent | a804d65f4aa31c7088e7f2150d96f1bf92e9c3be (diff) | |
download | base-2013cb1f917b3d29df9a6f0caf34e17632bd240f.tar.gz |
Merge "Prevent system_server shutdown when trying to format external storage"
-rw-r--r-- | core/java/com/android/internal/app/ExternalMediaFormatActivity.java | 5 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java index 5ab9217b6b12..8efe8adcbd61 100644 --- a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java +++ b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java @@ -25,6 +25,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; +import android.os.storage.StorageVolume; import android.util.Log; /** @@ -95,6 +96,10 @@ public class ExternalMediaFormatActivity extends AlertActivity implements Dialog if (which == POSITIVE_BUTTON) { Intent intent = new Intent(ExternalStorageFormatter.FORMAT_ONLY); intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME); + // Transfer the storage volume to the new intent + final StorageVolume storageVolume = getIntent().getParcelableExtra( + StorageVolume.EXTRA_STORAGE_VOLUME); + intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, storageVolume); startService(intent); } diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java index 2c36ab7c0c3b..e634e30b59d5 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java @@ -28,6 +28,7 @@ import android.os.HandlerThread; import android.os.UserHandle; import android.os.storage.StorageEventListener; import android.os.storage.StorageManager; +import android.os.storage.StorageVolume; import android.provider.Settings; import android.util.Log; @@ -198,6 +199,8 @@ public class StorageNotification extends SystemUI { */ Intent intent = new Intent(); intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class); + intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, + getVolumeByPath(mStorageManager.getVolumeList(), path)); PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); setMediaStorageNotification( @@ -212,6 +215,8 @@ public class StorageNotification extends SystemUI { */ Intent intent = new Intent(); intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class); + intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, + getVolumeByPath(mStorageManager.getVolumeList(), path)); PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); setMediaStorageNotification( @@ -247,6 +252,19 @@ public class StorageNotification extends SystemUI { } /** + * Get the corresponding StorageVolume object for a specific path. + */ + private final StorageVolume getVolumeByPath(StorageVolume[] volumes, String path) { + for (StorageVolume volume : volumes) { + if (volume.getPath().equals(path)) { + return volume; + } + } + Log.w(TAG, "No storage found"); + return null; + } + + /** * Update the state of the USB mass storage notification */ void updateUsbMassStorageNotification(boolean available) { |