Android NFC架構(gòu)分析
Android中對NFC的實(shí)現(xiàn)代碼分布在如下幾個(gè)地方:
本文引用地址:http://www.ex-cimer.com/article/201809/388756.htm./frameworks/base/core/java/android/nfc/
./frameworks/base/core/java/android/nfc/tech
./frameworks/base/core/java/com/android/internal/nfc/
./external/libnfc-nxp
./packages/apps/nfc
其中
./external/libnfc-nxp是用C語言編寫的函數(shù)庫,編譯生成libnfc和libnfc_ndef兩個(gè)函數(shù)庫。libnfc是一個(gè)主要的庫,實(shí)現(xiàn)了NFC Stack的大部分功能,主要供NFC的服務(wù)進(jìn)程調(diào)用。
libnfc_ndef是一個(gè)很小的函數(shù)庫,主要是實(shí)現(xiàn)NDEF消息的解析,供Framework調(diào)用。
./packages/apps/nfc是一個(gè)類似于電話本的應(yīng)用程序,但這個(gè)程序在手機(jī)開機(jī)后自動(dòng)啟動(dòng),一直運(yùn)行,是作為NFC的服務(wù)進(jìn)程存在的。是NFC架構(gòu)中的核心。
./frameworks/base/core/java/android/nfc/,./frameworks/base/core/java/android/nfc/tech和./frameworks/base/core/java/com/android/internal/nfc/這三個(gè)目錄
實(shí)現(xiàn)了NFC的應(yīng)用接口,其中./frameworks/base/core/java/com/android/internal/nfc/是一些內(nèi)部類或結(jié)構(gòu),不對外開放,僅供./frameworks/base/core/java/android/nfc/和
./frameworks/base/core/java/android/nfc/tech中的類調(diào)用。
./frameworks/base/core/java/android/nfc實(shí)現(xiàn)了接口包c(diǎn)om.android.nfc,./frameworks/base/core/java/android/nfc/tech實(shí)現(xiàn)了接口包c(diǎn)om.android.nfc.tech.
圖示如下:
附錄:
NFC Service的說明
NFC: Move NFC service implementation out of system_server.
NFC service is now an application service in packages/apps/Nfc.
NFC service is registered through ServiceManager.addService(), and the proxy object NfcAdapter obtains a handle to it through
ServiceManager.getService().
**Important** Had to add new symbols AID_NFC / NFC_UID / android.uid.nfc and modify service_manager.c, Process.java and PackageManagerService.java
in order to force the com.android.nfc process to take a fixed uid, so that it can use ServiceManager.addService().
Most of the JNI has moved to packages/apps/Nfc/jni. However NdefRecord and NdefMessage require some in-process native code, so
android_com_NdefMessage.cpp and android_com_NdefRecord.cpp stay in frameworks/base/core/jni. They link to a very small library libnfc_ndef.so
that implements NDEF message parsing. This has been added to core.mk so all devices (even without NFC hardware) can work with NDEF data.
評(píng)論