Merge "[MEP] adding portindex to sim access APIs"

This commit is contained in:
Rambo Wang
2022-03-23 21:42:56 +00:00
committed by Gerrit Code Review
2 changed files with 194 additions and 4 deletions

View File

@@ -11661,10 +11661,14 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getVoiceActivationState(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getVoiceActivationState();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmi(String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmi(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmiForSubscriber(int, String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmiForSubscriber(int, String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean iccCloseLogicalChannelBySlot(int, int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void iccCloseLogicalChannelByPort(int, int, int);
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int, @Nullable String, int); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean iccCloseLogicalChannelBySlot(int, int);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelBySlot(int, int, int, int, int, int, @Nullable String); method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelByPort(int, int, @Nullable String, int);
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelBySlot(int, int, int, int, int, int, int, @Nullable String); method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int, @Nullable String, int);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelByPort(int, int, int, int, int, int, int, @Nullable String);
method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelBySlot(int, int, int, int, int, int, @Nullable String);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelByPort(int, int, int, int, int, int, int, int, @Nullable String);
method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelBySlot(int, int, int, int, int, int, int, @Nullable String);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAnyRadioPoweredOn(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAnyRadioPoweredOn();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApnMetered(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApnMetered(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int);

View File

@@ -6776,10 +6776,12 @@ public class TelephonyManager {
* @param p2 P2 parameter (described in ISO 7816-4). * @param p2 P2 parameter (described in ISO 7816-4).
* @return an IccOpenLogicalChannelResponse object. * @return an IccOpenLogicalChannelResponse object.
* @hide * @hide
* @deprecated instead use {@link #iccOpenLogicalChannelByPort(int, int, String, int)}
*/ */
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi @SystemApi
@Nullable @Nullable
@Deprecated
public IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int slotIndex, public IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int slotIndex,
@Nullable String aid, int p2) { @Nullable String aid, int p2) {
try { try {
@@ -6799,6 +6801,58 @@ public class TelephonyManager {
return null; return null;
} }
/**
* Opens a logical channel to the ICC card using the physical slot index and port index.
*
* Use this method when no subscriptions are available on the SIM and the operation must be
* performed using the physical slot index and port index.
*
* This operation wraps two APDU instructions:
* <ul>
* <li>MANAGE CHANNEL to open a logical channel</li>
* <li>SELECT the given {@code AID} using the given {@code p2}</li>
* </ul>
*
* Per Open Mobile API Specification v3.2 section 6.2.7.h, only p2 values of 0x00, 0x04, 0x08,
* and 0x0C are guaranteed to be supported.
*
* If the SELECT command's status word is not '9000', '62xx', or '63xx', the status word will be
* considered an error and the channel shall not be opened.
*
* Input parameters equivalent to TS 27.007 AT+CCHO command.
*
* @param slotIndex the physical slot index of the ICC card
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
* @param aid Application id. See ETSI 102.221 and 101.220.
* @param p2 P2 parameter (described in ISO 7816-4).
* @return an IccOpenLogicalChannelResponse object.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
@NonNull
public IccOpenLogicalChannelResponse iccOpenLogicalChannelByPort(int slotIndex,
int portIndex, @Nullable String aid, int p2) {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
IccLogicalChannelRequest request = new IccLogicalChannelRequest();
request.slotIndex = slotIndex;
request.portIndex = portIndex;
request.aid = aid;
request.p2 = p2;
request.callingPackage = getOpPackageName();
request.binder = new Binder();
return telephony.iccOpenLogicalChannel(request);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
throw ex.rethrowAsRuntimeException();
}
}
/** /**
* Opens a logical channel to the ICC card. * Opens a logical channel to the ICC card.
* *
@@ -6889,9 +6943,11 @@ public class TelephonyManager {
* iccOpenLogicalChannel. * iccOpenLogicalChannel.
* @return true if the channel was closed successfully. * @return true if the channel was closed successfully.
* @hide * @hide
* @deprecated instead use {@link #iccCloseLogicalChannelByPort(int, int, int)}
*/ */
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi @SystemApi
@Deprecated
public boolean iccCloseLogicalChannelBySlot(int slotIndex, int channel) { public boolean iccCloseLogicalChannelBySlot(int slotIndex, int channel) {
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
@@ -6907,6 +6963,45 @@ public class TelephonyManager {
return false; return false;
} }
/**
* Closes a previously opened logical channel to the ICC card using the physical slot index and
* port index.
*
* Use this method when no subscriptions are available on the SIM and the operation must be
* performed using the physical slot index and port index.
*
* Input parameters equivalent to TS 27.007 AT+CCHC command.
*
* @param slotIndex the physical slot index of the ICC card
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
* @param channel is the channel id to be closed as returned by a successful
* iccOpenLogicalChannel.
*
* @throws IllegalStateException if the Telephony process is not currently available or modem
* currently can't process this command.
* @throws IllegalArgumentException if invalid arguments are passed.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
public void iccCloseLogicalChannelByPort(int slotIndex, int portIndex, int channel) {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
IccLogicalChannelRequest request = new IccLogicalChannelRequest();
request.slotIndex = slotIndex;
request.portIndex = portIndex;
request.channel = channel;
telephony.iccCloseLogicalChannel(request);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
throw ex.rethrowAsRuntimeException();
}
}
/** /**
* Closes a previously opened logical channel to the ICC card. * Closes a previously opened logical channel to the ICC card.
* *
@@ -6978,10 +7073,13 @@ public class TelephonyManager {
* @return The APDU response from the ICC card with the status appended at the end, or null if * @return The APDU response from the ICC card with the status appended at the end, or null if
* there is an issue connecting to the Telephony service. * there is an issue connecting to the Telephony service.
* @hide * @hide
* @deprecated instead use
* {@link #iccTransmitApduLogicalChannelByPort(int, int, int, int, int, int, int, int, String)}
*/ */
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi @SystemApi
@Nullable @Nullable
@Deprecated
public String iccTransmitApduLogicalChannelBySlot(int slotIndex, int channel, int cla, public String iccTransmitApduLogicalChannelBySlot(int slotIndex, int channel, int cla,
int instruction, int p1, int p2, int p3, @Nullable String data) { int instruction, int p1, int p2, int p3, @Nullable String data) {
try { try {
@@ -6996,6 +7094,50 @@ public class TelephonyManager {
return null; return null;
} }
/**
* Transmit an APDU to the ICC card over a logical channel using the physical slot index.
*
* Use this method when no subscriptions are available on the SIM and the operation must be
* performed using the physical slot index.
*
* Input parameters equivalent to TS 27.007 AT+CGLA command.
*
* @param slotIndex the physical slot index of the ICC card
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
* @param channel is the channel id to be closed as returned by a successful
* iccOpenLogicalChannel.
* @param cla Class of the APDU command.
* @param instruction Instruction of the APDU command.
* @param p1 P1 value of the APDU command.
* @param p2 P2 value of the APDU command.
* @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU
* is sent to the SIM.
* @param data Data to be sent with the APDU.
* @return The APDU response from the ICC card with the status appended at the end, or null if
* there is an issue connecting to the Telephony service.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
@NonNull
public String iccTransmitApduLogicalChannelByPort(int slotIndex, int portIndex, int channel,
int cla, int instruction, int p1, int p2, int p3, @Nullable String data) {
String response;
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
response = telephony.iccTransmitApduLogicalChannelByPort(slotIndex, portIndex,
channel, cla, instruction, p1, p2, p3, data);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
throw ex.rethrowAsRuntimeException();
}
return response;
}
/** /**
* Transmit an APDU to the ICC card over a logical channel. * Transmit an APDU to the ICC card over a logical channel.
* *
@@ -7081,10 +7223,13 @@ public class TelephonyManager {
* @return The APDU response from the ICC card with the status appended at * @return The APDU response from the ICC card with the status appended at
* the end. * the end.
* @hide * @hide
* @deprecated instead use
* {@link #iccTransmitApduBasicChannelByPort(int, int, int, int, int, int, int, String)}
*/ */
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi @SystemApi
@NonNull @NonNull
@Deprecated
public String iccTransmitApduBasicChannelBySlot(int slotIndex, int cla, int instruction, int p1, public String iccTransmitApduBasicChannelBySlot(int slotIndex, int cla, int instruction, int p1,
int p2, int p3, @Nullable String data) { int p2, int p3, @Nullable String data) {
try { try {
@@ -7099,6 +7244,47 @@ public class TelephonyManager {
return null; return null;
} }
/**
* Transmit an APDU to the ICC card over the basic channel using the physical slot index.
*
* Use this method when no subscriptions are available on the SIM and the operation must be
* performed using the physical slot index.
*
* Input parameters equivalent to TS 27.007 AT+CSIM command.
*
* @param slotIndex the physical slot index of the ICC card to target
* @param portIndex The port index is an enumeration of the ports available on the UICC.
* Use {@link UiccPortInfo#getPortIndex()} to get portIndex.
* @param cla Class of the APDU command.
* @param instruction Instruction of the APDU command.
* @param p1 P1 value of the APDU command.
* @param p2 P2 value of the APDU command.
* @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU
* is sent to the SIM.
* @param data Data to be sent with the APDU.
* @return The APDU response from the ICC card with the status appended at
* the end.
* @hide
*/
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
@NonNull
public String iccTransmitApduBasicChannelByPort(int slotIndex, int portIndex, int cla,
int instruction, int p1, int p2, int p3, @Nullable String data) {
String response;
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
response = telephony.iccTransmitApduBasicChannelByPort(slotIndex, portIndex,
getOpPackageName(), cla, instruction, p1, p2, p3, data);
} else {
throw new IllegalStateException("telephony service is null.");
}
} catch (RemoteException ex) {
throw ex.rethrowAsRuntimeException();
}
return response;
}
/** /**
* Transmit an APDU to the ICC card over the basic channel. * Transmit an APDU to the ICC card over the basic channel.
* *