summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/usb
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2011-02-03 17:44:47 -0800
committerJoe Onorato <joeo@google.com>2011-02-03 17:50:02 -0800
commitc7f8b6fcf56aeb457013832555f6358f6babee90 (patch)
tree6512a3b10dae686eb22e5dcc2819064893fbe4c9 /packages/SystemUI/src/com/android/systemui/usb
parent8444023f351b22816f6827d3314ff81b3533e3d9 (diff)
downloadframeworks_base-c7f8b6fcf56aeb457013832555f6358f6babee90.zip
frameworks_base-c7f8b6fcf56aeb457013832555f6358f6babee90.tar.gz
frameworks_base-c7f8b6fcf56aeb457013832555f6358f6babee90.tar.bz2
Managed dialogs should run on the same thread as their activity.
Bug: 3418998 Change-Id: I9b1cf73f9d6f8a5594f405546fcaa3cfd6f03c45
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/usb')
-rw-r--r--packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java
index 1383216..5c52783 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbStorageActivity.java
@@ -71,6 +71,7 @@ public class UsbStorageActivity extends Activity
private static final int DLG_CONFIRM_KILL_STORAGE_USERS = 1;
private static final int DLG_ERROR_SHARING = 2;
static final boolean localLOGV = false;
+ private boolean mDestroyed;
// UI thread
private Handler mUIHandler;
@@ -136,6 +137,12 @@ public class UsbStorageActivity extends Activity
mProgressBar = (ProgressBar) findViewById(com.android.internal.R.id.progress);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mDestroyed = true;
+ }
+
private void switchDisplay(final boolean usbStorageInUse) {
mUIHandler.post(new Runnable() {
@Override
@@ -232,9 +239,16 @@ public class UsbStorageActivity extends Activity
return null;
}
- private void showDialogInner(int id) {
- removeDialog(id);
- showDialog(id);
+ private void scheduleShowDialog(final int id) {
+ mUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (!mDestroyed) {
+ removeDialog(id);
+ showDialog(id);
+ }
+ }
+ });
}
private void switchUsbMassStorage(final boolean on) {
@@ -276,7 +290,7 @@ public class UsbStorageActivity extends Activity
IMountService ims = getMountService();
if (ims == null) {
// Display error dialog
- showDialogInner(DLG_ERROR_SHARING);
+ scheduleShowDialog(DLG_ERROR_SHARING);
}
String extStoragePath = Environment.getExternalStorageDirectory().toString();
boolean showDialog = false;
@@ -294,11 +308,11 @@ public class UsbStorageActivity extends Activity
}
} catch (RemoteException e) {
// Display error dialog
- showDialogInner(DLG_ERROR_SHARING);
+ scheduleShowDialog(DLG_ERROR_SHARING);
}
if (showDialog) {
// Display dialog to user
- showDialogInner(DLG_CONFIRM_KILL_STORAGE_USERS);
+ scheduleShowDialog(DLG_CONFIRM_KILL_STORAGE_USERS);
} else {
if (localLOGV) Log.i(TAG, "Enabling UMS");
switchUsbMassStorage(true);