From 4886dcd321d0a147532146a48c324210c5f7d72b Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Sat, 5 Oct 2024 17:41:01 +0800 Subject: [PATCH] =?utf8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9A=E4=BF=AE=E6=94=B9?= =?utf8?q?=E5=85=85=E7=94=B5=E5=BC=B9=E7=AA=97=E7=9A=84CallBack=E5=88=B7?= =?utf8?q?=E6=96=B0=EF=BC=9B=E6=8F=90=E5=89=8D=E9=A2=84=E9=98=B2=E5=88=B7?= =?utf8?q?=E6=96=B0=E7=A9=BA=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/message/src/MessageShowView.cpp | 2 +- .../nativeui/system/src/SystemLogModel.cpp | 22 +++++++++++-------- .../src/notify/charge_notification.cpp | 6 +++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp index 8585c26d0..5a3b373b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowView.cpp @@ -227,7 +227,7 @@ namespace OHOS titleStr = data->labelTitle; timeStr = data->labelTime; messageStr = data->labelDetails; - WEARABLE_LOGED(WEARABLE_LOG_MODULE_APP, "UpdateMessage title %s time %s message %s", titleStr.c_str(), timeStr.c_str(), messageStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateMessage title %s time %s message %s", titleStr.c_str(), timeStr.c_str(), messageStr.c_str()); } void MessageShowView::PreLoad(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp index de6459db7..208c1fb72 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp @@ -61,6 +61,7 @@ uint32_t SystemLogModel::GetCurrentTime() { return time; } +//保存日志 // 保存日志 bool SystemLogModel::saveLog(SystemLogData data) { // 将新日志添加到日志数据 @@ -71,7 +72,7 @@ bool SystemLogModel::saveLog(SystemLogData data) { logData.erase(logData.begin()); } - // 将日志写入文件 + // 将所有日志写入文件 std::ofstream ofs(SYSTEM_LOG_FILE_PATH, std::ios::trunc); if (!ofs.is_open()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, @@ -79,7 +80,10 @@ bool SystemLogModel::saveLog(SystemLogData data) { return false; } - ofs << static_cast(data.type) << " " << data.timestamp << std::endl; + for (const auto &log : logData) { + ofs << static_cast(log.type) << " " << log.timestamp << std::endl; + } + return true; } @@ -92,18 +96,18 @@ bool SystemLogModel::loadLog() { return false; } - logData.clear(); // 清空现有日志 + logData.clear(); SystemLogData data; - - while (ifs >> reinterpret_cast(data.type) >> data.timestamp) { - logData.push_back(data); + int type; + while (ifs >> type >> data.timestamp) { + data.type = static_cast(type); // 转换为 SystemLogType + logData.push_back(data); // 将读取的日志数据存入 logData } + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Loaded %d logs from file", + logData.size()); - ifs.close(); // 确保文件关闭 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Loaded log is ok"); return true; } - // 获取日志记录 std::vector SystemLogModel::getLogData() { return logData; } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp index 17674ce93..bc26730d0 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp @@ -57,6 +57,12 @@ namespace OHOS // 刷新回调 void Chargeing_Timer_CallBack(int data) { + if (UIViewGroup_charge == nullptr || UILabel_Chargeing == nullptr || + UILabel_power == nullptr || UILabel_time == nullptr || + batteryprogress== nullptr) { + return; + } + float voltage = 0.0F; uint8_t power = battery_get_voltage(&voltage); -- 2.17.1