am 163c28b5
: Merge "Managed dialogs should run on the same thread as their activity." into gingerbread
* commit '163c28b5ca0a85be4c3f64c5419eb95fec4a6d43': Managed dialogs should run on the same thread as their activity.
This commit is contained in:
@ -71,6 +71,7 @@ public class UsbStorageActivity extends Activity
|
|||||||
private static final int DLG_CONFIRM_KILL_STORAGE_USERS = 1;
|
private static final int DLG_CONFIRM_KILL_STORAGE_USERS = 1;
|
||||||
private static final int DLG_ERROR_SHARING = 2;
|
private static final int DLG_ERROR_SHARING = 2;
|
||||||
static final boolean localLOGV = false;
|
static final boolean localLOGV = false;
|
||||||
|
private boolean mDestroyed;
|
||||||
|
|
||||||
// UI thread
|
// UI thread
|
||||||
private Handler mUIHandler;
|
private Handler mUIHandler;
|
||||||
@ -136,6 +137,12 @@ public class UsbStorageActivity extends Activity
|
|||||||
mProgressBar = (ProgressBar) findViewById(com.android.internal.R.id.progress);
|
mProgressBar = (ProgressBar) findViewById(com.android.internal.R.id.progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mDestroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void switchDisplay(final boolean usbStorageInUse) {
|
private void switchDisplay(final boolean usbStorageInUse) {
|
||||||
mUIHandler.post(new Runnable() {
|
mUIHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -232,9 +239,16 @@ public class UsbStorageActivity extends Activity
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDialogInner(int id) {
|
private void scheduleShowDialog(final int id) {
|
||||||
removeDialog(id);
|
mUIHandler.post(new Runnable() {
|
||||||
showDialog(id);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!mDestroyed) {
|
||||||
|
removeDialog(id);
|
||||||
|
showDialog(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchUsbMassStorage(final boolean on) {
|
private void switchUsbMassStorage(final boolean on) {
|
||||||
@ -276,7 +290,7 @@ public class UsbStorageActivity extends Activity
|
|||||||
IMountService ims = getMountService();
|
IMountService ims = getMountService();
|
||||||
if (ims == null) {
|
if (ims == null) {
|
||||||
// Display error dialog
|
// Display error dialog
|
||||||
showDialogInner(DLG_ERROR_SHARING);
|
scheduleShowDialog(DLG_ERROR_SHARING);
|
||||||
}
|
}
|
||||||
String extStoragePath = Environment.getExternalStorageDirectory().toString();
|
String extStoragePath = Environment.getExternalStorageDirectory().toString();
|
||||||
boolean showDialog = false;
|
boolean showDialog = false;
|
||||||
@ -294,11 +308,11 @@ public class UsbStorageActivity extends Activity
|
|||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Display error dialog
|
// Display error dialog
|
||||||
showDialogInner(DLG_ERROR_SHARING);
|
scheduleShowDialog(DLG_ERROR_SHARING);
|
||||||
}
|
}
|
||||||
if (showDialog) {
|
if (showDialog) {
|
||||||
// Display dialog to user
|
// Display dialog to user
|
||||||
showDialogInner(DLG_CONFIRM_KILL_STORAGE_USERS);
|
scheduleShowDialog(DLG_CONFIRM_KILL_STORAGE_USERS);
|
||||||
} else {
|
} else {
|
||||||
if (localLOGV) Log.i(TAG, "Enabling UMS");
|
if (localLOGV) Log.i(TAG, "Enabling UMS");
|
||||||
switchUsbMassStorage(true);
|
switchUsbMassStorage(true);
|
||||||
|
Reference in New Issue
Block a user