From 2febffb2658f4de85aee31a11fc2c1ae32077149 Mon Sep 17 00:00:00 2001 From: Qingxi Li Date: Tue, 23 Jan 2018 16:16:35 -0800 Subject: [PATCH] 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 --- .../SystemUI/res-keyguard/values/strings.xml | 8 +++++-- .../android/keyguard/KeyguardEsimArea.java | 22 ++++++++++++++----- .../android/keyguard/KeyguardSimPinView.java | 6 ++++- .../android/keyguard/KeyguardSimPukView.java | 6 ++++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res-keyguard/values/strings.xml b/packages/SystemUI/res-keyguard/values/strings.xml index 3a41681f53e95..8a48e7bd93544 100644 --- a/packages/SystemUI/res-keyguard/values/strings.xml +++ b/packages/SystemUI/res-keyguard/values/strings.xml @@ -124,6 +124,10 @@ Delete Disable eSIM + + Can\u2019t disable eSIM + + The eSIM can\u2019t be disabled due to an error. Enter @@ -146,8 +150,8 @@ Enter SIM PIN. Enter SIM PIN for \"%1$s\". - - Disable eSIM to use device without mobile service. + + %1$s Disable eSIM to use device without mobile service. Enter PIN diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardEsimArea.java index cb5afec79073a..b8a07cdbdc417 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 @@ class KeyguardEsimArea extends Button implements View.OnClickListener { 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 @@ class KeyguardEsimArea extends Button implements View.OnClickListener { @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 e7432ba5855d9..703b20531390a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java @@ -131,7 +131,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { } 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 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { 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 afee8ece26c42..347c9792ec95b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -181,7 +181,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { } } 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 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { 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;