From: luozheng <1732036298@qq.com> Date: Mon, 23 Jun 2025 08:33:41 +0000 (+0800) Subject: debug测试窗口代码添加 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~264 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a1f59ab97b0e214fee024303b34178239b999a5c;p=mirrors%2FFD230.git debug测试窗口代码添加 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/include/HeartModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/include/HeartModel.h index 00809cf43..316ba179e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/include/HeartModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/include/HeartModel.h @@ -1,12 +1,13 @@ #ifndef HEART_MODEL_H #define HEART_MODEL_H -#include "MainClockView.h" #include "broadcast_feature.h" #include "broadcast_service.h" #include "samgr_lite.h" #include - +#include "iostream" +#include "main/include/UiServersMsg.h" +#include "graphic_types.h" #ifdef __cplusplus extern "C" { #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartChartPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartChartPresenter.cpp index 9a3b0174e..f60a66a7b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartChartPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartChartPresenter.cpp @@ -27,6 +27,7 @@ #include "gfx_utils/mem_check.h" #include "NativeRegisterManager.h" +#include namespace OHOS { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartDetectionPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartDetectionPresenter.cpp index 08c9c0799..7d47169ce 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartDetectionPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartDetectionPresenter.cpp @@ -19,6 +19,7 @@ #include "heartrate/include/HeartModel.h" #include "MainModel.h" #include "NativeRegisterManager.h" +#include namespace OHOS { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp index 8abe2a0e5..838b1b012 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/heartrate/src/HeartModel.cpp @@ -27,7 +27,7 @@ #include "wearable_log.h" #include - +#include "MainClockView.h" // #include #include diff --git a/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c index 90c58937a..487ff8aee 100644 --- a/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c @@ -40,6 +40,7 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE, A_CORE_MASK, 1}, {TOPIC_EVENT_INACTIVITY_UPDATE, A_CORE_MASK, 1}, {TOPIC_EVENT_FIND_WATCH, A_CORE_MASK, 1}, + {TOPIC_EVENT_DEBUGOUTPUT, A_CORE_MASK, 1}, }; /* 所有的topic,其对应的位图 */ diff --git a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt index 6ee28d279..01d51049e 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt @@ -140,6 +140,9 @@ set(PRIVATE_HEADER ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/ + + ${ROOT_DIR}/zhihui/drivers + ${ROOT_DIR}/zhihui/services ) if("JS_ENABLE" IN_LIST DEFINES) @@ -157,6 +160,9 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/motion_recognition_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sedentaryReminder_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification_adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification_itemview.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification.cpp ) else() set(SOURCES @@ -172,6 +178,9 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/motion_recognition_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sedentaryReminder_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/findwatch_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification_adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification_itemview.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/debug_output_notification/debug_output_notification.cpp ) endif() diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h new file mode 100644 index 000000000..08aabfd7f --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification.h @@ -0,0 +1,62 @@ +#ifndef DEBUG_OUTPUT_NOTIFICATION_H +#define DEBUG_OUTPUT_NOTIFICATION_H +#include "View.h" +#include "debug_output_notification_item.h" +#include +namespace OHOS +{ + UIViewGroup *CreateDebugOutputMainView(void); + void FreeDebugOutputMainView(void); + + static const int ITEM_COUNT = 50; + class DebugOutputViewEventListener : public UIView::OnClickListener, public UIView::OnDragListener + { + public: + static DebugOutputViewEventListener &GetInstance(); + bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event) override; + bool ChangeDebugOutputMainView(int16_t thisView); + bool ChangeDebugOutputView1(int16_t thisView); + bool ClickFunc(int16_t interface); + bool CheckViewParam(int16_t hideView, int16_t showView); + void ChangeView(int16_t hideView, int16_t showView); + void DestroyTempView(int16_t hideView); + void SetCurViewIndex(int16_t viewNum); + int GetCurViewIndex(void); + void InitDebugOutputItem(); + void UpdateView(std::string str); + std::string get_bt_runtime_status_t(void); + std::string get_cat1_runtime_status_t(void); + std::string get_runtime_status_t(void); + std::string get_system_log(void); + std::string get_battery_info(void); + std::string get_shutdown_info(void); + std::string get_sleep_time(void); + std::string get_wear_status(void); + std::string get_battery_percent(void); + std::string get_free_memory(void); + std::string get_nextday_log(void); + std::string get_heart_rate(void); + std::string get_popup_windows_log(void); + 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(); + ~DebugOutputViewEventListener(); + DebugOutputViewEventListener(const DebugOutputViewEventListener &) = delete; + const DebugOutputViewEventListener &operator=(const DebugOutputViewEventListener &) = delete; + + DebugOutputItem debugOutputItemInfo[ITEM_COUNT] = {-1, nullptr}; + int curView{0}; + int usedLen{0}; + bool X_DRAG_FLAG{false}; + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_adapter.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_adapter.h new file mode 100644 index 000000000..0684cf762 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_adapter.h @@ -0,0 +1,35 @@ +#ifndef DEBUG_OUTPUT_NOTIFICATION_ADAPTER_H +#define DEBUG_OUTPUT_NOTIFICATION_ADAPTER_H + +#include +#include "components/ui_list.h" +#include "components/abstract_adapter.h" +#include "debug_output_notification_item.h" +namespace OHOS +{ + class DebugOutputAdapter : public AbstractAdapter + { + public: + explicit DebugOutputAdapter(); + ~DebugOutputAdapter() override; + + void SetData(std::list &data); + + uint16_t GetCount(void) override; + + UIView *GetView(UIView *inView, int16_t index) override; + + void AddListItem(const DebugOutputItem &item); + + void SetItemClickListener(UIView::OnClickListener *itemclicklistener) + { + itemClickListener = itemclicklistener; + } + + private: + std::list listData; + UIView::OnClickListener *itemClickListener{nullptr}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_item.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_item.h new file mode 100644 index 000000000..e8aa6fa79 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_item.h @@ -0,0 +1,14 @@ +#ifndef DEBUG_OUTPUT_NOTIFICATION_ITEM_H +#define DEBUG_OUTPUT_NOTIFICATION_ITEM_H +#include +#include "iostream" +#include "string" +namespace OHOS +{ + typedef struct + { + int index; + const char *name; + } DebugOutputItem; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_itemview.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_itemview.h new file mode 100644 index 000000000..149429f32 --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/debug_output_notification/debug_output_notification_itemview.h @@ -0,0 +1,26 @@ +#ifndef DEBUG_OUTPUT_NOTIFICATION_ITEMVIEW_H +#define DEBUG_OUTPUT_NOTIFICATION_ITEMVIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_button.h" +#include "components/ui_label.h" +#include "debug_output_notification_item.h" + +namespace OHOS +{ + class DebugOutputItemView : public UIViewGroup + { + public: + explicit DebugOutputItemView(); + ~DebugOutputItemView() override; + void SetItemInfo(const DebugOutputItem itemInfo); + void SetUpChild(); + + private: + UILabel label; + UILabelButton labelButton; + DebugOutputItem sItemInfo = {-1, nullptr}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp index ffbdb1844..c9c7a399c 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp @@ -51,6 +51,7 @@ #include "motion_recognition_notification.h" #include "sedentaryReminder_notification.h" #include "findwatch_notification.h" +#include "debug_output_notification/debug_output_notification.h" #ifdef SUPPORT_POWER_MANAGER #include "power_display_service.h" @@ -85,6 +86,7 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_INACTIVITY_UPDATE, PRIORITY_TWO}, // #endif {TOPIC_EVENT_FIND_WATCH,PRIORITY_TWO}, // 查找找手表 + {TOPIC_EVENT_DEBUGOUTPUT,PRIORITY_ONE},//开发调试专用窗口 }; @@ -131,6 +133,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_UPDATE); // #endif MsgCenterSubscribeTopic(TOPIC_EVENT_FIND_WATCH); + MsgCenterSubscribeTopic(TOPIC_EVENT_DEBUGOUTPUT); } @@ -206,6 +209,11 @@ static OHOS::UIViewGroup* showFindWatchNotify(void) return OHOS::CreateFindWatchView(); } +static OHOS::UIViewGroup* showDebugOutputNotify(void) +{ + return OHOS::CreateDebugOutputMainView(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -629,6 +637,17 @@ void MsgCenterNotifyFindWatchProc(const Topic topic, Request* req) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyPriority = %d ",NotificationManager::GetInstance()->GetNotifyPriority()); } } + +void MsgCenterNotifyDebugOutProc(const Topic topic, Request *req) +{ + unused(req); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyDebugOutProc !"); + if (CheckPriority(topic)) + { + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + NotificationManager::GetInstance()->ShowNotify(showDebugOutputNotify, (uint16_t)topic, true); + } +} #endif /* 订阅事件通知逻辑可定制 */ @@ -653,6 +672,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_INACTIVITY_UPDATE, MsgCenterNotifyInactivityProc}, // #endif {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc}, + {TOPIC_EVENT_DEBUGOUTPUT,MsgCenterNotifyDebugOutProc}, // {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc}, // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc}, diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp new file mode 100644 index 000000000..5aa95e8ef --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -0,0 +1,1653 @@ +#include "debug_output_notification/debug_output_notification_adapter.h" +#include "debug_output_notification/debug_output_notification_itemview.h" +#include "debug_output_notification/debug_output_notification.h" +#include "notification_manager.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "broadcast_feature.h" +#include "broadcast_service.h" +#include "custom_runtime.h" +#include "custom_utils.h" +#include "samgr_lite.h" +#include "tcxo.h" +#include "thread_adapter.h" +#include "thread_init.h" +#include "wearable_log.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "BluetoothModel.h" +#include +#include "diag_log.h" +#include "ConfigModelC.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button.h" +#include "components/ui_label_ext.h" +#include "components/ui_scroll_view.h" +#include "components/ui_toggle_button.h" +#include "system/include/SystemLogModel.h" +#include "sleep/include/SleepModel.h" + +// #ifdef FD230_650 +#include "heartrate/include/HeartModel.h" +// #endif +#include "heart_blood/health_service/health_service.h" +#include "displaybrightness/include/DisplayBrightnessModel.h" +#include "bluetooth/include/BluetoothModel.h" +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_hal.h" +#endif + +#ifdef SUPPORT_BLE_SERVICE +#include "bleService.h" +#include "bleEvent.h" +#include "bleInstruct.h" +#endif + +#include "battery_hal.h" +#include "battery_service.h" + +#ifdef SUPPORT_CAT1_SERVICE +#include "cat1_tcpServer.h" +#include "cat1_ctl.h" +#include "cat1_server.h" +#include "lwip/apps/http_client.h" +#endif + +#ifdef SUPPORT_PPG_SERVICE +#include "ppg_service.h" +#endif + +#include "vibrator_service.h" +namespace OHOS +{ + /**************************************************************************************************** */ + static int get_battery_percent_flag = 0; + static int refreshbutton_is_visible = 1; // 刷新按钮是否显示 + // 辅助函数 + + // 函数:读取文件夹中的文件 + std::vector readDirectory(const char *path) + { + std::vector fileNames; // 存储读取的文件名 + struct dirent *entry; // 定义目录项 + + // 打开目录 + DIR *dir = opendir(path); + if (!dir) + { + std::cerr << "Error opening directory: " << path << " - " << strerror(errno) << std::endl; + return fileNames; // 返回空列表 + } + + // 读取目录项 + while ((entry = readdir(dir)) != nullptr) + { + // 跳过 . 和 .. + if (entry->d_name[0] != '.') + { + fileNames.push_back(entry->d_name); // 存储文件名 + } + } + + // 关闭目录 + closedir(dir); + return fileNames; + } + + // 格式化时间的辅助函数 + std::string formatTime(uint32_t time) + { + char labelTime[20]; + if (uapi_get_TIME_STR(time, labelTime, '.', ':', DATE_TIME_DEFULL) != ERRCODE_SUCC) + { + return "--"; // 默认值 + } + else + { + return labelTime; // 成功获取时间 + } + } + /**************************************************************************************************** */ + + struct DebugOutputViewMapper + { + const int16_t viewId; + bool (DebugOutputViewEventListener::*func)(int16_t thisView); + }; + + static const DebugOutputViewMapper ViewMapper[] = { + {0, &DebugOutputViewEventListener::ChangeDebugOutputMainView}, + {1, &DebugOutputViewEventListener::ChangeDebugOutputView1}, + }; + + /* -------------------------------------------------------------------------- */ + UIViewGroup *DebugGroupView{nullptr}; + UIScrollView *DebugScrollView[sizeof(ViewMapper) / sizeof(ViewMapper[0])]{nullptr}; + UIList *debugOutputList{nullptr}; + DebugOutputAdapter *debugOutputAdapter{nullptr}; + UILabel *debugOutputLabel{nullptr}; + UILabelButton *debugOutputLabelButton{nullptr}; + UIToggleButton *toggleButton = nullptr; + UIToggleButton *toggleButtonOffline = nullptr; + UILabelButton *debugOutputbleServiceLabelButton{nullptr}; + UILabelButton *nextorprepageLabelButton{nullptr}; + static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton"; + static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton"; + static constexpr const char *NEXTORPREPAGELABELBUTTON = "nextorprepageLabelButton"; + /* -------------------------------------------------------------------------- */ + + void DebugOutputViewEventListener::InitDebugOutputItem() + { + int index = 0; + debugOutputItemInfo[index++] = {index, "exit"}; // 标题:设置() + debugOutputItemInfo[index++] = {index, "bt_ble_connectstat"}; + debugOutputItemInfo[index++] = {index, "cat1_runtime_status_t"}; + debugOutputItemInfo[index++] = {index, "runtime_status_t"}; + // 系统日志 + debugOutputItemInfo[index++] = {index, "system_log"}; + // 电池服务 + debugOutputItemInfo[index++] = {index, "battery_service"}; + // 死机文件列表 + debugOutputItemInfo[index++] = {index, "shutdown_file_list"}; + // 睡眠数据 + debugOutputItemInfo[index++] = {index, "sleep_data"}; + // 系统空闲内存 + debugOutputItemInfo[index++] = {index, "system_free_memory"}; + // nextday执行日志 + debugOutputItemInfo[index++] = {index, "nextday_log"}; + // 读取心率 + debugOutputItemInfo[index++] = {index, "heart_rate_data"}; + // 弹窗日志 + debugOutputItemInfo[index++] = {index, "popup_windows_log"}; + // 当前系统亮屏时长 + debugOutputItemInfo[index++] = {index, "current_screen_time"}; + // 串口状态服务 + debugOutputItemInfo[index++] = {index, "uart_service_status"}; + // Vote状态服务 + debugOutputItemInfo[index++] = {index, "vote_service_status"}; + // 佩戴状态 + 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"}; + // 心率广播 + debugOutputItemInfo[index++] = {index, "hrs_ble_swtich"}; + + debugOutputItemInfo[index++] = {index, "save_runtime_log"}; + // CAT1升级 + debugOutputItemInfo[index++] = {index, "CAT1_UPDATA"}; + + debugOutputItemInfo[index++] = {index, "cwm_runtime_log"}; + + usedLen = index; + /* -------------------------------- Add data -------------------------------- */ + for (uint8_t i = 0; i < usedLen; i++) + { + if (debugOutputAdapter) + debugOutputAdapter->AddListItem(debugOutputItemInfo[i]); + } + /* -------------------------------------------------------------------------- */ + } + + DebugOutputViewEventListener::DebugOutputViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::DebugOutputViewEventListener"); + } + + DebugOutputViewEventListener::~DebugOutputViewEventListener() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::DebugOutputViewEventListener"); + } + + DebugOutputViewEventListener &DebugOutputViewEventListener::GetInstance() + { + static DebugOutputViewEventListener instance; + return instance; + } + static std::string getCurrentWatchMacAddress() + { + uint32_t len = 32; + char *buf_btaddr = (char *)malloc(32); + if (buf_btaddr == NULL) + return ""; + memset_s(buf_btaddr, 32, 0, 32); + uint8_t ret = uapi_get_btaddr((uint8_t *)buf_btaddr, &len); + std::string str = std::string(buf_btaddr); + printf("%s | %s \n", buf_btaddr, str.c_str()); + free(buf_btaddr); + return (str); + } + + static std::string getCurrentWatchadvdata() + { + uint32_t len = 64; + char *buf_advdata = (char *)malloc(len); + + if (buf_advdata == NULL) + return ""; + memset_s(buf_advdata, 64, 0, 64); + get_adv_data(buf_advdata); + + std::string str = std::string(buf_advdata); + printf("%s | %s \n", buf_advdata, str.c_str()); + + free(buf_advdata); + return (str); + } + + std::string DebugOutputViewEventListener::get_bt_runtime_status_t(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_bt_runtime_status_t"); + std::string result = "bt_powerOn:" + std::to_string(uapi_dev_runtime_get_bt_powerstat()) + " "; + result += "bt_ble_connectstat:" + std::to_string(get_ble_connect()) + " "; + result += "bt_br_connectstat:" + std::to_string(uapi_get_acl_connect_state()) + " "; + result += "bt_earphone_connectstat:" + std::to_string(uapi_dev_runtime_get_earphone_connect_stat()) + " "; + result += "android_app_connected:" + std::to_string(get_ble_pair()) + " "; + result += "localAddress:" + (getCurrentWatchMacAddress()) + " "; + result += "advdata:" + (getCurrentWatchadvdata()) + " "; + result += "ble广播状态:" + std::to_string(get_ble_adv_status()); + + // 蓝牙ble广播开关,基础信息如,地址,广播状态 + + return result; + } + + std::string DebugOutputViewEventListener::get_cat1_runtime_status_t(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_cat1_runtime_status_t"); + std::string cat1_powerOn = std::to_string(uapi_dev_runtime_get_cat1_powerstat()); + std::string volte; + std::string network_on = std::to_string(uapi_dev_runtime_get_cat1_networkstat()); + std::string cat1_network_type = std::to_string(uapi_dev_runtime_get_cat1_networtype()); + std::string sim = std::to_string(uapi_dev_runtime_get_cat1_simstat()); + std::string signal = std::to_string(uapi_dev_runtime_get_cat1_signal()); + std::string opera = uapi_dev_runtime_get_cat1_operator(); + std::string pyVer = uapi_dev_runtime_get_cat1_pyver(); + std::string modemVer = uapi_dev_runtime_get_cat1_modemver(); + std::string result = "cat1_powerOn:" + cat1_powerOn + " " + "volte: " + "network_on:" + network_on + " " + "cat1_network_type:" + cat1_network_type + " " + "sim:" + sim + " " + "signal:" + signal + " " + "opera:" + opera + " " + "pyVer:" + pyVer + " " + "modemVer:" + modemVer + " "; + + return result; + } + + std::string DebugOutputViewEventListener::get_runtime_status_t() + { + std::string result = "enter_safemode:" + std::to_string(uapi_dev_runtime_get_safemode_flag()) + " "; + result += "in_silent_mode: "; + result += "in_lowpower_mode: "; + result += "stepcount: "; + result += "vibmod:" + std::to_string(uapi_dev_runtime_get_vibmod()) + " "; + result += "current_dial_name:" + std::string(uapi_dev_runtime_get_dialname()) + " "; + result += "time_hour_show_model:" + std::to_string(uapi_dev_runtime_get_time_hour_show_model()) + " "; + result += "sleep_monitoring_status:" + std::to_string(uapi_dev_runtime_get_sleep_monitoring_status()) + " "; + result += "sleep_status:" + std::to_string(uapi_dev_runtime_get_sleep_status()) + " "; + result += "nap_status:" + std::to_string(uapi_dev_runtime_get_nap_status()) + " "; + result += "nap_monitoring_status:" + std::to_string(uapi_dev_runtime_get_nap_monitoring_status()) + " "; + result += "sedentary_status:" + std::to_string(uapi_dev_runtime_get_sedentary_status()) + " "; + result += "wear_status:" + std::to_string(uapi_dev_runtime_get_wear_status_flag()) + " "; + result += "drinkremind_status:" + std::to_string(uapi_dev_runtime_get_drinkremind_status()) + " "; + result += "train_status:" + std::to_string(uapi_dev_runtime_get_train_status()) + " "; + result += "saveele_status:" + std::to_string(uapi_dev_runtime_get_saveele_status()) + " "; + result += "lock_status:" + std::to_string(uapi_dev_runtime_get_lock_status()) + " "; + result += "motion_recognition_status:" + std::to_string(uapi_dev_runtime_get_motion_recognition_status()) + " "; + result += "sleep_mode_flag:" + std::to_string(uapi_sleep_mode_flag_get()) + " "; + result += "absolute_static_state:" + std::to_string(uapi_dev_runtime_get_absolute_static_status()) + " "; + result += "checkres_status:" + std::to_string(uapi_dev_runtime_get_checkres_status()) + " "; + result += "repair_download_status:" + std::to_string(uapi_dev_runtime_get_repair_download_status()) + " "; + result += "hrs_passivity_status:" + std::to_string(uapi_dev_runtime_get_hrs_passivity_flag()) + " "; + result += "mmc_status:" + std::to_string(uapi_dev_runtime_get_mmc_status_flag()) + " "; + result += "rwlock_status:" + std::to_string(uapi_dev_runtime_get_rwlock_status()) + " "; + result += "lock_flag_training:" + std::to_string(uapi_dev_runtime_get_train_storage_status()) + " "; + result += "lock_flag_heartrate:" + std::to_string(uapi_dev_runtime_get_heartrate_storage_status()) + " "; + result += "lock_flag_blood:" + std::to_string(uapi_dev_runtime_get_bloodoxygen_storage_status()) + " "; + result += "lock_flag_sleep:" + std::to_string(uapi_dev_runtime_get_sleep_storage_status()) + " "; + result += "lock_flag_goal:" + std::to_string(uapi_dev_runtime_get_goal_storage_status()) + " "; + result += "respiratory_training_status:" + std::to_string(uapi_dev_runtime_get_respiratory_training_status()) + " "; + result += "heartrate_detect_status:" + std::to_string(uapi_dev_runtime_get_heartrate_detect_status()) + " "; + result += "factory_test_status:" + std::to_string(uapi_dev_runtime_get_factory_test_status_flag()) + " "; + result += "screen_always_on_status:" + std::to_string(uapi_dev_runtime_get_screen_always_on_status()) + " "; + return result; + } + + // 日志服务 + std::string DebugOutputViewEventListener::get_system_log() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_system_log"); + + // 获取系统日志实例 + auto logModel = SystemLogModel::GetInstance(); + uint8_t logSize = logModel->getLogSize(); + if (logSize == 0) + { + return "目前没有日志"; + } + + std::deque systemlogs = logModel->getLogData(); + std::ostringstream str; + + for (int i = 0; i < logSize; i++) + { + // 处理日志类型 + switch (systemlogs[i].type) + { + case SystemLogType::POWER_ON: + str << "开机:"; + break; + case SystemLogType::POWER_OFF: + str << "关机:"; + break; + case SystemLogType::RESTART: + str << "重启:"; + break; + case SystemLogType::FACTORY_RESET: + str << "恢复出厂设置:"; + break; + case SystemLogType::SOFTWARE_UPDATE: + str << "软件更新:"; + break; + default: + str << "UNKNOWN:"; + break; + } + + // 格式化时间 + std::string timestr; + if (systemlogs[i].timestamp == 0) + { + timestr = "--"; // 默认值 + } + else + { + timestr = formatTime(systemlogs[i].timestamp); + } + + str << "[" << timestr << "] " << "\n"; // 拼接日志内容 + } + + return str.str(); // 返回拼接后的字符串 + } + + // 获取电池相关信息 + std::string DebugOutputViewEventListener::get_battery_info() + { + // 获取电池温度 + float bat_temp = 0.0f; + batteryservice_get_battery_temp(&bat_temp); + + // 获取 PCB 温度 + float pcb_temp = 0.0f; + batteryservice_get_pcb_temp(&pcb_temp); + + // 获取电量 + float voltage = 0.0f; + uint8_t percent = batteryservice_get_voltage(&voltage); + + // 获取充电状态 + bool isCharging = get_charge_stat(); + + // 拼接字符串,并简化为保留两位小数 + std::ostringstream oss; + oss << std::fixed + << std::setprecision(2) // 设置为固定小数位,保留两位小数 + << "Bat Temp: " << bat_temp << " °C\n" + << "PCB Temp: " << pcb_temp << " °C\n" + << "Voltage: " << voltage << " V\n" + << "Percent: " << static_cast(percent) + << " %\n" + << "Charge: " << (isCharging ? "Yes" : "No"); + + return oss.str(); + } + + // 获取死机列表 + static const char *SHUTDOWN_PATH = EXC_TAR_PATH; + std::string DebugOutputViewEventListener::get_shutdown_info() + { + std::ostringstream oss; + + // 打开目录 + DIR *dir = opendir(SHUTDOWN_PATH); + if (dir == nullptr) + { + return "死机目录不存在: " + std::string(strerror(errno)); + } + + struct dirent *entry; + while ((entry = readdir(dir)) != nullptr) + { + // 跳过. 和 .. + if (entry->d_name[0] != '.') + { + oss << entry->d_name << "\n"; // 逐行添加 + } + } + + closedir(dir); // 关闭目录 + + if (oss.str().empty()) + { + return "无死机文件"; + } + + return oss.str(); // 返回以换行符分隔的文件名字符串 + } + + // 获取睡眠数据 + static const char *SLEEP_DATA_PATH = "/user/userdata/sleep"; + // 获取睡眠数据 + std::string DebugOutputViewEventListener::get_sleep_time(void) + { + std::string result; + uint8_t falg = 0; + result += "--------------------\n"; + // 进行文件读取 + do_custom_fileoperate_service_check_msg( + CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0); + LOS_Msleep(100); // 等待文件系统准备 + + // 打开目录 + DIR *dir = opendir(SLEEP_DATA_PATH); + if (dir == NULL) + { + // 如果失败,打印错误信息 + perror("Error opening directory"); + return "目前无睡眠数据"; + } + + struct dirent *entry; // 结构体用于存放目录项信息 + while ((entry = readdir(dir)) != NULL) + { + // 忽略当前目录和父目录 + if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) + { + // 检查文件类型是否为普通文件 + if (entry->d_type == DT_REG) + { + // 获取文件名并添加到结果中 + result += entry->d_name; + result += "\n"; // 添加换行符以分隔文件名 + falg = 1; + } + } + } + + // 关闭目录 + closedir(dir); + if (falg == 0) + { + result += "目录没有文件\n"; + } + + result += "--------------------\n"; + + // 获取当天最新的入睡与醒来时间 + // result += "asleep_time: " + get_sleep_asleep_time_str() + " "; + // result += "wake_time: " + get_sleep_wake_time_str() + " "; + result += get_sleep_star_str(); + + return result; // 返回结果字符串 + } + + // 获取佩戴状态 + std::string DebugOutputViewEventListener::get_wear_status(void) + { + return get_wear_status_str(); // 返回结果字符串 + } + + // 获取电池状态 + std::string DebugOutputViewEventListener::get_battery_percent(void) + { + std::string result; + std::string charge_stat; + int index = 0; + // 进行文件读取 + do_custom_fileoperate_service_check_msg( + CUSTOM_FILEOPERATE_MSG_TYPE_BATTERY_DATA_READ, nullptr, 0); + LOS_Msleep(100); // 等待文件系统准备 + BATTERY_DATA_T *data = NULL; + uint16_t len = 0; + battery_get_data_t(&data, &len); + if (len == 0) + return result; + + len = len / sizeof(BATTERY_DATA_T); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "111111len : %d", len); + + if (get_battery_percent_flag == 1) + { + if (len >= 60) + { + index = 30; + len = 60; + } + else if (len >= 30 && len < 60) + index = 30; + else + return result; + } + else if (get_battery_percent_flag == 2) + { + if (len >= 90) + { + index = 60; + len = 90; + } + else if (len >= 60 && len < 90) + index = 60; + else + return result; + } + else if (get_battery_percent_flag == 3) + { + if (len >= 120) + { + index = 90; + len = 120; + } + else if (len >= 90 && len < 120) + index = 90; + else + return result; + } + else if (get_battery_percent_flag == 4) + { + if (len >= 150) + { + index = 120; + len = 150; + } + else if (len >= 120 && len < 150) + index = 120; + else + return result; + } + else if (get_battery_percent_flag == 5) + { + if (len >= 180) + { + index = 150; + len = 180; + } + else if (len >= 150 && len < 180) + index = 150; + else + return result; + } + else + { + if (len >= 30) + len = 30; + } + for (int i = index; i < len; i++) + { + std::string timestr; + char labelTime[20] = {0}; + + if (uapi_get_TIME_STR(data[i].tm, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) + { + timestr = "--"; + } + else + { + timestr = labelTime; + } + + std::ostringstream oss; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data[%d].voltage : %f , data[%d].percent : %d", i, data[i].voltage, i, data[i].percent); + + if (data[i].stat) + // charge_stat = static_cast(i) + ":充电中"; + charge_stat = "充电中"; + else + // charge_stat = static_cast(i) + ":未充电"; + charge_stat = "未充电"; + + // result += std::to_string(i) + ":" + charge_stat + "[" + timestr + "]\n" + std::to_string(data[i].voltage) + " V, " + std::to_string(data[i].percent) + "%\n"; + + oss << std::fixed + << std::setprecision(3) // 设置为固定小数位,保留两位小数 + << charge_stat + << ", [" << timestr << "] ," + << data[i].voltage << "V , " + << static_cast(data[i].percent) << "%\n"; + // << static_cast(i) << "%\n"; + + result += oss.str(); + // result += std::to_string(i*10) + " min , " + std::to_string(data[i].voltage) + "V , "+ std::to_string(data[i].percent) + "%" + "\n"; + } + free(data); + return result; // 返回结果字符串 + } + + // 获取系统free内存 + std::string DebugOutputViewEventListener::get_free_memory() + { + auto logModel = SystemLogModel::GetInstance(); + std::string result = logModel->get_system_mem_info(); + return result; + } + std::string DebugOutputViewEventListener::get_nextday_log() + { + std::ostringstream result; + result << "nextday_log:\n"; // 添加标题 + + auto logModel = SystemLogModel::GetInstance(); + const auto &nextday_logs = logModel->get_nextday_log(); + + // 遍历日志并拼接到结果字符串 + for (const auto &log : nextday_logs) + { + std::string timestr; + if (log.timestamp == 0) + { + timestr = "--"; // 默认值 + } + else + { + timestr = formatTime(log.timestamp); + if (log.type == nextday_type::NEXTDAY_BEGAN) + { + timestr += " 开始"; + } + else if (log.type == nextday_type::NEXTDAY_END) + { + timestr += " 结束:"; + } + } + result << "[" << timestr << "] "; // 使用格式化后的时间拼接日志记录 + } + + return result.str(); + } + + // 定义心率数据文件夹的路径 + static const char *HEART_DATA_PATH = "/user/userdata/health/heart"; + + // 主要函数:获取心率 + std::string DebugOutputViewEventListener::get_heart_rate() + { + std::ostringstream result; + + // 1. 读取文件并形成文件名字符串 + std::vector heartFiles = readDirectory(HEART_DATA_PATH); + if (heartFiles.empty()) + { + result << "No heart rate files found in directory.\n"; + } + else + { + result << "Heart rate files:\n"; + for (const auto &file : heartFiles) + { + result << file << "\n"; // 输出文件名 + } + } + + result << "=====================\n"; + + // 2. 获取模型里的数据(当前值与时间) + uint32_t checkTime = 0; + uint16_t currentHeartRate = 0; +#ifdef FD230_650 + auto heartModel = HeartModel::GetInstance(); + checkTime = heartModel->GetCheckTime(); + currentHeartRate = heartModel->GetHeartdata(); +#endif + + std::string timestr = formatTime(checkTime); + + result << "CurrentHeart: " << currentHeartRate << "\n" + << "Time: " << timestr << "\n"; + + result << "=====================\n"; + + // 3.读取文件里面的心率数据 + auto healthService = HealthService::GetInstance(); + result << healthService->get_heart_data(); + + result << "=====================\n"; + + // 4. 获取一天的心率列表 + uint32_t listtime = healthService->GetListTime(); + std::string listtimestr; + if (listtime == 0) + { + listtimestr = "--"; // 默认值 + } + else + { + listtimestr = formatTime(listtime); + } + result << "listt_ime: " << listtimestr << "\n"; + for (int serialIndex = 0; serialIndex < 24; ++serialIndex) + { + uint32_t heartRate = HealthService::GetInstance()->GetHourlyHeartRate(serialIndex); + uint32_t time = HealthService::GetInstance()->GetHourlyTimestamp(serialIndex); + + std::string timestr; + if (time == 0) + { + timestr = "--"; // 默认值 + } + else + { + timestr = formatTime(time); + } + + result << timestr << " " << heartRate << "\n"; // 输出每小时的心率 + } + + result << "=====================\n"; + return result.str(); // 返回完整结果 + } + + std::string DebugOutputViewEventListener::get_popup_windows_log(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_popup_windows_log"); + // 获取系统日志实例 + auto logModel = SystemLogModel::GetInstance(); + uint8_t logSize = logModel->get_popup_windows_log_size(); + if (logSize == 0) + { + return "目前没有日志"; + } + + std::deque popup_windows_logs = logModel->get_popup_windows_log(); + std::ostringstream str; + + for (int i = 0; i < logSize; i++) + { + // 处理日志类型 + switch (popup_windows_logs[i].type) + { + case popup_windows_type::MOTION_RECOGNITION: + str << "运动识别:"; + break; + case popup_windows_type::DRINK_WATER_REMINDER: + str << "喝水提醒:"; + break; + case popup_windows_type::SEDENTARY_REMINDER: + str << "久坐提醒:"; + break; + default: + str << "UNKNOWN:"; + break; + } + str << "\n"; + // 格式化时间 + char labelTime[20]; + std::string timestr; + if (uapi_get_TIME_STR(popup_windows_logs[i].timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) + { + timestr = "--"; + } + else + { + timestr = labelTime; + } + str << "[" << timestr << "] " << "\n"; // 拼接日志内容 + } + return str.str(); // 返回拼接后的字符串 + } + + std::string DebugOutputViewEventListener::get_system_screen_time(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_system_screen_time"); + + std::ostringstream str; + str << "当前系统亮屏时长:"; + std::string timestr = std::to_string(DisplayBrightnessModel::GetInstance()->GetScreenDurationTime() / 1000) + "秒"; + str << "[" << timestr << "]\n"; + str << "系统是否处于长亮屏状态:"; + str << "[" << std::to_string(uapi_dev_runtime_get_screen_always_on_status()) << "]\n"; + return str.str(); + } + // 增加串口日志服务 + std::string DebugOutputViewEventListener::get_uart_at_status() + { + // 获取系统日志实例 + auto logModel = SystemLogModel::GetInstance(); + bool status = logModel->get_uart_status(); + return std::string("uart_at_status:") + std::to_string(status); + } + // 获取vote状态 + std::string DebugOutputViewEventListener::get_current_vote_status() + { + // 获取系统日志实例 + char buf[256]; + get_vote_status(buf, sizeof(buf)); + 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(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewId %s", viewId.c_str()); + int viewIndex; + std::string str; + if (viewId == DEBUGOUTPUTBLESERVICELABELBUTTON) // 开启ble广播 + { + // if (BluetoothModel::GetInstance()->GetAdvStartState() == false) // 如果广播是关的就去开启广播 + // BleAdvStart(); + + svr_ble_adv_start(); + return true; + } + else if (viewId == DEBUGOUTPUTLABELBUTTON) // 点击的是刷新按钮 + { + viewIndex = GetCurViewIndex(); + } + // 点击开启按键 + else if (viewId == "uart_at_set") + { + if (toggleButton) + { + if (toggleButton->GetState() == false) + { + // toggleButton->SetState(false); + SystemLogModel::GetInstance()->set_uart_status(false); + remove_debug_vote(); // 关闭uart的同时也取消 debug的投票,保证关闭开关后可以正常休眠 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uart_at_set false"); + } + else + { + // toggleButton->SetState(true); + SystemLogModel::GetInstance()->set_uart_status(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uart_at_set true"); + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "组件不存在"); + } + // 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 if (viewId == "hrs_ble_switch") + { + if (toggleButtonOffline) + { + if (toggleButtonOffline->GetState() == false) + { + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hrs_ble_switch false"); + } + else + { + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hrs_ble_switch true"); + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "组件不存在"); + } + return true; // 进行UI刷新 + } + else if (viewId == "runtime_log_is_save") + { + if (toggleButtonOffline) + { + if (toggleButtonOffline->GetState() == false) + { + set_save_runtime_log_switch(0); + } + else + { + set_save_runtime_log_switch(1); + } + + // 重启 + NotificationManager::GetInstance()->StopNotify(); + shutdown_reboot_prejobs(REBOOT_TYPE); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "组件不存在"); + } + return true; // 进行UI刷新 + } + else if (viewId == "CAT1_UPDATA") + { + Cat1_OTA(CAT1_TCP_START_OTA); + } + else if (viewId == NEXTORPREPAGELABELBUTTON) + { + // std::string str; + viewIndex = GetCurViewIndex(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "111111 viewIndex : %d", viewIndex); + + if (get_battery_percent_flag == 1) + { + nextorprepageLabelButton->SetText("第三页"); + get_battery_percent_flag = 2; + } + else if (get_battery_percent_flag == 2) + { + nextorprepageLabelButton->SetText("第四页"); + get_battery_percent_flag = 3; + } + else if (get_battery_percent_flag == 3) + { + nextorprepageLabelButton->SetText("第五页"); + get_battery_percent_flag = 4; + } + else if (get_battery_percent_flag == 4) + { + nextorprepageLabelButton->SetText("第六页"); + get_battery_percent_flag = 5; + } + else if (get_battery_percent_flag == 5) + { + nextorprepageLabelButton->SetText("第一页"); + get_battery_percent_flag = 6; + } + else + { + nextorprepageLabelButton->SetText("第二页"); + get_battery_percent_flag = 1; + } + // if(nextorprepageLabelButton) + // { + // if(get_battery_percent_flag == 0) + // { + // nextorprepageLabelButton->SetText("下一页"); + // // str = get_battery_percent(); + // } + // else if(get_battery_percent_flag == 1) + // { + // nextorprepageLabelButton->SetText("上一页"); + // // str = get_battery_percent(); + // } + // } + } + else if (viewId == "cwm_ble_switch") + { + if (toggleButtonOffline) + { + if (toggleButtonOffline->GetState() == false) + { +// send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_log_switch(0); +#endif + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cwm_ble_switch false"); + } + else + { +// send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_log_switch(1); +#endif + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cwm_ble_switch true"); + } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "组件不存在"); + } + return true; // 进行UI刷新 + } + else // 如果点击的是列表中的itemview + { + DebugOutputItemView *debugOutputItemView = static_cast(&view); + viewIndex = debugOutputItemView->GetViewIndex(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewIndex:%d", viewIndex); + if (viewIndex == 0) + { + NotificationManager::GetInstance()->StopNotify(); + return true; + } + ChangeView(0, 1); + SetCurViewIndex(viewIndex); + } + if (debugOutputLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is nullptr"); + return false; + } + switch (viewIndex) + { + case 1: + str = get_bt_runtime_status_t(); + break; + case 2: + str = get_cat1_runtime_status_t(); + break; + case 3: + str = get_runtime_status_t(); + break; + case 4: + str = get_system_log(); + break; + case 5: + str = get_battery_info(); + break; + case 6: + str = get_shutdown_info(); + break; + case 7: + str = get_sleep_time(); + break; + case 8: + str = get_free_memory(); + break; + case 9: + str = get_nextday_log(); + break; + case 10: + str = get_heart_rate(); + break; + case 11: + str = get_popup_windows_log(); + break; + case 12: + str = get_system_screen_time(); + break; + case 13: + str = get_uart_at_status(); + if (toggleButton) + { + if (toggleButton->IsVisible() == false) + { + toggleButton->SetVisible(true); + } + } + break; + case 14: + str = get_current_vote_status(); + break; + case 15: + str = get_wear_status(); + break; + case 16: + refreshbutton_is_visible = 0; + str = get_battery_percent(); + if (nextorprepageLabelButton) + { + if (nextorprepageLabelButton->IsVisible() == false) + { + nextorprepageLabelButton->SetVisible(true); + } + } + break; + case 17: + str = get_offline_log_status(); + // uapi_diag_info_log(0, "test out info log. value = %d", 1); + // uapi_diag_error_log(0, "test out error log. a = %d, b = %d\r\n", 3, 4); + // uapi_diag_warning_log(0, "test out warning log. a = %d, b = %d c= 0x%x", 3, 4, 5); + if (toggleButtonOffline) + { + if (toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetVisible(true); + toggleButtonOffline->SetViewId("offline_log_switch"); + } + } + break; + case 18: + // str = get_hrs_ble_status(); + str = ""; + if (toggleButtonOffline) + { + if (toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetViewId("hrs_ble_switch"); + toggleButtonOffline->SetVisible(true); + } + } + break; + case 19: + // str = get_hrs_ble_status(); + str = "runtime_log_is_save"; + if (toggleButtonOffline) + { + if (toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetState(get_save_runtime_log_switch()); + toggleButtonOffline->SetViewId("runtime_log_is_save"); + toggleButtonOffline->SetVisible(true); + } + } + break; + case 20: + if (toggleButtonOffline) + { + if (toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetState(false); + toggleButtonOffline->SetViewId("CAT1_UPDATA"); + toggleButtonOffline->SetVisible(true); + } + } + break; + case 21: + str = ""; + if (toggleButtonOffline) + { + if (toggleButtonOffline->IsVisible() == false) + { + toggleButtonOffline->SetViewId("cwm_ble_switch"); + toggleButtonOffline->SetVisible(true); + } + } + break; + default: + str = "--"; + break; + } + + GraphicService::GetInstance()->PostGraphicEvent(std::bind( + &DebugOutputViewEventListener::UpdateView, &DebugOutputViewEventListener::GetInstance(), str)); + + return true; + } + + // 获取视图 + void DebugOutputViewEventListener::UpdateView(std::string str) + { + if (debugOutputLabel != nullptr) + { + debugOutputLabel->SetText(str.c_str()); + } + if (refreshbutton_is_visible) + { + if (debugOutputLabelButton) + { + debugOutputLabelButton->SetY(debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20); + debugOutputLabelButton->Invalidate(); + } + } + else + { + debugOutputLabelButton->SetVisible(false); + } + debugOutputLabel->Invalidate(); + } + bool DebugOutputViewEventListener::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::OnDrag"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + int16_t deltaX; + int16_t deltaY; + deltaX = event.GetDeltaX(); + deltaY = event.GetDeltaY(); + if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > 20) + { + X_DRAG_FLAG = true; + } + } + return true; + } + + bool DebugOutputViewEventListener::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event) + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) + { + if (&view == DebugGroupView) + { + NotificationManager::GetInstance()->StopNotify(); + } + else if (&view == DebugScrollView[1]) + { + ChangeView(1, 0); + } + X_DRAG_FLAG = false; + } + return true; + } + + bool DebugOutputViewEventListener::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + bool DebugOutputViewEventListener::CheckViewParam(int16_t hideView, int16_t showView) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + if (showView < 0 || showView > funcSize) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showView err."); + return false; + } + + if (hideView < 0 || hideView > funcSize) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView err."); + return false; + } + + return true; + } + + void DebugOutputViewEventListener::DestroyTempView(int16_t hideView) + { + if (hideView == 1) + { + refreshbutton_is_visible = 1; + DebugGroupView->Remove(DebugScrollView[1]); + if (DebugScrollView[1] != nullptr) + { + DebugScrollView[1]->RemoveAll(); + + delete debugOutputLabel; + debugOutputLabel = nullptr; + + delete toggleButton; + toggleButton = nullptr; + + delete nextorprepageLabelButton; + nextorprepageLabelButton = nullptr; + get_battery_percent_flag = 0; + + delete toggleButtonOffline; + toggleButtonOffline = nullptr; + + delete debugOutputLabelButton; + debugOutputLabelButton = nullptr; + + delete DebugScrollView[1]; + DebugScrollView[1] = nullptr; + } + } + } + + void DebugOutputViewEventListener::ChangeView(int16_t hideView, int16_t showView) + { + if (!CheckViewParam(hideView, showView)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckViewParam failed."); + return; + } + DebugScrollView[hideView]->SetVisible(false); + ClickFunc(showView); + DebugScrollView[showView]->SetVisible(true); + DestroyTempView(hideView); + RootView::GetInstance()->Invalidate(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView:%d -> showView:%d success!!", hideView, showView); + } + + UIScrollView *CreateDebugOutputView1(void) + { + if (DebugScrollView[1] == nullptr) + { + DebugScrollView[1] = new UIScrollView(); + if (DebugScrollView[1] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!"); + return nullptr; + } + } + DebugScrollView[1]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_OPA, 255); + DebugScrollView[1]->SetHorizontalScrollState(false); + DebugScrollView[1]->SetTouchable(true); + DebugScrollView[1]->SetScrollBlankSize(70); + DebugScrollView[1]->SetReboundSize(35); + DebugScrollView[1]->SetThrowDrag(true); + DebugScrollView[1]->SetMaxScrollDistance(1000); + UIView::OnDragListener *dragListener = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!"); + return nullptr; + } + DebugScrollView[1]->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + debugOutputLabel = new UILabel(); + if (debugOutputLabel == nullptr) + { + if (debugOutputLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is new fail!!"); + return nullptr; + } + } + debugOutputLabel->SetPosition(53, 120, 360, 100); + debugOutputLabel->SetStyle(STYLE_TEXT_FONT, 30); + debugOutputLabel->SetText("123"); + debugOutputLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + debugOutputLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + DebugScrollView[1]->Add(debugOutputLabel); + /* -------------------------------------------------------------------------- */ + if (nextorprepageLabelButton == nullptr) + { + nextorprepageLabelButton = new UILabelButton(); + if (nextorprepageLabelButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "nextorprepageLabelButton is new fail!!"); + return nullptr; + } + } + nextorprepageLabelButton->SetPosition(143, 20); + nextorprepageLabelButton->Resize(100, 100); + nextorprepageLabelButton->SetViewId(NEXTORPREPAGELABELBUTTON); + nextorprepageLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + nextorprepageLabelButton->SetText("第一页"); + nextorprepageLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + nextorprepageLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffff0000, UIButton::PRESSED); + nextorprepageLabelButton->SetVisible(false); + DebugScrollView[1]->Add(nextorprepageLabelButton); + UIView::OnClickListener *nextorpreclickListener = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (nextorpreclickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "nextorpreclickListener is new fail!!"); + return nullptr; + } + nextorprepageLabelButton->SetOnClickListener(nextorpreclickListener); + /* -------------------------------------------------------------------------- */ + if (debugOutputLabelButton == nullptr) + { + debugOutputLabelButton = new UILabelButton(); + if (debugOutputLabelButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabelButton is new fail!!"); + return nullptr; + } + } + debugOutputLabelButton->SetPosition(43, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20); + debugOutputLabelButton->Resize(380, 100); + debugOutputLabelButton->SetViewId(DEBUGOUTPUTLABELBUTTON); + debugOutputLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + debugOutputLabelButton->SetText("刷新"); + debugOutputLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + debugOutputLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + UIView::OnClickListener *clickListener = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!"); + return nullptr; + } + debugOutputLabelButton->SetOnClickListener(clickListener); + DebugScrollView[1]->Add(debugOutputLabelButton); + /* -------------------------------------------------------------------------- */ + if (toggleButton == nullptr) + { + toggleButton = new UIToggleButton(); + } + toggleButton->SetPosition(147, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20 + 120); // widget's left position and top position + toggleButton->Resize(171, 121); // widget's width and height + 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(); + toggleButton->SetState(status); + toggleButton->SetVisible(false); // 设置不可见 + UIView::OnClickListener *clickListener_ = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (clickListener_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!"); + return nullptr; + } + toggleButton->SetOnClickListener(clickListener_); + DebugScrollView[1]->Add(toggleButton); + + return DebugScrollView[1]; + } + + bool DebugOutputViewEventListener::ChangeDebugOutputMainView(int16_t thisView) + { + if (DebugScrollView[thisView] == nullptr) + { + DebugGroupView->Add(DebugScrollView[thisView]); + } + return true; + } + + bool DebugOutputViewEventListener::ChangeDebugOutputView1(int16_t thisView) + { + if (DebugScrollView[thisView] == nullptr) + { + DebugScrollView[thisView] = CreateDebugOutputView1(); + if (DebugScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new DebugScrollView[%d] fail", thisView); + return false; + } + DebugGroupView->Add(DebugScrollView[thisView]); + } + return true; + } + + void DebugOutputViewEventListener::SetCurViewIndex(int16_t viewNum) + { + curView = viewNum; + } + + int DebugOutputViewEventListener::GetCurViewIndex(void) + { + return curView; + } + + /*创建调试专用主窗口视图*/ + UIViewGroup *CreateDebugOutputMainView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateDebugOutputMainView"); + if (DebugGroupView == nullptr) + { + if (DebugGroupView == nullptr) + { + DebugGroupView = new UIViewGroup(); + if (DebugGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugGroupView is new fail!!"); + return nullptr; + } + } + DebugGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *dragListener = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!"); + return nullptr; + } + DebugGroupView->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + if (DebugScrollView[0] == nullptr) + { + DebugScrollView[0] = new UIScrollView(); + if (DebugScrollView[0] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!"); + return nullptr; + } + } + DebugScrollView[0]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_OPA, 255); + DebugScrollView[0]->SetHorizontalScrollState(false); + DebugScrollView[0]->SetTouchable(true); + DebugScrollView[0]->SetThrowDrag(true); + DebugScrollView[0]->SetScrollBlankSize(70); + // DebugScrollView[0]->SetReboundSize(30); + DebugGroupView->Add(DebugScrollView[0]); + /* -------------------------------------------------------------------------- */ + if (debugOutputAdapter == nullptr) + { + debugOutputAdapter = new DebugOutputAdapter(); + if (debugOutputAdapter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputAdapter is new fail!!"); + return nullptr; + } + } + UIView::OnClickListener *clickListener = static_cast(&DebugOutputViewEventListener::GetInstance()); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!"); + return nullptr; + } + debugOutputAdapter->SetItemClickListener(clickListener); + DebugOutputViewEventListener::GetInstance().InitDebugOutputItem(); + /* -------------------------------------------------------------------------- */ + if (debugOutputList == nullptr) + { + debugOutputList = new UIList(UIList::VERTICAL); + if (debugOutputList == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputList is new fail!!"); + return nullptr; + } + } + debugOutputList->SetPosition(0, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION - 120); + debugOutputList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + debugOutputList->SetThrowDrag(true); + debugOutputList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐 + // debugOutputList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + // debugOutputList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + // debugOutputList->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ + debugOutputList->SetAdapter(debugOutputAdapter); + debugOutputList->RefreshList(); + // debugOutputList->SetReboundSize(30); + // debugOutputList->SetScrollBlankSize(30); + debugOutputList->SetRotateFactor(1.0); + DebugScrollView[0]->Add(debugOutputList); + /* -------------------------------------------------------------------------- */ + if (debugOutputbleServiceLabelButton == nullptr) + { + debugOutputbleServiceLabelButton = new UILabelButton(); + if (debugOutputbleServiceLabelButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputbleServiceLabelButton is new fail!!"); + return nullptr; + } + } + debugOutputbleServiceLabelButton->SetPosition(43, debugOutputList->GetY() + debugOutputList->GetHeight()); + debugOutputbleServiceLabelButton->SetViewId(DEBUGOUTPUTBLESERVICELABELBUTTON); + debugOutputbleServiceLabelButton->Resize(380, 100); + debugOutputbleServiceLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + debugOutputbleServiceLabelButton->SetText("开启ble广播"); + debugOutputbleServiceLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + debugOutputbleServiceLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + debugOutputbleServiceLabelButton->SetOnClickListener(clickListener); + debugOutputbleServiceLabelButton->SetVisible(false); + // DebugScrollView[0]->Add(debugOutputbleServiceLabelButton); + /* -------------------------------------------------------------------------- */ + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDebugOutputMainView); + /* -------------------------------------------------------------------------- */ + enable_drag(0, 1); + enable_drag(1, 1); + } + return DebugGroupView; + } + + /*释放调试专用主窗口视图*/ + void FreeDebugOutputMainView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView"); + + if (DebugGroupView != nullptr) + { + DebugGroupView->RemoveAll(); + if (DebugScrollView[0] != nullptr) + { + DebugScrollView[0]->RemoveAll(); + + delete debugOutputList; + debugOutputList = nullptr; + + delete debugOutputAdapter; + debugOutputAdapter = nullptr; + + delete debugOutputbleServiceLabelButton; + debugOutputbleServiceLabelButton = nullptr; + + delete DebugScrollView[0]; + DebugScrollView[0] = nullptr; + } + RootView::GetInstance()->Remove(DebugGroupView); + delete DebugGroupView; + DebugGroupView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView success!!"); + } + if (uapi_dev_runtime_get_saveele_status() == 1) // 如果省电模式开启,该调试窗口关闭时候恢复原状态 + { + enable_drag(0, 0); + enable_drag(1, 0); + } + return; + } +} diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_adapter.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_adapter.cpp new file mode 100644 index 000000000..26f1a6f4b --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_adapter.cpp @@ -0,0 +1,73 @@ +#include "debug_output_notification/debug_output_notification_adapter.h" +#include "debug_output_notification/debug_output_notification_itemview.h" +#include "wearable_log.h" +namespace OHOS +{ + DebugOutputAdapter::DebugOutputAdapter() {} + + DebugOutputAdapter::~DebugOutputAdapter() + { + listData.clear(); + } + + uint16_t DebugOutputAdapter::GetCount(void) + { + return listData.size(); + } + + void DebugOutputAdapter::SetData(std::list &data) + { + if (!listData.empty()) + { + listData.clear(); + } + std::list::iterator it; + for (it = data.begin(); it != data.end(); it++) + { + listData.push_back(*it); + } + } + + UIView *DebugOutputAdapter::GetView(UIView *inView, int16_t index) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputAdapter::GetView:%d", index); + if (listData.empty()) + { + return nullptr; + } + if (index < 0) + { + return nullptr; + } + size_t uindex = index; + if (uindex >= listData.size()) + { + return nullptr; + } + + std::list::iterator it = listData.begin(); + for (int i = 0; i < index; i++) + { + it++; + } + DebugOutputItem itemData = *it; + DebugOutputItemView *item = nullptr; + if (inView == nullptr) + { + item = new DebugOutputItemView(); + } + else + { + item = static_cast(inView); + } + item->SetViewIndex(index); + item->SetItemInfo(itemData); + item->SetOnClickListener(itemClickListener); + return item; + } + + void DebugOutputAdapter::AddListItem(const DebugOutputItem &item) + { + listData.push_back(item); + } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_itemview.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_itemview.cpp new file mode 100644 index 000000000..ffc60d55a --- /dev/null +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification_itemview.cpp @@ -0,0 +1,56 @@ +#include "debug_output_notification/debug_output_notification_itemview.h" +#include "wearable_log.h" +#include "UiConfig.h" +namespace OHOS +{ + DebugOutputItemView::DebugOutputItemView() + { + SetPosition(43, 120, 466, 120); + SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + SetStyle(STYLE_BACKGROUND_OPA, 255); + SetUpChild(); + Add(&labelButton); + } + + DebugOutputItemView::~DebugOutputItemView() + { + Remove(&labelButton); + } + + void DebugOutputItemView::SetItemInfo(const DebugOutputItem itemInfo) + { + sItemInfo = itemInfo; + labelButton.SetText(itemInfo.name); + if (itemInfo.index != 0) + { + labelButton.SetAlign(TEXT_ALIGNMENT_LEFT); + labelButton.SetImagePosition(326, 37); + labelButton.SetLabelPosition(47, 0); + // labelButton.SetStyle(STYLE_BACKGROUND_OPA, 255); + labelButton.SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + SetTouchable(true); + } + else + { + labelButton.SetAlign(TEXT_ALIGNMENT_CENTER); + labelButton.SetImagePosition(-100, 0); + labelButton.SetLabelPosition(0, 0); + // labelButton.SetStyle(STYLE_BACKGROUND_OPA, 0x00); + labelButton.SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + SetTouchable(false); + } + } + + void DebugOutputItemView::SetUpChild() + { + labelButton.SetPosition(43, 0, 380, 100); + labelButton.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + labelButton.SetStyle(STYLE_LINE_HEIGHT, 35); + labelButton.SetAlign(TEXT_ALIGNMENT_LEFT); + labelButton.SetLabelPosition(47, 0); + labelButton.SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + labelButton.SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + labelButton.SetImagePosition(326, 37); + labelButton.SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); + } +} \ No newline at end of file diff --git a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c index dbe840e5e..dc932567c 100644 --- a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c @@ -304,9 +304,9 @@ void log_factory_at_callback(const void *buffer, uint16_t length, bool remaining #endif #ifndef SUPPORT_RECOVERY_DISPLAY //判定是否是在编译RECOVERY image,本参数不支持RECOVERY -// #ifdef CUSTOM_UTILS -// if (uapi_custom_uart_rx_enable_flag() == false) -// #endif +#ifdef CUSTOM_UTILS + if (uapi_custom_uart_rx_enable_flag() == false) +#endif { if (buffer != NULL && ((uint8_t*)buffer)[0]=='A' && ((uint8_t*)buffer)[1]=='T') { diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp index 9aaa00654..64578d9bc 100644 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp @@ -196,6 +196,56 @@ void PointerInputDevice::DispatchReleaseEvent(UIViewGroup* rootView) touchableView_ = nullptr; } +extern "C" { + +static uint16_t DRAG_LIMIT_X = INDEV_DRAG_LIMIT; +static uint16_t DRAG_LIMIT_Y = INDEV_DRAG_LIMIT; +/** + * param direction 0 = X , 1 = Y +*/ +void enable_drag(uint8_t direction, uint8_t enable) +{ + if (enable == 0 ) //disable drag + { + if (direction == 0) //X + { + DRAG_LIMIT_X = 0xFFFF; + }else{ //Y + DRAG_LIMIT_Y= 0xFFFF; + } + }else{ //enable drag + if (direction == 0) //X + { + DRAG_LIMIT_X = INDEV_DRAG_LIMIT; + }else{ //Y + DRAG_LIMIT_Y= INDEV_DRAG_LIMIT; + } + } + +} + +void set_drag_limit(uint8_t direction, uint16_t limit) +{ + + if (direction == 0) //X + { + DRAG_LIMIT_X = limit; + }else{ //Y + DRAG_LIMIT_Y= limit; + } +} + +uint16_t get_drag_limit(uint8_t direction) +{ + if (direction == 0) + { + return DRAG_LIMIT_X; + }else{ + return DRAG_LIMIT_Y; + } +} + +} void PointerInputDevice::DispatchDragStartEvent() { if (draggableView_ == nullptr) { @@ -206,12 +256,20 @@ void PointerInputDevice::DispatchDragStartEvent() dragLen_.x += dragStep_.x; dragLen_.y += dragStep_.y; if (!isDragging_) { - if ((MATH_ABS(dragLen_.x) >= INDEV_DRAG_LIMIT) || (MATH_ABS(dragLen_.y) >= INDEV_DRAG_LIMIT)) { + if ((MATH_ABS(dragLen_.x) >= DRAG_LIMIT_X) || (MATH_ABS(dragLen_.y) >= DRAG_LIMIT_Y)) { + // if ((MATH_ABS(dragLen_.x) >= INDEV_DRAG_LIMIT) || (MATH_ABS(dragLen_.y) >= INDEV_DRAG_LIMIT)) { // HISI delete begin //if ((touchableView_ != nullptr) && !cancelSent_) { // DispatchCancelEvent(); //} // HISI delete end + printf("=====PointerInputDevice::DispatchDragStartEvent absx(%d) limitx(%d) absy(%d) limity(%d) \r\n", + MATH_ABS(dragLen_.x),DRAG_LIMIT_X, + MATH_ABS(dragLen_.y),DRAG_LIMIT_Y); + + if ((touchableView_ != nullptr) && !cancelSent_) { + DispatchCancelEvent(); + } // Send Drag Begin Event. DragEvent evt(curPos_, lastPos_, dragLen_); UIView* parent = draggableView_->GetParent(); diff --git a/code/sdk/zhihui/config/include/ConfigModel.h b/code/sdk/zhihui/config/include/ConfigModel.h index 87d229f4a..04a61f021 100644 --- a/code/sdk/zhihui/config/include/ConfigModel.h +++ b/code/sdk/zhihui/config/include/ConfigModel.h @@ -418,7 +418,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "goal_standup_times_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES, //运动目标站立次数 10 {ConfigDataType::DATATYPE_INT, "goal_duration_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION, //运动目标时长 30(分钟) {ConfigDataType::DATATYPE_INT, "goal_distance_time", "1" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) - {ConfigDataType::DATATYPE_INT, "urat_at_status", "false" },//CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS // 串口AT 默认 关闭 + {ConfigDataType::DATATYPE_BOOL, "urat_at_status", "false" },//CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS // 串口AT 默认 关闭 {ConfigDataType::DATATYPE_INT, "runtime_log_status", "0" },//CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS,//运行日志保存 diff --git a/code/sdk/zhihui/services/battery/service/battery_service.h b/code/sdk/zhihui/services/battery/service/battery_service.h index 6f810f7ba..73627a4ba 100644 --- a/code/sdk/zhihui/services/battery/service/battery_service.h +++ b/code/sdk/zhihui/services/battery/service/battery_service.h @@ -59,6 +59,9 @@ uint8_t battery_get_percent_onstart(void); //0 停止充电 , 1 低电流充电, 2 正常电流充电 int get_charge_current_status(void); uint8_t get_02c_value(void); +void battery_get_data(void); +void battery_save_data(void); +void battery_get_data_t(BATTERY_DATA_T **data,uint16_t *length); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index 93fe0614d..a66847ae4 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -593,7 +593,7 @@ void startup_post_init_task(void) // ota_updata_init();//开启会死机需适配 -#ifdef FD230_COMPONENT +#ifdef FD230 system_init_uart();//配置uartat #endif if ( cm_poweron_cat1_on_bootup_flag() )