mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
The latest OpenThread has updated the usage of the platform log APIs. This CL updates the log APIs usages and implementations. Bug: b/333301206 Test: Run ThreadNetwork HAL and check logs. Change-Id: I0c0999edbed1c041e2752d195e753d02b2c734f4
63 lines
2.2 KiB
C++
63 lines
2.2 KiB
C++
|
|
/*
|
|
* Copyright (C) 2022 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 <openthread/instance.h>
|
|
#include <openthread/logging.h>
|
|
#include <openthread/platform/alarm-milli.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, ...) {
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
__android_log_vprint(ANDROID_LOG_FATAL, LOG_TAG, format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
void otDumpDebgPlat(const char* aText, const void* aData, uint16_t aDataLength) {
|
|
constexpr uint16_t kBufSize = 512;
|
|
char buf[kBufSize];
|
|
|
|
if ((aText != nullptr) && (aData != nullptr)) {
|
|
const uint8_t* data = reinterpret_cast<const uint8_t*>(aData);
|
|
|
|
for (uint16_t i = 0; (i < aDataLength) && (i < (kBufSize - 1) / 3); i++) {
|
|
snprintf(buf + (i * 3), (kBufSize - 1) - (i * 3), "%02x ", data[i]);
|
|
}
|
|
|
|
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s: %s", aText, buf);
|
|
}
|
|
}
|
|
|
|
OT_TOOL_WEAK void otPlatAlarmMilliFired(otInstance* aInstance) {
|
|
OT_UNUSED_VARIABLE(aInstance);
|
|
}
|