Add alert dialog for disabling current eSIM profile failed
This CL add an alert dialog under SIM PIN/PUK screen when users try to
disable current eSIM profile and failed.
Bug: 62680294
Test: E2E
Change-Id: I97d8cf1ae8fb30ece48c4731e72bfdfedf69d49a
diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml
index 3a41681..8a48e7b 100644
--- a/packages/SystemUI/res-keyguard/values/strings.xml
+++ b/packages/SystemUI/res-keyguard/values/strings.xml
@@ -124,6 +124,10 @@
<string name="keyboardview_keycode_delete">Delete</string>
<!-- Description of the button used to disable current carrier when the device supported embedded SIM. [CHAR LIMIT=30] -->
<string name="disable_carrier_button_text">Disable eSIM</string>
+ <!-- Title of Error message when disabling current carrier failed for the device supported embedded SIM. [CHAR LIMIT=80] -->
+ <string name="error_disable_esim_title">Can\u2019t disable eSIM</string>
+ <!-- Description of Error message when disabling current carrier failed for the device supported embedded SIM. [CHAR LIMIT=80] -->
+ <string name="error_disable_esim_msg">The eSIM can\u2019t be disabled due to an error.</string>
<!-- Description of the Enter button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_enter">Enter</string>
@@ -146,8 +150,8 @@
<string name="kg_sim_pin_instructions">Enter SIM PIN.</string>
<!-- Instructions for using the SIM PIN unlock screen when there's more than one SIM -->
<string name="kg_sim_pin_instructions_multi">Enter SIM PIN for \"<xliff:g id="carrier" example="CARD 1">%1$s</xliff:g>\".</string>
- <!-- Instructions for disabling eSIM carrier to unlock the phone with embedded SIM -->
- <string name="kg_sim_lock_instructions_esim">Disable eSIM to use device without mobile service.</string>
+ <!-- Instructions for disabling eSIM carrier to unlock the phone with embedded SIM. This message follows the original SIM PIN/PUK message of device without embedded SIM. -->
+ <string name="kg_sim_lock_esim_instructions"><xliff:g id="previous_msg" example="Enter SIM PIN.">%1$s</xliff:g> Disable eSIM to use device without mobile service.</string>
<!-- Instructions for using the PIN unlock screen -->
<string name="kg_pin_instructions">Enter PIN</string>
<!-- Instructions for using the password unlock screen -->
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
index cb5afec..b8a07cd 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java
@@ -16,14 +16,18 @@
package com.android.keyguard;
+import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.view.View;
+import android.view.WindowManager;
import android.widget.Button;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionInfo;
@@ -50,8 +54,17 @@
if (ACTION_DISABLE_ESIM.equals(intent.getAction())) {
int resultCode = getResultCode();
if (resultCode != EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_OK) {
- // TODO (b/62680294): Surface more info. to the end users for this failure.
Log.e(TAG, "Error disabling esim, result code = " + resultCode);
+ AlertDialog.Builder builder =
+ new AlertDialog.Builder(mContext)
+ .setMessage(R.string.error_disable_esim_msg)
+ .setTitle(R.string.error_disable_esim_title)
+ .setCancelable(false /* cancelable */)
+ .setNeutralButton(R.string.ok, null /* listener */);
+ AlertDialog alertDialog = builder.create();
+ alertDialog.getWindow().setType(
+ WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
+ alertDialog.show();
}
}
}
@@ -101,14 +114,13 @@
@Override
public void onClick(View v) {
- Intent intent = new Intent(mContext, KeyguardEsimArea.class);
- intent.setAction(ACTION_DISABLE_ESIM);
+ Intent intent = new Intent(ACTION_DISABLE_ESIM);
intent.setPackage(mContext.getPackageName());
- PendingIntent callbackIntent = PendingIntent.getBroadcast(
+ PendingIntent callbackIntent = PendingIntent.getBroadcastAsUser(
mContext,
0 /* requestCode */,
intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT, UserHandle.SYSTEM);
mEuiccManager
.switchToSubscription(SubscriptionManager.INVALID_SUBSCRIPTION_ID, callbackIntent);
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index e7432ba..703b205 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -131,7 +131,7 @@
}
if (isEsimLocked) {
- msg = msg + " " + rez.getString(R.string.kg_sim_lock_instructions_esim);
+ msg = rez.getString(R.string.kg_sim_lock_esim_instructions, msg);
}
mSecurityMessageDisplay.setMessage(msg);
@@ -187,6 +187,10 @@
msgId = isDefault ? R.string.kg_sim_pin_instructions : R.string.kg_password_pin_failed;
displayMessage = getContext().getString(msgId);
}
+ if (KeyguardEsimArea.isEsimLocked(mContext, mSubId)) {
+ displayMessage = getResources()
+ .getString(R.string.kg_sim_lock_esim_instructions, displayMessage);
+ }
if (DEBUG) Log.d(LOG_TAG, "getPinPasswordErrorMessage:"
+ " attemptsRemaining=" + attemptsRemaining + " displayMessage=" + displayMessage);
return displayMessage;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index afee8ec..347c979 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
@@ -181,7 +181,7 @@
}
}
if (isEsimLocked) {
- msg = msg + " " + rez.getString(R.string.kg_sim_lock_instructions_esim);
+ msg = rez.getString(R.string.kg_sim_lock_esim_instructions, msg);
}
mSecurityMessageDisplay.setMessage(msg);
mSimImageView.setImageTintList(ColorStateList.valueOf(color));
@@ -231,6 +231,10 @@
R.string.kg_password_puk_failed;
displayMessage = getContext().getString(msgId);
}
+ if (KeyguardEsimArea.isEsimLocked(mContext, mSubId)) {
+ displayMessage = getResources()
+ .getString(R.string.kg_sim_lock_esim_instructions, displayMessage);
+ }
if (DEBUG) Log.d(LOG_TAG, "getPukPasswordErrorMessage:"
+ " attemptsRemaining=" + attemptsRemaining + " displayMessage=" + displayMessage);
return displayMessage;