From 69d49298eeb35b7af5e2f363869141fbc72868b5 Mon Sep 17 00:00:00 2001 From: Sebastian Pickl Date: Mon, 13 Mar 2023 10:28:57 +0000 Subject: [PATCH] [DO NOT MERGE] Revert "Migrate getSimStateForSlotIndex to TelephonyManager" Revert submission 2481148-getSimStateForSlotIndex Reason for revert: trying to find culprit for https://android-build.googleplex.com/builds/tests/view?testResultId=TR96728544297958511&legacy=&invocationId=I86700010138773900 Reverted changes: /q/submissionid:2481148-getSimStateForSlotIndex Change-Id: I8659ba8a581f9fdaa918dc39866f523999338ca8 --- .../telephony/SubscriptionManager.java | 41 +++++++++++++++---- .../android/telephony/TelephonyManager.java | 38 ++++------------- .../com/android/internal/telephony/ISub.aidl | 5 +++ .../internal/telephony/ITelephony.aidl | 7 ---- 4 files changed, 45 insertions(+), 46 deletions(-) diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 59b822ebecbfa..46cf979fa8e3a 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -2586,18 +2586,41 @@ public class SubscriptionManager { } /** - * Set a field in the subscription database. Note not all fields are supported. + * Returns a constant indicating the state of sim for the slot index. * - * @param subscriptionId Subscription Id of Subscription. - * @param columnName Column name in the database. Note not all fields are supported. - * @param value Value to store in the database. + * @param slotIndex * - * @throws IllegalArgumentException if {@code subscriptionId} is invalid, or the field is not - * exposed. - * @throws SecurityException if callers do not hold the required permission. - * - * @see android.provider.Telephony.SimInfo for all the columns. + * {@See TelephonyManager#SIM_STATE_UNKNOWN} + * {@See TelephonyManager#SIM_STATE_ABSENT} + * {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} + * {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} + * {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} + * {@See TelephonyManager#SIM_STATE_READY} + * {@See TelephonyManager#SIM_STATE_NOT_READY} + * {@See TelephonyManager#SIM_STATE_PERM_DISABLED} + * {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} * + * {@hide} + */ + public static int getSimStateForSlotIndex(int slotIndex) { + int simState = TelephonyManager.SIM_STATE_UNKNOWN; + + try { + ISub iSub = TelephonyManager.getSubscriptionService(); + if (iSub != null) { + simState = iSub.getSimStateForSlotIndex(slotIndex); + } + } catch (RemoteException ex) { + } + + return simState; + } + + /** + * Store properties associated with SubscriptionInfo in database + * @param subId Subscription Id of Subscription + * @param propKey Column name in database associated with SubscriptionInfo + * @param propValue Value to store in DB for particular subId & column name * @hide */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 9d418e144f4ca..7a19d36ba7437 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -3504,7 +3504,7 @@ public class TelephonyManager { "state as absent"); return SIM_STATE_ABSENT; } - return getSimStateForSlotIndex(slotIndex); + return SubscriptionManager.getSimStateForSlotIndex(slotIndex); } /** @@ -3651,7 +3651,9 @@ public class TelephonyManager { @Deprecated public @SimState int getSimApplicationState(int physicalSlotIndex) { int activePort = getFirstActivePortIndex(physicalSlotIndex); - int simState = getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, activePort)); + int simState = + SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, + activePort)); return getSimApplicationStateFromSimState(simState); } @@ -3677,7 +3679,9 @@ public class TelephonyManager { @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) public @SimState int getSimApplicationState(int physicalSlotIndex, int portIndex) { - int simState = getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, portIndex)); + int simState = + SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, + portIndex)); return getSimApplicationStateFromSimState(simState); } @@ -3746,7 +3750,7 @@ public class TelephonyManager { */ @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) public @SimState int getSimState(int slotIndex) { - int simState = getSimStateForSlotIndex(slotIndex); + int simState = SubscriptionManager.getSimStateForSlotIndex(slotIndex); if (simState == SIM_STATE_LOADED) { simState = SIM_STATE_READY; } @@ -17002,30 +17006,4 @@ public class TelephonyManager { } return false; } - - /** - * Returns a constant indicating the state of sim for the slot index. - * - * @param slotIndex Logical SIM slot index. - * - * @see TelephonyManager.SimState - * - * @hide - */ - @SimState - public static int getSimStateForSlotIndex(int slotIndex) { - try { - ITelephony telephony = ITelephony.Stub.asInterface( - TelephonyFrameworkInitializer - .getTelephonyServiceManager() - .getTelephonyServiceRegisterer() - .get()); - if (telephony != null) { - return telephony.getSimStateForSlotIndex(slotIndex); - } - } catch (RemoteException e) { - Log.e(TAG, "Error in getSimStateForSlotIndex: " + e); - } - return TelephonyManager.SIM_STATE_UNKNOWN; - } } diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index c5f6902062ff6..2cf5e67ad2877 100644 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -272,6 +272,11 @@ interface ISub { boolean isSubscriptionEnabled(int subId); int getEnabledSubscriptionId(int slotIndex); + /** + * Get the SIM state for the slot index + * @return SIM state as the ordinal of IccCardConstants.State + */ + int getSimStateForSlotIndex(int slotIndex); boolean isActiveSubId(int subId, String callingPackage, String callingFeatureId); diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index ecafe702ea4ed..da1ffcdea812f 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -2564,11 +2564,4 @@ interface ITelephony { * @hide */ boolean isRemovableEsimDefaultEuicc(String callingPackage); - - /** - * Get the SIM state for the logical SIM slot index. - * - * @param slotIndex Logical SIM slot index. - */ - int getSimStateForSlotIndex(int slotIndex); }