添加离线日志功能,通过 ./autobuild.sh uoffline 可以编译专门的离线日志版本,并添加了调试窗口离线日志的开关。 1416/1 1416/head
authorSnickerSun <snickersun@163.com>
Mon, 18 Nov 2024 08:26:42 +0000 (16:26 +0800)
committerSnickerSun <snickersun@163.com>
Mon, 18 Nov 2024 08:26:42 +0000 (16:26 +0800)
code/sdk/application/wearable/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp
code/sdk/build/config/target_config/brandy/config.py
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/middleware/chips/brandy/dfx/include/log_def_app.h

index 9fc759a..4574473 100644 (file)
@@ -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();
index d59ff94..1447a51 100644 (file)
@@ -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<UIView::OnClickListener *>(&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;
             }
index a376097..a9a2dfa 100755 (executable)
@@ -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',
index c0ed150..2f64b0a 100644 (file)
@@ -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
index cd99679..e84ada1 100644 (file)
@@ -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"
 
 
index 82d949d..179e005 100755 (executable)
@@ -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;