mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 21:37:44 +00:00
Merge "[threadnetwork] update the platform log API usages and implementations" into main am: f02c7e0b2f
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3029147 Change-Id: Ibde625fd05767f311c13d280d2e3795813b0712c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -42,6 +42,8 @@ namespace android {
|
|||||||
namespace hardware {
|
namespace hardware {
|
||||||
namespace threadnetwork {
|
namespace threadnetwork {
|
||||||
|
|
||||||
|
const char SocketInterface::kLogModuleName[] = "SocketIntface";
|
||||||
|
|
||||||
SocketInterface::SocketInterface(const ot::Url::Url& aRadioUrl)
|
SocketInterface::SocketInterface(const ot::Url::Url& aRadioUrl)
|
||||||
: mReceiveFrameCallback(nullptr),
|
: mReceiveFrameCallback(nullptr),
|
||||||
mReceiveFrameContext(nullptr),
|
mReceiveFrameContext(nullptr),
|
||||||
@@ -157,7 +159,7 @@ void SocketInterface::Read(void) {
|
|||||||
} else if (rval < 0) {
|
} else if (rval < 0) {
|
||||||
DieNow(OT_EXIT_ERROR_ERRNO);
|
DieNow(OT_EXIT_ERROR_ERRNO);
|
||||||
} else {
|
} else {
|
||||||
otLogCritPlat("Socket connection is closed by remote.");
|
LogCrit("Socket connection is closed by remote.");
|
||||||
exit(OT_EXIT_FAILURE);
|
exit(OT_EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +194,7 @@ void SocketInterface::HandleSocketFrame(otError aError) {
|
|||||||
mReceiveFrameCallback(mReceiveFrameContext);
|
mReceiveFrameCallback(mReceiveFrameContext);
|
||||||
} else {
|
} else {
|
||||||
mReceiveFrameBuffer->DiscardFrame();
|
mReceiveFrameBuffer->DiscardFrame();
|
||||||
otLogWarnPlat("Process socket frame failed: %s", otThreadErrorToString(aError));
|
LogWarn("Process socket frame failed: %s", otThreadErrorToString(aError));
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@@ -204,16 +206,16 @@ int SocketInterface::OpenFile(const ot::Url::Url& aRadioUrl) {
|
|||||||
sockaddr_un serverAddress;
|
sockaddr_un serverAddress;
|
||||||
|
|
||||||
VerifyOrExit(sizeof(serverAddress.sun_path) > strlen(aRadioUrl.GetPath()),
|
VerifyOrExit(sizeof(serverAddress.sun_path) > strlen(aRadioUrl.GetPath()),
|
||||||
otLogCritPlat("Invalid file path length"));
|
LogCrit("Invalid file path length"));
|
||||||
strncpy(serverAddress.sun_path, aRadioUrl.GetPath(), sizeof(serverAddress.sun_path));
|
strncpy(serverAddress.sun_path, aRadioUrl.GetPath(), sizeof(serverAddress.sun_path));
|
||||||
serverAddress.sun_family = AF_UNIX;
|
serverAddress.sun_family = AF_UNIX;
|
||||||
|
|
||||||
fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
||||||
VerifyOrExit(fd != -1, otLogCritPlat("open(): errno=%s", strerror(errno)));
|
VerifyOrExit(fd != -1, LogCrit("open(): errno=%s", strerror(errno)));
|
||||||
|
|
||||||
if (connect(fd, reinterpret_cast<struct sockaddr*>(&serverAddress), sizeof(serverAddress)) ==
|
if (connect(fd, reinterpret_cast<struct sockaddr*>(&serverAddress), sizeof(serverAddress)) ==
|
||||||
-1) {
|
-1) {
|
||||||
otLogCritPlat("connect(): errno=%s", strerror(errno));
|
LogCrit("connect(): errno=%s", strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
@@ -225,9 +227,9 @@ exit:
|
|||||||
void SocketInterface::CloseFile(void) {
|
void SocketInterface::CloseFile(void) {
|
||||||
VerifyOrExit(mSockFd != -1);
|
VerifyOrExit(mSockFd != -1);
|
||||||
|
|
||||||
VerifyOrExit(0 == close(mSockFd), otLogCritPlat("close(): errno=%s", strerror(errno)));
|
VerifyOrExit(0 == close(mSockFd), LogCrit("close(): errno=%s", strerror(errno)));
|
||||||
VerifyOrExit(wait(nullptr) != -1 || errno == ECHILD,
|
VerifyOrExit(wait(nullptr) != -1 || errno == ECHILD,
|
||||||
otLogCritPlat("wait(): errno=%s", strerror(errno)));
|
LogCrit("wait(): errno=%s", strerror(errno)));
|
||||||
|
|
||||||
mSockFd = -1;
|
mSockFd = -1;
|
||||||
|
|
||||||
@@ -254,7 +256,7 @@ void SocketInterface::WaitForSocketFileCreated(const char* aPath) {
|
|||||||
wd = inotify_add_watch(inotifyFd, folderPath.c_str(), IN_CREATE);
|
wd = inotify_add_watch(inotifyFd, folderPath.c_str(), IN_CREATE);
|
||||||
VerifyOrDie(wd != -1, OT_EXIT_ERROR_ERRNO);
|
VerifyOrDie(wd != -1, OT_EXIT_ERROR_ERRNO);
|
||||||
|
|
||||||
otLogInfoPlat("Waiting for socket file %s be created...", aPath);
|
LogInfo("Waiting for socket file %s be created...", aPath);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
@@ -286,7 +288,7 @@ void SocketInterface::WaitForSocketFileCreated(const char* aPath) {
|
|||||||
close(inotifyFd);
|
close(inotifyFd);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
otLogInfoPlat("Socket file: %s is created", aPath);
|
LogInfo("Socket file: %s is created", aPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "lib/spinel/spinel_interface.hpp"
|
#include "lib/spinel/spinel_interface.hpp"
|
||||||
#include "lib/url/url.hpp"
|
#include "lib/url/url.hpp"
|
||||||
|
#include "logger.hpp"
|
||||||
|
|
||||||
namespace aidl {
|
namespace aidl {
|
||||||
namespace android {
|
namespace android {
|
||||||
@@ -32,8 +33,11 @@ namespace threadnetwork {
|
|||||||
* Defines a Socket interface to the Radio Co-processor (RCP)
|
* Defines a Socket interface to the Radio Co-processor (RCP)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SocketInterface : public ot::Spinel::SpinelInterface {
|
class SocketInterface : public ot::Spinel::SpinelInterface,
|
||||||
|
public ot::Posix::Logger<SocketInterface> {
|
||||||
public:
|
public:
|
||||||
|
static const char kLogModuleName[]; ///< Module name used for logging.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the object.
|
* Initializes the object.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,6 +20,20 @@
|
|||||||
#include <openthread/platform/alarm-milli.h>
|
#include <openthread/platform/alarm-milli.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
void otLogPlatArgs(otLogLevel aLogLevel, const char* aPlatModuleName, const char* aFormat,
|
||||||
|
va_list aArgs) {
|
||||||
|
OT_UNUSED_VARIABLE(aPlatModuleName);
|
||||||
|
static const android_LogPriority kLogPriorities[] = {ANDROID_LOG_SILENT, ANDROID_LOG_FATAL,
|
||||||
|
ANDROID_LOG_WARN, ANDROID_LOG_INFO,
|
||||||
|
ANDROID_LOG_INFO, ANDROID_LOG_DEBUG};
|
||||||
|
|
||||||
|
if (aLogLevel >= sizeof(kLogPriorities) / sizeof(android_LogPriority)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
__android_log_vprint(kLogPriorities[aLogLevel], LOG_TAG, aFormat, aArgs);
|
||||||
|
}
|
||||||
|
|
||||||
void otLogCritPlat(const char* format, ...) {
|
void otLogCritPlat(const char* format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -28,38 +42,6 @@ void otLogCritPlat(const char* format, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void otLogWarnPlat(const char* format, ...) {
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
__android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void otLogNotePlat(const char* format, ...) {
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
__android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void otLogInfoPlat(const char* format, ...) {
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
__android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void otLogDebgPlat(const char* format, ...) {
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
__android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void otDumpDebgPlat(const char* aText, const void* aData, uint16_t aDataLength) {
|
void otDumpDebgPlat(const char* aText, const void* aData, uint16_t aDataLength) {
|
||||||
constexpr uint16_t kBufSize = 512;
|
constexpr uint16_t kBufSize = 512;
|
||||||
char buf[kBufSize];
|
char buf[kBufSize];
|
||||||
|
|||||||
Reference in New Issue
Block a user