#include "bleInstruct.h"
#endif
+#ifdef FD230
+#include "main/include/PullUpDownView.h"
+#include "custom_save_runtime.h"
#include "transmitting.h"
+#include "charge_notification.h"
+
+#ifdef SUPPORT_POWER_MANAGER
+#include "power_display_service.h"
+#endif
+#endif
namespace OHOS {
{TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE},
{TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
{TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE},
- {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE}
+ {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE},
+ {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO},
+ {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO},
+ {TOPIC_EVENT_LOWPOWER_ALARM,PRIORITY_TWO},
// {TOPIC_EVENT_DEVICE_UNBIND, PRIORITY_TWO},
// {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, PRIORITY_TWO},
MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE);
MsgCenterSubscribeTopic(TOPIC_EVENT_DEVICE_BIND);
MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRANSMIT);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_PLUG);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_CHARGE_UNPLUG);
+ MsgCenterSubscribeTopic(TOPIC_EVENT_LOWPOWER_ALARM);
}
{
return OHOS::transmittingShow();
}
+//充电弹窗
+static OHOS::UIViewGroup* ShowChargeingNotify(void)
+{
+ return OHOS::ShowChargeingView();
+}
+
+/*显示低电量通知*/
+static OHOS::UIViewGroup* showlowpowerNotify(void)
+{
+ return OHOS::lowPowerShow();
+}
void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
{
NotificationManager::GetInstance()->SetWatchCallStatus(true);
}
}
-
+#ifdef FD230
void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
{
#ifdef SUPPORT_BLE_SERVICE
// unused(req);
#endif
}
+
+void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
+{
+ unused(req);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug !");
+
+ uapi_save_runtime_log(RUNTIME_LOG_CHARGE_START);//充电开始事件
+
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+ if (display_api->get_screen_state() != SCREEN_ON)
+ {
+ display_api->turn_on_screen();
+ }
+
+ if(PullUpDownView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
+ }
+
+ #if 0
+#if DIALDATASET
+ DialModelCharge::GetInstance()->UpdatechargeStatus(1);
+#endif
+ SaveEleModel::GetInstance()->SetChargeStatus(true);
+ if (uapi_dev_runtime_get_train_status())
+ {
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug ! but train status is true");
+ return ;
+ }
+
+
+ testCHANINGView *t = testCHANINGView::GetInstance();
+ if(t != nullptr)
+ {
+ t->ChangeViewcolor(true);
+ }
+ else
+ {
+ if (CheckPriority(topic) && !uapi_dev_runtime_get_factory_test_status_flag()) //产测模式不弹充电弹窗
+ {
+ NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
+ }
+ }
+ #endif
+
+}
+
+/*充电器已拔掉*/
+void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
+{
+ unused(req);
+ unused(topic);
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger UnPlug !");
+ //充电停止事件
+ uapi_save_runtime_log(RUNTIME_LOG_CHARGE_STOP);//TOOD*
+
+ if(PullUpDownView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
+ }
+
+ #if 0
+#if DIALDATASET
+ DialModelCharge::GetInstance()->UpdatechargeStatus(0);
+#endif
+ SaveEleModel::GetInstance()->SetChargeStatus(false);
+
+ testCHANINGView *t = testCHANINGView::GetInstance();
+ if(t != nullptr)
+ {
+ t->ChangeViewcolor(false);
+ }
+ else
+ {
+ if(is_UIViewGroup_charge())
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ }
+ #endif
+}
+
+/*低电量提醒*/
+void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: LowPower Alarm !");
+ #if 0
+ 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();
+ }
+ else if(*x==0)
+ {
+ //提醒低电充电
+ if (display_api->get_screen_state() != SCREEN_ON)
+ {
+ display_api->turn_on_screen();
+ }
+ display_api->set_screen_set_keepon_timeout(1000*5);
+
+ set_lowpower_falg(0);
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ }
+ }
+ else
+ {
+ //电量过低,直接提醒关机
+ if (display_api->get_screen_state() != SCREEN_ON)
+ {
+ display_api->turn_on_screen();
+ }
+ display_api->set_screen_set_keepon_timeout(1000*10);
+
+ set_lowpower_falg(1);
+ if (NotificationManager::GetInstance()->HasNotifyShowing())
+ NotificationManager::GetInstance()->StopNotify();
+ if (CheckPriority(topic))
+ {
+ NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+ NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
+ }
+ }
+ //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机)
+ // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
+ // SaveEleModel::GetInstance()->SetChargeStatus(0);
+
+ // testCHANINGView *t=testCHANINGView::GetInstance();
+ // if(t!=NULL)
+ // {
+ // t->ChangeViewcolor(false);
+ // }
+ #endif
+}
+#endif
+
/* 订阅事件通知逻辑可定制 */
static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
{TOPIC_EVENT_ALARM_RING, MsgCenterNotifyAlarmProc},
{TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc},
{TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
{TOPIC_EVENT_BLE_TRANSMIT, MsgCenterNotifybleTransmit},
-
{TOPIC_EVENT_DEVICE_BIND, MsgCenterNotifyDeviceBindProc},
+ {TOPIC_EVENT_CHARGE_PLUG, MsgCenterNotifyChargePlugProc},
+ {TOPIC_EVENT_CHARGE_UNPLUG, MsgCenterNotifyChargeUnPlugProc},
+ {TOPIC_EVENT_LOWPOWER_ALARM, MsgCenterNotifyLowPowerAlarmProc},
// {TOPIC_EVENT_DEVICE_UNBIND, MsgCenterNotifyDeviceUnBindProc},
// {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST, MsgCenterNotifyDeviceUnBindingRequestProc},
--- /dev/null
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "AlarmPopUpPresenter.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button_ext.h"
+#include "battery_service.h"
+#include "NativeAbility.h"
+#include "custom_utils.h"
+#include "cmsis_os2.h"
+#include "linux/delay.h"
+#include "components/ui_circle_progress.h"
+#include "battery_hal.h"
+#include "uicomponents/UIComponents.h"
+#include "charge_notification.h"
+
+//#include "ui_resource_string.h"
+
+namespace OHOS
+{
+ UIImageView *imageCharge = nullptr;
+ UIViewGroup *UIViewGroup_lowpower=nullptr;
+ UIImageView *alarm_img=nullptr;
+ UILabelExt *alarm_UILabel=nullptr;
+ UILabelButtonExt *alarm_labelbutton=nullptr;
+ UIViewGroup *group=nullptr;
+ UIImageAnimatorView *ShutDownImageAnimatorView=nullptr;
+ static constexpr char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; //关机图片路径
+ #define SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES 30 // 图片帧数
+ static int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 130; // 图片更新间隔
+
+ static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 0;
+ static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 0;
+ static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 466;
+ static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 466;
+ const ImageInfo **ShutDownInfoArray{nullptr}; // 关机图片路径数组
+ ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
+ #define LOW_POWER_BUTTON "LOW_POWER_BUTTON"
+ #define CHARGE_GROUP "UIViewGroup_charge"
+
+ // GILROY_BOLD_FONT
+ //充电中 UI
+ UIViewGroup *UIViewGroup_charge =nullptr;
+
+ UICircleProgress *batteryprogress = nullptr;
+
+ UIImageView *image_circle = nullptr;
+ UIImageView *image_lightning=nullptr;
+
+ UILabelExt *UILabel_time=nullptr;
+ UILabelExt *UILabel_power=nullptr;
+ UILabelExt *UILabel_Chargeing=nullptr;
+
+ osTimerId_t Chargeing_timer= NULL;
+
+ // 刷新回调
+ void Chargeing_Timer_CallBack(int data) {
+ if (UIViewGroup_charge == nullptr || UILabel_Chargeing == nullptr ||
+ UILabel_power == nullptr || UILabel_time == nullptr ||
+ batteryprogress== nullptr) {
+ return;
+ }
+
+ float voltage = 0.0F;
+ uint8_t power = battery_get_voltage(&voltage);
+
+ // 使用 std::to_string 生成电池电量字符串
+ std::string powerstr = std::to_string(power) + "%";
+
+ // 获取当前时间
+ time_t seconds = time(nullptr);
+ struct tm pTM;
+ localtime_r(&seconds, &pTM); // 使用 localtime_r 以确保线程安全
+
+ // 解析时间并格式化为字符串
+ std::string stringtime =
+ (pTM.tm_hour < 10 ? "0" : "") + std::to_string(pTM.tm_hour) + ":" +
+ (pTM.tm_min < 10 ? "0" : "") + std::to_string(pTM.tm_min);
+
+ // 更新充电状态标签
+ if (UILabel_Chargeing) {
+ if (power == 100) {
+ UILabel_Chargeing->SetTextId(STR_CHARG_DOWN); // TODO: 增加多国语言
+ } else {
+ UILabel_Chargeing->SetTextId(STR_CHAEGING);
+ // UILabel_Chargeing->SetTextId(STR_CHARGE);
+ }
+ UILabel_Chargeing->Invalidate();
+ }
+
+ // 刷新时间标签
+ if (UILabel_time) {
+ UILabel_time->SetText(stringtime.c_str());
+ UILabel_time->Invalidate();
+ }
+
+ // 刷新电池百分比标签
+ if (UILabel_power) {
+ UILabel_power->SetText(powerstr.c_str());
+ UILabel_power->Invalidate();
+ }
+
+ // 刷新进度条
+ if (batteryprogress) {
+ batteryprogress->SetValue(power);
+ batteryprogress->Invalidate();
+ }
+ }
+
+ bool is_UIViewGroup_charge(void)
+ {
+ if(UIViewGroup_charge != nullptr)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ void FreeChargePower(void)
+ {
+ if (UIViewGroup_charge != nullptr)
+ {
+
+ if(Chargeing_timer)
+ {
+ osTimerStop(Chargeing_timer);
+ osTimerDelete(Chargeing_timer);
+ Chargeing_timer = NULL;
+ }
+
+ UIViewGroup_charge->RemoveAll();
+
+ if (batteryprogress) {
+ delete batteryprogress;
+ batteryprogress = nullptr;
+ }
+ if(image_lightning)
+ {
+ delete image_lightning;
+ image_lightning = nullptr;
+ }
+
+ if(UILabel_time)
+ {
+ delete UILabel_time;
+ UILabel_time = nullptr;
+ }
+
+ if(UILabel_power)
+ {
+ delete UILabel_power;
+ UILabel_power = nullptr;
+
+ }
+ if(UILabel_Chargeing)
+ {
+ delete UILabel_Chargeing;
+ UILabel_Chargeing = nullptr;
+
+ }
+
+
+ RootView::GetInstance()->Remove(UIViewGroup_charge);
+ delete UIViewGroup_charge;
+ UIViewGroup_charge = nullptr;
+ }
+ }
+
+ UIViewGroup * ShowChargeingView(void)
+ {
+
+ if (UIViewGroup_charge == nullptr)
+ {
+ UIViewGroup_charge = new UIViewGroup();
+ UIViewGroup_charge->SetPosition(0, 0, 466, 466);
+ //UIViewGroup_charge->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ }
+ UIViewGroup_charge->SetViewId(CHARGE_GROUP);
+ UIViewGroup_charge->SetTouchable(true);
+ UIView::OnClickListener *UIViewGroup_charge_Click = static_cast<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());
+ UIViewGroup_charge->SetOnClickListener(UIViewGroup_charge_Click);
+
+
+ float voltage = 0.0F;
+ uint8_t power = 0;
+ power = battery_get_voltage(&voltage);
+
+ char buf[16]={0};
+ sprintf(buf,"%d%c",power,'%');
+ //printf("power:%s\r\n",buf);
+
+ time_t currtime;
+ struct tm *timeinfo;
+ time(&currtime);
+ timeinfo = localtime(&currtime);
+
+ char time_buf[16]={0};
+ sprintf_s(time_buf,16,"%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
+
+ if (batteryprogress == nullptr) {
+ 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->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+ // Set BackgroundStyle
+ batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x05);
+ batteryprogress->SetBackgroundStyle(STYLE_BORDER_OPA, 0x07);
+ batteryprogress->SetBackgroundStyle(STYLE_LINE_OPA, 0x07);
+ batteryprogress->SetBackgroundStyle(STYLE_LINE_WIDTH, 22);
+ // Set ForegroundStyle
+ batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6);
+ batteryprogress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000);
+ batteryprogress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4FC34C);
+ batteryprogress->SetForegroundStyle(STYLE_LINE_WIDTH, 22);
+ batteryprogress->SetCenterPosition(111, 109);
+ batteryprogress->SetRadius(108);
+ batteryprogress->SetEndAngle(359);
+ batteryprogress->SetValue(power);
+ batteryprogress->SetVisible(true);
+ // batteryprogress->SetCapType(CAP_ROUND); 不使用圆形边缘
+
+ if (image_lightning == nullptr) {
+ 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->SetStyle(STYLE_BORDER_COLOR, 0xff191919);
+ char* image2imagesPath = "/user/res/solar-energy_1.bin";
+ image_lightning->SetSrc(image2imagesPath);
+ image_lightning->SetVisible(true);
+
+
+ if (image_circle == nullptr) {
+ 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
+ char* image1imagesPath = "/user/res/Ellipse_37.bin";
+ image_circle->SetSrc(image1imagesPath);
+ image_circle->SetVisible(true);
+
+ if (UILabel_power == nullptr) {
+ 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->SetStyle(STYLE_TEXT_FONT, 40);
+
+ UILabel_power->SetText(buf);
+ UILabel_power->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ UILabel_power->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ UILabel_power->SetRollSpeed(0);
+ UILabel_power->SetFont(GILROY_BOLD_FONT, 40);
+ UILabel_power->SetVisible(true);
+
+
+ if (UILabel_Chargeing == nullptr) {
+ 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->SetStyle(STYLE_TEXT_FONT, 30);
+ // UILabel_Chargeing->SetText("正在充电");
+ // UILabel_Chargeing->SetTextId(STR_CHARGE);
+ UILabel_Chargeing->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ UILabel_Chargeing->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
+ UILabel_Chargeing->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ UILabel_Chargeing->SetRollSpeed(0);
+ UILabel_Chargeing->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
+ UILabel_Chargeing->SetVisible(true);
+
+
+ if (UILabel_time == nullptr) {
+ 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->SetStyle(STYLE_TEXT_FONT, 40);
+ // Set additional property
+ UILabel_time->SetText(time_buf);
+ UILabel_time->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ UILabel_time->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ UILabel_time->SetRollSpeed(0);
+ UILabel_time->SetFont(GILROY_BOLD_FONT, 40);
+ UILabel_time->SetVisible(true);
+
+ osStatus_t retTimer;
+ Chargeing_timer = osTimerNew((osTimerFunc_t)Chargeing_Timer_CallBack, osTimerPeriodic, NULL, NULL);
+ retTimer = osTimerStart(Chargeing_timer, 1000*1);
+ if (retTimer != osOK && Chargeing_timer != NULL) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+ osTimerDelete(Chargeing_timer);
+ Chargeing_timer = NULL;
+ }
+
+
+
+ UIViewGroup_charge->Add(image_lightning);
+ UIViewGroup_charge->Add(image_circle);
+
+ UIViewGroup_charge->Add(batteryprogress);
+
+ UIViewGroup_charge->Add(UILabel_time);
+ UIViewGroup_charge->Add(UILabel_power);
+ UIViewGroup_charge->Add(UILabel_Chargeing);
+
+ NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeChargePower);
+ return UIViewGroup_charge;
+ }
+
+
+ void ShowUpShutDownAnimatorView()
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+ return ;
+ }
+ group->SetPosition(0, 0, 466, 466);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView");
+ ShutDownInfoArray = CreateImageInfoArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+ if (ShutDownImageAnimatorView == nullptr)
+ {
+ ShutDownImageAnimatorView = new UIImageAnimatorView();
+ if (ShutDownImageAnimatorView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail");
+ return ;
+ }
+
+ for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+ {
+ ShutDownImageInfo[i].imageInfo = (ShutDownInfoArray[i]);
+ ShutDownImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+ ShutDownImageInfo[i].pos.x = SHUTDOWN_IMAGE_ANIMATOR_VIEW_X;
+ ShutDownImageInfo[i].pos.y = SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y;
+ ShutDownImageInfo[i].width = SHUTDOWN_IMAGE_ANIMATOR_VIEW_W;
+ ShutDownImageInfo[i].height = SHUTDOWN_IMAGE_ANIMATOR_VIEW_H;
+ }
+ ShutDownImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H);
+ ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ ShutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, SHUTDOWN_IMAGE_ANIMATOR_TIME);
+ ShutDownImageAnimatorView->SetRepeat(false);
+ ShutDownImageAnimatorView->SetRepeatTimes(1);
+
+ }
+ UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
+ ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
+ if (stoplistener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
+ return;
+ }
+
+ ShutDownImageAnimatorView->SetVisible(true);
+ //ShutDownImageAnimatorView->Start();
+ group->SetVisible(false);
+ group->Add(ShutDownImageAnimatorView);
+ return ;
+ }
+
+ static uint8_t battery_falg=0;
+ void set_lowpower_falg(uint8_t falg)
+ {
+ battery_falg=falg;
+ }
+
+ osTimerId_t low_power_timer= NULL;
+ void FreelowPower(void)
+ {
+ if (UIViewGroup_lowpower != nullptr)
+ {
+ UIViewGroup_lowpower->RemoveAll();
+ if(alarm_img)
+ {
+ delete alarm_img;
+ alarm_img = nullptr;
+ }
+ if(alarm_UILabel)
+ {
+ delete alarm_UILabel;
+ alarm_UILabel = nullptr;
+ }
+ if(alarm_labelbutton)
+ {
+ delete alarm_labelbutton;
+ alarm_labelbutton = nullptr;
+ }
+ if(group)
+ {
+ group->RemoveAll();
+ ShutDownImageAnimatorView->Stop();
+ if(ShutDownImageAnimatorView)
+ {
+ delete ShutDownImageAnimatorView;
+ ShutDownImageAnimatorView = nullptr;
+ }
+ FreeImageInfoArray(ShutDownInfoArray,ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ delete group;
+ group = nullptr;
+
+ }
+ //FreeImagePathsArray(ShutDownPathsArray,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+ RootView::GetInstance()->Remove(UIViewGroup_lowpower);
+ delete UIViewGroup_lowpower;
+ 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)
+ {
+ 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);
+ low_power_play_toUI(3);
+ }
+
+ }
+
+ }
+
+ void low_power_play()
+ {
+ //uapi_poweroff_device(); // 关机
+
+ //osTimerStop(low_power_timer);
+ group->SetVisible(true);
+ UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
+ ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
+ if (stoplistener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
+ return ;
+ }
+ ShutDownImageAnimatorView->Start();
+ set_lowpower_show(1,0);
+
+
+
+ }
+
+ UIViewGroup *lowPowerShow()
+ {
+
+ if (UIViewGroup_lowpower == nullptr) {
+ UIViewGroup_lowpower = new UIViewGroup();
+ 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();
+ }
+ 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
+ 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
+ if (alarm_UILabel == nullptr) {
+ alarm_UILabel = new UILabelExt();
+ }
+ 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->SetStyle(STYLE_TEXT_FONT, 30);
+
+ // Set additional property
+ 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->SetText("当前电量低于10%请及时充电");
+ alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_1);
+
+ alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ alarm_UILabel->SetRollSpeed(0);
+ alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ set_lowpower_show(0,0);
+ }
+ // Set additional property
+ if(battery_falg==1)
+ {
+ alarm_UILabel->SetPosition(110, 252);
+ alarm_UILabel->Resize(245, 70); // widget's width and height
+ //alarm_UILabel->SetText("当前电量低于5%,将自动关机");
+ alarm_UILabel->SetTextId(STR_LOW_POWER_NOTIF_2);
+ UpdateLabel(alarm_UILabel, 5, STR_LOW_POWER_NOTIF_2);
+ alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ alarm_UILabel->SetRollSpeed(0);
+ alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ osStatus_t retTimer;
+ low_power_timer = osTimerNew((osTimerFunc_t)low_power_TimerCallBack, osTimerPeriodic, NULL, NULL);
+ retTimer = osTimerStart(low_power_timer, 1000*1);
+ if (retTimer != osOK && low_power_timer != NULL) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+ osTimerDelete(low_power_timer);
+ low_power_timer = NULL;
+ }
+ 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();
+ }
+ // 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->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<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());
+ alarm_labelbutton->SetOnClickListener(button1Click);
+
+ // Add to rootView
+ UIViewGroup_lowpower->Add(alarm_labelbutton);
+ alarm_labelbutton->SetVisible(true);
+ UIViewGroup_lowpower->SetTouchable(true);
+ alarm_labelbutton->SetTouchable(true);
+
+ ShowUpShutDownAnimatorView();
+ if(group)
+ UIViewGroup_lowpower->Add(group);
+ if(battery_falg>=3)
+ {
+ group->SetVisible(true);
+ ShutDownImageAnimatorView->Start();
+ ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏
+
+ }
+
+ NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreelowPower);
+ return UIViewGroup_lowpower;
+ }
+
+ lowppowrViewEventListener::lowppowrViewEventListener()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallViewEventListener :%p", this);
+ }
+
+ lowppowrViewEventListener::~lowppowrViewEventListener()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~CallViewEventListener");
+ }
+
+ lowppowrViewEventListener *lowppowrViewEventListener::GetInstance(void)
+ {
+ static lowppowrViewEventListener lowppowrViewEventListene_t;
+ return &lowppowrViewEventListene_t;
+ }
+
+ bool lowppowrViewEventListener::OnClick(UIView& view, const ClickEvent& event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnClick.....");
+ if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)==0)
+ {
+ if(battery_falg)
+ {
+ osTimerStop(low_power_timer);
+ low_power_play();
+
+ }
+ else
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+
+ }
+ if(strcmp(view.GetViewId(),CHARGE_GROUP)==0)
+ {
+ NotificationManager::GetInstance()->StopNotify();
+ }
+ return true;
+ UNUSED(event);
+ }
+
+ void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view)
+ {
+ //UNUSED(view);
+ // NotificationManager::GetInstance()->StopNotify();//hcj改动
+ msleep(500);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
+
+ if(battery_falg==4)
+ 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)
+ // {
+
+ // }
+
+ }
+
+
+
+}
{TOPIC_DEMO_ACORE_MSG, A_CORE_MASK, 1},
{TOPIC_DEMO_ALL_MSG, A_CORE_MASK, 1},
{TOPIC_EVENT_ALARM_RING, A_CORE_MASK, 1},
- {TOPIC_EVENT_ON_TIME, A_CORE_MASK, 1},
{TOPIC_EVENT_UTCTIME_UPDATE, A_CORE_MASK, 1},
{TOPIC_EVENT_NEXTDAY_UPDATE, A_CORE_MASK, 1},
{TOPIC_EVENT_WEARSTATE_UPDATE, A_CORE_MASK, 1},
{TOPIC_EVENT_STEPDATA_UPDATE, A_CORE_MASK, 1},
{TOPIC_EVENT_SHUTDOWN, A_CORE_MASK, 1},
{TOPIC_EVENT_HEARTRATE_UPDATA, A_CORE_MASK, 1},
- {TOPIC_EVENT_STATIC_HEARTRATE_UPDATA, A_CORE_MASK, 1},
-#ifdef SUPPORT_CYWEE_SERVICE
- {TOPIC_EVENT_ACTIVITY_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_INACTIVITY_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_BLE_TRAINING,A_CORE_MASK,1},
- {TOPIC_EVENT_BLE_TRANSMIT,A_CORE_MASK,1},
- {TOPIC_EVENT_GOAL_SHOW_VIEW,A_CORE_MASK,1},
-
-#endif
-#ifdef SUPPORT_SPO2_NOTIFICATION
- {TOPIC_EVENT_SPO2_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_START_HRS_MONITORING, A_CORE_MASK, 1},
- {TOPIC_EVENT_STOP_HRS_MONITORING, A_CORE_MASK, 1},
- {TOPIC_EVENT_START_SPO2_MONITORING, A_CORE_MASK, 1},
- {TOPIC_EVENT_STOP_SPO2_MONITORING, A_CORE_MASK, 1},
- {TOPIC_EVENT_GRAYCARD_UPDATA, A_CORE_MASK, 1},
- {TOPIC_EVENT_LEAKLIGHT_UPDATA, A_CORE_MASK, 1},
-#endif
{TOPIC_EVENT_HFP_INCOMMING, A_CORE_MASK, 1},
{TOPIC_EVENT_HFP_PHONE_ACTIVE, A_CORE_MASK, 1},
{TOPIC_EVENT_HFP_WATCH_ACTIVE, A_CORE_MASK, 1},
{TOPIC_EVENT_HFP_FINISHED, A_CORE_MASK, 1},
{TOPIC_EVENT_HFP_PHONE_TO_WATCH, A_CORE_MASK, 1},
{TOPIC_EVENT_HFP_WATCH_TO_PHONE, A_CORE_MASK, 1},
- {TOPIC_EVENT_HFP_HINT, A_CORE_MASK, 1},
-
-#ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
- {TOPIC_EVENT_CHARGE_PLUG, A_CORE_MASK, 1},
- {TOPIC_EVENT_CHARGE_UNPLUG, A_CORE_MASK, 1},
- {TOPIC_EVENT_LOWPOWER_ALARM, A_CORE_MASK, 1},
-#endif
-#ifdef SUPPORT_DEVICE_PAIRING_NOTIFICATION
- {TOPIC_EVENT_DEVICE_BIND,A_CORE_MASK, 1},
- // {TOPIC_EVENT_DEVICE_UNBIND,A_CORE_MASK, 1},
- // {TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,A_CORE_MASK, 1},
-#endif
- {TOPIC_EVENT_ENTER_CMAERA,A_CORE_MASK, 1},//遥控拍照
- {TOPIC_EVENT_ASSISTANT_NOTE,A_CORE_MASK, 1},//语音助手
- {TOPIC_EVENT_CANCEL_CMAERA,A_CORE_MASK, 1},
- {TOPIC_EVENT_FIND_WATCH,A_CORE_MASK, 1},//查找手表
- {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1},
- {TOPIC_EVENT_DRINKREMINDER,A_CORE_MASK, 1},
- {TOPIC_EVENT_MESSAGENOTE,A_CORE_MASK, 1},
- {TOPIC_EVENT_MESSAGE_UPDATA,A_CORE_MASK, 1},
- {TOPIC_EVENT_SLEEPNOTE,A_CORE_MASK, 1},
- {TOPIC_EVENT_DEBUGOUTPUT,A_CORE_MASK, 1},
- {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,A_CORE_MASK, 1},
-#ifdef SUPPORT_CAT1_MODEM
- {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_CALLENDED, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_CALLDIAL, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_POWER_ON, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_POWER_OFF, A_CORE_MASK, 1},
- {TOPIC_EVENT_CAT1_CALL_FAIL,A_CORE_MASK, 1},
-#endif
};
/* 所有的topic,其对应的位图 */