Skip to content

Commit 344c993

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Don't unregister receiver twice." into jb-dev
2 parents 57c2e3d + 2efb6a9 commit 344c993

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

policy/src/com/android/internal/policy/impl/GlobalActions.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,21 @@ public void showDialog(boolean keyguardShowing, boolean isDeviceProvisioned) {
114114
mDeviceProvisioned = isDeviceProvisioned;
115115
if (mDialog != null) {
116116
mDialog.dismiss();
117+
mDialog = null;
118+
// Show delayed, so that the dismiss of the previous dialog completes
119+
mHandler.sendEmptyMessage(MESSAGE_SHOW);
120+
} else {
121+
handleShow();
117122
}
123+
}
124+
125+
private void handleShow() {
118126
mDialog = createDialog();
119127
prepareDialog();
120128

121129
mDialog.show();
122130
mDialog.getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_DISABLE_EXPAND);
123131
}
124-
125132
/**
126133
* Create the global actions dialog.
127134
* @return A new dialog.
@@ -280,7 +287,6 @@ private void prepareDialog() {
280287
}
281288
}
282289

283-
284290
/** {@inheritDoc} */
285291
public void onDismiss(DialogInterface dialog) {
286292
if (SHOW_SILENT_TOGGLE) {
@@ -694,16 +700,23 @@ public void onReceive(Context context, Intent intent) {
694700

695701
private static final int MESSAGE_DISMISS = 0;
696702
private static final int MESSAGE_REFRESH = 1;
703+
private static final int MESSAGE_SHOW = 2;
697704
private static final int DIALOG_DISMISS_DELAY = 300; // ms
698705

699706
private Handler mHandler = new Handler() {
700707
public void handleMessage(Message msg) {
701-
if (msg.what == MESSAGE_DISMISS) {
708+
switch (msg.what) {
709+
case MESSAGE_DISMISS:
702710
if (mDialog != null) {
703711
mDialog.dismiss();
704712
}
705-
} else if (msg.what == MESSAGE_REFRESH) {
713+
break;
714+
case MESSAGE_REFRESH:
706715
mAdapter.notifyDataSetChanged();
716+
break;
717+
case MESSAGE_SHOW:
718+
handleShow();
719+
break;
707720
}
708721
}
709722
};

0 commit comments

Comments
 (0)