Adding getSimApplicationState & getSimSlotMapping

Adding getSimApplicationState & getSimSlotMapping API in TelphonyManager
Test: atest TelephonyManagerTest#getSimSlotMappingTestReadPermission
Test: atest TelephonyManagerTest#getSimCardStateTest
Test: atest TelephonyManagerTest#getSimSlotMappingTest
Bug: 206718882

Change-Id: I40ec6c8083d9e8718a300b119ceb089648b8dea4
This commit is contained in:
sandeepjs
2021-11-17 03:48:51 +00:00
parent 78337f8a21
commit 1fb2b00c3a
3 changed files with 105 additions and 12 deletions

View File

@@ -12273,7 +12273,7 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEmergencyNumberDbVersion(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEmergencyNumberDbVersion();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map<java.lang.Integer,java.lang.Integer> getLogicalToPhysicalSlotMapping(); method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map<java.lang.Integer,java.lang.Integer> getLogicalToPhysicalSlotMapping();
method public int getMaxNumberOfSimultaneouslyActiveSims(); method public int getMaxNumberOfSimultaneouslyActiveSims();
method public static long getMaxNumberVerificationTimeoutMillis(); method public static long getMaxNumberVerificationTimeoutMillis();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String[] getMergedImsisFromGroup(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String[] getMergedImsisFromGroup();
@@ -12281,10 +12281,13 @@ package android.telephony {
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask(); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask();
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState(); method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState();
method public int getSimApplicationState(); method public int getSimApplicationState();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimApplicationState(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimApplicationState(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimApplicationState(int, int);
method public int getSimCardState(); method public int getSimCardState();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimCardState(int); method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimCardState(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSimCardState(int, int);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Locale getSimLocale(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Locale getSimLocale();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Collection<android.telephony.UiccSlotMapping> getSimSlotMapping();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getSupportedRadioAccessFamily(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getSupportedRadioAccessFamily();
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.telephony.RadioAccessSpecifier> getSystemSelectionChannels(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<android.telephony.RadioAccessSpecifier> getSystemSelectionChannels();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public java.util.List<android.telephony.TelephonyHistogram> getTelephonyHistograms(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public java.util.List<android.telephony.TelephonyHistogram> getTelephonyHistograms();

View File

@@ -3465,14 +3465,38 @@ public class TelephonyManager {
* @see #SIM_STATE_PRESENT * @see #SIM_STATE_PRESENT
* *
* @hide * @hide
* @deprecated instead use {@link #getSimCardState(int, int)}
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@Deprecated
public @SimState int getSimCardState(int physicalSlotIndex) { public @SimState int getSimCardState(int physicalSlotIndex) {
int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex)); int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex, DEFAULT_PORT_INDEX));
return getSimCardStateFromSimState(simState); return getSimCardStateFromSimState(simState);
} }
/**
* Returns a constant indicating the state of the device SIM card in a physical slot and
* port index.
*
* @param physicalSlotIndex physical slot index
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
*
* @see #SIM_STATE_UNKNOWN
* @see #SIM_STATE_ABSENT
* @see #SIM_STATE_CARD_IO_ERROR
* @see #SIM_STATE_CARD_RESTRICTED
* @see #SIM_STATE_PRESENT
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public @SimState int getSimCardState(int physicalSlotIndex, int portIndex) {
int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex, portIndex));
return getSimCardStateFromSimState(simState);
}
/** /**
* Converts SIM state to SIM card state. * Converts SIM state to SIM card state.
* @param simState * @param simState
@@ -3493,13 +3517,19 @@ public class TelephonyManager {
/** /**
* Converts a physical slot index to logical slot index. * Converts a physical slot index to logical slot index.
* @param physicalSlotIndex physical slot index * @param physicalSlotIndex physical slot index
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
* @return logical slot index * @return logical slot index
*/ */
private int getLogicalSlotIndex(int physicalSlotIndex) { private int getLogicalSlotIndex(int physicalSlotIndex, int portIndex) {
UiccSlotInfo[] slotInfos = getUiccSlotsInfo(); UiccSlotInfo[] slotInfos = getUiccSlotsInfo();
if (slotInfos != null && physicalSlotIndex >= 0 && physicalSlotIndex < slotInfos.length if (slotInfos != null && physicalSlotIndex >= 0 && physicalSlotIndex < slotInfos.length
&& slotInfos[physicalSlotIndex] != null) { && slotInfos[physicalSlotIndex] != null) {
return slotInfos[physicalSlotIndex].getLogicalSlotIdx(); for (UiccPortInfo portInfo : slotInfos[physicalSlotIndex].getPorts()) {
if (portInfo.getPortIndex() == portIndex) {
return portInfo.getLogicalSlotIndex();
}
}
} }
return SubscriptionManager.INVALID_SIM_SLOT_INDEX; return SubscriptionManager.INVALID_SIM_SLOT_INDEX;
@@ -3539,12 +3569,42 @@ public class TelephonyManager {
* @see #SIM_STATE_LOADED * @see #SIM_STATE_LOADED
* *
* @hide * @hide
* @deprecated instead use {@link #getSimApplicationState(int, int)}
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@Deprecated
public @SimState int getSimApplicationState(int physicalSlotIndex) { public @SimState int getSimApplicationState(int physicalSlotIndex) {
int simState = int simState =
SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex)); SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex,
DEFAULT_PORT_INDEX));
return getSimApplicationStateFromSimState(simState);
}
/**
* Returns a constant indicating the state of the card applications on the device SIM card in
* a physical slot.
*
* @param physicalSlotIndex physical slot index
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
*
* @see #SIM_STATE_UNKNOWN
* @see #SIM_STATE_PIN_REQUIRED
* @see #SIM_STATE_PUK_REQUIRED
* @see #SIM_STATE_NETWORK_LOCKED
* @see #SIM_STATE_NOT_READY
* @see #SIM_STATE_PERM_DISABLED
* @see #SIM_STATE_LOADED
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public @SimState int getSimApplicationState(int physicalSlotIndex, int portIndex) {
int simState =
SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex,
portIndex));
return getSimApplicationStateFromSimState(simState); return getSimApplicationStateFromSimState(simState);
} }
@@ -4143,18 +4203,21 @@ public class TelephonyManager {
* should be {@link #getPhoneCount()} if success, otherwise return an empty map. * should be {@link #getPhoneCount()} if success, otherwise return an empty map.
* *
* @hide * @hide
* @deprecated use {@link #getSimSlotMapping()} instead.
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@NonNull @NonNull
@Deprecated
public Map<Integer, Integer> getLogicalToPhysicalSlotMapping() { public Map<Integer, Integer> getLogicalToPhysicalSlotMapping() {
Map<Integer, Integer> slotMapping = new HashMap<>(); Map<Integer, Integer> slotMapping = new HashMap<>();
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony != null) { if (telephony != null) {
int[] slotMappingArray = telephony.getSlotsMapping(mContext.getOpPackageName()); List<UiccSlotMapping> simSlotsMapping = telephony.getSlotsMapping(
for (int i = 0; i < slotMappingArray.length; i++) { mContext.getOpPackageName());
slotMapping.put(i, slotMappingArray[i]); for (UiccSlotMapping slotMap : simSlotsMapping) {
slotMapping.put(slotMap.getLogicalSlotIndex(), slotMap.getPhysicalSlotIndex());
} }
} }
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -4163,6 +4226,33 @@ public class TelephonyManager {
return slotMapping; return slotMapping;
} }
/**
* Get the mapping from logical slots to physical sim slots and port indexes. Initially the
* logical slot index was mapped to physical slot index, but with support for multi-enabled
* profile(MEP) logical slot is now mapped to port index.
*
* @return a collection of {@link UiccSlotMapping} which indicates the mapping from logical
* slots to ports and physical slots.
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@NonNull
public Collection<UiccSlotMapping> getSimSlotMapping() {
List<UiccSlotMapping> slotMap = new ArrayList<>();
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
slotMap = telephony.getSlotsMapping(mContext.getOpPackageName());
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
return slotMap;
}
// //
// //
// Subscriber Info // Subscriber Info

View File

@@ -2134,9 +2134,9 @@ interface ITelephony {
String callingFeatureId); String callingFeatureId);
/** /**
* Get the mapping from logical slots to physical slots. * Get the mapping from logical slots to port index.
*/ */
int[] getSlotsMapping(String callingPackage); List<UiccSlotMapping> getSlotsMapping(String callingPackage);
/** /**
* Get the IRadio HAL Version encoded as 100 * MAJOR_VERSION + MINOR_VERSION or -1 if unknown * Get the IRadio HAL Version encoded as 100 * MAJOR_VERSION + MINOR_VERSION or -1 if unknown