blob: 44ba70cdf28b4cc0393738277b5b3f0bd054fc93 [file] [log] [blame]
Shishir Agrawala122e8d2014-07-29 21:15:42 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.telephony;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22
23/**
24 * Response to the {@link TelephonyManager#iccOpenLogicalChannel} command.
25 */
26public class IccOpenLogicalChannelResponse implements Parcelable {
Shishir Agrawalef489ef2014-08-25 08:53:29 -070027 /**
28 * Indicates an invalid channel.
29 */
Shishir Agrawaled62dd42014-09-04 12:32:00 -070030 public static final int INVALID_CHANNEL = -1;
Shishir Agrawala122e8d2014-07-29 21:15:42 -070031
Shishir Agrawalef489ef2014-08-25 08:53:29 -070032 /**
33 * Possible status values returned by open channel command.
34 *
35 * STATUS_NO_ERROR: Open channel command returned successfully.
36 * STATUS_MISSING_RESOURCE: No logical channels available.
37 * STATUS_NO_SUCH_ELEMENT: AID not found on UICC.
38 * STATUS_UNKNOWN_ERROR: Unknown error in open channel command.
39 */
Shishir Agrawaled62dd42014-09-04 12:32:00 -070040 public static final int STATUS_NO_ERROR = 1;
41 public static final int STATUS_MISSING_RESOURCE = 2;
42 public static final int STATUS_NO_SUCH_ELEMENT = 3;
43 public static final int STATUS_UNKNOWN_ERROR = 4;
Shishir Agrawala122e8d2014-07-29 21:15:42 -070044
45 private final int mChannel;
46 private final int mStatus;
47 private final byte[] mSelectResponse;
48
49 /**
50 * Constructor.
51 *
52 * @hide
53 */
54 public IccOpenLogicalChannelResponse(int channel, int status, byte[] selectResponse) {
55 mChannel = channel;
56 mStatus = status;
57 mSelectResponse = selectResponse;
58 }
59
60 /**
61 * Construct a IccOpenLogicalChannelResponse from a given parcel.
62 */
63 private IccOpenLogicalChannelResponse(Parcel in) {
64 mChannel = in.readInt();
65 mStatus = in.readInt();
66 int arrayLength = in.readInt();
67 if (arrayLength > 0) {
68 mSelectResponse = new byte[arrayLength];
69 in.readByteArray(mSelectResponse);
70 } else {
71 mSelectResponse = null;
72 }
73 }
74
75 /**
76 * @return the channel id.
77 */
78 public int getChannel() {
79 return mChannel;
80 }
81
82 /**
83 * @return the status of the command.
84 */
85 public int getStatus() {
86 return mStatus;
87 }
88
89 /**
90 * @return the select response.
91 */
92 public byte[] getSelectResponse() {
93 return mSelectResponse;
94 }
95
96 @Override
97 public int describeContents() {
98 return 0;
99 }
100
101 @Override
102 public void writeToParcel(Parcel out, int flags) {
103 out.writeInt(mChannel);
104 out.writeInt(mStatus);
Shishir Agrawal1521e5a2014-07-31 19:01:12 -0700105 if (mSelectResponse != null && mSelectResponse.length > 0) {
Shishir Agrawala122e8d2014-07-29 21:15:42 -0700106 out.writeInt(mSelectResponse.length);
107 out.writeByteArray(mSelectResponse);
108 } else {
109 out.writeInt(0);
110 }
111 }
112
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700113 public static final @android.annotation.NonNull Parcelable.Creator<IccOpenLogicalChannelResponse> CREATOR
Shishir Agrawala122e8d2014-07-29 21:15:42 -0700114 = new Parcelable.Creator<IccOpenLogicalChannelResponse>() {
115
116 @Override
117 public IccOpenLogicalChannelResponse createFromParcel(Parcel in) {
118 return new IccOpenLogicalChannelResponse(in);
119 }
120
121 public IccOpenLogicalChannelResponse[] newArray(int size) {
122 return new IccOpenLogicalChannelResponse[size];
123 }
124 };
125
126 @Override
127 public String toString() {
128 return "Channel: " + mChannel + " Status: " + mStatus;
129 }
130}