Skip to content

Commit 367f41f

Browse files
author
Nick Pelly
committed
Implement new NFC-EE API's as shared library (frameworks/base).
Change-Id: I45c4eaf59ec78167fc236fdd59676465a5e1bcb7
1 parent dfcb8c5 commit 367f41f

File tree

11 files changed

+357
-218
lines changed

11 files changed

+357
-218
lines changed

Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ LOCAL_SRC_FILES += \
121121
core/java/android/nfc/ILlcpServiceSocket.aidl \
122122
core/java/android/nfc/ILlcpSocket.aidl \
123123
core/java/android/nfc/INfcAdapter.aidl \
124+
core/java/android/nfc/INfcAdapterExtras.aidl \
124125
core/java/android/nfc/INfcTag.aidl \
125126
core/java/android/nfc/IP2pInitiator.aidl \
126127
core/java/android/nfc/IP2pTarget.aidl \
127-
core/java/android/nfc/INfcSecureElement.aidl \
128128
core/java/android/os/IHardwareService.aidl \
129129
core/java/android/os/IMessenger.aidl \
130130
core/java/android/os/INetworkManagementService.aidl \

CleanSpec.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/androi
7373
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/trustedlogic)
7474
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/com/trustedlogic)
7575
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc/INdefTag.java)
76+
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc)
7677

7778
# ************************************************
7879
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST

core/java/android/nfc/INfcAdapter.aidl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import android.nfc.ILlcpConnectionlessSocket;
2828
import android.nfc.INfcTag;
2929
import android.nfc.IP2pTarget;
3030
import android.nfc.IP2pInitiator;
31-
import android.nfc.INfcSecureElement;
31+
import android.nfc.INfcAdapterExtras;
3232

3333
/**
3434
* @hide
@@ -41,13 +41,12 @@ interface INfcAdapter
4141
INfcTag getNfcTagInterface();
4242
IP2pTarget getP2pTargetInterface();
4343
IP2pInitiator getP2pInitiatorInterface();
44-
INfcSecureElement getNfcSecureElementInterface();
44+
INfcAdapterExtras getNfcAdapterExtrasInterface();
4545

4646
// NfcAdapter-class related methods
4747
boolean isEnabled();
4848
NdefMessage localGet();
4949
void localSet(in NdefMessage message);
50-
void openTagConnection(in Tag tag);
5150
void enableForegroundDispatch(in ComponentName activity, in PendingIntent intent,
5251
in IntentFilter[] filters, in TechListParcel techLists);
5352
void disableForegroundDispatch(in ComponentName activity);
@@ -59,12 +58,8 @@ interface INfcAdapter
5958
int createLlcpConnectionlessSocket(int sap);
6059
int createLlcpServiceSocket(int sap, String sn, int miu, int rw, int linearBufferLength);
6160
int createLlcpSocket(int sap, int miu, int rw, int linearBufferLength);
62-
int deselectSecureElement();
6361
boolean disable();
6462
boolean enable();
6563
String getProperties(String param);
66-
int[] getSecureElementList();
67-
int getSelectedSecureElement();
68-
int selectSecureElement(int seId);
6964
int setProperties(String param, String value);
70-
}
65+
}

core/java/android/nfc/INfcSecureElement.aidl renamed to core/java/android/nfc/INfcAdapterExtras.aidl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010 The Android Open Source Project
2+
* Copyright (C) 2011 The Android Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,13 +16,15 @@
1616

1717
package android.nfc;
1818

19+
import android.os.Bundle;
20+
1921
/**
2022
* {@hide}
2123
*/
22-
interface INfcSecureElement {
23-
int openSecureElementConnection();
24-
int closeSecureElementConnection(int nativeHandle);
25-
byte[] exchangeAPDU(int nativeHandle, in byte[] data);
26-
int[] getSecureElementTechList(int nativeHandle);
27-
byte[] getSecureElementUid(int nativeHandle);
28-
}
24+
interface INfcAdapterExtras {
25+
Bundle open(IBinder b);
26+
Bundle close();
27+
Bundle transceive(in byte[] data_in);
28+
int getCardEmulationRoute();
29+
void setCardEmulationRoute(int route);
30+
}

