Merge "Add NanoappRpcService to Context Hub HAL"

This commit is contained in:
Arthur Ishiguro
2021-12-15 22:00:26 +00:00
committed by Android (Google) Code Review
5 changed files with 98 additions and 0 deletions

View File

@@ -38,4 +38,5 @@ parcelable NanoappInfo {
int nanoappVersion;
boolean enabled;
String[] permissions;
android.hardware.contexthub.NanoappRpcService[] rpcServices;
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.contexthub;
@VintfStability
parcelable NanoappRpcService {
long id;
int version;
}

View File

@@ -16,6 +16,8 @@
package android.hardware.contexthub;
import android.hardware.contexthub.NanoappRpcService;
@VintfStability
parcelable NanoappInfo {
/** The unique identifier of the nanoapp. */
@@ -39,4 +41,9 @@ parcelable NanoappInfo {
* this list.
*/
String[] permissions;
/**
* The list of RPC services supported by this nanoapp.
*/
NanoappRpcService[] rpcServices;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.contexthub;
/**
* An RPC service exposed by a nanoapp.
*
* The implementation of the RPC interface is not defined by the HAL, and is written
* at the messaging endpoint layers (Android app and/or CHRE nanoapp). NanoappRpcService
* contains the informational metadata to be consumed by the RPC interface layer.
*/
@VintfStability
parcelable NanoappRpcService {
/**
* The unique 64-bit ID of an RPC service exposed by a nanoapp. Note that
* the uniqueness is only required within the nanoapp's domain (i.e. the
* combination of the nanoapp ID and service id must be unique).
*/
long id;
/**
* The software version of this service, which follows the semantic
* versioning scheme (see semver.org). It follows the format
* major.minor.patch, where major and minor versions take up one byte
* each, and the patch version takes up the final 2 bytes.
*/
int version;
}

View File

@@ -41,6 +41,7 @@ using ::android::hardware::contexthub::IContextHub;
using ::android::hardware::contexthub::IContextHubCallbackDefault;
using ::android::hardware::contexthub::NanoappBinary;
using ::android::hardware::contexthub::NanoappInfo;
using ::android::hardware::contexthub::NanoappRpcService;
using ::android::hardware::contexthub::Setting;
using ::android::hardware::contexthub::vts_utils::kNonExistentAppId;
using ::android::hardware::contexthub::vts_utils::waitForCallback;
@@ -151,6 +152,14 @@ TEST_P(ContextHubAidl, TestQueryApps) {
for (const NanoappInfo& appInfo : appInfoList) {
EXPECT_NE(appInfo.nanoappId, UINT64_C(0));
EXPECT_NE(appInfo.nanoappId, kNonExistentAppId);
// Verify services are unique.
std::set<uint64_t> existingServiceIds;
for (const NanoappRpcService& rpcService : appInfo.rpcServices) {
EXPECT_NE(rpcService.id, UINT64_C(0));
EXPECT_EQ(existingServiceIds.count(rpcService.id), 0);
existingServiceIds.insert(rpcService.id);
}
}
}