summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/usb
diff options
context:
space:
mode:
authorJohn Eckerdal <john.eckerdal@sonymobile.com>2014-02-21 17:54:15 +0100
committerHenrik Baard <henrik.baard@sonymobile.com>2014-03-20 14:37:30 +0100
commita804d65f4aa31c7088e7f2150d96f1bf92e9c3be (patch)
tree22d4429337d82e4c817572c79e33c8363f4323ea /packages/SystemUI/src/com/android/systemui/usb
parentdac298005ce3c1361e27bb740e4b518765d43d77 (diff)
downloadframeworks_base-a804d65f4aa31c7088e7f2150d96f1bf92e9c3be.zip
frameworks_base-a804d65f4aa31c7088e7f2150d96f1bf92e9c3be.tar.gz
frameworks_base-a804d65f4aa31c7088e7f2150d96f1bf92e9c3be.tar.bz2
Prevent system_server shutdown when trying to format external storage
The SystemUI does not provied path information on which volume that should be formatted. So when the user selects "Blank CD Card" an intent is sent to ExternalMediaFormatActivity and forwarded to ExternalStorageFormatter then actual volume that is unformatted is not included in the information sent in the Intent. This causes the ExternalStorageFormatter to go through Environment to find a Volume but the actual volume found that way is not correct. To solve the issue look up the correct StorageVolumeand reuse the existing EXTRA_STORAGE_VOLUME extra and send it as part of the Intent. Change-Id: Ib360a9ce071ebe95fc3ca847ed68b6db05928a42
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/usb')
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 2c36ab7..e634e30 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) {