Migrate getSimStateForSlotIndex to TelephonyManager
Most of the SIM APIs are in TelephonyManager. SubscriptionManager
handles subscription related information only.
Test: Manual
Bug: 239607619
Change-Id: I18d5ff3a7b4b403e7694c45135ad8fb89a79c208
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 40049fc..5dd7f41 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -111,6 +111,7 @@
import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.TelephonyHistogram;
import android.telephony.TelephonyManager;
+import android.telephony.TelephonyManager.SimState;
import android.telephony.TelephonyScanManager;
import android.telephony.ThermalMitigationRequest;
import android.telephony.UiccCardInfo;
@@ -167,6 +168,7 @@
import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccLogicalChannelRequest;
import com.android.internal.telephony.LocaleTracker;
import com.android.internal.telephony.NetworkScanRequestTracker;
@@ -11635,4 +11637,37 @@
return SmsApplication.getDefaultRespondViaMessageApplicationAsUser(context,
updateIfNeeded, userHandle);
}
+
+ /**
+ * Get the SIM state for the slot index.
+ * For Remote-SIMs, this method returns {@link IccCardConstants.State#UNKNOWN}
+ *
+ * @return SIM state as the ordinal of {@link IccCardConstants.State}
+ */
+ @Override
+ @SimState
+ public int getSimStateForSlotIndex(int slotIndex) {
+ IccCardConstants.State simState;
+ if (slotIndex < 0) {
+ simState = IccCardConstants.State.UNKNOWN;
+ } else {
+ Phone phone = null;
+ try {
+ phone = PhoneFactory.getPhone(slotIndex);
+ } catch (IllegalStateException e) {
+ // ignore
+ }
+ if (phone == null) {
+ simState = IccCardConstants.State.UNKNOWN;
+ } else {
+ IccCard icc = phone.getIccCard();
+ if (icc == null) {
+ simState = IccCardConstants.State.UNKNOWN;
+ } else {
+ simState = icc.getState();
+ }
+ }
+ }
+ return simState.ordinal();
+ }
}
\ No newline at end of file