From 02bb546154b83cb276b384a58e556b9cf7630c2e Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Mon, 18 Nov 2024 16:26:42 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E7=A6=BB=E7=BA=BF=E6=97=A5?= =?utf8?q?=E5=BF=97=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=80=9A=E8=BF=87=20./autob?= =?utf8?q?uild.sh=20uoffline=20=E5=8F=AF=E4=BB=A5=E7=BC=96=E8=AF=91?= =?utf8?q?=E4=B8=93=E9=97=A8=E7=9A=84=E7=A6=BB=E7=BA=BF=E6=97=A5=E5=BF=97?= =?utf8?q?=E7=89=88=E6=9C=AC=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?utf8?q?=E8=B0=83=E8=AF=95=E7=AA=97=E5=8F=A3=E7=A6=BB=E7=BA=BF=E6=97=A5?= =?utf8?q?=E5=BF=97=E7=9A=84=E5=BC=80=E5=85=B3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../debug_output_notification.h | 6 +- .../debug_output_notification.cpp | 62 +++++++++++++++++++ .../config/target_config/brandy/config.py | 2 +- .../drivers/peripheral/utils/custom_utils.c | 38 ++++++++++++ .../drivers/peripheral/utils/custom_utils.h | 9 +++ .../chips/brandy/dfx/include/log_def_app.h | 1 + 6 files changed, 115 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h index 9fc759a45..45744739c 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-10-02 14:12:12 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-11-12 10:27:28 + * @LastEditors: SnickerSun snickersun@163.com + * @LastEditTime: 2024-11-18 15:33:22 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification.h */ #ifndef DEBUG_OUTPUT_NOTIFICATION_H @@ -49,6 +49,8 @@ namespace OHOS std::string get_system_screen_time(void); std::string get_uart_at_status(void); std::string get_current_vote_status(void); + std::string get_offline_log_status(void); + private: DebugOutputViewEventListener(); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index d59ff94e1..1447a5192 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -117,6 +117,7 @@ namespace OHOS UILabel *debugOutputLabel{nullptr}; UILabelButton *debugOutputLabelButton{nullptr}; UIToggleButton* toggleButton = nullptr; + UIToggleButton* toggleButtonOffline = nullptr; UILabelButton *debugOutputbleServiceLabelButton{nullptr}; static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton"; static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton"; @@ -155,6 +156,9 @@ namespace OHOS debugOutputItemInfo[index++] = {index, "wear_status"}; // 电量信息 debugOutputItemInfo[index++] = {index, "battery_percent"}; + //离线日志开关控制窗口,需要采用 ./autobuild.sh uoffline 【CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1】编译才有效 + debugOutputItemInfo[index++] = {index, "offline_log"}; + usedLen = index; /* -------------------------------- Add data -------------------------------- */ for (uint8_t i = 0; i < usedLen; i++) @@ -666,6 +670,12 @@ namespace OHOS return std::string(buf); } + + std::string DebugOutputViewEventListener::get_offline_log_status() { + uint8_t offline = get_offline_log_nv(); + return std::string("offline_log_status:") + std::to_string(offline); + } + bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) { std::string viewId = view.GetViewId(); @@ -701,6 +711,22 @@ namespace OHOS } // viewIndex = GetCurViewIndex(); return true; //进行UI刷新 + }//点击开启按键 + else if (viewId == "offline_log_switch") { + if (toggleButtonOffline) { + if (toggleButtonOffline->GetState() == false) { + int ret1 = enable_offline_log_nv(0); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"offline_log_switch false %d",ret1); + } + else { + int ret1 = enable_offline_log_nv(1); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"offline_log_switch true %d",ret1); + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"组件不存在"); + } + // viewIndex = GetCurViewIndex(); + return true; //进行UI刷新 } else // 如果点击的是列表中的itemview { @@ -775,6 +801,14 @@ namespace OHOS case 16: str = get_battery_percent(); break; + case 17: + str = get_offline_log_status(); + if (toggleButtonOffline) { + if (toggleButtonOffline->IsVisible() == false) { + toggleButtonOffline->SetVisible(true); + } + } + break; default: str = "--"; break; @@ -983,6 +1017,28 @@ namespace OHOS toggleButton->SetViewId("uart_at_set");// Set style toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + if (toggleButtonOffline == nullptr) { + toggleButtonOffline = new UIToggleButton(); + } + toggleButtonOffline->SetPosition(147, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20+120); // widget's left position and top position + toggleButtonOffline->Resize(171, 121); // widget's width and height + toggleButtonOffline->SetViewId("offline_log_switch");// Set style + toggleButtonOffline->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + + if(get_offline_log_nv()==0) + toggleButtonOffline->SetState(false); + else + toggleButtonOffline->SetState(true); + toggleButtonOffline->SetVisible(false); //设置不可见 + UIView::OnClickListener *clickListeneroffline_ = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (clickListeneroffline_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListeneroffline is new fail!!"); + return nullptr; + } + toggleButtonOffline->SetOnClickListener(clickListeneroffline_); + DebugScrollView[1]->Add(toggleButtonOffline); //获取状态 auto logModel = SystemLogModel::GetInstance(); bool status = logModel->get_uart_status(); @@ -1167,6 +1223,12 @@ namespace OHOS delete debugOutputbleServiceLabelButton; debugOutputbleServiceLabelButton = nullptr; + delete toggleButton; + toggleButton = nullptr; + + delete toggleButtonOffline; + toggleButtonOffline = nullptr; + delete DebugScrollView[0]; DebugScrollView[0] = nullptr; } diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index a37609761..a9a2dfa02 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -226,7 +226,7 @@ target = { '-:DUMP_MEM_SUPPORT', '-:DUMP_REG_SUPPORT', '-:SUPPORT_DFX_EXCEPTION', - 'CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1'], + '-:CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1'], }, 'brandy-native-js-oob128': { 'base_target_name': 'brandy-native-js', diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index c0ed150bd..2f64b0a90 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -3920,4 +3920,42 @@ void uapi_custom_set_uart_rx_enable_flag(bool enable_uart) errcode_t touch_resume_in_cmd_queue(void) { return do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_TOUCH_RESUME,NULL,0); +} + + +uint8_t get_offline_log_nv(void) +{ +#ifdef CONFIG_NV_FEATURE_SUPPORT + uint8_t flag = 0; + uint16_t length; + errcode_t ret = uapi_nv_read(NV_ID_OFFLINELOG_ENBALE_FLAG, sizeof(flag), &length, &flag); + if (ret != ERRCODE_SUCC) { + return 0; + } + return flag; +#else + return 0; +#endif +} +errcode_t enable_offline_log_nv(uint8_t log_enable) +{ + +#ifdef CONFIG_NV_FEATURE_SUPPORT + uint8_t flag = log_enable; + uint16_t length; + errcode_t ret = uapi_nv_write(NV_ID_OFFLINELOG_ENBALE_FLAG, &flag, sizeof(flag)); + if (ret != ERRCODE_SUCC) { + // uapi_zdiag_set_offline_log_enable(false); + return ret; + } + if (log_enable != 0) { + uapi_zdiag_set_offline_log_enable(true); + } else { + uapi_zdiag_set_offline_log_enable(false); + } + return ERRCODE_SUCC; +#endif + + + return ERRCODE_SUCC; } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index cd99679da..e84ada1f4 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -410,6 +410,15 @@ void BtInitSpp(void); void mcu_reset(void); void mcu_poweroff(void); +/** + * 获取offline log 开关标识 需要采用 ./autobuild.sh uoffline 【 CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1】编译才有效 +*/ +uint8_t get_offline_log_nv(void); +/** + * 设置 offline log 开关标识,需要采用 ./autobuild.sh uoffline 【CONFIG_DFX_SUPPORT_OFFLINE_LOG_FILE=1】编译才有效 +*/ +errcode_t enable_offline_log_nv(uint8_t log_enable); + #include "custom_utilscpp.h" diff --git a/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h b/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h index 82d949d16..179e0054d 100755 --- a/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h +++ b/code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h @@ -519,6 +519,7 @@ typedef enum { TESTPING_CPP, CALENDARVIEW_CPP, CALENDARPRESENTER_CPP, + SETTIMEFORMATMODEL_CPP, APP_FILE_ID_MAX = 1024, } log_file_list_enum_app_t; -- 2.17.1