mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 10:44:41 +00:00
uwb: Default HAL implementation
Skeletal implementation of UWB HAL which will be used for cuttlefish/reference implementation in the future. Bug: 195992658 Test: Manual verification of HAL booting up and handling HAL API calls. Change-Id: I894b7aef893ff2ed4f287f72471326b5211245c3
This commit is contained in:
@@ -23,6 +23,7 @@ aidl_interface {
|
||||
enabled: true,
|
||||
},
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"com.android.uwb",
|
||||
],
|
||||
min_sdk_version: "current",
|
||||
|
||||
35
uwb/aidl/default/Android.bp
Normal file
35
uwb/aidl/default/Android.bp
Normal file
@@ -0,0 +1,35 @@
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.uwb-service",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["uwb-service.rc"],
|
||||
vintf_fragments: ["uwb-service.xml"],
|
||||
vendor: true,
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-g",
|
||||
],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libbinder_ndk",
|
||||
],
|
||||
static_libs: [
|
||||
"libbase",
|
||||
"libutils",
|
||||
"android.hardware.uwb-V1-ndk",
|
||||
],
|
||||
srcs: [
|
||||
"service.cpp",
|
||||
"uwb.cpp",
|
||||
"uwb_chip.cpp",
|
||||
],
|
||||
}
|
||||
2
uwb/aidl/default/OWNERS
Normal file
2
uwb/aidl/default/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
# Bug component: 1042770
|
||||
include platform/packages/modules/Uwb:/OWNERS
|
||||
42
uwb/aidl/default/service.cpp
Normal file
42
uwb/aidl/default/service.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
#include "uwb.h"
|
||||
|
||||
using ::aidl::android::hardware::uwb::IUwb;
|
||||
using ::android::sp;
|
||||
using ::android::base::InitLogging;
|
||||
using ::android::base::StderrLogger;
|
||||
using ::android::hardware::uwb::impl::Uwb;
|
||||
|
||||
int main(int /*argc*/, char* argv[]) {
|
||||
InitLogging(argv, StderrLogger);
|
||||
LOG(INFO) << "UWB HAL starting up";
|
||||
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<IUwb> uwb = ndk::SharedRefBase::make<Uwb>();
|
||||
const std::string instance = std::string() + IUwb::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(uwb->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
3
uwb/aidl/default/uwb-service.rc
Normal file
3
uwb/aidl/default/uwb-service.rc
Normal file
@@ -0,0 +1,3 @@
|
||||
service vendor.uwb_hal /vendor/bin/hw/android.hardware.uwb-service
|
||||
class hal
|
||||
user uwb
|
||||
10
uwb/aidl/default/uwb-service.xml
Normal file
10
uwb/aidl/default/uwb-service.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.uwb</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IUwb</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
55
uwb/aidl/default/uwb.cpp
Normal file
55
uwb/aidl/default/uwb.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "uwb.h"
|
||||
|
||||
namespace {
|
||||
static constexpr char kDefaultChipName[] = "default";
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace uwb {
|
||||
namespace impl {
|
||||
using namespace ::aidl::android::hardware::uwb;
|
||||
|
||||
// The default implementation of the HAL assumes 1 chip on the device.
|
||||
Uwb::Uwb() : chips_({{kDefaultChipName, ndk::SharedRefBase::make<UwbChip>(kDefaultChipName)}}) {}
|
||||
|
||||
Uwb::~Uwb() {}
|
||||
|
||||
::ndk::ScopedAStatus Uwb::getChips(std::vector<std::string>* names) {
|
||||
for (const auto& chip : chips_) {
|
||||
names->push_back(chip.first);
|
||||
}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus Uwb::getChip(const std::string& name, std::shared_ptr<IUwbChip>* chip) {
|
||||
const auto chip_found = chips_.find(name);
|
||||
if (chip_found == chips_.end()) {
|
||||
LOG(ERROR) << "Unknown chip name" << name;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
*chip = chip_found->second;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
} // namespace impl
|
||||
} // namespace uwb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
49
uwb/aidl/default/uwb.h
Normal file
49
uwb/aidl/default/uwb.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
#ifndef ANDROID_HARDWARE_UWB_UWB
|
||||
#define ANDROID_HARDWARE_UWB_UWB
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <aidl/android/hardware/uwb/BnUwb.h>
|
||||
#include <aidl/android/hardware/uwb/IUwbChip.h>
|
||||
|
||||
#include "uwb_chip.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace uwb {
|
||||
namespace impl {
|
||||
using namespace ::aidl::android::hardware::uwb;
|
||||
// Default implementation mean't to be used on simulator targets.
|
||||
class Uwb : public BnUwb {
|
||||
public:
|
||||
Uwb();
|
||||
virtual ~Uwb();
|
||||
|
||||
::ndk::ScopedAStatus getChips(std::vector<std::string>* names) override;
|
||||
::ndk::ScopedAStatus getChip(const std::string& name, std::shared_ptr<IUwbChip>* chip) override;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<UwbChip>> chips_;
|
||||
};
|
||||
} // namespace impl
|
||||
} // namespace uwb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_UWB_UWB
|
||||
57
uwb/aidl/default/uwb_chip.cpp
Normal file
57
uwb/aidl/default/uwb_chip.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
#include "uwb.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace uwb {
|
||||
namespace impl {
|
||||
using namespace ::aidl::android::hardware::uwb;
|
||||
|
||||
UwbChip::UwbChip(const std::string& name) : name_(name) {}
|
||||
UwbChip::~UwbChip() {}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::getName(std::string* name) {
|
||||
*name = name_;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::open(
|
||||
const std::shared_ptr<IUwbClientCallback>& /* clientCallback */) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::close() {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::coreInit() {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::getSupportedVendorUciVersion(int32_t* /* version */) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus UwbChip::sendUciMessage(const std::vector<uint8_t>& /* data */,
|
||||
int32_t* /* bytes_written */) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
} // namespace impl
|
||||
} // namespace uwb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
52
uwb/aidl/default/uwb_chip.h
Normal file
52
uwb/aidl/default/uwb_chip.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_UWB_UWBCHIP
|
||||
#define ANDROID_HARDWARE_UWB_UWBCHIP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <aidl/android/hardware/uwb/BnUwbChip.h>
|
||||
#include <aidl/android/hardware/uwb/IUwbClientCallback.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace uwb {
|
||||
namespace impl {
|
||||
using namespace ::aidl::android::hardware::uwb;
|
||||
// Default implementation mean't to be used on simulator targets.
|
||||
class UwbChip : public BnUwbChip {
|
||||
public:
|
||||
UwbChip(const std::string& name);
|
||||
virtual ~UwbChip();
|
||||
|
||||
::ndk::ScopedAStatus getName(std::string* name) override;
|
||||
::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 sendUciMessage(const std::vector<uint8_t>& data,
|
||||
int32_t* bytes_written) override;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
} // namespace impl
|
||||
} // namespace uwb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_UWB_UWBCHIP
|
||||
Reference in New Issue
Block a user