diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index f8954a3f7c..61438b4687 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -206,6 +206,7 @@ android.hardware.contexthub + 2 IContextHub default diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl index f0676bec74..272d76823b 100644 --- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl +++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl @@ -45,5 +45,6 @@ interface IContextHub { void sendMessageToHub(in int contextHubId, in android.hardware.contexthub.ContextHubMessage message); void onHostEndpointConnected(in android.hardware.contexthub.HostEndpointInfo hostEndpointInfo); void onHostEndpointDisconnected(char hostEndpointId); + long[] getPreloadedNanoappIds(); const int EX_CONTEXT_HUB_UNSPECIFIED = -1; } diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl index 16666efd95..9fa67a5aa1 100644 --- a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl +++ b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl @@ -21,6 +21,7 @@ import android.hardware.contexthub.ContextHubMessage; import android.hardware.contexthub.HostEndpointInfo; import android.hardware.contexthub.IContextHubCallback; import android.hardware.contexthub.NanoappBinary; +import android.hardware.contexthub.NanoappInfo; import android.hardware.contexthub.Setting; @VintfStability @@ -194,6 +195,14 @@ interface IContextHub { */ void onHostEndpointDisconnected(char hostEndpointId); + /** + * Provides the list of preloaded nanoapp IDs on the system. The output of this API must + * not change. + * + * @return The list of preloaded nanoapp IDs + */ + long[] getPreloadedNanoappIds(); + /** * Error codes that are used as service specific errors with the AIDL return * value EX_SERVICE_SPECIFIC. diff --git a/contexthub/aidl/default/Android.bp b/contexthub/aidl/default/Android.bp index 269057a2a2..6ee7407de8 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-V1-ndk", + "android.hardware.contexthub-V2-ndk", ], export_include_dirs: ["include"], srcs: [ @@ -50,7 +50,7 @@ cc_binary { shared_libs: [ "libbase", "libbinder_ndk", - "android.hardware.contexthub-V1-ndk", + "android.hardware.contexthub-V2-ndk", ], static_libs: [ "libcontexthubexampleimpl", diff --git a/contexthub/aidl/default/ContextHub.cpp b/contexthub/aidl/default/ContextHub.cpp index 35e4650ef2..ac1dc46139 100644 --- a/contexthub/aidl/default/ContextHub.cpp +++ b/contexthub/aidl/default/ContextHub.cpp @@ -76,6 +76,17 @@ ScopedAStatus ContextHub::queryNanoapps(int32_t in_contextHubId) { } } +ScopedAStatus ContextHub::getPreloadedNanoappIds(std::vector* out_preloadedNanoappIds) { + if (out_preloadedNanoappIds == nullptr) { + return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + + for (uint64_t i = 0; i < 10; ++i) { + out_preloadedNanoappIds->push_back(i); + } + return ndk::ScopedAStatus::ok(); +} + ScopedAStatus ContextHub::registerCallback(int32_t in_contextHubId, const std::shared_ptr& in_cb) { if (in_contextHubId == kMockHubId) { diff --git a/contexthub/aidl/default/contexthub-default.xml b/contexthub/aidl/default/contexthub-default.xml index e383c50ca0..930f672197 100644 --- a/contexthub/aidl/default/contexthub-default.xml +++ b/contexthub/aidl/default/contexthub-default.xml @@ -1,7 +1,10 @@ android.hardware.contexthub - 1 - IContextHub/default + 2 + + IContextHub + default + diff --git a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h index 03d8432134..4aeb948375 100644 --- a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h +++ b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h @@ -19,6 +19,7 @@ #include #include +#include namespace aidl { namespace android { @@ -37,6 +38,8 @@ class ContextHub : public BnContextHub { int32_t in_transactionId) override; ::ndk::ScopedAStatus onSettingChanged(Setting in_setting, bool in_enabled) override; ::ndk::ScopedAStatus queryNanoapps(int32_t in_contextHubId) override; + ::ndk::ScopedAStatus getPreloadedNanoappIds( + std::vector* out_preloadedNanoappIds) override; ::ndk::ScopedAStatus registerCallback( int32_t in_contextHubId, const std::shared_ptr& in_cb) override; ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId, diff --git a/contexthub/aidl/vts/Android.bp b/contexthub/aidl/vts/Android.bp index 673eac0b93..1534b40876 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-V1-cpp", + "android.hardware.contexthub-V2-cpp", "VtsHalContexthubUtils", ], test_suites: [ diff --git a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp index 3c01c6bac2..8104f27f5b 100644 --- a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp +++ b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp @@ -156,6 +156,19 @@ TEST_P(ContextHubAidl, TestQueryApps) { } } +// Calls getPreloadedNanoapps() and verifies there are preloaded nanoapps +TEST_P(ContextHubAidl, TestGetPreloadedNanoapps) { + std::vector preloadedNanoappIds; + Status status = contextHub->getPreloadedNanoappIds(&preloadedNanoappIds); + if (status.exceptionCode() == Status::EX_UNSUPPORTED_OPERATION || + status.transactionError() == android::UNKNOWN_TRANSACTION) { + return; // not supported -> old API; or not implemented + } + + ASSERT_TRUE(status.isOk()); + ASSERT_FALSE(preloadedNanoappIds.empty()); +} + // Helper callback that puts the TransactionResult for the expectedTransactionId into a // promise class TransactionResultCallback : public android::hardware::contexthub::BnContextHubCallback {