Merge "Thread HAL: support dynamic radio URLs" into main am: db7bab9eba

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3064585

Change-Id: I27cfc5508a80b2ca250b67e5f7f138b17501b287
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2024-04-30 01:47:13 +00:00 committed by Automerger Merge Worker
commit 8517eacd26
3 changed files with 22 additions and 19 deletions

View file

@ -26,24 +26,29 @@
using aidl::android::hardware::threadnetwork::IThreadChip;
using aidl::android::hardware::threadnetwork::ThreadChip;
namespace {
void addThreadChip(int id, const char* url) {
binder_status_t status;
const std::string serviceName(std::string() + IThreadChip::descriptor + "/chip" +
std::to_string(id));
ALOGI("ServiceName: %s, Url: %s", serviceName.c_str(), url);
auto threadChip = ndk::SharedRefBase::make<ThreadChip>(url);
CHECK_NE(threadChip, nullptr);
status = AServiceManager_addService(threadChip->asBinder().get(), serviceName.c_str());
CHECK_EQ(status, STATUS_OK);
}
}
int main(int argc, char* argv[]) {
CHECK_GT(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));
addThreadChip(id, argv[id + 1]);
}
ALOGI("Thread Network HAL is running");

View file

@ -32,11 +32,9 @@ namespace android {
namespace hardware {
namespace threadnetwork {
ThreadChip::ThreadChip(char* url) : mUrl(), mRxFrameBuffer(), mCallback(nullptr) {
ThreadChip::ThreadChip(const char* url) : mUrl(url), mRxFrameBuffer(), mCallback(nullptr) {
const char* interfaceName;
CHECK_EQ(mUrl.Init(url), 0);
interfaceName = mUrl.GetProtocol();
CHECK_NE(interfaceName, nullptr);

View file

@ -20,8 +20,8 @@
#include <aidl/android/hardware/threadnetwork/IThreadChipCallback.h>
#include "lib/spinel/spinel_interface.hpp"
#include "lib/url/url.hpp"
#include "mainloop.hpp"
#include "radio_url.hpp"
#include <android/binder_auto_utils.h>
#include <android/binder_ibinder.h>
@ -34,7 +34,7 @@ namespace threadnetwork {
class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
public:
ThreadChip(char* url);
ThreadChip(const char* url);
~ThreadChip() {}
ndk::ScopedAStatus open(const std::shared_ptr<IThreadChipCallback>& in_callback) override;
@ -55,7 +55,7 @@ class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
ndk::ScopedAStatus initChip(const std::shared_ptr<IThreadChipCallback>& in_callback);
ndk::ScopedAStatus deinitChip();
ot::Url::Url mUrl;
ot::Posix::RadioUrl mUrl;
std::shared_ptr<ot::Spinel::SpinelInterface> mSpinelInterface;
ot::Spinel::SpinelInterface::RxFrameBuffer mRxFrameBuffer;
std::shared_ptr<IThreadChipCallback> mCallback;