Skip to content

Commit 78a9766

Browse files
jparksAndroid (Google) Code Review
authored andcommitted
Merge "Implement teardown script." into gingerbread
2 parents 84d3407 + ab8f48c commit 78a9766

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+

core/java/android/nfc/INfcAdapterExtras.aidl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package android.nfc;
1818

19+
import android.nfc.ApduList;
1920
import 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
}

nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.annotation.SdkConstant;
2020
import android.annotation.SdkConstant.SdkConstantType;
21+
import android.nfc.ApduList;
2122
import android.nfc.INfcAdapterExtras;
2223
import android.nfc.NfcAdapter;
2324
import 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
}

0 commit comments

Comments
 (0)