Revert "[DO NOT MERGE] Revert "Migrate getSimStateForSlotIndex t..."
Revert submission 2484175-revert-2481148-getSimStateForSlotIndex-UWFWFIPUUM
Reason for revert: reverting the revert as it caused build failures in downstream branches. Exact causes still TBD, see b/273394101.
Reverted changes: /q/submissionid:2484175-revert-2481148-getSimStateForSlotIndex-UWFWFIPUUM
Bug: 273394101
Change-Id: I21a11b312712e947fc609e83e2e651a38358d4ef
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 051d676..0b48c59 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -1005,7 +1005,7 @@
if (isNoSimConfig) {
fileName = getFilenameForNoSimConfig(packageName);
} else {
- if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
+ if (TelephonyManager.getSimStateForSlotIndex(phoneId)
!= TelephonyManager.SIM_STATE_LOADED) {
loge("Skip save config because SIM records are not loaded.");
return;
@@ -1096,7 +1096,7 @@
if (isNoSimConfig) {
fileName = getFilenameForNoSimConfig(packageName);
} else {
- if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
+ if (TelephonyManager.getSimStateForSlotIndex(phoneId)
!= TelephonyManager.SIM_STATE_LOADED) {
loge("Skip restore config because SIM records are not loaded.");
return null;
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ccace4c..976799a 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -109,6 +109,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;
@@ -165,6 +166,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;
@@ -11326,5 +11328,36 @@
}
}
-
+ /**
+ * 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();
+ }
}
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 8cf2215..ed81aed 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -216,7 +216,7 @@
@Override
public int getSimStateForSlotIdx(int slotId) {
- return SubscriptionManager.getSimStateForSlotIndex(slotId);
+ return TelephonyManager.getSimStateForSlotIndex(slotId);
}
@Override