summaryrefslogtreecommitdiffstats
path: root/src/com/android/nfc/nxp/NativeNfcManager.java
diff options
context:
space:
mode:
authorJeff Hamilton <jham@android.com>2011-06-13 22:22:11 -0500
committerJeff Hamilton <jham@android.com>2011-06-13 23:00:59 -0500
commit81c476dd93f059d4082c15369894d5d16fbea05d (patch)
treef705333cb44d05731a763284eea7ed755577bef7 /src/com/android/nfc/nxp/NativeNfcManager.java
parentfbd90779b1525b254726eb58d07883ca74e1b21c (diff)
downloadpackages_apps_nfc-81c476dd93f059d4082c15369894d5d16fbea05d.zip
packages_apps_nfc-81c476dd93f059d4082c15369894d5d16fbea05d.tar.gz
packages_apps_nfc-81c476dd93f059d4082c15369894d5d16fbea05d.tar.bz2
Relocate the libnfc-nxp Java bridge sources.
Change-Id: I0b743245d60bf9c47ce84ec0ab7fd8c5b6202ec9
Diffstat (limited to 'src/com/android/nfc/nxp/NativeNfcManager.java')
-rwxr-xr-xsrc/com/android/nfc/nxp/NativeNfcManager.java129
1 files changed, 129 insertions, 0 deletions
diff --git a/src/com/android/nfc/nxp/NativeNfcManager.java b/src/com/android/nfc/nxp/NativeNfcManager.java
new file mode 100755
index 0000000..97d8e4f
--- /dev/null
+++ b/src/com/android/nfc/nxp/NativeNfcManager.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.nfc.nxp;
+
+import com.android.nfc.NfcService;
+
+import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
+import android.content.Context;
+
+/**
+ * Native interface to the NFC Manager functions
+ */
+public class NativeNfcManager {
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String INTERNAL_LLCP_LINK_STATE_CHANGED_ACTION = "com.android.nfc.action.INTERNAL_LLCP_LINK_STATE_CHANGED";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String INTERNAL_LLCP_LINK_STATE_CHANGED_EXTRA = "com.android.nfc.extra.INTERNAL_LLCP_LINK_STATE";
+
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String INTERNAL_TARGET_DESELECTED_ACTION = "com.android.nfc.action.INTERNAL_TARGET_DESELECTED";
+
+ /* Native structure */
+ private int mNative;
+
+ private final NfcService mNfcService;
+
+ public NativeNfcManager(Context context, NfcService service) {
+ mNfcService = service;
+ }
+
+ public native boolean initializeNativeStructure();
+
+ public native boolean initialize();
+
+ public native boolean deinitialize();
+
+ public native void enableDiscovery();
+
+ public native void disableDiscovery();
+
+ public native int[] doGetSecureElementList();
+
+ public native void doSelectSecureElement();
+
+ public native void doDeselectSecureElement();
+
+ public native int doGetLastError();
+
+ public native NativeLlcpConnectionlessSocket doCreateLlcpConnectionlessSocket(int nSap);
+
+ public native NativeLlcpServiceSocket doCreateLlcpServiceSocket(int nSap, String sn, int miu,
+ int rw, int linearBufferLength);
+
+ public native NativeLlcpSocket doCreateLlcpSocket(int sap, int miu, int rw,
+ int linearBufferLength);
+
+ public native boolean doCheckLlcp();
+
+ public native boolean doActivateLlcp();
+
+ public native void doResetTimeouts();
+ public void resetTimeouts() {
+ doResetTimeouts();
+ }
+
+ public native boolean doSetTimeout(int tech, int timeout);
+ public boolean setTimeout(int tech, int timeout) {
+ return doSetTimeout(tech, timeout);
+ }
+
+ /**
+ * Notifies Ndef Message (TODO: rename into notifyTargetDiscovered)
+ */
+ private void notifyNdefMessageListeners(NativeNfcTag tag) {
+ mNfcService.sendMessage(NfcService.MSG_NDEF_TAG, tag);
+ }
+
+ /**
+ * Notifies transaction
+ */
+ private void notifyTargetDeselected() {
+ mNfcService.sendMessage(NfcService.MSG_TARGET_DESELECTED, null);
+ }
+
+ /**
+ * Notifies transaction
+ */
+ private void notifyTransactionListeners(byte[] aid) {
+ mNfcService.sendMessage(NfcService.MSG_CARD_EMULATION, aid);
+ }
+
+ /**
+ * Notifies P2P Device detected, to activate LLCP link
+ */
+ private void notifyLlcpLinkActivation(NativeP2pDevice device) {
+ mNfcService.sendMessage(NfcService.MSG_LLCP_LINK_ACTIVATION, device);
+ }
+
+ /**
+ * Notifies P2P Device detected, to activate LLCP link
+ */
+ private void notifyLlcpLinkDeactivated(NativeP2pDevice device) {
+ mNfcService.sendMessage(NfcService.MSG_LLCP_LINK_DEACTIVATED, device);
+ }
+
+ private void notifySeFieldActivated() {
+ mNfcService.sendMessage(NfcService.MSG_SE_FIELD_ACTIVATED, null);
+ }
+
+ private void notifySeFieldDeactivated() {
+ mNfcService.sendMessage(NfcService.MSG_SE_FIELD_DEACTIVATED, null);
+ }
+}