From 8b75b778e763adcd96fc3cdc10e6076c5b1ba3b6 Mon Sep 17 00:00:00 2001 From: ziyiw Date: Tue, 2 Jul 2024 18:06:25 +0000 Subject: [PATCH] [Hal] Add request/release control event in aidl interface. Test: compile Bug: 344753047 Change-Id: I1e5628a3105f8ee804ed0f40d386fda872b4442b --- compatibility_matrices/compatibility_matrix.202504.xml | 1 + .../current/android/hardware/nfc/INfc.aidl | 1 + .../current/android/hardware/nfc/NfcEvent.aidl | 2 ++ nfc/aidl/android/hardware/nfc/INfc.aidl | 9 +++++++++ nfc/aidl/android/hardware/nfc/NfcEvent.aidl | 10 ++++++++++ nfc/aidl/vts/functional/Android.bp | 4 ++-- nfc/aidl/vts/functional/VtsAidlHalNfcTargetTest.cpp | 10 ++++++++++ 7 files changed, 35 insertions(+), 2 deletions(-) diff --git a/compatibility_matrices/compatibility_matrix.202504.xml b/compatibility_matrices/compatibility_matrix.202504.xml index ee62163924..5f9d41f141 100644 --- a/compatibility_matrices/compatibility_matrix.202504.xml +++ b/compatibility_matrices/compatibility_matrix.202504.xml @@ -372,6 +372,7 @@ android.hardware.nfc + 1-2 INfc default diff --git a/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/INfc.aidl b/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/INfc.aidl index 7a0ae54963..220912e287 100644 --- a/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/INfc.aidl +++ b/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/INfc.aidl @@ -44,4 +44,5 @@ interface INfc { int write(in byte[] data); void setEnableVerboseLogging(in boolean enable); boolean isVerboseLoggingEnabled(); + android.hardware.nfc.NfcStatus controlGranted(); } diff --git a/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/NfcEvent.aidl b/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/NfcEvent.aidl index dda258eb08..aebe836173 100644 --- a/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/NfcEvent.aidl +++ b/nfc/aidl/aidl_api/android.hardware.nfc/current/android/hardware/nfc/NfcEvent.aidl @@ -40,4 +40,6 @@ enum NfcEvent { PRE_DISCOVER_CPLT = 3, HCI_NETWORK_RESET = 4, ERROR = 5, + REQUEST_CONTROL = 6, + RELEASE_CONTROL = 7, } diff --git a/nfc/aidl/android/hardware/nfc/INfc.aidl b/nfc/aidl/android/hardware/nfc/INfc.aidl index 662f8d4c8f..1d18b9e008 100644 --- a/nfc/aidl/android/hardware/nfc/INfc.aidl +++ b/nfc/aidl/android/hardware/nfc/INfc.aidl @@ -140,4 +140,13 @@ interface INfc { * @return true if verbose logging flag value is enabled, false if disabled. */ boolean isVerboseLoggingEnabled(); + + /** + * Requests control of NFCC to libnfc-nci. + * If an API request is sent when the framework has no control of NFCC, the request will be + * queued until the control is released from HAL. + * The control will be taken out of the framework for at most 2 seconds. + * @return NfcStatus::OK on success and NfcStatus::FAILED on error. + */ + NfcStatus controlGranted(); } diff --git a/nfc/aidl/android/hardware/nfc/NfcEvent.aidl b/nfc/aidl/android/hardware/nfc/NfcEvent.aidl index a78b1cdb44..7e0231af6e 100644 --- a/nfc/aidl/android/hardware/nfc/NfcEvent.aidl +++ b/nfc/aidl/android/hardware/nfc/NfcEvent.aidl @@ -50,4 +50,14 @@ enum NfcEvent { * Error event to notify upper layer when there's an unknown error. */ ERROR = 5, + /** + * Request control event to notify upper layer when HAL + * request control of NFCC to libnfc-nci + */ + REQUEST_CONTROL = 6, + /** + * Release control event to notify upper layer when HAL + * release control of NFCC to libnfc-nci. + */ + RELEASE_CONTROL = 7, } diff --git a/nfc/aidl/vts/functional/Android.bp b/nfc/aidl/vts/functional/Android.bp index d0b684b32d..82ce026d14 100644 --- a/nfc/aidl/vts/functional/Android.bp +++ b/nfc/aidl/vts/functional/Android.bp @@ -38,7 +38,7 @@ cc_test { "libbinder_ndk", ], static_libs: [ - "android.hardware.nfc-V1-ndk", + "android.hardware.nfc-V2-ndk", ], test_suites: [ "general-tests", @@ -71,7 +71,7 @@ cc_test { "libstatssocket", ], static_libs: [ - "android.hardware.nfc-V1-ndk", + "android.hardware.nfc-V2-ndk", "android.hardware.nfc@1.0", "android.hardware.nfc@1.1", "android.hardware.nfc@1.2", diff --git a/nfc/aidl/vts/functional/VtsAidlHalNfcTargetTest.cpp b/nfc/aidl/vts/functional/VtsAidlHalNfcTargetTest.cpp index 977b25cf92..12f4364bc0 100644 --- a/nfc/aidl/vts/functional/VtsAidlHalNfcTargetTest.cpp +++ b/nfc/aidl/vts/functional/VtsAidlHalNfcTargetTest.cpp @@ -440,6 +440,16 @@ TEST_P(NfcAidl, CheckisVerboseLoggingEnabledAfterSetEnableVerboseLogging) { EXPECT_TRUE(!enabled); } +TEST_P(NfcAidl, CheckControlGrantedStatus) { + int interface_version; + EXPECT_TRUE(infc_->getInterfaceVersion(&interface_version).isOk()); + if (interface_version > 1) { + NfcStatus status; + EXPECT_TRUE(infc_->controlGranted(&status).isOk()); + EXPECT_EQ(status, NfcStatus::OK); + } +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(NfcAidl); INSTANTIATE_TEST_SUITE_P(Nfc, NfcAidl, testing::ValuesIn(::android::getAidlHalInstanceNames(INfc::descriptor)),