From 528296aa1e651f39af1dab6f91a9325b88055a93 Mon Sep 17 00:00:00 2001 From: aliyun3243248791 Date: Mon, 8 Jun 2026 08:30:29 +0000 Subject: [PATCH] Merge #3440 into HJ02 from refs/changes/3440/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from aliyun3243248791 * refs/changes/3440/head: (7 commits squashed) - 修复sos未设置号码时呼出sos界面退出不了问题 - 解决表盘浏览特效界面按键退出不了问题 - 屏蔽蓝牙耳机相关代码 - 解决直线列表表冠不能转动问题 - 解决更多运动界面按键失效问题 - 修复低电量管不了机,卡住问题 - Merge branch 'n9_2.0' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into n9_2.0 Signed-off-by: 薛文强 Merged-by: aliyun6865282430 <1624952103@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/3440 --- .../nativelauncher/src/NativeLauncher.cpp | 4 - .../applist/src/ListDesktopFragment.cpp | 2 + .../player/src/MusicPlayerSourceView.cpp | 14 +- .../set_dial/src/SetDialPresenter.cpp | 3 +- .../nativeui/set_dial/src/SetDialView.cpp | 2 +- .../include/SetDialStylePresenter.h | 1 + .../src/SetDialStylePresenter.cpp | 5 + .../include/TraingMorePresenter.h | 2 +- .../src/TraingMorePresenter.cpp | 7 +- .../msg_center/src/msg_center_customer.cpp | 113 ++++++----- .../src/notify/charge_notification.cpp | 186 ++++++++++-------- .../msg_center/src/notify/phone_crt.cpp | 28 ++- .../vibrator/service/vibrator_service.cpp | 19 +- .../battery/service/battery_service.cpp | 11 +- 14 files changed, 226 insertions(+), 171 deletions(-) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/src/NativeLauncher.cpp index 6744e7ef8..3a513aa25 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -170,10 +170,6 @@ void NativeLauncher::InitNativeLauncher(LaunchMode mode) // 初始化屏幕时长 cm_initializeScreenDuration(); - - // 开机增加震动 页面启动震动一次 - // custom_VibratorFunc_int(0); - } // 注册开机时间 SystemLogData systemlog; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ListDesktopFragment.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ListDesktopFragment.cpp index 538396b7f..ff7bc88c7 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ListDesktopFragment.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/applist/src/ListDesktopFragment.cpp @@ -35,6 +35,8 @@ void ListDesktopFragment::OnCreateView(void* data) contentList_->SetDraggable(true); contentList_->SetThrowDrag(true); contentList_->EnableAutoAlign(true); + contentList_->SetRotateFactor(1.0); + contentList_->RequestFocus(); contentList_->SetScrollStateListener(this); contentList_->SetMaxScrollDistance(MAX_SCROLL_DIS); contentList_->SetYScrollBarVisible(true); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp index f02943741..4b42273c2 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp @@ -472,7 +472,7 @@ namespace OHOS } // UpdateBluetoothHeadsetConnectLabel(); - // UpdateBluetoothHeadSetViewIsVisible(); + UpdateBluetoothHeadSetViewIsVisible(); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(titleLabel); @@ -496,10 +496,14 @@ namespace OHOS bool value = PlayersModel::GetInstance()->GetMusicSource(); if (bluetoothHeadsetLabel && bluetoothHeadsetImage && bluetoothHeadsetLableButton && bluetoothHeadsetConnectState) { - bluetoothHeadsetLabel->SetVisible(value ? false : true); - bluetoothHeadsetImage->SetVisible(value ? false : true); - bluetoothHeadsetLableButton->SetVisible(value ? false : true); - bluetoothHeadsetConnectState->SetVisible(value ? false : true); + // bluetoothHeadsetLabel->SetVisible(value ? false : true); + // bluetoothHeadsetImage->SetVisible(value ? false : true); + // bluetoothHeadsetLableButton->SetVisible(value ? false : true); + // bluetoothHeadsetConnectState->SetVisible(value ? false : true); + bluetoothHeadsetLabel->SetVisible(false); + bluetoothHeadsetImage->SetVisible(false); + bluetoothHeadsetLableButton->SetVisible(false); + bluetoothHeadsetConnectState->SetVisible(false); } if (phoneLableButton && watchLableButton) { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp index 637580dc1..0e55dbff4 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp @@ -43,7 +43,6 @@ namespace OHOS void SetDialPresenter::OnStart() { - Presenter::OnStart(); } void SetDialPresenter::OnResume(void) @@ -53,7 +52,7 @@ namespace OHOS void SetDialPresenter::OnStop(void) { - model->ClearDialInfo(); + model->ClearDialInfo(); } void SetDialPresenter::OnClickAction(void) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialView.cpp index 170210bcd..3c307399e 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial/src/SetDialView.cpp @@ -37,7 +37,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"滚筒流"); SetUpRollerView(); } - + } void SetDialView::SetUpCoverflowView(void) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStylePresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStylePresenter.h index 2a0955ecb..9c136c94d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStylePresenter.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/include/SetDialStylePresenter.h @@ -18,6 +18,7 @@ namespace OHOS public: SetDialStylePresenter(); ~SetDialStylePresenter(); + void OnResume() override; SetDialStylePresenter(const SetDialStylePresenter &) = delete; SetDialStylePresenter &operator=(const SetDialStylePresenter &) = delete; bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp index 48e9320cf..f59447a03 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp @@ -19,6 +19,11 @@ namespace OHOS { } + void SetDialStylePresenter::OnResume(void) + { + RootView::GetInstance()->SetOnKeyActListener(this); + } + bool SetDialStylePresenter::OnClick(UIView &view, const ClickEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnClick"); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h index 1dac05709..89f9ed462 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h @@ -34,7 +34,7 @@ namespace OHOS virtual ~TraingMorePresenter(); void OnStart() override; - void OnStop() override; + void OnResume() override; void NavigateBack(); static TraingMorePresenter *GetInstance(); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp index 903555d42..ac489a4f3 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp @@ -62,9 +62,10 @@ namespace OHOS view_->RefreshTraingMoreList(itemInfo); } - void TraingMorePresenter::OnStop(void) - { - Presenter::OnStop(); + + void TraingMorePresenter::OnResume() + { + RootView::GetInstance()->SetOnKeyActListener(this); } void TraingMorePresenter::NavigateBack() diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp index b3fdbe2c4..9b765ba39 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp @@ -669,62 +669,79 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req) /*低电量提醒*/ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) { -WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: LowPower Alarm !"); -uint8 *x= (uint8 *)(req->data); -const power_display_svr_api_t *display_api = power_display_svr_get_api(); -// if(*x==3) -// { -// if (display_api->get_screen_state() != SCREEN_ON) -// { -// display_api->turn_on_screen(); -// } -// display_api->set_screen_set_keepon_timeout(1000*5); -// //倒计时结束后,直接执行关机动画 -// low_power_play(); -// } -if(*x==0) -{ - //提醒低电充电 - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); + if (req == NULL || req->data == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "低电量提醒: 请求数据为空"); + return; } - display_api->set_screen_set_keepon_timeout(1000*5); - set_lowpower_falg(0); - if (CheckPriority(topic)) + uint8 *x = (uint8 *)(req->data); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 收到事件 topic=%u, alarm_type=%u", topic, *x); + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "低电量提醒: 获取display_api失败"); + return; + } + + if (*x == 0) { - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 提醒低电充电"); + if (display_api->get_screen_state() != SCREEN_ON) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 屏幕未亮, 先亮屏"); + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000 * 5); + + set_lowpower_falg(0); + if (CheckPriority(topic)) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 优先级检查通过, 显示充电提醒弹窗"); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "低电量提醒: 优先级检查未通过, 不显示充电提醒弹窗"); + } } -} -else -{ - //电量过低,直接提醒关机 - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); + else if (*x == 3) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 倒计时结束, 执行关机动画 alarm_type=%u", *x); + if (display_api->get_screen_state() != SCREEN_ON) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 屏幕未亮, 先亮屏"); + display_api->turn_on_screen(); + } + /* 倒计时弹窗 UI 已存在,直接播放关机动画,勿 StopNotify/ShowNotify 否则会重置倒计时 */ + OHOS::low_power_play(); } - display_api->set_screen_set_keepon_timeout(1000*10); - set_lowpower_falg(1); - if (NotificationManager::GetInstance()->HasNotifyShowing()) - NotificationManager::GetInstance()->StopNotify(); - if (CheckPriority(topic)) + else { - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); - NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 电量过低, 提醒关机 alarm_type=%u", *x); + if (display_api->get_screen_state() != SCREEN_ON) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 屏幕未亮, 先亮屏"); + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000 * 10); + set_lowpower_falg(1); + if (NotificationManager::GetInstance()->HasNotifyShowing()) { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 关闭当前弹窗"); + NotificationManager::GetInstance()->StopNotify(); + } + if (CheckPriority(topic)) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量提醒: 优先级检查通过, 显示关机提醒弹窗"); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "低电量提醒: 优先级检查未通过, 不显示关机提醒弹窗"); + } } } -} - //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机) - // DialModelCharge::GetInstance()->UpdatechargeStatus(0); - // SaveEleModel::GetInstance()->SetChargeStatus(0); - - // testCHANINGView *t=testCHANINGView::GetInstance(); - // if(t!=NULL) - // { - // t->ChangeViewcolor(false); - // } #ifdef SUPPORT_CAT1_MODEM void MsgCenterNotifyHfpIncomingProc(const Topic topic, Request* req) diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp index e7ca83a0f..64a41836c 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/notify/charge_notification.cpp @@ -218,10 +218,8 @@ namespace OHOS { batteryprogress = new UICircleProgress(); } - batteryprogress->SetPosition( - 123, 123); // widget's left position and top position - batteryprogress->Resize(224, 222); // widget's width and height - batteryprogress->SetViewId("circleProgress1"); // Set style + batteryprogress->SetPosition(123, 123,224,222); + batteryprogress->SetViewId("circleProgress1"); batteryprogress->SetStyle(STYLE_BACKGROUND_OPA, 0x00); // Set additional property @@ -247,9 +245,9 @@ namespace OHOS { image_lightning = new UIImageView(); } - image_lightning->SetPosition(207, 176); // widget's left position and top position - image_lightning->Resize(70, 60); // widget's width and height - image_lightning->SetViewId("image2"); // Set style + image_lightning->SetPosition(207, 176); + image_lightning->Resize(70, 60); + image_lightning->SetViewId("image2"); image_lightning->SetStyle(STYLE_BORDER_COLOR, 0xff191919); char *image2imagesPath = "/user/res/solar-energy_1.bin"; image_lightning->SetSrc(image2imagesPath); @@ -259,9 +257,9 @@ namespace OHOS { image_circle = new UIImageView(); } - image_circle->SetPosition(126, 125); // widget's left position and top position - image_circle->Resize(194, 194); // widget's width and height - image_circle->SetViewId("image1"); // Set style + image_circle->SetPosition(126, 125); + image_circle->Resize(194, 194); + image_circle->SetViewId("image1"); char *image1imagesPath = "/user/res/Ellipse_37.bin"; image_circle->SetSrc(image1imagesPath); image_circle->SetVisible(true); @@ -270,9 +268,9 @@ namespace OHOS { UILabel_power = new UILabelExt(); } - UILabel_power->SetPosition(133, 252); // widget's left position and top position - UILabel_power->Resize(200, 60); // widget's width and height - UILabel_power->SetViewId("label5"); // Set style + UILabel_power->SetPosition(133, 252); + UILabel_power->Resize(200, 60); + UILabel_power->SetViewId("label5"); UILabel_power->SetStyle(STYLE_TEXT_FONT, 40); UILabel_power->SetText(buf); @@ -286,9 +284,9 @@ namespace OHOS { UILabel_Chargeing = new UILabelExt(); } - UILabel_Chargeing->SetPosition(133, 356); // widget's left position and top position - UILabel_Chargeing->Resize(200, 60); // widget's width and height - UILabel_Chargeing->SetViewId("label4"); // Set style + UILabel_Chargeing->SetPosition(133, 356); + UILabel_Chargeing->Resize(200, 60); + UILabel_Chargeing->SetViewId("label4"); UILabel_Chargeing->SetStyle(STYLE_TEXT_FONT, 30); // UILabel_Chargeing->SetText("正在充电"); // UILabel_Chargeing->SetTextId(STR_CHARGE); @@ -303,9 +301,9 @@ namespace OHOS { UILabel_time = new UILabelExt(); } - UILabel_time->SetPosition(173, 65); // widget's left position and top position - UILabel_time->Resize(120, 48); // widget's width and height - UILabel_time->SetViewId("label3"); // Set style + UILabel_time->SetPosition(173, 65); + UILabel_time->Resize(120, 48); + UILabel_time->SetViewId("label3"); UILabel_time->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property UILabel_time->SetText(time_buf); @@ -401,8 +399,15 @@ namespace OHOS } osTimerId_t low_power_timer = NULL; + static uint8_t timer_falg_low_power = 6; void FreelowPower(void) { + if (low_power_timer != NULL) { + osTimerStop(low_power_timer); + osTimerDelete(low_power_timer); + low_power_timer = NULL; + } + timer_falg_low_power = 6; if (UIViewGroup_lowpower != nullptr) { UIViewGroup_lowpower->RemoveAll(); @@ -441,34 +446,46 @@ namespace OHOS UIViewGroup_lowpower = nullptr; } } - static uint8_t timer_falg_low_power = 6; + void low_power_TimerCallBack(int data) { - // uapi_poweroff_device(); // 关机 - if (timer_falg_low_power) + if (timer_falg_low_power == 0) { + return; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "关机倒计时:%d", timer_falg_low_power); + timer_falg_low_power--; + UpdateLabel(alarm_UILabel, timer_falg_low_power, STR_LOW_POWER_NOTIF_2); + alarm_UILabel->Invalidate(); + if (timer_falg_low_power == 0) { - timer_falg_low_power--; - // char buf[34]={0}; - // sprintf(buf,"电量过低%ds后将自动关机",timer_falg_low_power); - // alarm_UILabel->GetText(); - // printf("%s\r\n",alarm_UILabel); - UpdateLabel(alarm_UILabel, timer_falg_low_power, STR_LOW_POWER_NOTIF_2); - alarm_UILabel->Invalidate(); - if (timer_falg_low_power == 0) - { - alarm_UILabel->SetVisible(false); + alarm_UILabel->SetVisible(false); + if (low_power_timer != NULL) { + osTimerStop(low_power_timer); + osTimerDelete(low_power_timer); + low_power_timer = NULL; + } + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "关机倒计时: 结束, 触发关机动画"); #ifdef SUPPORT_BATTERY_SERVICE - low_power_play_toUI(3); + low_power_play_toUI(3); #endif - } } + UNUSED(data); } void low_power_play() { - // uapi_poweroff_device(); // 关机 - - // osTimerStop(low_power_timer); + if (group == nullptr || ShutDownImageAnimatorView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "low_power_play: group or animator is null"); + return; + } + if (low_power_timer != NULL) { + osTimerStop(low_power_timer); + osTimerDelete(low_power_timer); + low_power_timer = NULL; + } + if (alarm_labelbutton != nullptr) { + alarm_labelbutton->SetVisible(false); + } group->SetVisible(true); UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast(lowppowrAnimatorStopListener::GetInstance()); ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); @@ -478,53 +495,57 @@ namespace OHOS return; } ShutDownImageAnimatorView->Start(); + ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); #ifdef SUPPORT_BATTERY_SERVICE set_lowpower_show(1, 0); #endif } + // 低电量提醒 UIViewGroup *lowPowerShow() { - if (UIViewGroup_lowpower == nullptr) { UIViewGroup_lowpower = new UIViewGroup(); + if (UIViewGroup_lowpower == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lowPowerShow: UIViewGroup_lowpower is null"); + return nullptr; + } UIViewGroup_lowpower->SetPosition(0, 0, 466, 466); - // UIViewGroup_lowpower->SetStyle(STYLE_BACKGROUND_OPA, 0); } - // Add ImageView to App if (alarm_img == nullptr) { alarm_img = new UIImageView(); + if (alarm_img == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lowPowerShow: alarm_img is null"); + return nullptr; + } } - alarm_img->SetPosition(171, 155); // widget's left position and top position - alarm_img->Resize(100, 100); // widget's width and height - alarm_img->SetViewId("image1"); // Set style - - // Set additional property + alarm_img->SetPosition(171, 155); + alarm_img->Resize(100, 100); const char *imageimagesPath = "/user/res/lowpower.bin"; alarm_img->SetSrc(imageimagesPath); - - // Add to rootView - UIViewGroup_lowpower->Add(alarm_img); alarm_img->SetVisible(true); - - // Add Label to App + UIViewGroup_lowpower->Add(alarm_img); + /* -------------------------------------------------------------------------- */ if (alarm_UILabel == nullptr) { alarm_UILabel = new UILabelExt(); + if (alarm_UILabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lowPowerShow: alarm_UILabel is null"); + return nullptr; + } } - alarm_UILabel->SetPosition(101, 215); // widget's left position and top position - alarm_UILabel->Resize(466, 212); // widget's width and height - alarm_UILabel->SetViewId("label1"); // Set style + alarm_UILabel->SetPosition(101, 215); + alarm_UILabel->Resize(466, 212); alarm_UILabel->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - if (battery_falg == 0) + if (battery_falg == 0) //低电量提醒 { - alarm_UILabel->SetPosition(110, 252); // widget's left position and top position - alarm_UILabel->Resize(245, 70); // widget's width and height - + alarm_UILabel->SetPosition(110, 252); + alarm_UILabel->Resize(245, 70); // alarm_UILabel->SetText("当前电量低于10%请及时充电"); alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_1); @@ -536,11 +557,10 @@ namespace OHOS set_lowpower_show(0, 0); #endif } - // Set additional property - if (battery_falg == 1) + if (battery_falg == 1) //低电量关机 { alarm_UILabel->SetPosition(110, 252); - alarm_UILabel->Resize(245, 70); // widget's width and height + alarm_UILabel->Resize(245, 70); // alarm_UILabel->SetText("当前电量低于5%,将自动关机"); alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_2); UpdateLabel(alarm_UILabel, 5, STR_LOW_POWER_NOTIF_2); @@ -548,6 +568,11 @@ namespace OHOS alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); alarm_UILabel->SetRollSpeed(0); alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + if (low_power_timer != NULL) { + osTimerStop(low_power_timer); + osTimerDelete(low_power_timer); + low_power_timer = NULL; + } osStatus_t retTimer; low_power_timer = osTimerNew((osTimerFunc_t)low_power_TimerCallBack, osTimerPeriodic, NULL, NULL); retTimer = osTimerStart(low_power_timer, 1000 * 1); @@ -560,32 +585,28 @@ namespace OHOS } timer_falg_low_power = 5; } - - // Add to rootView UIViewGroup_lowpower->Add(alarm_UILabel); alarm_UILabel->SetVisible(true); - - // Add LabelButtonExt to App + /* -------------------------------------------------------------------------- */ if (alarm_labelbutton == nullptr) { alarm_labelbutton = new UILabelButtonExt(); + if (alarm_labelbutton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lowPowerShow: alarm_labelbutton is null"); + return nullptr; + } } - // alarm_labelbutton->SetPosition(165, 378); // widget's left position and top position - // alarm_labelbutton->Resize(135, 88); // widget's width and height - alarm_labelbutton->SetViewId(LOW_POWER_BUTTON); // Set style + alarm_labelbutton->SetViewId(LOW_POWER_BUTTON); alarm_labelbutton->SetPosition(0, 366, 466, 100); const char *ImgSrc = "/user/res/466x100button.bin"; alarm_labelbutton->SetImageSrc(ImgSrc, ImgSrc); - // Set additional property // alarm_labelbutton->SetText("确认"); alarm_labelbutton->SetTextId(STR_KONW); alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); alarm_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - UIView::OnClickListener *button1Click = static_cast(lowppowrViewEventListener::GetInstance()); alarm_labelbutton->SetOnClickListener(button1Click); - - // Add to rootView UIViewGroup_lowpower->Add(alarm_labelbutton); alarm_labelbutton->SetVisible(true); UIViewGroup_lowpower->SetTouchable(true); @@ -600,19 +621,16 @@ namespace OHOS ShutDownImageAnimatorView->Start(); ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏 } - NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreelowPower); return UIViewGroup_lowpower; } lowppowrViewEventListener::lowppowrViewEventListener() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "lowppowrViewEventListener :%p", this); } lowppowrViewEventListener::~lowppowrViewEventListener() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~lowppowrViewEventListener"); } lowppowrViewEventListener *lowppowrViewEventListener::GetInstance(void) @@ -628,7 +646,12 @@ namespace OHOS { if (battery_falg) { - osTimerStop(low_power_timer); + if(low_power_timer != NULL) + { + osTimerStop(low_power_timer); + osTimerDelete(low_power_timer); + low_power_timer = NULL; + } low_power_play(); } else @@ -641,7 +664,6 @@ namespace OHOS NotificationManager::GetInstance()->StopNotify(); } return true; - UNUSED(event); } void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view) @@ -655,14 +677,6 @@ namespace OHOS shutdown_reboot_prejobs(REBOOT_TYPE); else shutdown_reboot_prejobs(SHUTDOWN_TYPE); - // uapi_poweroff_device(); // 关机 - - // NotificationManager::GetInstance()->StopNotify(); - // - // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0) - // { - - // } } diff --git a/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_crt.cpp b/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_crt.cpp index f31d4b7b7..58f2b23a1 100644 --- a/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_crt.cpp +++ b/code/sdk/application/wearable/n9/service/msg_center/src/notify/phone_crt.cpp @@ -164,6 +164,30 @@ void start_SOS_phone_dail(void) namespace OHOS { + class CallViewEventListener : public OHOS::UIView::OnClickListener + { + public: + static CallViewEventListener *GetInstance() + { + static CallViewEventListener callViewEventListener; + return &callViewEventListener; + } + bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override + { + if (strcmp(view.GetViewId(), "SOS_FAIL") == 0) + { + NotificationManager::GetInstance()->StopNotify(); + } + return true; + } + private: + CallViewEventListener(){}; + ~CallViewEventListener(){}; + CallViewEventListener(const CallViewEventListener &) = delete; + const CallViewEventListener &operator=(const CallViewEventListener &) = delete; + }; + + void phone_VibratorFunc(void); uint8 call_stat=0; @@ -501,8 +525,8 @@ UIViewGroup* SOS_cant_dial(void) alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 44); alarm_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - // UIView::OnClickListener *button1Click = static_cast(CallViewEventListener::GetInstance()); - // alarm_labelbutton->SetOnClickListener(button1Click); + UIView::OnClickListener *button1Click = static_cast(CallViewEventListener::GetInstance()); + alarm_labelbutton->SetOnClickListener(button1Click); SOSView->Add(alarm_labelbutton); alarm_labelbutton->SetVisible(true); diff --git a/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp b/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp index 7b06bf4e6..7dbb252a6 100644 --- a/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp +++ b/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp @@ -106,12 +106,6 @@ void custom_VibratorFunc(OHOS::VibratorType vibratorType) } } -// // UI 界面震动一次接口 -// void ui_api_vibrate_once_func(void) -// { -// custom_VibratorFunc_int(0); -// } - static unsigned long g_app_queue= 0xFFFFFFFF; static bool vibrator_service_running_stat = false; @@ -192,22 +186,11 @@ errcode_t uapi_vibrator_service_init(void) OHOS::VibratorManager::GetInstance()->RegisterVibratorFunc(custom_VibratorFunc); /* ---------------------------------- 开机震动一次 ---------------------------------- */ -#ifdef BOARD_FD272 + PRINT("开机震动一次\n"); custom_VibratorFunc_int(5); -#else - custom_VibratorFunc_int(0); -#endif /* -------------------------------------------------------------------------- */ - return ERRCODE_SUCC; } - -void uapi_vibrator_service_deinit(void) -{ - -} - - #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/zhihui/services/battery/service/battery_service.cpp b/code/sdk/zhihui/services/battery/service/battery_service.cpp index 05561f491..c64db565d 100644 --- a/code/sdk/zhihui/services/battery/service/battery_service.cpp +++ b/code/sdk/zhihui/services/battery/service/battery_service.cpp @@ -654,20 +654,29 @@ void set_lowpower_show( uint8_t type,uint8_t data) errcode_t Play_shutdown_animation_notify(uint8_t alarm_level) { - //PRINT("alarm_level[%d],low_power_flag_1[%d],low_power_flag_2[%d]\n",alarm_level,low_power_flag_1,low_power_flag_2); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量UI: Play_shutdown_animation_notify alarm_level=%u, flag1=%u, flag2=%u", + alarm_level, low_power_flag_1, low_power_flag_2); + if(alarm_level==0 && low_power_flag_1) { //low_power_flag_1=0; + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量UI: 发布充电提醒事件 alarm_level=0"); ChargerEventPublish(TOPIC_EVENT_LOWPOWER_ALARM,alarm_level); } else if(alarm_level==1 && low_power_flag_2) { //low_power_flag_2=0; + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量UI: 发布关机倒计时提醒事件 alarm_level=1"); ChargerEventPublish(TOPIC_EVENT_LOWPOWER_ALARM,alarm_level); } else if(alarm_level!=0 && alarm_level!=1) { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "低电量UI: 发布关机动画事件 alarm_level=%u", alarm_level); ChargerEventPublish(TOPIC_EVENT_LOWPOWER_ALARM,alarm_level); } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "低电量UI: 未发布事件, alarm_level=%u 已被去重或条件不满足", alarm_level); + } return 0; } -- 2.17.1