Skip to content

Commit

Permalink
Implement new NFC-EE API's as shared library (frameworks/base).
Browse files Browse the repository at this point in the history
Change-Id: I45c4eaf59ec78167fc236fdd59676465a5e1bcb7
  • Loading branch information
Nick Pelly committed Mar 11, 2011
1 parent dfcb8c5 commit 367f41f
Show file tree
Hide file tree
Showing 11 changed files with 357 additions and 218 deletions.
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ LOCAL_SRC_FILES += \
core/java/android/nfc/ILlcpServiceSocket.aidl \
core/java/android/nfc/ILlcpSocket.aidl \
core/java/android/nfc/INfcAdapter.aidl \
core/java/android/nfc/INfcAdapterExtras.aidl \
core/java/android/nfc/INfcTag.aidl \
core/java/android/nfc/IP2pInitiator.aidl \
core/java/android/nfc/IP2pTarget.aidl \
core/java/android/nfc/INfcSecureElement.aidl \
core/java/android/os/IHardwareService.aidl \
core/java/android/os/IMessenger.aidl \
core/java/android/os/INetworkManagementService.aidl \
Expand Down
1 change: 1 addition & 0 deletions CleanSpec.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/androi
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/trustedlogic)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/com/trustedlogic)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc/INdefTag.java)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/nfc)

# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
Expand Down
11 changes: 3 additions & 8 deletions core/java/android/nfc/INfcAdapter.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import android.nfc.ILlcpConnectionlessSocket;
import android.nfc.INfcTag;
import android.nfc.IP2pTarget;
import android.nfc.IP2pInitiator;
import android.nfc.INfcSecureElement;
import android.nfc.INfcAdapterExtras;

/**
* @hide
Expand All @@ -41,13 +41,12 @@ interface INfcAdapter
INfcTag getNfcTagInterface();
IP2pTarget getP2pTargetInterface();
IP2pInitiator getP2pInitiatorInterface();
INfcSecureElement getNfcSecureElementInterface();
INfcAdapterExtras getNfcAdapterExtrasInterface();

// NfcAdapter-class related methods
boolean isEnabled();
NdefMessage localGet();
void localSet(in NdefMessage message);
void openTagConnection(in Tag tag);
void enableForegroundDispatch(in ComponentName activity, in PendingIntent intent,
in IntentFilter[] filters, in TechListParcel techLists);
void disableForegroundDispatch(in ComponentName activity);
Expand All @@ -59,12 +58,8 @@ interface INfcAdapter
int createLlcpConnectionlessSocket(int sap);
int createLlcpServiceSocket(int sap, String sn, int miu, int rw, int linearBufferLength);
int createLlcpSocket(int sap, int miu, int rw, int linearBufferLength);
int deselectSecureElement();
boolean disable();
boolean enable();
String getProperties(String param);
int[] getSecureElementList();
int getSelectedSecureElement();
int selectSecureElement(int seId);
int setProperties(String param, String value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,13 +16,15 @@

package android.nfc;

import android.os.Bundle;

/**
* {@hide}
*/
interface INfcSecureElement {
int openSecureElementConnection();
int closeSecureElementConnection(int nativeHandle);
byte[] exchangeAPDU(int nativeHandle, in byte[] data);
int[] getSecureElementTechList(int nativeHandle);
byte[] getSecureElementUid(int nativeHandle);
}
interface INfcAdapterExtras {
Bundle open(IBinder b);
Bundle close();
Bundle transceive(in byte[] data_in);
int getCardEmulationRoute();
void setCardEmulationRoute(int route);
}
65 changes: 3 additions & 62 deletions core/java/android/nfc/NfcAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,6 @@ public final class NfcAdapter {
*/
public static final String EXTRA_ID = "android.nfc.extra.ID";

/**
* Broadcast Action: a transaction with a secure element has been detected.
* <p>
* Always contains the extra field
* {@link android.nfc.NfcAdapter#EXTRA_AID}
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_TRANSACTION_DETECTED =
"android.nfc.action.TRANSACTION_DETECTED";

/**
* Broadcast Action: an RF field ON has been detected.
* @hide
*/
public static final String ACTION_RF_FIELD_ON_DETECTED =
"android.nfc.action.RF_FIELD_ON_DETECTED";

/**
* Broadcast Action: an RF Field OFF has been detected.
* @hide
*/
public static final String ACTION_RF_FIELD_OFF_DETECTED =
"android.nfc.action.RF_FIELD_OFF_DETECTED";

/**
* Broadcast Action: an adapter's state changed between enabled and disabled.
*
Expand All @@ -200,15 +175,6 @@ public final class NfcAdapter {
*/
public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled";

/**
* Mandatory byte array extra field in
* {@link android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED}.
* <p>
* Contains the AID of the applet involved in the transaction.
* @hide
*/
public static final String EXTRA_AID = "android.nfc.extra.AID";

/**
* LLCP link status: The LLCP link is activated.
* @hide
Expand Down Expand Up @@ -691,39 +657,14 @@ public NdefMessage getLocalNdefMessage() {
}

/**
* Create an Nfc Secure Element Connection
* @hide
*/
public NfcSecureElement createNfcSecureElementConnection() {
public INfcAdapterExtras getNfcAdapterExtrasInterface() {
try {
return new NfcSecureElement(sService.getNfcSecureElementInterface());
return sService.getNfcAdapterExtrasInterface();
} catch (RemoteException e) {
Log.e(TAG, "createNfcSecureElementConnection failed", e);
attemptDeadServiceRecovery(e);
return null;
}
}

/**
* To change the Secure Element Card Emulation state (ON/OFF)
* @hide
*/
public void changeNfcSecureElementCardEmulationState(boolean state)
{
int seId = 11259375;
if(state){
/* Enable card emulation */
try {
sService.selectSecureElement(seId);
} catch (RemoteException e) {
Log.e(TAG, "Enable card emulation failed", e);
}
}else{
/* Disable card emulation */
try {
sService.deselectSecureElement();
} catch (RemoteException e) {
Log.e(TAG, " card emulation failed", e);
}
}
}
}
138 changes: 0 additions & 138 deletions core/java/android/nfc/NfcSecureElement.java

This file was deleted.

4 changes: 3 additions & 1 deletion core/res/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
<protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />

<protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
<protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" />
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
<protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
<protected-broadcast android:name="com.android.nfc_extras.action.AID_SELECTED" />

<!-- ====================================== -->
<!-- Permissions for things that cost money -->
Expand Down
11 changes: 11 additions & 0 deletions nfc-extras/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_MODULE:= com.android.nfc_extras

include $(BUILD_JAVA_LIBRARY)
20 changes: 20 additions & 0 deletions nfc-extras/com.android.nfc_extras.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<permissions>
<library name="com.android.nfc_extras"
file="/system/framework/com.android.nfc_extras.jar" />
</permissions>
Loading

0 comments on commit 367f41f

Please sign in to comment.