File tree Expand file tree Collapse file tree 4 files changed +109
-1
lines changed
nfc-extras/java/com/android/nfc_extras Expand file tree Collapse file tree 4 files changed +109
-1
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2011 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 android.nfc ;
18+
19+ parcelable ApduList ;
Original file line number Diff line number Diff line change 1+ package android .nfc ;
2+
3+ import android .os .Parcel ;
4+ import android .os .Parcelable ;
5+
6+ import java .util .ArrayList ;
7+ import java .util .List ;
8+
9+ /**
10+ * @hide
11+ */
12+ public class ApduList implements Parcelable {
13+
14+ private ArrayList <byte []> commands = new ArrayList <byte []>();
15+
16+ public ApduList () {
17+ }
18+
19+ public void add (byte [] command ) {
20+ commands .add (command );
21+ }
22+
23+ public List <byte []> get () {
24+ return commands ;
25+ }
26+
27+ public static final Parcelable .Creator <ApduList > CREATOR =
28+ new Parcelable .Creator <ApduList >() {
29+ @ Override
30+ public ApduList createFromParcel (Parcel in ) {
31+ return new ApduList (in );
32+ }
33+
34+ @ Override
35+ public ApduList [] newArray (int size ) {
36+ return new ApduList [size ];
37+ }
38+ };
39+
40+ private ApduList (Parcel in ) {
41+ int count = in .readInt ();
42+
43+ for (int i = 0 ; i < count ; i ++) {
44+
45+ int length = in .readInt ();
46+ byte [] cmd = new byte [length ];
47+ in .readByteArray (cmd );
48+ commands .add (cmd );
49+ }
50+ }
51+
52+ @ Override
53+ public int describeContents () {
54+ return 0 ;
55+ }
56+
57+ @ Override
58+ public void writeToParcel (Parcel dest , int flags ) {
59+ dest .writeInt (commands .size ());
60+
61+ for (byte [] cmd : commands ) {
62+ dest .writeInt (cmd .length );
63+ dest .writeByteArray (cmd );
64+ }
65+ }
66+ }
67+
68+
Original file line number Diff line number Diff line change 1616
1717package android.nfc ;
1818
19+ import android.nfc.ApduList ;
1920import android.os.Bundle ;
2021
22+
2123/**
2224 * {@hide}
2325 */
@@ -26,5 +28,7 @@ interface INfcAdapterExtras {
2628 Bundle close ();
2729 Bundle transceive (in byte [] data_in );
2830 int getCardEmulationRoute ();
29- void setCardEmulationRoute (int route );
31+ void setCardEmulationRoute (int route );
32+ void registerTearDownApdus (String packageName , in ApduList apdu );
33+ void unregisterTearDownApdus (String packageName );
3034}
Original file line number Diff line number Diff line change 1818
1919import android .annotation .SdkConstant ;
2020import android .annotation .SdkConstant .SdkConstantType ;
21+ import android .nfc .ApduList ;
2122import android .nfc .INfcAdapterExtras ;
2223import android .nfc .NfcAdapter ;
2324import android .os .RemoteException ;
@@ -184,4 +185,20 @@ public void setCardEmulationRoute(CardEmulationRoute route) {
184185 public NfcExecutionEnvironment getEmbeddedExecutionEnvironment () {
185186 return sEmbeddedEe ;
186187 }
188+
189+ public void registerTearDownApdus (String packageName , ApduList apdus ) {
190+ try {
191+ sService .registerTearDownApdus (packageName , apdus );
192+ } catch (RemoteException e ) {
193+ Log .e (TAG , "" , e );
194+ }
195+ }
196+
197+ public void unregisterTearDownApdus (String packageName ) {
198+ try {
199+ sService .unregisterTearDownApdus (packageName );
200+ } catch (RemoteException e ) {
201+ Log .e (TAG , "" , e );
202+ }
203+ }
187204}
You can’t perform that action at this time.
0 commit comments