Prevent network depersonalization dialog from showing multiple instances.
The EVENT_SIM_NETWORK_LOCKED event in Telephony triggers displaying the
depersonalization dialog. It appears, however, that there are instances
when the EVENT_SIM_NETWORK_LOCKED event gets triggered multiple times,
resulting in multiple stacked dialogs being shown.
Added singleton code into the dialog to ensure only a single instance can
be opened at the same time.
Bug: 22963631
Change-Id: Ib43b34acdc9da7dcf4b1cfc4c37ba30b10d16cad
diff --git a/src/com/android/phone/IccNetworkDepersonalizationPanel.java b/src/com/android/phone/IccNetworkDepersonalizationPanel.java
index 4831423..9dff461 100644
--- a/src/com/android/phone/IccNetworkDepersonalizationPanel.java
+++ b/src/com/android/phone/IccNetworkDepersonalizationPanel.java
@@ -48,6 +48,12 @@
*/
public class IccNetworkDepersonalizationPanel extends IccPanel {
+ /**
+ * Tracks whether there is an instance of the network depersonalization dialog showing or not.
+ * Ensures only a single instance of the dialog is visible.
+ */
+ private static boolean sShowingDialog = false;
+
//debug constants
private static final boolean DBG = false;
@@ -65,6 +71,21 @@
private Button mUnlockButton;
private Button mDismissButton;
+ /**
+ * Shows the network depersonalization dialog, but only if it is not already visible.
+ */
+ public static void showDialog() {
+ if (sShowingDialog) {
+ Log.i(TAG, "[IccNetworkDepersonalizationPanel] - showDialog; skipped already shown.");
+ return;
+ }
+ Log.i(TAG, "[IccNetworkDepersonalizationPanel] - showDialog; showing dialog.");
+ sShowingDialog = true;
+ IccNetworkDepersonalizationPanel ndpPanel =
+ new IccNetworkDepersonalizationPanel(PhoneGlobals.getInstance());
+ ndpPanel.show();
+ }
+
//private textwatcher to control text entry.
private TextWatcher mPinEntryWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence buffer, int start, int olen, int nlen) {
@@ -160,6 +181,13 @@
super.onStart();
}
+ @Override
+ public void onStop() {
+ super.onStop();
+ Log.i(TAG, "[IccNetworkDepersonalizationPanel] - showDialog; hiding dialog.");
+ sShowingDialog = false;
+ }
+
//Mirrors IccPinUnlockPanel.onKeyDown().
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 315929b..fc08c5f 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -250,9 +250,7 @@
// The user won't be able to do anything else until
// they enter a valid SIM network PIN.
Log.i(LOG_TAG, "show sim depersonal panel");
- IccNetworkDepersonalizationPanel ndpPanel =
- new IccNetworkDepersonalizationPanel(PhoneGlobals.getInstance());
- ndpPanel.show();
+ IccNetworkDepersonalizationPanel.showDialog();
}
break;