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();
414 std::string DebugOutputViewEventListener::get_nextday_log()
416 std::ostringstream result;
417 result << "nextday_log:\n"; // 添加标题
419 auto logModel = SystemLogModel::GetInstance();
420 const auto &nextday_logs = logModel->get_nextday_log();
423 for (const auto &log : nextday_logs) {
425 if (log.timestamp == 0) {
426 timestr = "--"; // 默认值
428 timestr = formatTime(log.timestamp);
429 if (log.type == nextday_type::NEXTDAY_BEGAN) {
431 } else if(log.type == nextday_type::NEXTDAY_END){
435 result << "[" << timestr << "] "; // 使用格式化后的时间拼接日志记录
443 static const char *HEART_DATA_PATH = "/user/userdata/health/heart";
446 std::string DebugOutputViewEventListener::get_heart_rate() {
447 std::ostringstream result;
450 std::vector<std::string> heartFiles = readDirectory(HEART_DATA_PATH);
451 if (heartFiles.empty()) {
452 result << "No heart rate files found in directory.\n";
454 result << "Heart rate files:\n";
455 for (const auto &file : heartFiles) {
456 result << file << "\n"; // 输出文件名
460 result << "=====================\n";
462 // 2. 获取模型里的数据(当前值与时间)
463 auto heartModel = HeartModel::GetInstance();
464 uint32_t checkTime = heartModel->GetCheckTime();
465 uint16_t currentHeartRate = heartModel->GetHeartdata();
467 std::string timestr = formatTime(checkTime);
469 result << "CurrentHeart: " << currentHeartRate << "\n"
470 << "Time: " << timestr << "\n";
472 result << "=====================\n";
475 result << "Today's HeartRate list\n";
476 for (int serialIndex = 0; serialIndex < 24; ++serialIndex) {
477 uint32_t heartRate = HealthService::GetInstance()->GetHourlyHeartRate(serialIndex);
478 uint32_t time = HealthService::GetInstance()->GetHourlyTimestamp(serialIndex);
482 timestr = "--"; // 默认值
484 timestr = formatTime(time);
487 result << "time " << timestr << ""<<"\n" <<"heart " << heartRate <<""<< "\n"; // 输出每小时的心率
490 result << "=====================\n";
491 return result.str(); // 返回完整结果
494 std::string DebugOutputViewEventListener::get_popup_windows_log(void)
496 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_popup_windows_log");
498 auto logModel = SystemLogModel::GetInstance();
499 uint8_t logSize = logModel->get_popup_windows_log_size();
505 std::deque<popup_windows_log_data> popup_windows_logs = logModel->get_popup_windows_log();
506 std::ostringstream str;
508 for (int i = 0; i < logSize; i++)
511 switch (popup_windows_logs[i].type)
513 case popup_windows_type::MOTION_RECOGNITION:
516 case popup_windows_type::DRINK_WATER_REMINDER:
519 case popup_windows_type::SEDENTARY_REMINDER:
530 if (uapi_get_TIME_STR(popup_windows_logs[i].timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC)
538 str << "[" << timestr << "] " << "\n"; // 拼接日志内容
540 return str.str(); // 返回拼接后的字符串
543 bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
545 std::string viewId = view.GetViewId();
548 if (viewId == DEBUGOUTPUTBLESERVICELABELBUTTON) // 开启ble广播
550 // if (BluetoothModel::GetInstance()->GetAdvStartState() == false) // 如果广播是关的就去开启广播
556 else if (viewId == DEBUGOUTPUTLABELBUTTON) // 点击的是刷新按钮
558 viewIndex = GetCurViewIndex();
560 else // 如果点击的是列表中的itemview
562 DebugOutputItemView *debugOutputItemView = static_cast<DebugOutputItemView *>(&view);
563 viewIndex = debugOutputItemView->GetViewIndex();
564 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewIndex:%d", viewIndex);
567 NotificationManager::GetInstance()->StopNotify();
571 SetCurViewIndex(viewIndex);
573 if (debugOutputLabel == nullptr)
575 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is nullptr");
581 str = get_bt_runtime_status_t();
584 str = get_cat1_runtime_status_t();
587 str = get_runtime_status_t();
590 str = get_system_log();
593 str = get_battery_info();
596 str = get_shutdown_info();
599 str = get_sleep_time();
602 str = get_free_memory();
605 str = get_nextday_log();
608 str = get_heart_rate();
611 str = get_popup_windows_log();
618 GraphicService::GetInstance()->PostGraphicEvent(std::bind(
619 &DebugOutputViewEventListener::UpdateView, &DebugOutputViewEventListener::GetInstance(), str));
625 void DebugOutputViewEventListener::UpdateView(std::string str)
627 if (debugOutputLabel != nullptr)
629 debugOutputLabel->SetText(str.c_str());
631 if (debugOutputLabelButton)
633 debugOutputLabelButton->SetY(debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20);
634 debugOutputLabelButton->Invalidate();
636 debugOutputLabel->Invalidate();
638 bool DebugOutputViewEventListener::OnDrag(UIView &view, const DragEvent &event)
641 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::OnDrag");
642 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
646 deltaX = event.GetDeltaX();
647 deltaY = event.GetDeltaY();
648 if (MATH_ABS(deltaX) >= MATH_ABS(deltaY) && MATH_ABS(deltaX) > 20)
656 bool DebugOutputViewEventListener::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event)
658 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG)
660 if (&view == DebugGroupView)
662 NotificationManager::GetInstance()->StopNotify();
664 else if (&view == DebugScrollView[1])
673 bool DebugOutputViewEventListener::ClickFunc(int16_t interface)
675 int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
676 for (int i = 0; i < funcSize; i++)
678 if (interface == ViewMapper[i].viewId)
680 bool jug = (this->*(ViewMapper[i].func))(interface);
691 bool DebugOutputViewEventListener::CheckViewParam(int16_t hideView, int16_t showView)
693 int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
694 if (showView < 0 || showView > funcSize)
696 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showView err.");
700 if (hideView < 0 || hideView > funcSize)
702 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView err.");
709 void DebugOutputViewEventListener::DestroyTempView(int16_t hideView)
713 DebugGroupView->Remove(DebugScrollView[1]);
714 if (DebugScrollView[1] != nullptr)
716 DebugScrollView[1]->RemoveAll();
718 delete debugOutputLabel;
719 debugOutputLabel = nullptr;
721 delete debugOutputLabelButton;
722 debugOutputLabelButton = nullptr;
724 delete DebugScrollView[1];
725 DebugScrollView[1] = nullptr;
730 void DebugOutputViewEventListener::ChangeView(int16_t hideView, int16_t showView)
732 if (!CheckViewParam(hideView, showView))
734 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckViewParam failed.");
737 DebugScrollView[hideView]->SetVisible(false);
739 DebugScrollView[showView]->SetVisible(true);
740 DestroyTempView(hideView);
741 RootView::GetInstance()->Invalidate();
742 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hideView:%d -> showView:%d success!!", hideView, showView);
745 UIScrollView *CreateDebugOutputView1(void)
747 if (DebugScrollView[1] == nullptr)
749 DebugScrollView[1] = new UIScrollView();
750 if (DebugScrollView[1] == nullptr)
752 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!");
756 DebugScrollView[1]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
757 DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
758 DebugScrollView[1]->SetStyle(STYLE_BACKGROUND_OPA, 255);
759 DebugScrollView[1]->SetHorizontalScrollState(false);
760 DebugScrollView[1]->SetTouchable(true);
761 DebugScrollView[1]->SetScrollBlankSize(70);
762 DebugScrollView[1]->SetReboundSize(35);
763 DebugScrollView[1]->SetThrowDrag(true);
764 UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(&DebugOutputViewEventListener::GetInstance());
765 if (dragListener == nullptr)
767 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!");
770 DebugScrollView[1]->SetOnDragListener(dragListener);
771 /* -------------------------------------------------------------------------- */
772 debugOutputLabel = new UILabel();
773 if (debugOutputLabel == nullptr)
775 if (debugOutputLabel == nullptr)
777 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is new fail!!");
781 debugOutputLabel->SetPosition(53, 120, 360, 100);
782 debugOutputLabel->SetStyle(STYLE_TEXT_FONT, 30);
783 debugOutputLabel->SetText("123");
784 debugOutputLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
785 debugOutputLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
786 DebugScrollView[1]->Add(debugOutputLabel);
787 /* -------------------------------------------------------------------------- */
788 if (debugOutputLabelButton == nullptr)
790 debugOutputLabelButton = new UILabelButton();
791 if (debugOutputLabelButton == nullptr)
793 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabelButton is new fail!!");
797 debugOutputLabelButton->SetPosition(43, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20);
798 debugOutputLabelButton->Resize(380, 100);
799 debugOutputLabelButton->SetViewId(DEBUGOUTPUTLABELBUTTON);
800 debugOutputLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
801 debugOutputLabelButton->SetText("刷新");
802 debugOutputLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
803 debugOutputLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
804 UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(&DebugOutputViewEventListener::GetInstance());
805 if (clickListener == nullptr)
807 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!");
810 debugOutputLabelButton->SetOnClickListener(clickListener);
811 DebugScrollView[1]->Add(debugOutputLabelButton);
813 return DebugScrollView[1];
816 bool DebugOutputViewEventListener::ChangeDebugOutputMainView(int16_t thisView)
818 if (DebugScrollView[thisView] == nullptr)
820 DebugGroupView->Add(DebugScrollView[thisView]);
825 bool DebugOutputViewEventListener::ChangeDebugOutputView1(int16_t thisView)
827 if (DebugScrollView[thisView] == nullptr)
829 DebugScrollView[thisView] = CreateDebugOutputView1();
830 if (DebugScrollView[thisView] == nullptr)
832 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new DebugScrollView[%d] fail", thisView);
835 DebugGroupView->Add(DebugScrollView[thisView]);
840 void DebugOutputViewEventListener::SetCurViewIndex(int16_t viewNum)
845 int DebugOutputViewEventListener::GetCurViewIndex(void)
851 UIViewGroup *CreateDebugOutputMainView(void)
853 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateDebugOutputMainView");
854 if (DebugGroupView == nullptr)
856 if (DebugGroupView == nullptr)
858 DebugGroupView = new UIViewGroup();
859 if (DebugGroupView == nullptr)
861 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugGroupView is new fail!!");
865 DebugGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
866 UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(&DebugOutputViewEventListener::GetInstance());
867 if (dragListener == nullptr)
869 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is new fail!!");
872 DebugGroupView->SetOnDragListener(dragListener);
873 /* -------------------------------------------------------------------------- */
874 if (DebugScrollView[0] == nullptr)
876 DebugScrollView[0] = new UIScrollView();
877 if (DebugScrollView[0] == nullptr)
879 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::DebugScrollView[0] is new fail!!");
883 DebugScrollView[0]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
884 DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
885 DebugScrollView[0]->SetStyle(STYLE_BACKGROUND_OPA, 255);
886 DebugScrollView[0]->SetHorizontalScrollState(false);
887 DebugScrollView[0]->SetTouchable(true);
888 DebugScrollView[0]->SetThrowDrag(true);
889 DebugScrollView[0]->SetScrollBlankSize(70);
890 DebugScrollView[0]->SetReboundSize(30);
891 DebugGroupView->Add(DebugScrollView[0]);
892 /* -------------------------------------------------------------------------- */
893 if (debugOutputAdapter == nullptr)
895 debugOutputAdapter = new DebugOutputAdapter();
896 if (debugOutputAdapter == nullptr)
898 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputAdapter is new fail!!");
902 UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(&DebugOutputViewEventListener::GetInstance());
903 if (clickListener == nullptr)
905 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener is new fail!!");
908 debugOutputAdapter->SetItemClickListener(clickListener);
909 DebugOutputViewEventListener::GetInstance().InitDebugOutputItem();
910 /* -------------------------------------------------------------------------- */
911 if (debugOutputList == nullptr)
913 debugOutputList = new UIList(UIList::VERTICAL);
914 if (debugOutputList == nullptr)
916 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputList is new fail!!");
920 debugOutputList->SetPosition(0, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
921 debugOutputList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
922 debugOutputList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐
923 debugOutputList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。
924 debugOutputList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。
925 debugOutputList->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/
926 debugOutputList->SetAdapter(debugOutputAdapter);
927 debugOutputList->RefreshList();
928 // debugOutputList->SetReboundSize(30);
929 // debugOutputList->SetScrollBlankSize(30);
930 debugOutputList->SetRotateFactor(1.0);
931 DebugScrollView[0]->Add(debugOutputList);
932 /* -------------------------------------------------------------------------- */
933 if (debugOutputbleServiceLabelButton == nullptr)
935 debugOutputbleServiceLabelButton = new UILabelButton();
936 if (debugOutputbleServiceLabelButton == nullptr)
938 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputbleServiceLabelButton is new fail!!");
942 debugOutputbleServiceLabelButton->SetPosition(43, debugOutputList->GetY() + debugOutputList->GetHeight());
943 debugOutputbleServiceLabelButton->SetViewId(DEBUGOUTPUTBLESERVICELABELBUTTON);
944 debugOutputbleServiceLabelButton->Resize(380, 100);
945 debugOutputbleServiceLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
946 debugOutputbleServiceLabelButton->SetText("开启ble广播");
947 debugOutputbleServiceLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
948 debugOutputbleServiceLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
949 debugOutputbleServiceLabelButton->SetOnClickListener(clickListener);
950 DebugScrollView[0]->Add(debugOutputbleServiceLabelButton);
951 /* -------------------------------------------------------------------------- */
952 NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDebugOutputMainView);
953 /* -------------------------------------------------------------------------- */
957 return DebugGroupView;
961 void FreeDebugOutputMainView(void)
963 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView");
965 if (DebugGroupView != nullptr)
967 DebugGroupView->RemoveAll();
968 if (DebugScrollView[0] != nullptr)
970 DebugScrollView[0]->RemoveAll();
972 delete debugOutputList;
973 debugOutputList = nullptr;
975 delete debugOutputAdapter;
976 debugOutputAdapter = nullptr;
978 delete debugOutputbleServiceLabelButton;
979 debugOutputbleServiceLabelButton = nullptr;
981 delete DebugScrollView[0];
982 DebugScrollView[0] = nullptr;
984 RootView::GetInstance()->Remove(DebugGroupView);
985 delete DebugGroupView;
986 DebugGroupView = nullptr;
987 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView success!!");
989 if (uapi_dev_runtime_get_saveele_status() == 1) // 如果省电模式开启,该调试窗口关闭时候恢复原状态