From 0a3f950601dae60642153885a95ca18855f08eb2 Mon Sep 17 00:00:00 2001 From: Jeremy Geslin Date: Mon, 26 Mar 2018 12:10:47 +0200 Subject: [PATCH] Initial commit --- FactoryTestApp/Android.mk | 5 + FactoryTestApp/NfcFactoryTestApp.c | 195 +++++++++++++++++++++++++++++ README.md | 14 +++ conf/libnfc-brcm.conf | 81 ++++++++++++ conf/libnfc-nxp.conf | 86 +++++++++++++ conf/libnfc-nxp_RF.conf | 55 ++++++++ install_NFC.sh | 44 +++++++ nxpnfc_manifest.xml | 9 ++ patch_build.txt | 13 ++ patch_frameworks_base.txt | 12 ++ patch_packages_apps_nfc.txt | 23 ++++ patch_system_nfc.txt | 73 +++++++++++ patch_system_sepolicy.txt | 77 ++++++++++++ 13 files changed, 687 insertions(+) create mode 100755 FactoryTestApp/Android.mk create mode 100755 FactoryTestApp/NfcFactoryTestApp.c create mode 100644 README.md create mode 100755 conf/libnfc-brcm.conf create mode 100755 conf/libnfc-nxp.conf create mode 100755 conf/libnfc-nxp_RF.conf create mode 100755 install_NFC.sh create mode 100644 nxpnfc_manifest.xml create mode 100644 patch_build.txt create mode 100644 patch_frameworks_base.txt create mode 100644 patch_packages_apps_nfc.txt create mode 100644 patch_system_nfc.txt create mode 100644 patch_system_sepolicy.txt diff --git a/FactoryTestApp/Android.mk b/FactoryTestApp/Android.mk new file mode 100755 index 0000000..a105efe --- /dev/null +++ b/FactoryTestApp/Android.mk @@ -0,0 +1,5 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := NfcFactoryTestApp +LOCAL_SRC_FILES := NfcFactoryTestApp.c +include $(BUILD_EXECUTABLE) \ No newline at end of file diff --git a/FactoryTestApp/NfcFactoryTestApp.c b/FactoryTestApp/NfcFactoryTestApp.c new file mode 100755 index 0000000..ea4d601 --- /dev/null +++ b/FactoryTestApp/NfcFactoryTestApp.c @@ -0,0 +1,195 @@ +#include +#include +#include +#include + +#if 0 +#define PRINT_BUF(x,y,z) {int loop; printf(x); \ + for(loop=0;loop> ", pBuff, ret); + return ret; +} + +static int receive(int handle, char *pBuff, int buffLen) +{ + int numRead; + struct timeval tv; + fd_set rfds; + int ret; + + FD_ZERO(&rfds); + FD_SET(handle, &rfds); + tv.tv_sec = 2; + tv.tv_usec = 1; + ret = select(handle+1, &rfds, NULL, NULL, &tv); + if(ret <= 0) return 0; + + ret = read(handle, pBuff, 3); + if (ret <= 0) return 0; + numRead = 3; + if(pBuff[2] + 3 > buffLen) return 0; + + ret = read(handle, &pBuff[3], pBuff[2]); + if (ret <= 0) return 0; + numRead += ret; + + PRINT_BUF("<< ", pBuff, numRead); + + return numRead; +} + +static int transceive(int handle, char *pTx, int TxLen, char *pRx, int RxLen) +{ + if(send(handle, pTx, TxLen) == 0) return 0; + return receive(handle, pRx, RxLen); +} + +static void RfOn (int handle) +{ + char NCIStartDiscovery[] = {0x21, 0x03, 0x09, 0x04, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x06, 0x01}; + char NCIRfOn[] = {0x2F, 0x3D, 0x02, 0x20, 0x01}; + char Answer[256]; + int NbBytes = 0; + + if (gNfcController_generation == 1) { + printf("Continuous RF ON test - please tap a card\n"); + NbBytes = transceive(handle, NCIStartDiscovery, sizeof(NCIStartDiscovery), Answer, sizeof(Answer)); + if((Answer[0] != 0x41) || (Answer[1] != 0x03) || (Answer[3] != 0x00)) { + printf("Cannot start discovery loop\n"); + return; + } + do { + NbBytes = receive(handle, Answer, sizeof(Answer)); + } while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03))); + } + else { + printf("Continuous RF ON test\n"); + NbBytes = transceive(handle, NCIRfOn, sizeof(NCIRfOn), Answer, sizeof(Answer)); + } + printf("NFC Controller is now in continuous RF ON mode - Press enter to stop\n"); + fgets(Answer, sizeof(Answer), stdin); +} + +static void Prbs (int handle) +{ + char NCIPrbsPN7120[] = {0x2F, 0x30, 0x04, 0x00, 0x00, 0x01, 0x01}; + char NCIPrbsPN7150[] = {0x2F, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01}; + char Answer[256]; + int NbBytes = 0; + int tech, bitrate; + + printf("PRBS test:\n"); + printf(" Select technology (A=0, B=1, F=2: "); + scanf("%d", &tech); + printf(" Select bitrate (106=0, 212=1, 424=2, 848=3: "); + scanf("%d", &bitrate); + + if (gNfcController_generation == 1) { + NCIPrbsPN7120[3] = tech; + NCIPrbsPN7120[4] = bitrate; + NbBytes = transceive(handle, NCIPrbsPN7120, sizeof(NCIPrbsPN7120), Answer, sizeof(Answer)); + } + else { + NCIPrbsPN7150[5] = tech; + NCIPrbsPN7150[6] = bitrate; + NbBytes = transceive(handle, NCIPrbsPN7150, sizeof(NCIPrbsPN7150), Answer, sizeof(Answer)); + } + printf("NFC Controller is now in PRBS mode - Press enter to stop\n"); + fgets(Answer, sizeof(Answer), stdin); +} + +int main() +{ + int nHandle; + char NCICoreReset[] = {0x20, 0x00, 0x01, 0x01}; + char NCICoreInit[] = {0x20, 0x01, 0x00}; + char NCIDisableStandby[] = {0x2F, 0x00, 0x01, 0x00}; + char Answer[256]; + int NbBytes = 0; + + printf("\n----------------------------\n"); + printf("NFC Factory Test Application\n"); + printf("----------------------------\n"); + + if(openNfc(&nHandle) != 0) { + printf("Cannot connect to PN71xx NFC controller\n"); + return -1; + } + + reset(nHandle); + + NbBytes = transceive(nHandle, NCICoreReset, sizeof(NCICoreReset), Answer, sizeof(Answer)); + NbBytes = transceive(nHandle, NCICoreInit, sizeof(NCICoreInit), Answer, sizeof(Answer)); + if((NbBytes < 19) || (Answer[0] != 0x40) || (Answer[1] != 0x01) || (Answer[3] != 0x00)) { + printf("Error communicating with PN71xx NFC Controller\n"); + return -1; + } + /* Retrieve NXP-NCI NFC Controller generation */ + if (Answer[17+Answer[8]] == 0x08) { + printf("PN7120 NFC controller detected\n"); + gNfcController_generation = 1; + } + else if (Answer[17+Answer[8]] == 0x10) { + printf("PN7150 NFC controller detected\n"); + gNfcController_generation = 2; + } + else { + printf("Wrong NFC controller detected\n"); + return -1; + } + + NbBytes = transceive(nHandle, NCIDisableStandby, sizeof(NCIDisableStandby), Answer, sizeof(Answer)); + + printf("Select the test to run:\n"); + printf("\t 1. Continuous RF ON\n"); + printf("\t 2. PRBS\n"); + printf("Your choice: "); + scanf("%d", &NbBytes); + + switch(NbBytes) { + case 1: RfOn(nHandle); break; + case 2: Prbs(nHandle); break; + default: printf("Wrong choice\n"); break; + } + + fgets(Answer, sizeof(Answer), stdin); + + reset(nHandle); + closeNfc(nHandle); + + return 0; +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..63e3f64 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# nxpnfc_android_nougat + +This repository contains the files allowing to patch 8.1.0 Oreo version of AOSP source in order to add support for PN7150 NXP-NCI NFC controller to an Android based system. +It only applies to Oreo Android versions (for other releases see appropriate repository: https://wiki.codeaurora.org/xwiki/bin/NCI+NFC+Controller+SW+resources/). + +Information about NXP NFC Controller can be found on [NXP website](http://www.nxp.com/products/identification_and_security/nfc_and_reader_ics/nfc_controller_solutions/#overview). + +Further details about the stack and integration guidelines [here](https://www.nxp.com/docs/en/application-note/AN11690.pdf). + +Any question ? see [NXP Community](https://community.nxp.com/community/identification-security/nfc/content). + +Release version +--------------- + * R1.0: Initial release based on NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc diff --git a/conf/libnfc-brcm.conf b/conf/libnfc-brcm.conf new file mode 100755 index 0000000..ba00b80 --- /dev/null +++ b/conf/libnfc-brcm.conf @@ -0,0 +1,81 @@ +########################### PN7150 libnfc-brcm.conf ########################### + +############################################################################### +# Log levels for libnfc-nci. Suggested value for debugging is 0xFF. +APPL_TRACE_LEVEL=0xFF +PROTOCOL_TRACE_LEVEL=0xFF + +############################################################################### +# File used for NFA storage +NFA_STORAGE="/data/vendor/nfc" + +############################################################################### +# Forcing HOST to listen for a selected protocol +# 0x00 : Disable Host Listen +# 0x01 : Enable Host to Listen (A) for ISO-DEP tech A +# 0x02 : Enable Host to Listen (B) for ISO-DEP tech B +# 0x04 : Enable Host to Listen (F) for T3T Tag Type Protocol tech F +# 0x07 : Enable Host to Listen (ABF)for ISO-DEP tech AB & T3T Tag Type Protocol tech F +HOST_LISTEN_TECH_MASK=0x07 + +############################################################################### +# When screen is turned off, specify the desired power state of the controller. +# 0: power-off-sleep state; DEFAULT +# 1: full-power state +# 2: screen-off card-emulation (CE4/CE3/CE1 modes are used) +SCREEN_OFF_POWER_STATE=1 + +############################################################################### +# Choose the presence-check algorithm for type-4 tag. If not defined, the default value is 1. +# 0 NFA_RW_PRES_CHK_DEFAULT; Let stack selects an algorithm +# 1 NFA_RW_PRES_CHK_I_BLOCK; ISO-DEP protocol's empty I-block +# 2 NFA_RW_PRES_CHK_RESET; Deactivate to Sleep, then re-activate +# 3 NFA_RW_PRES_CHK_RB_CH0; Type-4 tag protocol's ReadBinary command on channel 0 +# 4 NFA_RW_PRES_CHK_RB_CH3; Type-4 tag protocol's ReadBinary command on channel 3 +PRESENCE_CHECK_ALGORITHM=1 + +############################################################################### +# NCI Hal Module name +NCI_HAL_MODULE="nfc_nci.pn54x" + +############################################################################### +# Force tag polling for the following technology(s). +# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h. +# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | +# NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 | +# NFA_TECHNOLOGY_MASK_KOVIO | NFA_TECHNOLOGY_MASK_A_ACTIVE | +# NFA_TECHNOLOGY_MASK_F_ACTIVE +# +# Notable bits: +# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */ +# NFA_TECHNOLOGY_MASK_B 0x02 /* NFC Technology B */ +# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */ +# NFA_TECHNOLOGY_MASK_ISO15693 0x08 /* Proprietary Technology */ +# NFA_TECHNOLOGY_MASK_KOVIO 0x20 /* Proprietary Technology */ +# NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40 /* NFC Technology A active mode */ +# NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80 /* NFC Technology F active mode */ +# This flag when set to zero will disable Reader mode. +POLLING_TECH_MASK=0xEF + +############################################################################### +# Force P2P to only listen for the following technology(s). +# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h. +# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F | +# NFA_TECHNOLOGY_MASK_A_ACTIVE | NFA_TECHNOLOGY_MASK_F_ACTIVE +# +# Notable bits: +# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */ +# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */ +# NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40 /* NFC Technology A active mode */ +# NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80 /* NFC Technology F active mode */ +# This flag when set to zero will disable P2P Listen mode. +P2P_LISTEN_TECH_MASK=0xC5 + +############################################################################### +# Override the stack default for NFA_EE_MAX_EE_SUPPORTED set in nfc_target.h. +# The value is set to 3 by default as it assumes we will discover 0xF2, +# 0xF3, and 0xF4. If a platform will exclude and SE, this value can be reduced +# so that the stack will not wait any longer than necessary. +# +# For NXP PN7150 value must be fixed to 0x01 +NFA_MAX_EE_SUPPORTED=0x01 diff --git a/conf/libnfc-nxp.conf b/conf/libnfc-nxp.conf new file mode 100755 index 0000000..b8c72e1 --- /dev/null +++ b/conf/libnfc-nxp.conf @@ -0,0 +1,86 @@ +########################### PN7150 libnfc-nxp.conf ############################ + +############################################################################### +# Logging Levels. Suggested value for debugging is 0x03. +# NXPLOG_EXTNS_LOGLEVEL - Configuration for extns logging level +# NXPLOG_NCIX_LOGLEVEL - Configuration for enabling logging of NCI TX packets +# NXPLOG_NCIR_LOGLEVEL - Configuration for enabling logging of NCI RX packets +# NXPLOG_FWDNLD_LOGLEVEL - Configuration for enabling logging of FW download functionality +# NXPLOG_TML_LOGLEVEL - Configuration for enabling logging of TML +# NXPLOG_NCIHAL_LOGLEVEL - Configuration for enabling logging of HAL +NXPLOG_EXTNS_LOGLEVEL=0x03 +NXPLOG_NCIX_LOGLEVEL=0x03 +NXPLOG_NCIR_LOGLEVEL=0x03 +NXPLOG_FWDNLD_LOGLEVEL=0x03 +NXPLOG_TML_LOGLEVEL=0x03 +NXPLOG_NCIHAL_LOGLEVEL=0x03 + +############################################################################### +# Nfc Device Node name +NXP_NFC_DEV_NODE="/dev/pn544" + +############################################################################### +# Extension for Mifare reader enable +MIFARE_READER_ENABLE=0x01 + +############################################################################### +# System clock source selection configuration +#define CLK_SRC_XTAL 0x01 +#define CLK_SRC_PLL 0x02 +NXP_SYS_CLK_SRC_SEL=0x01 + +############################################################################### +# System clock frequency selection configuration. +# Only valid in case of PLL clock source. +#define CLK_FREQ_13MHZ 1 +#define CLK_FREQ_19_2MHZ 2 +#define CLK_FREQ_24MHZ 3 +#define CLK_FREQ_26MHZ 4 +#define CLK_FREQ_38_4MHZ 5 +#define CLK_FREQ_52MHZ 6 +NXP_SYS_CLK_FREQ_SEL=0x00 + +############################################################################### +# The timeout value to be used for clock request acknowledgment +# min value = 0x01 to max = 0x1A +# Only valid in case of PLL clock source. +NXP_SYS_CLOCK_TO_CFG=0x01 + +############################################################################### +# NXP proprietary settings to enable NXP Proprietary features +# +# For NXP NFC Controller value must be fixed to {2F, 02, 00} +NXP_ACT_PROP_EXTN={2F, 02, 00} + +############################################################################### +# NFC forum profile settings. +# For more details refer to the POLL_PROFILE_SEL_ CFG parameter definition from NFC Controller User Manual +NXP_NFC_PROFILE_EXTN={20, 02, 05, 01, A0, 44, 01, 00} + +############################################################################### +# Standby enable settings. (disable=2F 00 01 00, enable=2F 00 01 01) +NXP_CORE_STANDBY={2F, 00, 01, 01} + +############################################################################### +# TVDD configurations settings +# Allow NFCC to configure External TVDD +# There are two possible configurations (0x01 or 0x02): +# CFG1: Vbat is used to generate the VDD(TX) through TXLDO +# CFG2: external 5V is used to generate the VDD(TX) through TXLDO +NXP_EXT_TVDD_CFG=0x02 + +# CFG1: 3.3V for both Reader and Card modes +NXP_EXT_TVDD_CFG_1={20, 02, 07, 01, A0, 0E, 03, 02, 09, 00} + +# CFG2: VBAT2 to 5V and 4.7V for both Reader and Card modes +NXP_EXT_TVDD_CFG_2={20, 02, 07, 01, A0, 0E, 03, 06, 64, 00} + +############################################################################### +## Set configuration optimization decision setting +## Enable = 0x01 +## Disable = 0x00 +NXP_SET_CONFIG_ALWAYS=0x00 + +############################################################################### +# To enable i2c fragmentation set i2c fragmentation enable 0x01 to disable set to 0x00 +NXP_I2C_FRAGMENTATION_ENABLED=0x00 diff --git a/conf/libnfc-nxp_RF.conf b/conf/libnfc-nxp_RF.conf new file mode 100755 index 0000000..58333ce --- /dev/null +++ b/conf/libnfc-nxp_RF.conf @@ -0,0 +1,55 @@ +############################################################################### +# RF configuration settings +# Below settings relates to OM5578 demo kit RF performance optimization +NXP_RF_CONF_BLK_1={ 20, 02, A3, 13, + A0, 0D, 06, 04, 35, 90, 01, F4, 01, + A0, 0D, 06, 06, 44, 01, 90, 03, 00, + A0, 0D, 06, 06, 30, B0, 01, 10, 00, + A0, 0D, 06, 06, 42, 02, 00, FF, FF, + A0, 0D, 03, 06, 3F, 04, + A0, 0D, 06, 20, 42, 88, 00, FF, FF, + A0, 0D, 04, 22, 44, 22, 00, + A0, 0D, 06, 22, 2D, 50, 34, 0C, 00, + A0, 0D, 06, 32, 42, F8, 00, FF, FF, + A0, 0D, 06, 34, 2D, 24, 37, 0C, 00, + A0, 0D, 06, 34, 33, 86, 80, 00, 70, + A0, 0D, 04, 34, 44, 22, 00, + A0, 0D, 06, 42, 2D, 15, 45, 0D, 00, + A0, 0D, 04, 46, 44, 22, 00, + A0, 0D, 06, 46, 2D, 05, 59, 0E, 00, + A0, 0D, 06, 44, 42, 88, 00, FF, FF, + A0, 0D, 06, 56, 2D, 05, 9F, 0C, 00, + A0, 0D, 06, 54, 42, 88, 00, FF, FF, + A0, 0D, 06, 0A, 33, 80, 86, 00, 70 +} + +NXP_RF_CONF_BLK_2={ 20, 02, 15, 01, + A0, 1D, 11, 57, 33, 14, 17, 00, AA, 85, 00, 80, 55, 2A, 04, 00, 63, 00, 00, 00 +} + +############################################################################### +# Core configuration settings +NXP_CORE_CONF={ 20, 02, 2B, 0D, + 28, 01, 00, + 21, 01, 00, + 30, 01, 08, + 31, 01, 03, + 33, 04, 01, 02, 03, 04, + 54, 01, 06, + 50, 01, 02, + 5B, 01, 00, + 60, 01, 0E, + 80, 01, 01, + 81, 01, 01, + 82, 01, 0E, + 18, 01, 01 +} + +############################################################################### +# NXP Proprietary core configuration extensions +# For more details refer to the NFC Controller User Manual +NXP_CORE_CONF_EXTN={20, 02, 09, 02, + A0, 5E, 01, 01, + A0, 40, 01, 00 +} + diff --git a/install_NFC.sh b/install_NFC.sh new file mode 100755 index 0000000..152a243 --- /dev/null +++ b/install_NFC.sh @@ -0,0 +1,44 @@ +#!/bin/bash +echo +echo "+++ Installing NXP-NCI NFC support for PN7150 +++" + +echo +echo "- removing existing implementation" +rm -rf $ANDROID_BUILD_TOP/frameworks/base/core/java/android/nfc/* +rm -rf $ANDROID_BUILD_TOP/system/nfc/* $ANDROID_BUILD_TOP/system/nfc/.* +rm -rf $ANDROID_BUILD_TOP/packages/apps/Nfc/* $ANDROID_BUILD_TOP/packages/apps/Nfc/.* + +echo +echo "- copying required files" +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Base/core/java/android/nfc $ANDROID_BUILD_TOP/frameworks/base/core/java/android/ +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Vendor/* $ANDROID_BUILD_TOP/ +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_libnfcNci/* $ANDROID_BUILD_TOP/system/nfc/ +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_libnfcNci/.* $ANDROID_BUILD_TOP/system/nfc/ +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Nfc/* $ANDROID_BUILD_TOP/packages/apps/Nfc/ +cp -r $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Nfc/.* $ANDROID_BUILD_TOP/packages/apps/Nfc/ + +echo +echo "- removing temporary retrieved files" +rm -rf $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Base +rm -rf $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Vendor +rm -rf $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_libnfcNci +rm -rf $ANDROID_BUILD_TOP/NxpNfcAndroid/NfcAndroid_Nfc + +echo +echo "- patching required files" +cd $ANDROID_BUILD_TOP/build +patch -p1 <$ANDROID_BUILD_TOP/NxpNfcAndroid/patch_build.txt +cd $ANDROID_BUILD_TOP/frameworks/base +patch -p1 <$ANDROID_BUILD_TOP/NxpNfcAndroid/patch_frameworks_base.txt +cd $ANDROID_BUILD_TOP/system/sepolicy +patch -p1 <$ANDROID_BUILD_TOP/NxpNfcAndroid/patch_system_sepolicy.txt +cd $ANDROID_BUILD_TOP/packages/apps/Nfc +patch -p1 <$ANDROID_BUILD_TOP/NxpNfcAndroid/patch_packages_apps_nfc.txt +cd $ANDROID_BUILD_TOP/system/nfc +patch -p1 <$ANDROID_BUILD_TOP/NxpNfcAndroid/patch_system_nfc.txt +cd $ANDROID_BUILD_TOP + +echo +echo "+++ NXP-NCI NFC support installation completed +++" +exit 0 + diff --git a/nxpnfc_manifest.xml b/nxpnfc_manifest.xml new file mode 100644 index 0000000..532db76 --- /dev/null +++ b/nxpnfc_manifest.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/patch_build.txt b/patch_build.txt new file mode 100644 index 0000000..10a1081 --- /dev/null +++ b/patch_build.txt @@ -0,0 +1,13 @@ +diff --git a/core/tasks/check_boot_jars/package_whitelist.txt b/core/tasks/check_boot_jars/package_whitelist.txt +old mode 100644 +new mode 100755 +index 15b9990..ad9e405 +--- a/core/tasks/check_boot_jars/package_whitelist.txt ++++ b/core/tasks/check_boot_jars/package_whitelist.txt +@@ -237,3 +237,6 @@ org\.apache\.xalan\.xslt + # Packages in the google namespace across all bootclasspath jars. + com\.google\.android\..* + com\.google\.vr\.platform.* ++ ++com\.nxp\..* ++ diff --git a/patch_frameworks_base.txt b/patch_frameworks_base.txt new file mode 100644 index 0000000..8de1cff --- /dev/null +++ b/patch_frameworks_base.txt @@ -0,0 +1,12 @@ +diff --git a/Android.mk b/Android.mk +index dfcfa2b..7971b4a 100644 +--- a/Android.mk ++++ b/Android.mk +@@ -247,7 +247,6 @@ LOCAL_SRC_FILES += \ + core/java/android/nfc/INfcCardEmulation.aidl \ + core/java/android/nfc/INfcFCardEmulation.aidl \ + core/java/android/nfc/INfcUnlockHandler.aidl \ +- core/java/android/nfc/INfcDta.aidl \ + core/java/android/nfc/ITagRemovedCallback.aidl \ + core/java/android/os/IBatteryPropertiesListener.aidl \ + core/java/android/os/IBatteryPropertiesRegistrar.aidl \ diff --git a/patch_packages_apps_nfc.txt b/patch_packages_apps_nfc.txt new file mode 100644 index 0000000..d4a83ea --- /dev/null +++ b/patch_packages_apps_nfc.txt @@ -0,0 +1,23 @@ +diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp +old mode 100755 +new mode 100644 +index a0ee86d..eb9ad10 +--- a/nci/jni/NativeNfcManager.cpp ++++ b/nci/jni/NativeNfcManager.cpp +@@ -2942,6 +2942,7 @@ static void nfcManager_enableDiscovery (JNIEnv* e, jobject o, jint technologies_ + } + } + // Actually start discovery. ++ usleep(100*1000); + startRfDiscovery (true); + sDiscoveryEnabled = true; + +@@ -8587,7 +8588,7 @@ Transcation_Check_t* nfcManager_transactionDetail(void) + void nfcManager_getFeatureList() { + tNFC_chipType chipType;// = pn553; + chipType = NFC_GetChipType(); +- ALOGV("%s : chipType",__func__); ++ ALOGV("%s : chipType=%d",__func__, chipType); + CONFIGURE_FEATURELIST(chipType); + } + /******************************************************************************* diff --git a/patch_system_nfc.txt b/patch_system_nfc.txt new file mode 100644 index 0000000..8fd4281 --- /dev/null +++ b/patch_system_nfc.txt @@ -0,0 +1,73 @@ +diff --git a/halimpl/pn54x/configs/NxpNfcCapability.cpp b/halimpl/pn54x/configs/NxpNfcCapability.cpp +old mode 100644 +new mode 100755 +index 869a55c..0474c29 +--- a/halimpl/pn54x/configs/NxpNfcCapability.cpp ++++ b/halimpl/pn54x/configs/NxpNfcCapability.cpp +@@ -63,6 +63,7 @@ tNFC_chipType capability::processChipType(uint8_t* msg, uint16_t msg_len) { + + case 0x28 : + case 0x48 : //NQ210 ++ case 0x88 : //PN7150 + chipType = pn548C2; + break; + +diff --git a/halimpl/pn54x/hal/phNxpNciHal_ext.c b/halimpl/pn54x/hal/phNxpNciHal_ext.c +old mode 100644 +new mode 100755 +index 6e0c4f1..d860bf2 +--- a/halimpl/pn54x/hal/phNxpNciHal_ext.c ++++ b/halimpl/pn54x/hal/phNxpNciHal_ext.c +@@ -912,29 +912,29 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t* cmd_len, uint8_t* p_cmd_data, + } + } + +- if ((nfcFL.chipType == pn548C2) && +- (p_cmd_data[0] == 0x20 && p_cmd_data[1] == 0x02)) { +- uint8_t temp; +- uint8_t* p = p_cmd_data + 4; +- uint8_t* end = p_cmd_data + *cmd_len; +- while (p < end) { +- if (*p == 0x53) // LF_T3T_FLAGS +- { +- NXPLOG_NCIHAL_D("> Going through workaround - LF_T3T_FLAGS swap"); +- temp = *(p + 3); +- *(p + 3) = *(p + 2); +- *(p + 2) = temp; +- NXPLOG_NCIHAL_D("> Going through workaround - LF_T3T_FLAGS - End"); +- status = NFCSTATUS_SUCCESS; +- break; +- } +- if (*p == 0xA0) { +- p += *(p + 2) + 3; +- } else { +- p += *(p + 1) + 2; +- } +- } +- } ++ // if ((nfcFL.chipType == pn548C2) && ++ // (p_cmd_data[0] == 0x20 && p_cmd_data[1] == 0x02)) { ++ // uint8_t temp; ++ // uint8_t* p = p_cmd_data + 4; ++ // uint8_t* end = p_cmd_data + *cmd_len; ++ // while (p < end) { ++ // if (*p == 0x53) // LF_T3T_FLAGS ++ // { ++ // NXPLOG_NCIHAL_D("> Going through workaround - LF_T3T_FLAGS swap"); ++ // temp = *(p + 3); ++ // *(p + 3) = *(p + 2); ++ // *(p + 2) = temp; ++ // NXPLOG_NCIHAL_D("> Going through workaround - LF_T3T_FLAGS - End"); ++ // status = NFCSTATUS_SUCCESS; ++ // break; ++ // } ++ // if (*p == 0xA0) { ++ // p += *(p + 2) + 3; ++ // } else { ++ // p += *(p + 1) + 2; ++ // } ++ // } ++ // } + + return status; + } diff --git a/patch_system_sepolicy.txt b/patch_system_sepolicy.txt new file mode 100644 index 0000000..dc097a4 --- /dev/null +++ b/patch_system_sepolicy.txt @@ -0,0 +1,77 @@ +diff --git a/private/file_contexts b/private/file_contexts +old mode 100644 +new mode 100755 +index 5369758..eb68b26 +--- a/private/file_contexts ++++ b/private/file_contexts +@@ -262,6 +262,7 @@ + /system/bin/webview_zygote64 u:object_r:webview_zygote_exec:s0 + /system/bin/virtual_touchpad u:object_r:virtual_touchpad_exec:s0 + /system/bin/hw/android\.hidl\.allocator@1\.0-service u:object_r:hal_allocator_default_exec:s0 ++/system/bin/hw/vendor\.nxp\.nxpnfc@1\.0-service u:object_r:hal_nfc_default_exec:s0 + /system/etc/selinux/mapping/[0-9]+\.[0-9]+\.cil u:object_r:sepolicy_file:s0 + /system/etc/selinux/plat_mac_permissions\.xml u:object_r:mac_perms_file:s0 + /system/etc/selinux/plat_property_contexts u:object_r:property_contexts_file:s0 +diff --git a/private/nfc.te b/private/nfc.te +index b41558c..19beebe 100644 +--- a/private/nfc.te ++++ b/private/nfc.te +@@ -11,6 +11,7 @@ hal_client_domain(nfc, hal_nfc) + # Data file accesses. + allow nfc nfc_data_file:dir create_dir_perms; + allow nfc nfc_data_file:notdevfile_class_set create_file_perms; ++allow nfc nfc_data_file:dir { search read write create remove_name}; + + # SoundPool loading and playback + allow nfc audioserver_service:service_manager find; +@@ -28,6 +29,9 @@ allow nfc vr_manager_service:service_manager find; + + set_prop(nfc, nfc_prop); + ++#============= nfc ============== ++allow nfc default_android_hwservice:hwservice_manager find; ++ + # already open bugreport file descriptors may be shared with + # the nfc process, from a file in + # /data/data/com.android.shell/files/bugreports/bugreport-*. +diff --git a/private/platform_app.te b/private/platform_app.te +old mode 100644 +new mode 100755 +index 2aa7dc9..732f8d0 +--- a/private/platform_app.te ++++ b/private/platform_app.te +@@ -56,6 +56,7 @@ allow platform_app timezone_service:service_manager find; + allow platform_app app_api_service:service_manager find; + allow platform_app system_api_service:service_manager find; + allow platform_app vr_manager_service:service_manager find; ++allow platform_app nfc_service:service_manager find; + + # Access to /data/preloads + allow platform_app preloads_data_file:file r_file_perms; +diff --git a/public/domain.te b/public/domain.te +index f5c72cc..10cfb1f 100644 +--- a/public/domain.te ++++ b/public/domain.te +@@ -431,7 +431,7 @@ neverallow { domain -recovery } contextmount_type:dir_file_class_set + # from service name to service_type are defined in {,hw,vnd}service_contexts. + neverallow * default_android_service:service_manager add; + neverallow * default_android_vndservice:service_manager { add find }; +-neverallow * default_android_hwservice:hwservice_manager { add find }; ++#neverallow * default_android_hwservice:hwservice_manager { add find }; + + # Looking up the base class/interface of all HwBinder services is a bad idea. + # hwservicemanager currently offer such lookups only to make it so that security +diff --git a/vendor/hal_nfc_default.te b/vendor/hal_nfc_default.te +index c13baa7..91b61ee 100644 +--- a/vendor/hal_nfc_default.te ++++ b/vendor/hal_nfc_default.te +@@ -3,3 +3,9 @@ hal_server_domain(hal_nfc_default, hal_nfc) + + type hal_nfc_default_exec, exec_type, vendor_file_type, file_type; + init_daemon_domain(hal_nfc_default) ++ ++allow hal_nfc_default default_android_hwservice:hwservice_manager { add find }; ++ ++#============= hal_nfc_default ============== ++allow hal_nfc_default nfc_vendor_data_file:dir { add_name read write search remove_name}; ++allow hal_nfc_default nfc_vendor_data_file:file { getattr open create read write unlink};