diff options
| author | Jack Yu <jackcwyu@google.com> | 2018-10-09 10:43:52 +0800 |
|---|---|---|
| committer | Jack Yu <jackcwyu@google.com> | 2018-10-11 01:52:34 +0000 |
| commit | ea5d45291f2e740440adfa74f143299496db8c24 (patch) | |
| tree | 7b68935b4ad60105ba8725415cab01f44b8a2345 /halimpl/hal | |
| parent | c4840f552d9324c117ddb0fe56f5d51a6f530f49 (diff) | |
| download | android_hardware_nxp_nfc-ea5d45291f2e740440adfa74f143299496db8c24.tar.gz android_hardware_nxp_nfc-ea5d45291f2e740440adfa74f143299496db8c24.tar.bz2 android_hardware_nxp_nfc-ea5d45291f2e740440adfa74f143299496db8c24.zip | |
FactoryOTA: Disable factory OTA mode
When factoryOTA client set the property to "terminate", factoryOTA related setting should be cleared.
Check chipset's factory OTA setting and set the property to "terminated" if factoryOTA mode is disabled successfully.
Bug: 111528718
Test: NFC on/off, factoryOTA mode disabled and property set correctly
Change-Id: Iba1d7d99eb8ad3cf3375d6cfd5735d0093b0b1c6
Diffstat (limited to 'halimpl/hal')
| -rwxr-xr-x | halimpl/hal/phNxpNciHal.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/halimpl/hal/phNxpNciHal.cc b/halimpl/hal/phNxpNciHal.cc index 922a074..46670b5 100755 --- a/halimpl/hal/phNxpNciHal.cc +++ b/halimpl/hal/phNxpNciHal.cc @@ -118,6 +118,8 @@ static NFCSTATUS phNxpNciHalRFConfigCmdRecSequence(); static NFCSTATUS phNxpNciHal_CheckRFCmdRespStatus(); static void phNxpNciHal_getPersistUiccSetting(); int check_config_parameter(); +void phNxpNciHal_isFactoryOTAModeActive(); +static NFCSTATUS phNxpNciHal_disableFactoryOTAMode(void); /****************************************************************************** * Function phNxpNciHal_initialize_debug_enabled_flag * @@ -1874,6 +1876,48 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { #endif return NFCSTATUS_SUCCESS; } + +void phNxpNciHal_isFactoryOTAModeActive() { + uint8_t check_factoryOTA[] = {0x20, 0x03, 0x05, 0x02, 0xA0, 0x08, 0xA0, 0x88}; + NFCSTATUS status = NFCSTATUS_FAILED; + NXPLOG_NCIHAL_D("check FactoryOTA mode status"); + + status = phNxpNciHal_send_ext_cmd(sizeof(check_factoryOTA), check_factoryOTA); + + if (status == NFCSTATUS_SUCCESS) { + if(nxpncihal_ctrl.p_rx_data[9] == 0x1 && nxpncihal_ctrl.p_rx_data[13] == 0x1) { + NXPLOG_NCIHAL_E("FactoryOTA mode is active"); + } else { + NXPLOG_NCIHAL_D("FactoryOTA mode is disabled"); + if (property_set("persist.factoryota.reboot", "terminated") < 0) { + NXPLOG_NCIHAL_E("Fail to set factoryOTA property"); + } + } + } else { + NXPLOG_NCIHAL_E("Fail to get FactoryOTA mode status"); + } + return; +} + +NFCSTATUS phNxpNciHal_disableFactoryOTAMode() { + // NFCC GPIO output control + uint8_t nfcc_system_gpio[] = {0x20, 0x02, 0x06, 0x01, 0xA0, 0x08, 0x02, 0x00, 0x00}; + // NFCC automatically sets GPIO once a specific RF pattern is detected + uint8_t nfcc_gpio_pattern[] = {0x20, 0x02, 0x08, 0x01, 0xA0, 0x88, 0x04, 0x00, 0x96, 0x96, 0x03}; + + NFCSTATUS status = NFCSTATUS_SUCCESS; + NXPLOG_NCIHAL_D("Disable FactoryOTA mode"); + status = phNxpNciHal_send_ext_cmd(sizeof(nfcc_system_gpio), nfcc_system_gpio); + if (status != NFCSTATUS_SUCCESS ) { + NXPLOG_NCIHAL_E("Can't disable A008 for FactoryOTA mode"); + } + status = phNxpNciHal_send_ext_cmd(sizeof(nfcc_gpio_pattern), nfcc_gpio_pattern); + if (status != NFCSTATUS_SUCCESS ) { + NXPLOG_NCIHAL_E("Can't disable A088 for FactoryOTA mode"); + } + return status; +} + /****************************************************************************** * Function phNxpNciHal_CheckRFCmdRespStatus * @@ -2024,6 +2068,18 @@ int phNxpNciHal_close(bool bShutdown) { } } + char valueStr[PROPERTY_VALUE_MAX] = {0}; + bool factoryOTA_terminate = false; + int len = property_get("persist.factoryota.reboot", valueStr, "normal"); + if (len > 0) { + factoryOTA_terminate = (len == 9 && (memcmp(valueStr, "terminate", len) == 0)) ? true : false; + } + NXPLOG_NCIHAL_D("factoryOTA_terminate: %d", factoryOTA_terminate); + if (factoryOTA_terminate) { + phNxpNciHal_disableFactoryOTAMode(); + phNxpNciHal_isFactoryOTAModeActive(); + } + nxpncihal_ctrl.halStatus = HAL_STATUS_CLOSE; status = phNxpNciHal_send_ext_cmd(sizeof(cmd_reset_nci), cmd_reset_nci); |
