mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 22:04:26 +00:00
Merge changes from topic "cherrypicker-L18700000961261875:N88400001378560897" am: 59b018679b am: fb6fbba8b2 am: fe48fc62cc am: e3aab0b12a
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2627570 Change-Id: Ifc92a0284bfd91f8fb333aa641dfe568f373328a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -717,12 +717,4 @@
|
||||
<regex-instance>.*</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.threadnetwork</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IThreadChip</name>
|
||||
<regex-instance>chip[0-9]+</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</compatibility-matrix>
|
||||
|
||||
@@ -685,4 +685,12 @@
|
||||
<regex-instance>.*</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.threadnetwork</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IThreadChip</name>
|
||||
<regex-instance>chip[0-9]+</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</compatibility-matrix>
|
||||
|
||||
@@ -24,10 +24,6 @@ cc_defaults {
|
||||
"libutils",
|
||||
],
|
||||
|
||||
cppflags: [
|
||||
"-Wno-non-virtual-dtor",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"openthread-common",
|
||||
"openthread-hdlc",
|
||||
@@ -48,9 +44,43 @@ cc_binary {
|
||||
name: "android.hardware.threadnetwork-service.sim",
|
||||
defaults: ["threadnetwork_service_default"],
|
||||
init_rc: ["android.hardware.threadnetwork-service.sim.rc"],
|
||||
required: ["ot-rcp"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.threadnetwork-service",
|
||||
defaults: ["threadnetwork_service_default"],
|
||||
}
|
||||
|
||||
cc_fuzz {
|
||||
name: "android.hardware.threadnetwork-service.fuzzer",
|
||||
|
||||
defaults:["service_fuzzer_defaults"],
|
||||
shared_libs: [
|
||||
"libbinder_ndk",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"android.hardware.threadnetwork-V1-ndk",
|
||||
"libbase",
|
||||
"liblog",
|
||||
"openthread-common",
|
||||
"openthread-hdlc",
|
||||
"openthread-platform",
|
||||
"openthread-posix",
|
||||
"openthread-url",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
"thread_chip.cpp",
|
||||
"utils.cpp",
|
||||
"fuzzer.cpp",
|
||||
],
|
||||
|
||||
required: ["ot-rcp"],
|
||||
fuzz_config: {
|
||||
cc: [
|
||||
"zhanglongxia@google.com",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
* Copyright (C) 2023 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.
|
||||
@@ -14,7 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <fuzzbinder/libbinder_ndk_driver.h>
|
||||
#include <fuzzer/FuzzedDataProvider.h>
|
||||
#include "thread_chip.hpp"
|
||||
|
||||
using aidl::android::hardware::threadnetwork::ThreadChip;
|
||||
using android::fuzzService;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
char url[] = "spinel+hdlc+forkpty:///vendor/bin/ot-rcp?forkpty-arg=2";
|
||||
auto service = ndk::SharedRefBase::make<ThreadChip>(url);
|
||||
|
||||
fuzzService(service->asBinder().get(), FuzzedDataProvider(data, size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LOG_TAG "threadnetwork_hal"
|
||||
#include <utils/Log.h>
|
||||
@@ -14,14 +14,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <aidl/android/hardware/threadnetwork/IThreadChip.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "service.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "thread_chip.hpp"
|
||||
|
||||
using aidl::android::hardware::threadnetwork::IThreadChip;
|
||||
using aidl::android::hardware::threadnetwork::ThreadChip;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
CHECK_GT(argc, 1);
|
||||
aidl::android::hardware::threadnetwork::Service service(&argv[1], argc - 1);
|
||||
std::vector<std::shared_ptr<ThreadChip>> threadChips;
|
||||
aidl::android::hardware::threadnetwork::Service service;
|
||||
|
||||
for (int id = 0; id < argc - 1; id++) {
|
||||
binder_status_t status;
|
||||
const std::string serviceName(std::string() + IThreadChip::descriptor + "/chip" +
|
||||
std::to_string(id));
|
||||
auto threadChip = ndk::SharedRefBase::make<ThreadChip>(argv[id + 1]);
|
||||
|
||||
CHECK_NE(threadChip, nullptr);
|
||||
|
||||
status = AServiceManager_addService(threadChip->asBinder().get(), serviceName.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
|
||||
ALOGI("ServiceName: %s, Url: %s", serviceName.c_str(), argv[id + 1]);
|
||||
threadChips.push_back(std::move(threadChip));
|
||||
}
|
||||
|
||||
ALOGI("Thread Network HAL is running");
|
||||
|
||||
|
||||
@@ -18,25 +18,14 @@
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "thread_chip.hpp"
|
||||
#include "utils.hpp"
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace threadnetwork {
|
||||
|
||||
Service::Service(char* urls[], int numUrls) : mBinderFd(-1) {
|
||||
CHECK_NE(urls, nullptr);
|
||||
CHECK_GT(numUrls, 0);
|
||||
|
||||
for (int i = 0; i < numUrls; i++) {
|
||||
auto threadChip = ndk::SharedRefBase::make<ThreadChip>(i, urls[i]);
|
||||
CHECK_NE(threadChip, nullptr);
|
||||
mThreadChips.push_back(std::move(threadChip));
|
||||
}
|
||||
|
||||
Service::Service(void) : mBinderFd(-1) {
|
||||
binder_status_t status = ABinderProcess_setupPolling(&mBinderFd);
|
||||
CHECK_EQ(status, ::STATUS_OK);
|
||||
CHECK_GE(mBinderFd, 0);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include "mainloop.hpp"
|
||||
#include "thread_chip.hpp"
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
@@ -24,7 +23,7 @@ namespace threadnetwork {
|
||||
|
||||
class Service : public ot::Posix::Mainloop::Source {
|
||||
public:
|
||||
Service(char* urls[], int numUrls);
|
||||
Service(void);
|
||||
|
||||
void Update(otSysMainloopContext& context) override;
|
||||
void Process(const otSysMainloopContext& context) override;
|
||||
@@ -32,7 +31,6 @@ class Service : public ot::Posix::Mainloop::Source {
|
||||
|
||||
private:
|
||||
int mBinderFd;
|
||||
std::vector<std::shared_ptr<ThreadChip>> mThreadChips;
|
||||
};
|
||||
} // namespace threadnetwork
|
||||
} // namespace hardware
|
||||
|
||||
@@ -19,26 +19,19 @@
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "utils.hpp"
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace threadnetwork {
|
||||
|
||||
ThreadChip::ThreadChip(uint8_t id, char* url)
|
||||
ThreadChip::ThreadChip(char* url)
|
||||
: mUrl(),
|
||||
mInterface(handleReceivedFrame, this, mRxFrameBuffer),
|
||||
mRxFrameBuffer(),
|
||||
mCallback(nullptr) {
|
||||
const std::string name(std::string() + IThreadChip::descriptor + "/chip" + std::to_string(id));
|
||||
binder_status_t status;
|
||||
|
||||
ALOGI("ServiceName: %s, Url: %s", name.c_str(), url);
|
||||
CHECK_EQ(mUrl.Init(url), 0);
|
||||
status = AServiceManager_addService(asBinder().get(), name.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
}
|
||||
|
||||
void ThreadChip::clientDeathCallback(void* context) {
|
||||
@@ -85,17 +78,13 @@ ndk::ScopedAStatus ThreadChip::open(const std::shared_ptr<IThreadChipCallback>&
|
||||
status = ndk::ScopedAStatus::ok();
|
||||
|
||||
exit:
|
||||
if (!status.isOk())
|
||||
{
|
||||
if (mBinderDeathRecipient != nullptr)
|
||||
{
|
||||
AIBinder_DeathRecipient_delete(mBinderDeathRecipient);
|
||||
mBinderDeathRecipient = nullptr;
|
||||
if (!status.isOk()) {
|
||||
if (mBinderDeathRecipient != nullptr) {
|
||||
AIBinder_DeathRecipient_delete(mBinderDeathRecipient);
|
||||
mBinderDeathRecipient = nullptr;
|
||||
}
|
||||
ALOGW("Open failed, error: %s", status.getDescription().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ALOGI("open()");
|
||||
}
|
||||
|
||||
@@ -137,8 +126,7 @@ ndk::ScopedAStatus ThreadChip::sendSpinelFrame(const std::vector<uint8_t>& in_fr
|
||||
}
|
||||
|
||||
exit:
|
||||
if (!status.isOk())
|
||||
{
|
||||
if (!status.isOk()) {
|
||||
ALOGW("Send spinel frame failed, error: %s", status.getDescription().c_str());
|
||||
}
|
||||
|
||||
@@ -146,25 +134,20 @@ exit:
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ThreadChip::reset() {
|
||||
mInterface.OnRcpReset();
|
||||
mInterface.HardwareReset();
|
||||
ALOGI("reset()");
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
void ThreadChip::Update(otSysMainloopContext& context) {
|
||||
if (mCallback != nullptr) {
|
||||
mInterface.UpdateFdSet(context.mReadFdSet, context.mWriteFdSet, context.mMaxFd,
|
||||
context.mTimeout);
|
||||
mInterface.UpdateFdSet(&context);
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadChip::Process(const otSysMainloopContext& context) {
|
||||
struct RadioProcessContext radioContext;
|
||||
|
||||
if (mCallback != nullptr) {
|
||||
radioContext.mReadFdSet = &context.mReadFdSet;
|
||||
radioContext.mWriteFdSet = &context.mWriteFdSet;
|
||||
mInterface.Process(radioContext);
|
||||
mInterface.Process(&context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace threadnetwork {
|
||||
|
||||
class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
|
||||
public:
|
||||
ThreadChip(uint8_t id, char* url);
|
||||
ThreadChip(char* url);
|
||||
|
||||
ndk::ScopedAStatus open(const std::shared_ptr<IThreadChipCallback>& in_callback) override;
|
||||
ndk::ScopedAStatus close() override;
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/logging.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
void otLogCritPlat(const char* format, ...) {
|
||||
va_list args;
|
||||
@@ -34,3 +35,7 @@ void otLogWarnPlat(const char* format, ...) {
|
||||
__android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK void otPlatAlarmMilliFired(otInstance* aInstance) {
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user