core/java/android/nfc/NfcAdapter.java

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,6 @@ public final class NfcAdapter {
156156
*/
157157
public static final String EXTRA_ID = "android.nfc.extra.ID";
158158

159-
/**
160-
* Broadcast Action: a transaction with a secure element has been detected.
161-
* <p>
162-
* Always contains the extra field
163-
* {@link android.nfc.NfcAdapter#EXTRA_AID}
164-
* @hide
165-
*/
166-
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
167-
public static final String ACTION_TRANSACTION_DETECTED =
168-
"android.nfc.action.TRANSACTION_DETECTED";
169-
170-
/**
171-
* Broadcast Action: an RF field ON has been detected.
172-
* @hide
173-
*/
174-
public static final String ACTION_RF_FIELD_ON_DETECTED =
175-
"android.nfc.action.RF_FIELD_ON_DETECTED";
176-
177-
/**
178-
* Broadcast Action: an RF Field OFF has been detected.
179-
* @hide
180-
*/
181-
public static final String ACTION_RF_FIELD_OFF_DETECTED =
182-
"android.nfc.action.RF_FIELD_OFF_DETECTED";
183-
184159
/**
185160
* Broadcast Action: an adapter's state changed between enabled and disabled.
186161
*
@@ -200,15 +175,6 @@ public final class NfcAdapter {
200175
*/
201176
public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled";
202177

203-
/**
204-
* Mandatory byte array extra field in
205-
* {@link android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED}.
206-
* <p>
207-
* Contains the AID of the applet involved in the transaction.
208-
* @hide
209-
*/
210-
public static final String EXTRA_AID = "android.nfc.extra.AID";
211-
212178
/**
213179
* LLCP link status: The LLCP link is activated.
214180
* @hide
@@ -691,39 +657,14 @@ public NdefMessage getLocalNdefMessage() {
691657
}
692658

693659
/**
694-
* Create an Nfc Secure Element Connection
695660
* @hide
696661
*/
697-
public NfcSecureElement createNfcSecureElementConnection() {
662+
public INfcAdapterExtras getNfcAdapterExtrasInterface() {
698663
try {
699-
return new NfcSecureElement(sService.getNfcSecureElementInterface());
664+
return sService.getNfcAdapterExtrasInterface();
700665
} catch (RemoteException e) {
701-
Log.e(TAG, "createNfcSecureElementConnection failed", e);
666+
attemptDeadServiceRecovery(e);
702667
return null;
703668
}
704669
}
705-
706-
/**
707-
* To change the Secure Element Card Emulation state (ON/OFF)
708-
* @hide
709-
*/
710-
public void changeNfcSecureElementCardEmulationState(boolean state)
711-
{
712-
int seId = 11259375;
713-
if(state){
714-
/* Enable card emulation */
715-
try {
716-
sService.selectSecureElement(seId);
717-
} catch (RemoteException e) {
718-
Log.e(TAG, "Enable card emulation failed", e);
719-
}
720-
}else{
721-
/* Disable card emulation */
722-
try {
723-
sService.deselectSecureElement();
724-
} catch (RemoteException e) {
725-
Log.e(TAG, " card emulation failed", e);
726-
}
727-
}
728-
}
729670
}

core/java/android/nfc/NfcSecureElement.java

Lines changed: 0 additions & 138 deletions
This file was deleted.

core/res/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
<protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
8888

8989
<protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
90-
<protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" />
90+
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
91+
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
92+
<protected-broadcast android:name="com.android.nfc_extras.action.AID_SELECTED" />
9193

9294
<!-- ====================================== -->
9395
<!-- Permissions for things that cost money -->

nfc-extras/Android.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
5+
LOCAL_MODULE_TAGS := optional
6+
7+
LOCAL_SRC_FILES := $(call all-subdir-java-files)
8+
9+
LOCAL_MODULE:= com.android.nfc_extras
10+
11+
include $(BUILD_JAVA_LIBRARY)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
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+
<permissions>
18+
<library name="com.android.nfc_extras"
19+
file="/system/framework/com.android.nfc_extras.jar" />
20+
</permissions>

0 commit comments

Comments
 (0)