diff options
author | Shishir Agrawal <shishir@google.com> | 2014-07-29 21:15:42 -0700 |
---|---|---|
committer | Shishir Agrawal <shishir@google.com> | 2014-07-30 18:09:53 -0700 |
commit | a122e8df741456ea34e4a57d205411b8371a16db (patch) | |
tree | 312659c03d1cf99dcab3ffb9367db4f2c266b70d /telephony | |
parent | f9a274c9b8578dda6afeda422bff18b1577028b9 (diff) | |
download | frameworks_base-a122e8df741456ea34e4a57d205411b8371a16db.zip frameworks_base-a122e8df741456ea34e4a57d205411b8371a16db.tar.gz frameworks_base-a122e8df741456ea34e4a57d205411b8371a16db.tar.bz2 |
Add new APIs iccExchangeSimIO and iccTransmitApduBasicChannel to TelephonyManager.
The new APIs are needed to support SEEK.
Also modifies TelephonyManager.iccOpenLogicalChannel to return the status of
the command.
Change-Id: Iff2674fb0e23210f2579cb883e64571347ade5e6
Diffstat (limited to 'telephony')
4 files changed, 238 insertions, 7 deletions
diff --git a/telephony/java/android/telephony/IccOpenLogicalChannelResponse.aidl b/telephony/java/android/telephony/IccOpenLogicalChannelResponse.aidl new file mode 100644 index 0000000..fe28c97 --- /dev/null +++ b/telephony/java/android/telephony/IccOpenLogicalChannelResponse.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package android.telephony; + +parcelable IccOpenLogicalChannelResponse; diff --git a/telephony/java/android/telephony/IccOpenLogicalChannelResponse.java b/telephony/java/android/telephony/IccOpenLogicalChannelResponse.java new file mode 100644 index 0000000..bb5e277 --- /dev/null +++ b/telephony/java/android/telephony/IccOpenLogicalChannelResponse.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + + +/** + * Response to the {@link TelephonyManager#iccOpenLogicalChannel} command. + */ +public class IccOpenLogicalChannelResponse implements Parcelable { + // Indicates an invalid channel. + public static int INVALID_CHANNEL = -1; + + // Possible status values. + public static int NO_ERROR = 1; + public static int MISSING_RESOURCE = 2; + public static int NO_SUCH_ELEMENT = 3; + public static int UNKNOWN_ERROR = 4; + + private final int mChannel; + private final int mStatus; + private final byte[] mSelectResponse; + + /** + * Constructor. + * + * @hide + */ + public IccOpenLogicalChannelResponse(int channel, int status, byte[] selectResponse) { + mChannel = channel; + mStatus = status; + mSelectResponse = selectResponse; + } + + /** + * Construct a IccOpenLogicalChannelResponse from a given parcel. + */ + private IccOpenLogicalChannelResponse(Parcel in) { + mChannel = in.readInt(); + mStatus = in.readInt(); + int arrayLength = in.readInt(); + if (arrayLength > 0) { + mSelectResponse = new byte[arrayLength]; + in.readByteArray(mSelectResponse); + } else { + mSelectResponse = null; + } + } + + /** + * @return the channel id. + */ + public int getChannel() { + return mChannel; + } + + /** + * @return the status of the command. + */ + public int getStatus() { + return mStatus; + } + + /** + * @return the select response. + */ + public byte[] getSelectResponse() { + return mSelectResponse; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(mChannel); + out.writeInt(mStatus); + if (mSelectResponse != null & mSelectResponse.length > 0) { + out.writeInt(mSelectResponse.length); + out.writeByteArray(mSelectResponse); + } else { + out.writeInt(0); + } + } + + public static final Parcelable.Creator<IccOpenLogicalChannelResponse> CREATOR + = new Parcelable.Creator<IccOpenLogicalChannelResponse>() { + + @Override + public IccOpenLogicalChannelResponse createFromParcel(Parcel in) { + return new IccOpenLogicalChannelResponse(in); + } + + public IccOpenLogicalChannelResponse[] newArray(int size) { + return new IccOpenLogicalChannelResponse[size]; + } + }; + + @Override + public String toString() { + return "Channel: " + mChannel + " Status: " + mStatus; + } +} diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 35568cf..0772687 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -26,6 +26,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.util.Log; +import android.util.Pair; import com.android.internal.telecomm.ITelecommService; import com.android.internal.telephony.IPhoneSubInfo; @@ -2348,15 +2349,15 @@ public class TelephonyManager { * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * * @param AID Application id. See ETSI 102.221 and 101.220. - * @return The logical channel id which is negative on error. + * @return an IccOpenLogicalChannelResponse object. */ - public int iccOpenLogicalChannel(String AID) { + public IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID) { try { return getITelephony().iccOpenLogicalChannel(AID); } catch (RemoteException ex) { } catch (NullPointerException ex) { } - return -1; + return null; } /** @@ -2414,6 +2415,62 @@ public class TelephonyManager { } /** + * Transmit an APDU to the ICC card over the basic channel. + * + * Input parameters equivalent to TS 27.007 AT+CSIM command. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @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. If an error occurs, an empty string is returned. + */ + public String iccTransmitApduBasicChannel(int cla, + int instruction, int p1, int p2, int p3, String data) { + try { + return getITelephony().iccTransmitApduBasicChannel(cla, + instruction, p1, p2, p3, data); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return ""; + } + + /** + * Returns the response APDU for a command APDU sent through SIM_IO. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @param fileID + * @param 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. + * @param filePath + * @return The APDU response. + */ + byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, + String filePath) { + try { + return getITelephony().iccExchangeSimIO(fileID, command, p1, p2, + p3, filePath); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return null; + } + + /** * Send ENVELOPE to the SIM and return the response. * * <p>Requires Permission: diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 886de40..72b04cf 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -18,9 +18,10 @@ package com.android.internal.telephony; import android.content.Intent; import android.os.Bundle; -import java.util.List; -import android.telephony.NeighboringCellInfo; import android.telephony.CellInfo; +import android.telephony.IccOpenLogicalChannelResponse; +import android.telephony.NeighboringCellInfo; +import java.util.List; /** @@ -499,9 +500,9 @@ interface ITelephony { * Input parameters equivalent to TS 27.007 AT+CCHO command. * * @param AID Application id. See ETSI 102.221 and 101.220. - * @return The logical channel id which is set to -1 on error. + * @return an IccOpenLogicalChannelResponse object. */ - int iccOpenLogicalChannel(String AID); + IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID); /** * Closes a previously opened logical channel to the ICC card. @@ -535,6 +536,38 @@ interface ITelephony { int p1, int p2, int p3, String data); /** + * Transmit an APDU to the ICC card over the basic channel. + * + * Input parameters equivalent to TS 27.007 AT+CSIM command. + * + * @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. If an error occurs, an empty string is returned. + */ + String iccTransmitApduBasicChannel(int cla, int instruction, + int p1, int p2, int p3, String data); + + /** + * Returns the response APDU for a command APDU sent through SIM_IO. + * + * @param fileID + * @param 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. + * @param filePath + * @return The APDU response. + */ + byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, + String filePath); + + /** * Send ENVELOPE to the SIM and returns the response. * * @param contents String containing SAT/USAT response in hexadecimal |