From 8787afa9e6e774112439ae50d09150a881cdd5a9 Mon Sep 17 00:00:00 2001 From: Lei Ju Date: Wed, 28 Jun 2023 09:36:19 -0700 Subject: [PATCH] Introduce a new callback function to get client's UUID Bug: 247124878 Test: compilation and manual test Change-Id: I96b386fc232c4f65615858cf9b65317ae5bdc499 --- .../compatibility_matrix.9.xml | 2 +- contexthub/aidl/Android.bp | 2 +- .../contexthub/IContextHubCallback.aidl | 1 + .../contexthub/IContextHubCallback.aidl | 8 ++++++++ contexthub/aidl/default/Android.bp | 4 ++-- .../aidl/default/contexthub-default.xml | 2 +- contexthub/aidl/vts/Android.bp | 2 +- .../vts/VtsAidlHalContextHubTargetTest.cpp | 19 +++++++++++++++++++ 8 files changed, 34 insertions(+), 6 deletions(-) diff --git a/compatibility_matrices/compatibility_matrix.9.xml b/compatibility_matrices/compatibility_matrix.9.xml index 0c6ae7b1ab..29d62591f1 100644 --- a/compatibility_matrices/compatibility_matrix.9.xml +++ b/compatibility_matrices/compatibility_matrix.9.xml @@ -185,7 +185,7 @@ android.hardware.contexthub - 2 + 3 IContextHub default diff --git a/contexthub/aidl/Android.bp b/contexthub/aidl/Android.bp index a0315d0b30..cf10529ba1 100644 --- a/contexthub/aidl/Android.bp +++ b/contexthub/aidl/Android.bp @@ -49,6 +49,6 @@ aidl_interface { }, ], - frozen: true, + frozen: false, } diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl index 6163cfc662..d0099ffedb 100644 --- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl +++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHubCallback.aidl @@ -39,5 +39,6 @@ interface IContextHubCallback { void handleContextHubAsyncEvent(in android.hardware.contexthub.AsyncEventType evt); void handleTransactionResult(in int transactionId, in boolean success); void handleNanSessionRequest(in android.hardware.contexthub.NanSessionRequest request); + byte[16] getUuid(); const int CONTEXTHUB_NAN_TRANSACTION_TIMEOUT_MS = 10000; } diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl index bfcb51e589..41fb266d9b 100644 --- a/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl +++ b/contexthub/aidl/android/hardware/contexthub/IContextHubCallback.aidl @@ -90,6 +90,14 @@ interface IContextHubCallback { */ void handleNanSessionRequest(in NanSessionRequest request); + /** + * This callback is passed to the HAL implementation to allow the HAL to request a UUID that + * uniquely identifies an IContextHubCallback. + * + * @return a byte array representating the UUID + */ + byte[16] getUuid(); + /** * Amount of time, in milliseconds, that a handleNanSessionRequest can be pending before the * Contexthub service must respond. diff --git a/contexthub/aidl/default/Android.bp b/contexthub/aidl/default/Android.bp index 6ee7407de8..74bac699eb 100644 --- a/contexthub/aidl/default/Android.bp +++ b/contexthub/aidl/default/Android.bp @@ -29,7 +29,7 @@ cc_library_static { shared_libs: [ "libbase", "libbinder_ndk", - "android.hardware.contexthub-V2-ndk", + "android.hardware.contexthub-V3-ndk", ], export_include_dirs: ["include"], srcs: [ @@ -50,7 +50,7 @@ cc_binary { shared_libs: [ "libbase", "libbinder_ndk", - "android.hardware.contexthub-V2-ndk", + "android.hardware.contexthub-V3-ndk", ], static_libs: [ "libcontexthubexampleimpl", diff --git a/contexthub/aidl/default/contexthub-default.xml b/contexthub/aidl/default/contexthub-default.xml index 930f672197..2f8ddc8e1b 100644 --- a/contexthub/aidl/default/contexthub-default.xml +++ b/contexthub/aidl/default/contexthub-default.xml @@ -1,7 +1,7 @@ android.hardware.contexthub - 2 + 3 IContextHub default diff --git a/contexthub/aidl/vts/Android.bp b/contexthub/aidl/vts/Android.bp index 1534b40876..b166bafe26 100644 --- a/contexthub/aidl/vts/Android.bp +++ b/contexthub/aidl/vts/Android.bp @@ -32,7 +32,7 @@ cc_test { "libbinder", ], static_libs: [ - "android.hardware.contexthub-V2-cpp", + "android.hardware.contexthub-V3-cpp", "VtsHalContexthubUtils", ], test_suites: [ diff --git a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp index c1cc07cf51..e780857f24 100644 --- a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp +++ b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp @@ -48,6 +48,10 @@ using ::android::hardware::contexthub::Setting; using ::android::hardware::contexthub::vts_utils::kNonExistentAppId; using ::android::hardware::contexthub::vts_utils::waitForCallback; +// 6612b522-b717-41c8-b48d-c0b1cc64e142 +const std::array kUuid = {0x66, 0x12, 0xb5, 0x22, 0xb7, 0x17, 0x41, 0xc8, + 0xb4, 0x8d, 0xc0, 0xb1, 0xcc, 0x64, 0xe1, 0x42}; + class ContextHubAidl : public testing::TestWithParam> { public: virtual void SetUp() override { @@ -126,6 +130,11 @@ class EmptyContextHubCallback : public android::hardware::contexthub::BnContextH Status handleNanSessionRequest(const NanSessionRequest& /* request */) override { return Status::ok(); } + + Status getUuid(std::array* out_uuid) override { + *out_uuid = kUuid; + return Status::ok(); + } }; TEST_P(ContextHubAidl, TestRegisterCallback) { @@ -157,6 +166,11 @@ class QueryAppsCallback : public android::hardware::contexthub::BnContextHubCall return Status::ok(); } + Status getUuid(std::array* out_uuid) override { + *out_uuid = kUuid; + return Status::ok(); + } + std::promise> promise; }; @@ -223,6 +237,11 @@ class TransactionResultCallback : public android::hardware::contexthub::BnContex return Status::ok(); } + Status getUuid(std::array* out_uuid) override { + *out_uuid = kUuid; + return Status::ok(); + } + uint32_t expectedTransactionId = 0; std::promise promise; };