From fa2f6ebce486ccb48ce6dded69fa268b9964da7f Mon Sep 17 00:00:00 2001 From: Hyunho Date: Tue, 23 Apr 2024 08:13:01 +0000 Subject: [PATCH] Add a try-catch statement to handle the runtime exception Bug: 335903173 Test: manual test Change-Id: I657a907b01229473ad2ef21b1d843e5d7de74945 --- .../ConvertToEsimPreferenceController.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/com/android/settings/network/telephony/ConvertToEsimPreferenceController.java b/src/com/android/settings/network/telephony/ConvertToEsimPreferenceController.java index cf1350c8cb9..1acfaf89859 100644 --- a/src/com/android/settings/network/telephony/ConvertToEsimPreferenceController.java +++ b/src/com/android/settings/network/telephony/ConvertToEsimPreferenceController.java @@ -125,16 +125,21 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo } EuiccManager euiccManager = (EuiccManager) mContext.getSystemService(Context.EUICC_SERVICE); - if (!euiccManager.isPsimConversionSupported(subInfo.getCarrierId())) { - Log.i(TAG, "subId is not matched with pSIM conversion" - + " supported carriers:" + subInfo.getCarrierId()); - return CONDITIONALLY_UNAVAILABLE; - } - if (findConversionSupportComponent()) { - return mSubscriptionInfoEntity != null && mSubscriptionInfoEntity.isActiveSubscriptionId - && !mSubscriptionInfoEntity.isEmbedded && isActiveSubscription(subId) - ? AVAILABLE - : CONDITIONALLY_UNAVAILABLE; + try { + if (!euiccManager.isPsimConversionSupported(subInfo.getCarrierId())) { + Log.i(TAG, "subId is not matched with pSIM conversion" + + " supported carriers:" + subInfo.getCarrierId()); + return CONDITIONALLY_UNAVAILABLE; + } + if (findConversionSupportComponent()) { + return mSubscriptionInfoEntity != null + && mSubscriptionInfoEntity.isActiveSubscriptionId + && !mSubscriptionInfoEntity.isEmbedded && isActiveSubscription(subId) + ? AVAILABLE + : CONDITIONALLY_UNAVAILABLE; + } + } catch (RuntimeException e) { + Log.e(TAG, "Fail to check pSIM conversion supported carrier: " + e.getMessage()); } return CONDITIONALLY_UNAVAILABLE; }