From b9d34ecb2fba2f29b611779eff67a2a8cc448b3b Mon Sep 17 00:00:00 2001 From: Shivakumar Neginal Date: Fri, 13 May 2022 07:36:59 +0000 Subject: [PATCH] [MEP]Uncomment the EuiccManager switchToSubscription changes. Currently targetSdk enforcement inside switchToSubscription (without port) API is commented as apps such as tycho and CBRS are not yet adopted to the new Android T APIs. Test: Manually tested esim scenarios and atest executed Bug: 221887933 Merged-In: I8faf9cf58db7c9204193643d4fa710d6d6608d55 Change-Id: I7b1897df2ff350ef43617c3ede140ef4beb83165 --- .../android/telephony/euicc/EuiccManager.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index eede9dc474f86..a673807a3f974 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -25,18 +25,17 @@ import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Activity; import android.app.PendingIntent; -import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.content.pm.PackageManager; -import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.RemoteException; import android.telephony.SubscriptionInfo; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyFrameworkInitializer; import android.telephony.TelephonyManager; import android.telephony.UiccCardInfo; @@ -1209,18 +1208,16 @@ public class EuiccManager { return; } try { - // TODO: Uncomment below compat change code once callers are ported to use - // switchToSubscription with portIndex for disable operation. - // if (subscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID - // && getIEuiccController().isCompatChangeEnabled(mContext.getOpPackageName(), - // SWITCH_WITHOUT_PORT_INDEX_EXCEPTION_ON_DISABLE)) { - // // Apps targeting on Android T and beyond will get exception whenever - // // switchToSubscription without portIndex is called with INVALID_SUBSCRIPTION_ID. - // Log.e(TAG, "switchToSubscription without portIndex is not allowed for" - // + " disable operation"); - // throw new IllegalArgumentException("Must use switchToSubscription with portIndex" - // + " API for disable operation"); - // } + if (subscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID + && getIEuiccController().isCompatChangeEnabled(mContext.getOpPackageName(), + SWITCH_WITHOUT_PORT_INDEX_EXCEPTION_ON_DISABLE)) { + // Apps targeting on Android T and beyond will get exception whenever + // switchToSubscription without portIndex is called with INVALID_SUBSCRIPTION_ID. + Log.e(TAG, "switchToSubscription without portIndex is not allowed for" + + " disable operation"); + throw new IllegalArgumentException("Must use switchToSubscription with portIndex" + + " API for disable operation"); + } getIEuiccController().switchToSubscription(mCardId, subscriptionId, mContext.getOpPackageName(), callbackIntent); } catch (RemoteException e) {