Merge "Revert "[DO NOT MERGE] Revert "Migrate getSimStateForSlotIndex t...""

This commit is contained in:
Jack Yu
2023-03-14 16:28:49 +00:00
committed by Gerrit Code Review
4 changed files with 46 additions and 45 deletions

View File

@@ -2586,41 +2586,18 @@ public class SubscriptionManager {
} }
/** /**
* Returns a constant indicating the state of sim for the slot index. * Set a field in the subscription database. Note not all fields are supported.
* *
* @param slotIndex * @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.
* *
* {@See TelephonyManager#SIM_STATE_UNKNOWN} * @throws IllegalArgumentException if {@code subscriptionId} is invalid, or the field is not
* {@See TelephonyManager#SIM_STATE_ABSENT} * exposed.
* {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} * @throws SecurityException if callers do not hold the required permission.
* {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} *
* {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} * @see android.provider.Telephony.SimInfo for all the columns.
* {@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 * @hide
*/ */
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)

View File

@@ -3504,7 +3504,7 @@ public class TelephonyManager {
"state as absent"); "state as absent");
return SIM_STATE_ABSENT; return SIM_STATE_ABSENT;
} }
return SubscriptionManager.getSimStateForSlotIndex(slotIndex); return getSimStateForSlotIndex(slotIndex);
} }
/** /**
@@ -3651,9 +3651,7 @@ public class TelephonyManager {
@Deprecated @Deprecated
public @SimState int getSimApplicationState(int physicalSlotIndex) { public @SimState int getSimApplicationState(int physicalSlotIndex) {
int activePort = getFirstActivePortIndex(physicalSlotIndex); int activePort = getFirstActivePortIndex(physicalSlotIndex);
int simState = int simState = getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, activePort));
SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex,
activePort));
return getSimApplicationStateFromSimState(simState); return getSimApplicationStateFromSimState(simState);
} }
@@ -3679,9 +3677,7 @@ public class TelephonyManager {
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
public @SimState int getSimApplicationState(int physicalSlotIndex, int portIndex) { public @SimState int getSimApplicationState(int physicalSlotIndex, int portIndex) {
int simState = int simState = getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex, portIndex));
SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex,
portIndex));
return getSimApplicationStateFromSimState(simState); return getSimApplicationStateFromSimState(simState);
} }
@@ -3750,7 +3746,7 @@ public class TelephonyManager {
*/ */
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION) @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
public @SimState int getSimState(int slotIndex) { public @SimState int getSimState(int slotIndex) {
int simState = SubscriptionManager.getSimStateForSlotIndex(slotIndex); int simState = getSimStateForSlotIndex(slotIndex);
if (simState == SIM_STATE_LOADED) { if (simState == SIM_STATE_LOADED) {
simState = SIM_STATE_READY; simState = SIM_STATE_READY;
} }
@@ -17006,4 +17002,30 @@ public class TelephonyManager {
} }
return false; 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;
}
} }

View File

@@ -272,11 +272,6 @@ interface ISub {
boolean isSubscriptionEnabled(int subId); boolean isSubscriptionEnabled(int subId);
int getEnabledSubscriptionId(int slotIndex); 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); boolean isActiveSubId(int subId, String callingPackage, String callingFeatureId);

View File

@@ -2564,4 +2564,11 @@ interface ITelephony {
* @hide * @hide
*/ */
boolean isRemovableEsimDefaultEuicc(String callingPackage); boolean isRemovableEsimDefaultEuicc(String callingPackage);
/**
* Get the SIM state for the logical SIM slot index.
*
* @param slotIndex Logical SIM slot index.
*/
int getSimStateForSlotIndex(int slotIndex);
} }