1 #include "../notify/debug_output_notification/debug_output_notification_adapter.h"
2 #include "../notify/debug_output_notification/debug_output_notification_itemview.h"
3 #include "AppViewIDs.h"
4 #include "NativeAbility.h"
5 #include "battery_hal.h"
6 #include "battery_service.h"
8 #include "bluetooth/include/BluetoothModel.h"
9 #include "broadcast_feature.h"
10 #include "broadcast_service.h"
12 #include "cat1_server.h"
13 #include "components/ui_image_view.h"
14 #include "components/ui_label_button.h"
15 #include "components/ui_label_ext.h"
16 #include "components/ui_scroll_view.h"
17 #include "custom_runtime.h"
18 #include "custom_utils.h"
19 #include "graphic_service.h"
20 #include "lwip/apps/http_client.h"
21 #include "notification_manager.h"
22 #include "samgr_lite.h"
23 #include "system/include/SystemLogModel.h"
25 #include "thread_adapter.h"
26 #include "thread_init.h"
27 #include "vibrator_service.h"
28 #include "wearable_log.h"
30 #include <cmsis_os2.h>
32 #include <custom_runtime.h>
33 #include <custom_utils.h>
39 #include <service/graphic_service.h>
42 #include <sys/types.h>
46 #include "bleService.h"
47 #include "sleep/include/SleepModel.h"
48 #include "heartrate/include/HeartModel.h"
49 #include "heart_blood/health_service/health_service.h"
50 #include "BluetoothModel.h"
61 /**************************************************************************************************** */
65 std::vector<std::string> readDirectory(const char *path) {
66 std::vector<std::string> fileNames; // 存储读取的文件名
67 struct dirent *entry; // 定义目录项
70 DIR *dir = opendir(path);
72 std::cerr << "Error opening directory: " << path << " - " << strerror(errno) << std::endl;
73 return fileNames; // 返回空列表
77 while ((entry = readdir(dir)) != nullptr) {
79 if (entry->d_name[0] != '.') {
80 fileNames.push_back(entry->d_name); // 存储文件名
90 std::string formatTime(uint32_t time) {
92 if (uapi_get_TIME_STR(time, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) {
95 return labelTime; // 成功获取时间
98 /**************************************************************************************************** */
100 struct DebugOutputViewMapper
102 const int16_t viewId;
103 bool (DebugOutputViewEventListener::*func)(int16_t thisView);
106 static const DebugOutputViewMapper ViewMapper[] = {
107 {0, &DebugOutputViewEventListener::ChangeDebugOutputMainView},
108 {1, &DebugOutputViewEventListener::ChangeDebugOutputView1},
111 /* -------------------------------------------------------------------------- */
112 UIViewGroup *DebugGroupView{nullptr};
113 UIScrollView *DebugScrollView[sizeof(ViewMapper) / sizeof(ViewMapper[0])]{nullptr};
114 UIList *debugOutputList{nullptr};
115 DebugOutputAdapter *debugOutputAdapter{nullptr};
116 UILabel *debugOutputLabel{nullptr};
117 UILabelButton *debugOutputLabelButton{nullptr};
118 UILabelButton *debugOutputbleServiceLabelButton{nullptr};
119 static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton";
120 static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton";
121 /* -------------------------------------------------------------------------- */
123 void DebugOutputViewEventListener::InitDebugOutputItem()
126 debugOutputItemInfo[index++] = {index, "exit"}; // 标题:设置()
127 debugOutputItemInfo[index++] = {index, "bt_ble_connectstat"};
128 debugOutputItemInfo[index++] = {index, "cat1_runtime_status_t"};
129 debugOutputItemInfo[index++] = {index, "runtime_status_t"};
131 debugOutputItemInfo[index++] = {index, "system_log"};
133 debugOutputItemInfo[index++] = {index, "battery_service"};
135 debugOutputItemInfo[index++] = {index, "shutdown_file_list"};
137 debugOutputItemInfo[index++] = {index, "sleep_time"};
139 debugOutputItemInfo[index++] = {index, "system_free_memory"};
141 debugOutputItemInfo[index++] = {index, "nextday_log"};
143 debugOutputItemInfo[index++] = {index, "heart_rate_data"};
145 debugOutputItemInfo[index++] = {index, "popup_windows_log"};
147 /* -------------------------------- Add data -------------------------------- */
148 for (uint8_t i = 0; i < usedLen; i++)
150 if (debugOutputAdapter)
151 debugOutputAdapter->AddListItem(debugOutputItemInfo[i]);
153 /* -------------------------------------------------------------------------- */
156 DebugOutputViewEventListener::DebugOutputViewEventListener()
158 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::DebugOutputViewEventListener");
161 DebugOutputViewEventListener::~DebugOutputViewEventListener()
163 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::DebugOutputViewEventListener");
166 DebugOutputViewEventListener &DebugOutputViewEventListener::GetInstance()
168 static DebugOutputViewEventListener instance;
171 static std::string getCurrentWatchMacAddress()
174 char *buf_btaddr = (char *)malloc(32);
175 if (buf_btaddr == NULL)
177 memset_s(buf_btaddr, 32, 0, 32);
178 uint8_t ret = uapi_get_btaddr((uint8_t *)buf_btaddr, &len);
179 std::string str = std::string(buf_btaddr);
180 printf("%s | %s \n", buf_btaddr, str.c_str());
185 static std::string getCurrentWatchadvdata()
188 char *buf_advdata = (char *)malloc(len);
190 if (buf_advdata == NULL)
192 memset_s(buf_advdata, 64, 0, 64);
193 get_adv_data(buf_advdata);
195 std::string str = std::string(buf_advdata);
196 printf("%s | %s \n", buf_advdata, str.c_str());
202 std::string DebugOutputViewEventListener::get_bt_runtime_status_t(void)
204 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_bt_runtime_status_t");
205 std::string result = "bt_powerOn:" + std::to_string(uapi_dev_runtime_get_bt_powerstat()) + " ";
206 result += "bt_ble_connectstat:" + std::to_string(get_ble_connect()) + " ";
207 result += "bt_br_connectstat:" + std::to_string(uapi_get_acl_connect_state()) + " ";
208 result += "bt_earphone_connectstat:" + std::to_string(uapi_dev_runtime_get_earphone_connect_stat()) + " ";
209 result += "android_app_connected:" + std::to_string(get_ble_pair()) + " ";
210 result += "localAddress:" + (getCurrentWatchMacAddress()) + " ";
211 result += "advdata:" + (getCurrentWatchadvdata()) + " ";
212 result += "ble广播状态:" + std::to_string(get_ble_adv_status());
214 // 蓝牙ble广播开关,基础信息如,地址,广播状态
219 std::string DebugOutputViewEventListener::get_cat1_runtime_status_t(void)
221 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_cat1_runtime_status_t");
222 std::string cat1_powerOn = std::to_string(uapi_dev_runtime_get_cat1_powerstat());
224 std::string network_on = std::to_string(uapi_dev_runtime_get_cat1_networkstat());
225 std::string cat1_network_type = std::to_string(uapi_dev_runtime_get_cat1_networtype());
226 std::string sim = std::to_string(uapi_dev_runtime_get_cat1_simstat());
227 std::string signal = std::to_string(uapi_dev_runtime_get_cat1_signal());
228 std::string opera = uapi_dev_runtime_get_cat1_operator();
229 std::string pyVer = uapi_dev_runtime_get_cat1_pyver();
230 std::string modemVer = uapi_dev_runtime_get_cat1_modemver();
231 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 + " ";
236 std::string DebugOutputViewEventListener::get_runtime_status_t()
238 std::string result = "enter_safemode:" + std::to_string(uapi_dev_runtime_get_safemode_flag()) + " ";
239 result += "in_silent_mode: ";
240 result += "in_lowpower_mode: ";
241 result += "stepcount: ";
242 result += "vibmod:" + std::to_string(uapi_dev_runtime_get_vibmod()) + " ";
243 result += "current_dial_name:" + std::string(uapi_dev_runtime_get_dialname()) + " ";
244 result += "time_hour_show_model:" + std::to_string(uapi_dev_runtime_get_time_hour_show_model()) + " ";
245 result += "sleep_monitoring_status:" + std::to_string(uapi_dev_runtime_get_sleep_monitoring_status()) + " ";
246 result += "sleep_status:" + std::to_string(uapi_dev_runtime_get_sleep_status()) + " ";
247 result += "nap_status:" + std::to_string(uapi_dev_runtime_get_nap_status()) + " ";
248 result += "nap_monitoring_status:" + std::to_string(uapi_dev_runtime_get_nap_monitoring_status()) + " ";
249 result += "sedentary_status:" + std::to_string(uapi_dev_runtime_get_sedentary_status()) + " ";
250 result += "wear_status:" + std::to_string(uapi_dev_runtime_get_wear_status_flag()) + " ";
251 result += "drinkremind_status:" + std::to_string(uapi_dev_runtime_get_drinkremind_status()) + " ";
252 result += "train_status:" + std::to_string(uapi_dev_runtime_get_train_status()) + " ";
253 result += "saveele_status:" + std::to_string(uapi_dev_runtime_get_saveele_status()) + " ";
254 result += "lock_status:" + std::to_string(uapi_dev_runtime_get_lock_status()) + " ";
255 result += "motion_recognition_status:" + std::to_string(uapi_dev_runtime_get_motion_recognition_status()) + " ";
256 result += "sleep_mode_flag:" + std::to_string(uapi_sleep_mode_flag_get()) + " ";
257 result += "absolute_static_state:" + std::to_string(uapi_dev_runtime_get_absolute_static_status()) + " ";
258 result += "checkres_status:" + std::to_string(uapi_dev_runtime_get_checkres_status()) + " ";
259 result += "repair_download_status:" + std::to_string(uapi_dev_runtime_get_repair_download_status()) + " ";
260 result += "hrs_passivity_status:" + std::to_string(uapi_dev_runtime_get_hrs_passivity_flag()) + " ";
261 result += "mmc_status:" + std::to_string(uapi_dev_runtime_get_mmc_status_flag()) + " ";
262 result += "rwlock_status:" + std::to_string(uapi_dev_runtime_get_rwlock_status()) + " ";
263 result += "lock_flag_training:" + std::to_string(uapi_dev_runtime_get_train_storage_status()) + " ";
264 result += "lock_flag_heartrate:" + std::to_string(uapi_dev_runtime_get_heartrate_storage_status()) + " ";
265 result += "lock_flag_blood:" + std::to_string(uapi_dev_runtime_get_bloodoxygen_storage_status()) + " ";
266 result += "lock_flag_sleep:" + std::to_string(uapi_dev_runtime_get_sleep_storage_status()) + " ";
267 result += "lock_flag_goal:" + std::to_string(uapi_dev_runtime_get_goal_storage_status()) + " ";
268 result += "respiratory_training_status:" + std::to_string(uapi_dev_runtime_get_respiratory_training_status()) + " ";
269 result += "heartrate_detect_status:" + std::to_string(uapi_dev_runtime_get_heartrate_detect_status()) + " ";
270 result += "factory_test_status:" + std::to_string(uapi_dev_runtime_get_factory_test_status_flag()) + " ";
271 result += "screen_always_on_status:" + std::to_string(uapi_dev_runtime_get_screen_always_on_status()) + " ";
276 std::string DebugOutputViewEventListener::get_system_log()
278 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_system_log");
281 auto logModel = SystemLogModel::GetInstance();
282 uint8_t logSize = logModel->getLogSize();
288 std::deque<SystemLogData> systemlogs = logModel->getLogData();
289 std::ostringstream str;
291 for (int i = 0; i < logSize; i++)
294 switch (systemlogs[i].type)
296 case SystemLogType::POWER_ON:
299 case SystemLogType::POWER_OFF:
302 case SystemLogType::RESTART:
305 case SystemLogType::FACTORY_RESET:
308 case SystemLogType::SOFTWARE_UPDATE:
318 if (systemlogs[i].timestamp == 0) {
319 timestr = "--"; // 默认值
321 timestr = formatTime(systemlogs[i].timestamp);
324 str << "[" << timestr << "] "<< "\n"; // 拼接日志内容
327 return str.str(); // 返回拼接后的字符串
331 std::string DebugOutputViewEventListener::get_battery_info()
334 float bat_temp = 0.0f;
335 batteryservice_get_battery_temp(&bat_temp);
338 float pcb_temp = 0.0f;
339 batteryservice_get_pcb_temp(&pcb_temp);
342 float voltage = 0.0f;
343 uint8_t percent = batteryservice_get_voltage(&voltage);
346 bool isCharging = get_charge_stat();
349 std::ostringstream oss;
351 << std::setprecision(2) // 设置为固定小数位,保留两位小数
352 << "Bat Temp: " << bat_temp << " °C\n"
353 << "PCB Temp: " << pcb_temp << " °C\n"
354 << "Voltage: " << voltage << " V\n"
355 << "Percent: " << static_cast<int>(percent)
357 << "Charge: " << (isCharging ? "Yes" : "No");
363 static const char *SHUTDOWN_PATH = "/user/system/tar";
364 std::string DebugOutputViewEventListener::get_shutdown_info()
366 std::ostringstream oss;
369 DIR *dir = opendir(SHUTDOWN_PATH);
372 return "死机目录不存在: " + std::string(strerror(errno));
375 struct dirent *entry;
376 while ((entry = readdir(dir)) != nullptr)
379 if (entry->d_name[0] != '.')
381 oss << entry->d_name << "\n"; // 逐行添加
385 closedir(dir); // 关闭目录
387 if (oss.str().empty())
392 return oss.str(); // 返回以换行符分隔的文件名字符串
396 std::string DebugOutputViewEventListener::get_sleep_time(void)
398 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_sleep_time");
399 do_custom_fileoperate_service_check_msg(
400 CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ, nullptr, 0);
402 std::string result = "asleep_time:" + get_sleep_asleep_time_str() + " ";
403 result += "wake_time:" + get_sleep_wake_time_str() + " ";
408 std::string DebugOutputViewEventListener::get_free_memory()
410 auto logModel = SystemLogModel::GetInstance();
411 std::string result = logModel->get_system_mem_info();
415 std::string DebugOutputViewEventListener::get_nextday_log()
417 std::ostringstream result;
418 result << "nextday_log:\n"; // 添加标题
420 auto logModel = SystemLogModel::GetInstance();
421 const auto &nextday_logs = logModel->get_nextday_log();
424 for (const auto &log : nextday_logs) {
427 timestr = "--"; // 默认值
429 timestr = formatTime(log);
431 result << "[" << timestr << "] "; // 使用格式化后的时间拼接日志记录
439 static const char *HEART_DATA_PATH = "/user/userdata/health/heart";
442 std::string DebugOutputViewEventListener::get_heart_rate() {
443 std::ostringstream result;
446 std::vector<std::string> heartFiles = readDirectory(HEART_DATA_PATH);
447 if (heartFiles.empty()) {
448 result << "No heart rate files found in directory.\n";
450 result << "Heart rate files:\n";
451 for (const auto &file : heartFiles) {
452 result << file << "\n"; // 输出文件名
456 result << "=====================\n";
458 // 2. 获取模型里的数据(当前值与时间)
459 auto heartModel = HeartModel::GetInstance();
460 uint32_t checkTime = heartModel->GetCheckTime();
461 uint16_t currentHeartRate = heartModel->GetHeartdata();
463 std::string timestr = formatTime(checkTime);
465 result << "CurrentHeart: " << currentHeartRate << "\n"
466 << "Time: " << timestr << "\n";
468 result << "=====================\n";
471 result << "Today's HeartRate list\n";
472 for (int serialIndex = 0; serialIndex < 24; ++serialIndex) {
473 uint32_t heartRate = HealthService::GetInstance()->GetHourlyHeartRate(serialIndex);
474 uint32_t time = HealthService::GetInstance()->GetHourlyTimestamp(serialIndex);
478 timestr = "--"; // 默认值
480 timestr = formatTime(time);
483 result << "time " << timestr << ""<<"\n" <<"heart " << heartRate <<""<< "\n"; // 输出每小时的心率
486 result << "=====================\n";
487 return result.str(); // 返回完整结果
490 std::string DebugOutputViewEventListener::get_popup_windows_log(void)
492 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_popup_windows_log");
494 auto logModel = SystemLogModel::GetInstance();
495 uint8_t logSize = logModel->get_popup_windows_log_size();
501 std::deque<popup_windows_log_data> popup_windows_logs = logModel->get_popup_windows_log();
502 std::ostringstream str;
504 for (int i = 0; i < logSize; i++)
507 switch (popup_windows_logs[i].type)
509 case popup_windows_type::MOTION_RECOGNITION:
512 case popup_windows_type::DRINK_WATER_REMINDER:
515 case popup_windows_type::SEDENTARY_REMINDER:
526 if (uapi_get_TIME_STR(popup_windows_logs[i].timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC)
534 str << "[" << timestr << "] " << "\n"; // 拼接日志内容
536 return str.str(); // 返回拼接后的字符串
539 bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
541 std::string viewId = view.GetViewId();
544 if (viewId == DEBUGOUTPUTBLESERVICELABELBUTTON) // 开启ble广播
546 // if (BluetoothModel::GetInstance()->GetAdvStartState() == false) // 如果广播是关的就去开启广播
552 else if (viewId == DEBUGOUTPUTLABELBUTTON) // 点击的是刷新按钮
554 viewIndex = GetCurViewIndex();
556 else // 如果点击的是列表中的itemview
558 DebugOutputItemView *debugOutputItemView = static_cast<DebugOutputItemView *>(&view);
559 viewIndex = debugOutputItemView->GetViewIndex();
560 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewIndex:%d", viewIndex);
563 NotificationManager::GetInstance()->StopNotify();
567 SetCurViewIndex(viewIndex);
569 if (debugOutputLabel == nullptr)
571 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is nullptr");
577 str = get_bt_runtime_status_t();
580 str = get_cat1_runtime_status_t();
583 str = get_runtime_status_t();
586 str = get_system_log();
589 str = get_battery_info();
592 str = get_shutdown_info();
595 str = get_sleep_time();
598 str = get_free_memory();
601 str = get_nextday_log();
604 str = get_heart_rate();
607 str = get_popup_windows_log();
614 GraphicService::GetInstance()->PostGraphicEvent(std::bind(
615 &DebugOutputViewEventListener::UpdateView, &DebugOutputViewEventListener::GetInstance(), str));
621 void DebugOutputViewEventListener::UpdateView(std::string str)
623 if (debugOutputLabel != nullptr)
625 debugOutputLabel->SetText(str.c_str());
627 if (debugOutputLabelButton)
629 debugOutputLabelButton->SetY(debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20);
630 debugOutputLabelButton->Invalidate();
632 debugOutputLabel->Invalidate();
634 bool DebugOutputViewEventListener::OnDrag(UIView &view, const DragEvent &event)
637 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::OnDrag");
638 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
642 deltaX = event.GetDeltaX();
643 deltaY = event.GetDeltaY();
644 if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > 20)
652 bool DebugOutputViewEventListener::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event)
654 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG)
656 if (&view == DebugGroupView)
658 NotificationManager::GetInstance()->StopNotify();
660 else if (&view == DebugScrollView[1])
669 bool DebugOutputViewEventListener::ClickFunc(int16_t interface)
671 int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
672 for (int i = 0; i < funcSize; i++)
674 if (interface == ViewMapper[i].viewId)
676 bool jug = (this->*(ViewMapper[i].func))(interface);
687 bool DebugOutputViewEventListener::CheckViewParam(int16_t hideView, int16_t showView)
689 int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
690 if (showView < 0 || showView > funcSize)
692 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showView err.");
696 if (hideView < 0 || hideView > funcSize)
698 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView err.");
705 void DebugOutputViewEventListener::DestroyTempView(int16_t hideView)
709 DebugGroupView->Remove(DebugScrollView[1]);
710 if (DebugScrollView[1] != nullptr)
712 DebugScrollView[1]->RemoveAll();
714 delete debugOutputLabel;
715 debugOutputLabel = nullptr;
717 delete debugOutputLabelButton;
718 debugOutputLabelButton = nullptr;
720 delete DebugScrollView[1];
721 DebugScrollView[1] = nullptr;
726 void DebugOutputViewEventListener::ChangeView(int16_t hideView, int16_t showView)
728 if (!CheckViewParam(hideView, showView))
730 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckViewParam failed.");
733 DebugScrollView[hideView]->SetVisible(false);
735 DebugScrollView[showView]->SetVisible(true);
736 DestroyTempView(hideView);
737 RootView::GetInstance()->Invalidate();
738 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView:%d -> showView:%d success!!", hideView, showView);
741 UIScrollView *CreateDebugOutputView1(void)
743 if (DebugScrollView[1] == nullptr)
745 DebugScrollView[1] = new UIScrollView();
746 if (DebugScrollView[1] == nullptr)
748 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!");
752 DebugScrollView[1]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
753 DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
754 DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_OPA, 255);
755 DebugScrollView[1]->SetHorizontalScrollState(false);
756 DebugScrollView[1]->SetTouchable(true);
757 DebugScrollView[1]->SetScrollBlankSize(70);
758 DebugScrollView[1]->SetReboundSize(35);
759 DebugScrollView[1]->SetThrowDrag(true);
760 UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(&DebugOutputViewEventListener::GetInstance());
761 if (dragListener == nullptr)
763 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!");
766 DebugScrollView[1]->SetOnDragListener(dragListener);
767 /* -------------------------------------------------------------------------- */
768 debugOutputLabel = new UILabel();
769 if (debugOutputLabel == nullptr)
771 if (debugOutputLabel == nullptr)
773 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is new fail!!");
777 debugOutputLabel->SetPosition(53, 120, 360, 100);
778 debugOutputLabel->SetStyle(STYLE_TEXT_FONT, 30);
779 debugOutputLabel->SetText("123");
780 debugOutputLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
781 debugOutputLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
782 DebugScrollView[1]->Add(debugOutputLabel);
783 /* -------------------------------------------------------------------------- */
784 if (debugOutputLabelButton == nullptr)
786 debugOutputLabelButton = new UILabelButton();
787 if (debugOutputLabelButton == nullptr)
789 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabelButton is new fail!!");
793 debugOutputLabelButton->SetPosition(43, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20);
794 debugOutputLabelButton->Resize(380, 100);
795 debugOutputLabelButton->SetViewId(DEBUGOUTPUTLABELBUTTON);
796 debugOutputLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
797 debugOutputLabelButton->SetText("刷新");
798 debugOutputLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
799 debugOutputLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
800 UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(&DebugOutputViewEventListener::GetInstance());
801 if (clickListener == nullptr)
803 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!");
806 debugOutputLabelButton->SetOnClickListener(clickListener);
807 DebugScrollView[1]->Add(debugOutputLabelButton);
809 return DebugScrollView[1];
812 bool DebugOutputViewEventListener::ChangeDebugOutputMainView(int16_t thisView)
814 if (DebugScrollView[thisView] == nullptr)
816 DebugGroupView->Add(DebugScrollView[thisView]);
821 bool DebugOutputViewEventListener::ChangeDebugOutputView1(int16_t thisView)
823 if (DebugScrollView[thisView] == nullptr)
825 DebugScrollView[thisView] = CreateDebugOutputView1();
826 if (DebugScrollView[thisView] == nullptr)
828 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new DebugScrollView[%d] fail", thisView);
831 DebugGroupView->Add(DebugScrollView[thisView]);
836 void DebugOutputViewEventListener::SetCurViewIndex(int16_t viewNum)
841 int DebugOutputViewEventListener::GetCurViewIndex(void)
847 UIViewGroup *CreateDebugOutputMainView(void)
849 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateDebugOutputMainView");
850 if (DebugGroupView == nullptr)
852 if (DebugGroupView == nullptr)
854 DebugGroupView = new UIViewGroup();
855 if (DebugGroupView == nullptr)
857 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugGroupView is new fail!!");
861 DebugGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
862 UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(&DebugOutputViewEventListener::GetInstance());
863 if (dragListener == nullptr)
865 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!");
868 DebugGroupView->SetOnDragListener(dragListener);
869 /* -------------------------------------------------------------------------- */
870 if (DebugScrollView[0] == nullptr)
872 DebugScrollView[0] = new UIScrollView();
873 if (DebugScrollView[0] == nullptr)
875 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!");
879 DebugScrollView[0]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
880 DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
881 DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_OPA, 255);
882 DebugScrollView[0]->SetHorizontalScrollState(false);
883 DebugScrollView[0]->SetTouchable(true);
884 DebugScrollView[0]->SetThrowDrag(true);
885 DebugScrollView[0]->SetScrollBlankSize(70);
886 DebugScrollView[0]->SetReboundSize(30);
887 DebugGroupView->Add(DebugScrollView[0]);
888 /* -------------------------------------------------------------------------- */
889 if (debugOutputAdapter == nullptr)
891 debugOutputAdapter = new DebugOutputAdapter();
892 if (debugOutputAdapter == nullptr)
894 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputAdapter is new fail!!");
898 UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(&DebugOutputViewEventListener::GetInstance());
899 if (clickListener == nullptr)
901 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!");
904 debugOutputAdapter->SetItemClickListener(clickListener);
905 DebugOutputViewEventListener::GetInstance().InitDebugOutputItem();
906 /* -------------------------------------------------------------------------- */
907 if (debugOutputList == nullptr)
909 debugOutputList = new UIList(UIList::VERTICAL);
910 if (debugOutputList == nullptr)
912 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputList is new fail!!");
916 debugOutputList->SetPosition(0, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
917 debugOutputList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
918 debugOutputList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐
919 debugOutputList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。
920 debugOutputList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。
921 debugOutputList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/
922 debugOutputList->SetAdapter(debugOutputAdapter);
923 debugOutputList->RefreshList();
924 // debugOutputList->SetReboundSize(30);
925 // debugOutputList->SetScrollBlankSize(30);
926 debugOutputList->SetRotateFactor(1.0);
927 DebugScrollView[0]->Add(debugOutputList);
928 /* -------------------------------------------------------------------------- */
929 if (debugOutputbleServiceLabelButton == nullptr)
931 debugOutputbleServiceLabelButton = new UILabelButton();
932 if (debugOutputbleServiceLabelButton == nullptr)
934 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputbleServiceLabelButton is new fail!!");
938 debugOutputbleServiceLabelButton->SetPosition(43, debugOutputList->GetY() + debugOutputList->GetHeight());
939 debugOutputbleServiceLabelButton->SetViewId(DEBUGOUTPUTBLESERVICELABELBUTTON);
940 debugOutputbleServiceLabelButton->Resize(380, 100);
941 debugOutputbleServiceLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
942 debugOutputbleServiceLabelButton->SetText("开启ble广播");
943 debugOutputbleServiceLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
944 debugOutputbleServiceLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
945 debugOutputbleServiceLabelButton->SetOnClickListener(clickListener);
946 DebugScrollView[0]->Add(debugOutputbleServiceLabelButton);
947 /* -------------------------------------------------------------------------- */
948 NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDebugOutputMainView);
949 /* -------------------------------------------------------------------------- */
953 return DebugGroupView;
957 void FreeDebugOutputMainView(void)
959 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView");
961 if (DebugGroupView != nullptr)
963 DebugGroupView->RemoveAll();
964 if (DebugScrollView[0] != nullptr)
966 DebugScrollView[0]->RemoveAll();
968 delete debugOutputList;
969 debugOutputList = nullptr;
971 delete debugOutputAdapter;
972 debugOutputAdapter = nullptr;
974 delete debugOutputbleServiceLabelButton;
975 debugOutputbleServiceLabelButton = nullptr;
977 delete DebugScrollView[0];
978 DebugScrollView[0] = nullptr;
980 RootView::GetInstance()->Remove(DebugGroupView);
981 delete DebugGroupView;
982 DebugGroupView = nullptr;
983 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView success!!");
985 if (uapi_dev_runtime_get_saveele_status() == 1) // 如果省电模式开启,该调试窗口关闭时候恢复原状态