mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
uwb(hal): Add a capabilities mechanism for vendor commands
For the vendor commands defined for Android, allow UWB chip vendors to optionally expose some of the features defined in a given version. Without this mechanism, any vendor commands added has to be supported by all chip vendors unconditionally (which may not be feasible based on hardware capabilities). Bug: 197886322 Test: Compiles Change-Id: I917f2dc0d203ba9304f58955ac3cdb9d1735106c
This commit is contained in:
@@ -53,9 +53,6 @@ aidl_interface {
|
||||
],
|
||||
},
|
||||
ndk: {
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"com.android.uwb",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.uwb.fira_android;
|
||||
@Backing(type="long") @VintfStability
|
||||
enum UwbAndroidCapabilities {
|
||||
POWER_STATS_QUERY = 1,
|
||||
}
|
||||
@@ -40,6 +40,7 @@ interface IUwbChip {
|
||||
void open(in android.hardware.uwb.IUwbClientCallback clientCallback);
|
||||
void close();
|
||||
void coreInit();
|
||||
int getSupportedVendorUciVersion();
|
||||
int getSupportedAndroidUciVersion();
|
||||
long getSupportedAndroidCapabilities();
|
||||
int sendUciMessage(in byte[] data);
|
||||
}
|
||||
|
||||
26
uwb/aidl/android/hardware/uwb/IUwbChip.aidl
Executable file → Normal file
26
uwb/aidl/android/hardware/uwb/IUwbChip.aidl
Executable file → Normal file
@@ -49,14 +49,24 @@ interface IUwbChip {
|
||||
*/
|
||||
void coreInit();
|
||||
|
||||
/**
|
||||
* Supported version of vendor UCI specification.
|
||||
*
|
||||
* This corresponds to the version of the "android.hardware.uwb.fira_android" types-only
|
||||
* package included in the HAL implementation. This vendor params/commands package will be
|
||||
* updated on a different cadence to the main UWB HAL interface package.
|
||||
*/
|
||||
int getSupportedVendorUciVersion();
|
||||
/**
|
||||
* Supported version of vendor UCI specification.
|
||||
*
|
||||
* @return Returns the version of the "android.hardware.uwb.fira_android" types-only
|
||||
* package included in the HAL implementation. This vendor params/commands package will be
|
||||
* updated on a different cadence to the main UWB HAL interface package.
|
||||
*/
|
||||
int getSupportedAndroidUciVersion();
|
||||
|
||||
/**
|
||||
* Mechanism to allow HAL implementation to optionally expose features that are defined
|
||||
* in the "android.hardware.uwb.fira_android" types-only package.
|
||||
*
|
||||
* @return Returns the bitmask of capabilities
|
||||
* (android.hardware.uwb.fira_android.UwbAndroidCapabilities) that is supported by the
|
||||
* HAL implementation.
|
||||
*/
|
||||
long getSupportedAndroidCapabilities();
|
||||
|
||||
/**
|
||||
* Write the UCI message to the UWB Subsystem.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.uwb.fira_android;
|
||||
|
||||
/**
|
||||
* Android specific capabilities should be defined here.
|
||||
*
|
||||
* For any features enabled via the FIRA vendor commands for Android, use this bitmask
|
||||
* to allow devices to expose the features supported by the HAL implementation.
|
||||
*
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="long")
|
||||
enum UwbAndroidCapabilities {
|
||||
/** TODO: Change the name if necessary when the corresponding vendor commands are added */
|
||||
POWER_STATS_QUERY = 0x1,
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
#include "uwb.h"
|
||||
|
||||
namespace {
|
||||
constexpr static int kVendorUciVersion = 1;
|
||||
constexpr static int32_t kAndroidUciVersion = 1;
|
||||
constexpr static int64_t kAndroidCapabilities = 0;
|
||||
}
|
||||
|
||||
namespace android {
|
||||
@@ -50,8 +51,13 @@ UwbChip::~UwbChip() {}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::getSupportedVendorUciVersion(int32_t* version) {
|
||||
*version = kVendorUciVersion;
|
||||
::ndk::ScopedAStatus UwbChip::getSupportedAndroidUciVersion(int32_t* version) {
|
||||
*version = kAndroidUciVersion;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::getSupportedAndroidCapabilities(int64_t* capabilities) {
|
||||
*capabilities = kAndroidCapabilities;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class UwbChip : public BnUwbChip {
|
||||
::ndk::ScopedAStatus open(const std::shared_ptr<IUwbClientCallback>& clientCallback) override;
|
||||
::ndk::ScopedAStatus close() override;
|
||||
::ndk::ScopedAStatus coreInit() override;
|
||||
::ndk::ScopedAStatus getSupportedVendorUciVersion(int32_t* version) override;
|
||||
::ndk::ScopedAStatus getSupportedAndroidUciVersion(int32_t* version) override;
|
||||
::ndk::ScopedAStatus getSupportedAndroidCapabilities(int64_t* capabilities) override;
|
||||
::ndk::ScopedAStatus sendUciMessage(const std::vector<uint8_t>& data,
|
||||
int32_t* bytes_written) override;
|
||||
|
||||
|
||||
@@ -166,15 +166,23 @@ TEST_P(UwbAidl, ChipCoreInit) {
|
||||
EXPECT_TRUE(iuwb_chip->coreInit().isOk());
|
||||
}
|
||||
|
||||
TEST_P(UwbAidl, ChipGetSupportedVendorUciVersion) {
|
||||
TEST_P(UwbAidl, ChipGetSupportedAndroidUciVersion) {
|
||||
const auto iuwb_chip = getAnyChipAndOpen();
|
||||
EXPECT_TRUE(iuwb_chip->coreInit().isOk());
|
||||
|
||||
int version;
|
||||
EXPECT_TRUE(iuwb_chip->getSupportedVendorUciVersion(&version).isOk());
|
||||
int32_t version;
|
||||
EXPECT_TRUE(iuwb_chip->getSupportedAndroidUciVersion(&version).isOk());
|
||||
EXPECT_GT(version, 0);
|
||||
}
|
||||
|
||||
TEST_P(UwbAidl, ChipGetSupportedAndroidCapabilities) {
|
||||
const auto iuwb_chip = getAnyChipAndOpen();
|
||||
EXPECT_TRUE(iuwb_chip->coreInit().isOk());
|
||||
|
||||
int64_t capabilities;
|
||||
EXPECT_TRUE(iuwb_chip->getSupportedAndroidCapabilities(&capabilities).isOk());
|
||||
}
|
||||
|
||||
TEST_P(UwbAidl, ChipGetName) {
|
||||
std::string chip_name = getAnyChipName();
|
||||
std::shared_ptr<IUwbChip> iuwb_chip;
|
||||
|
||||
Reference in New Issue
Block a user