1 /*
2  * Copyright (C) 2018 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 
17 package com.android.internal.telephony.uicc.euicc.apdu;
18 
19 /**
20  * Parts of an APDU command.
21  *
22  * @hide
23  */
24 class ApduCommand {
25     /** Channel of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
26     public final int channel;
27 
28     /** Class of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
29     public final int cla;
30 
31     /** Instruction of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
32     public final int ins;
33 
34     /** Parameter 1 of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
35     public final int p1;
36 
37     /** Parameter 2 of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
38     public final int p2;
39 
40     /** Parameter 3 of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
41     public final int p3;
42 
43     /** Command data of an APDU as defined in GlobalPlatform Card Specification v.2.3. */
44     public final String cmdHex;
45 
46     /**
47      * isEs10 indicates that the current streaming APDU contains an ES10 command or it is a regular
48      * APDU. (As per spec SGP.22 V3.0, ES10 commands needs to be sent over command port of MEP-A1)
49      */
50     public final boolean isEs10;
51 
52     /** The parameters are defined as in GlobalPlatform Card Specification v.2.3. */
ApduCommand(int channel, int cla, int ins, int p1, int p2, int p3, String cmdHex)53     ApduCommand(int channel, int cla, int ins, int p1, int p2, int p3, String cmdHex) {
54         this.channel = channel;
55         this.cla = cla;
56         this.ins = ins;
57         this.p1 = p1;
58         this.p2 = p2;
59         this.p3 = p3;
60         this.cmdHex = cmdHex;
61         // TODO: Currently ApduCommand is used for ES10 commands, so updating to true by default.
62         //  Modify it in case used for non ES10 commands in future.
63         this.isEs10 = true;
64     }
65 
66     @Override
toString()67     public String toString() {
68         return "ApduCommand(channel=" + channel + ", cla=" + cla + ", ins=" + ins + ", p1=" + p1
69                 + ", p2=" + p2 + ", p3=" + p3 + ", cmd=" + cmdHex + ", isEs10=" + isEs10 + ")";
70     }
71 }
72