Merge "Adds a HAL API to get the list of preloaded nanoapp"
This commit is contained in:
commit
3d598ca5b8
9 changed files with 46 additions and 5 deletions
|
@ -206,6 +206,7 @@
|
|||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.contexthub</name>
|
||||
<version>2</version>
|
||||
<interface>
|
||||
<name>IContextHub</name>
|
||||
<instance>default</instance>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -76,6 +76,17 @@ ScopedAStatus ContextHub::queryNanoapps(int32_t in_contextHubId) {
|
|||
}
|
||||
}
|
||||
|
||||
ScopedAStatus ContextHub::getPreloadedNanoappIds(std::vector<int64_t>* 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<IContextHubCallback>& in_cb) {
|
||||
if (in_contextHubId == kMockHubId) {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.contexthub</name>
|
||||
<version>1</version>
|
||||
<fqname>IContextHub/default</fqname>
|
||||
<version>2</version>
|
||||
<interface>
|
||||
<name>IContextHub</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <aidl/android/hardware/contexthub/BnContextHub.h>
|
||||
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
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<int64_t>* out_preloadedNanoappIds) override;
|
||||
::ndk::ScopedAStatus registerCallback(
|
||||
int32_t in_contextHubId, const std::shared_ptr<IContextHubCallback>& in_cb) override;
|
||||
::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId,
|
||||
|
|
|
@ -32,7 +32,7 @@ cc_test {
|
|||
"libbinder",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.contexthub-V1-cpp",
|
||||
"android.hardware.contexthub-V2-cpp",
|
||||
"VtsHalContexthubUtils",
|
||||
],
|
||||
test_suites: [
|
||||
|
|
|
@ -156,6 +156,19 @@ TEST_P(ContextHubAidl, TestQueryApps) {
|
|||
}
|
||||
}
|
||||
|
||||
// Calls getPreloadedNanoapps() and verifies there are preloaded nanoapps
|
||||
TEST_P(ContextHubAidl, TestGetPreloadedNanoapps) {
|
||||
std::vector<int64_t> 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 {
|
||||
|
|
Loading…
Reference in a new issue