From: Caisking <3449750381@qq.com> Date: Sat, 5 Oct 2024 09:41:01 +0000 (+0800) Subject: 系统:修改充电弹窗的CallBack刷新;提前预防刷新空组件 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1113%2Fhead;p=mirrors%2FFD230.git 系统:修改充电弹窗的CallBack刷新;提前预防刷新空组件 --- 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);