From: hcj <1224667075@qq.com> Date: Fri, 29 Mar 2024 08:52:38 +0000 (+0800) Subject: 低电量报警UI X-Git-Tag: release_V1.2.70_20241020_135402~1241^2~18 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=e36154281bf289f55365d80ee9c48657a2eead11;p=mirrors%2FFD230.git 低电量报警UI --- diff --git a/code/sdk/application/battery/service/battery_service.cpp b/code/sdk/application/battery/service/battery_service.cpp index 15e1a43dd..7afeecb4d 100644 --- a/code/sdk/application/battery/service/battery_service.cpp +++ b/code/sdk/application/battery/service/battery_service.cpp @@ -304,6 +304,26 @@ errcode_t charger_plug_event_notify(uint8_t plugged) #endif return 0; } + +errcode_t Play_shutdown_animation_notify(uint8_t plugged) +{ + ChargerEventPublish(TOPIC_EVENT_LOWPOWER_ALARM,3); + // return 0; + + return 0; +} + + +errcode_t low_power_play_toUI(uint8_t plugged) +{ + + /**通过UI事件发送Notify*/ + GraphicService::GetInstance()->PostGraphicEvent(std::bind(Play_shutdown_animation_notify, plugged)); + + return ERRCODE_SUCC; +} + + errcode_t charger_plug_event_ui_sendmsg_toUI(uint8_t plugged) { diff --git a/code/sdk/application/battery/service/battery_service.h b/code/sdk/application/battery/service/battery_service.h index 9d50cabc8..4d1f7d7cc 100644 --- a/code/sdk/application/battery/service/battery_service.h +++ b/code/sdk/application/battery/service/battery_service.h @@ -26,7 +26,7 @@ errcode_t uapi_battery_init(void); void uapi_battery_deinit(void); void battery_service_resume(void); void battery_service_suspend(void); - +errcode_t low_power_play_toUI(uint8_t); void enable_02c(void); void disable_02c(void); void enable_charge(void); diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 702122931..4ee9f4acf 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -535,7 +535,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testmakephone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testcat1.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testhrsenson.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testgsenson.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testgsenson.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testold.cpp #${CMAKE_CURRENT_SOURCE_DIR} /service/acc_service.c ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testold.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testold.h new file mode 100644 index 000000000..d234ca4ef --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testold.h @@ -0,0 +1,54 @@ +#ifndef TEST_OLD_VIEW_H +#define TEST_OLD_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" +//#include "cmsis_os.h" +#include + +namespace OHOS +{ + class testoldView + { + + public: + + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + + testoldView(); + virtual ~testoldView(); + static testoldView *GetInstance(void); + + UIScrollView *testoldInitIView(void); + void ClearAll(void); + void set_data(); + UILabel *x{nullptr}; + void setlightvalue(int ,int ,int); + private: + bool testoldScrollViewcrollViewinit(void); + UILabel *InitLabel(LabelConfig &labelConfig); + UIScrollView *testoldScrollView{nullptr}; + bool initViewStatus{false}; + UILabel *title{nullptr}; + // UILabel *x{nullptr}; + UILabel *y{nullptr}; + UILabel *z{nullptr}; + + UILabelButtonExt* labelButton_next = nullptr; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp index 35594208d..1d437bd2d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -51,6 +51,7 @@ namespace OHOS {MAKEPHONE,"makephonebutton", "hrsensonbutton_next",true}, {HRSENSON,"hrsensonbutton", "gsensonbutton_next",true}, {GSENSON,"gsensonbutton","xxxx" ,true}, + {OLDTEST,"oldtestbutton","xxxxxxxxx",true}, }; // {FACTORYRESETVIEW,"FactoryResetButton",true}, // {SYSTEMLUPGRADE,"systemupgread",true}, @@ -174,6 +175,13 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick"); + if(strcmp(view.GetViewId(),"xxxx") == 0) + { + //testSPEAKView::GetInstance()->Changspeak(true); + testView::GetInstance()->ChangeView(GSENSON,TESTVIEW); + return true; + } + for(int i=0;iSetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); SystemLabel->SetRollSpeed(6); SystemLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + return true; } @@ -469,6 +472,23 @@ namespace OHOS return true; } + bool testView::ChangeoldTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + test_old_view = new testoldView(); + if (test_old_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_old_view->testoldInitIView(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); + } + return true; + } + UIScrollView *testView::GetSystemScrollView(int ViewId) { if (SystemScrollView[ViewId] == nullptr) @@ -579,6 +599,12 @@ namespace OHOS View::OnStart(); //InitIView(); initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin"); + 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(); + } + display_api->set_screen_set_keepon_timeout(-1); } void testView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp index d9a79b85b..73eb1c0ca 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp @@ -94,10 +94,10 @@ namespace OHOS gsenson_t t; get_gsonsen_xyz(&t); char buf[124]={0}; - float x_t=t.x/1024.0; - float y_t=t.y/1024.0; - float z_t=t.z/1024.0; - sprintf(buf,"X:%3f\nY:%3f\nZ:%3f",x_t,y_t,z_t); + uint16 x_t=t.x; + uint16 y_t=t.y; + uint16 z_t=t.z; + sprintf(buf,"X:%d\nY:%d\nZ:%d",x_t,y_t,z_t); x->SetText(buf); RootView::GetInstance()->Invalidate(); @@ -208,7 +208,7 @@ namespace OHOS testGsonsonScrollView->Add(x); /* -------------------------------------------------------------------------- */ - labelButton_next= testAboutView::GetInstance()->init_button_next(167,378,"luminanceButton_next"); + labelButton_next= testAboutView::GetInstance()->init_button_next(167,378,"xxxx"); testGsonsonScrollView->Add(labelButton_next); diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp index f82777e87..f67f42874 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testhrsenson.cpp @@ -8,6 +8,7 @@ #include "cat1_ctl.h" #include "cat1_server_hal.h" #include "ppg_service.h" + namespace OHOS { @@ -261,6 +262,8 @@ namespace OHOS + labelButton_next= testAboutView::GetInstance()->init_button_next(167,378,"gsensonbutton_next"); + testhrsensonScrollView->Add(labelButton_next); testhrsensonScrollView->SetTouchable(true); diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testold.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testold.cpp new file mode 100644 index 000000000..256fba9b9 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testold.cpp @@ -0,0 +1,268 @@ +#include "wearable_log.h" +#include "custom_utils.h" +#include "producttest/include/testPresenter.h" +#include "producttest/include/testold.h" +#include "mag_service.h" +#include "cmsis_os2.h" +#include "cywee_hal.h" +#include "tcxo.h" +#include "ppg_service.h" +#include "CompassModel.h" +#include "linux/delay.h" +#include "power_display_service.h" +//#include "acc_service.h" +namespace OHOS +{ + static void AGING_task(void *arg) + { + while (1) + { + msleep(1000); + // uapi_tcxo_delay_ms(3000); + for(int i=0;i<1;i++) + { + int8_t md = PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST; + send_ppg_cmd_msg(md); + msleep(3000); + + } + for(int i=0;i<3;i++) + { + uint16_t angle_value= (int16_t)mag_service_get_fAzimuth(); + char buf[16]={0}; + sprintf(buf,"angle:%d",angle_value); + testoldView::GetInstance()->x->SetText(buf); + RootView::GetInstance()->Invalidate(); + msleep(1000); + } + for(int i=0;i<3;i++) + { + gsenson_t t; + get_gsonsen_xyz(&t); + char buf[64]={0}; + uint16 x_t=t.x; + uint16 y_t=t.y; + uint16 z_t=t.z; + sprintf(buf,"gsensor:\nX:%d\nY:%d\nZ:%d",x_t,y_t,z_t); + testoldView::GetInstance()->x->SetText(buf); + RootView::GetInstance()->Invalidate(); + + msleep(1000); + } + // uapi_tcxo_delay_ms(3000); + } + + } + + errcode_t old_test_init(void) + { + + PRINT("uapi_ppg_service_init !\r\n"); + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="old_test_service"; + taskcfg.attr.priority = TASK_PRIORITY_APP; + taskcfg.attr.stack_size = 1024*8; + taskcfg.func = AGING_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + PRINT("create ppg_service failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; + } + + static testoldView *g_pSystemAboutTheWatchView{nullptr}; + + void testoldView:: setlightvalue(int g,int r,int ir) + { + + if(x!=nullptr) + { + char buf[124]={0}; + sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",g,r,ir); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); + x->SetText(buf); + RootView::GetInstance()->Invalidate(); + int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; + send_ppg_cmd_msg(md); + } + + } + + testoldView::testoldView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + testoldView::~testoldView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView"); + ClearAll(); + g_pSystemAboutTheWatchView = nullptr; + } + + testoldView *testoldView::GetInstance() + { + + return g_pSystemAboutTheWatchView; + } + static osTimerId_t Gsenson_TEST_timer=NULL; + void testoldView::ClearAll() + { + if(testoldScrollView) + { + testoldScrollView->RemoveAll(); + + if (Gsenson_TEST_timer != NULL) { + osTimerDelete(Gsenson_TEST_timer); + Gsenson_TEST_timer = NULL; + return ; + } + + if(title!=NULL) + { + delete title; + title=nullptr; + } + if(x!=NULL) + { + delete x; + x=nullptr; + } + if(labelButton_next) + { + delete labelButton_next; + labelButton_next=nullptr; + } + delete testoldScrollView; + testoldScrollView=nullptr; + } + } + + + UILabel *testoldView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + + + + bool testoldView::testoldScrollViewcrollViewinit(void) + { + + + CompassModel::GetInstance()->OpenCompassSensor(); + + testoldScrollView = new UIScrollView(); + if (testoldScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testoldScrollView new fail!"); + return false; + } + testoldScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + testoldScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + testoldScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + + + testoldScrollView->SetScrollBlankSize(0); + testoldScrollView->SetReboundSize(0); + testoldScrollView->SetDirection(1); + //UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + // if (draglistener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + // return false; + // } + // testoldScrollView->SetOnDragListener(draglistener); + + LabelConfig Config = { + .left = 203, + .top = 52, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "old_test", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + title = InitLabel(Config); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return false; + } + testoldScrollView->Add(title); + /* -------------------------------------------------------------------------- */ + // uint16_t angle_value= (int16_t)mag_service_get_fAzimuth(); + gsenson_t t; + //get_gsonsen_xyz(&t); + char buf[124]={0}; + //sprintf(buf,"X:%f\nY:%f\nZ:%f",t.x,t.y,t.z); + Config = { + .left = 173, + .top = 160, + .width = 120, + .height = 35, + .fontSize = 40, + .lineHeigh = 35, + .text = buf, + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + + x = InitLabel(Config); + if (x == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::WatchNameTitle new fail!"); + return false; + } + testoldScrollView->Add(x); + + /* -------------------------------------------------------------------------- */ + + labelButton_next= testAboutView::GetInstance()->init_button_next(167,378,"xxxx"); + testoldScrollView->Add(labelButton_next); + + + testoldScrollView->SetTouchable(true); + testoldScrollView->SetDraggable(false); + + 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(); + } + display_api->set_screen_set_keepon_timeout(-1); + + + + old_test_init(); + return true; + } + + UIScrollView *testoldView::testoldInitIView() + { + if (!testoldScrollViewcrollViewinit()) + { + return nullptr; + } + return testoldScrollView; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index 2588b8dbe..99f73a0b0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -16,6 +16,7 @@ #include "lwip/apps/http_client.h" #include "tcxo.h" #include "cat1_server.h" + #include "linux/delay.h" namespace OHOS { @@ -36,7 +37,8 @@ namespace OHOS static void upgrade_task(void *arg) { - uapi_tcxo_delay_ms(3000); + msleep(3000); + //uapi_tcxo_delay_ms(3000); char buf[1024]={0}; FILE * fp = fopen(Path,"rb"); if(fp==NULL) @@ -96,7 +98,7 @@ namespace OHOS static void upgrade_task_fwpkg(void *arg) { - uapi_tcxo_delay_ms(3000); + msleep(3000); FILE * fp = fopen(Path_ota_package,"rb"); if(fp!=NULL) { diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index 1209027e6..9e3e6904d 100755 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -146,6 +146,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_customer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_cmd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/charge_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/vendor_app/baidu/baidu_app.cpp @@ -157,6 +158,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_customer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_cmd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/alarm_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/charge_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/makephone_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/notification_manager_customer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/pairing_notification.cpp diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h index 7cbcade6c..809a6f84e 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h @@ -1,9 +1,76 @@ #ifndef CHARGE_NOTIFICATION_H #define CHARGE_NOTIFICATION_H +#include "components/ui_image_animator.h" namespace OHOS { - UIViewGroup *ChargingStatuShow(void); - UIView *view_ = nullptr; + // UIViewGroup *ChargingStatuShow(void); + // UIView *view_ = nullptr; + + UIViewGroup* lowPowerShow(void); + void set_lowpower_falg(bool falg); + void FreelowPower(void); + void low_power_paly(void); + + class lowppowrAnimatorStopListener :public OHOS::UIImageAnimatorView::AnimatorStopListener + { + public: + lowppowrAnimatorStopListener() + { + } + virtual ~lowppowrAnimatorStopListener(){ + + } + static lowppowrAnimatorStopListener *GetInstance(void) + { + static lowppowrAnimatorStopListener lowppowrAnimatorStopListener_T; + return &lowppowrAnimatorStopListener_T; + } + + virtual void OnAnimatorStop(UIView &view) override; + + + + }; + + + + class lowppowrViewEventListener : public OHOS::UIView::OnClickListener, + public OHOS::UIView::OnLongPressListener, + public OHOS::UIView::OnTouchListener, + public OHOS::UIView::OnDragListener + { +public: + lowppowrViewEventListener(); + virtual ~lowppowrViewEventListener(); + static lowppowrViewEventListener *GetInstance(void); + + bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; + bool OnDrag(UIView& view, const DragEvent& event) override + { + return true; + } + bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } + virtual bool OnPress(OHOS::UIView& view, const OHOS::PressEvent& event) override + { + return true; + } + virtual bool OnLongPress(OHOS::UIView& view, const OHOS::LongPressEvent& event) override + { + return true; + } + virtual bool OnRelease(OHOS::UIView& view, const OHOS::ReleaseEvent& event) override + { + return true; + } + + virtual bool OnDragStart(OHOS::UIView& view, const OHOS::DragEvent& event) override + { + return true; + } +}; }; #endif /* CHARGE_NOTIFICATION_H */ \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h index 3dbd415ce..70ef95a00 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h @@ -23,6 +23,7 @@ #include "components/ui_view_group.h" #include "alarm_notification.h" #include "makephone_notification.h" +#include "charge_notification.h" #include "pairing_notification.h" #include "findwatch_notification.h" diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index e81516821..5d569f2f5 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -36,6 +36,7 @@ #include "cat1_server.h" #include "testchanging.h" #include "testcat1.h" +#include "testold.h" #include "testhrsenson.h" #include "ConfigModel.h" #include "power_display_service.h" @@ -189,7 +190,12 @@ static OHOS::UIViewGroup* showDeviceUnbindingRequestNotify(void) return OHOS::CreateDeviceUnbindingRequestGroupView(); } -/*显示查找手表通知*/ +/*显示低电量通知*/ +static OHOS::UIViewGroup* showlowpowerNotify(void) +{ + return OHOS::lowPowerShow(); +} + static OHOS::UIViewGroup* showFindWatchNotify(void) { return OHOS::CreateFindWatchView(); @@ -250,9 +256,31 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req) void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) { - unused(req); + //unused(req); unused(topic); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: LowPower Alarm !"); + //if(req->data); + uint8 *x= (uint8 *)(req->data); + if(*x==3) + { + low_power_paly(); + } + else if(*x==0) + { + set_lowpower_falg(false); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + } + else + { + set_lowpower_falg(true); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); + + } + + + //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机) // DialModelCharge::GetInstance()->UpdateChargeStuaut(0); // SaveEleModel::GetInstance()->SetChargeStuaut(0); @@ -364,6 +392,12 @@ void MsgCenterNotifyleaklighthProc(const Topic topic, Request* req) { t->setlightvalue(green,red,ir); } + + testoldView * t_1= testoldView::GetInstance(); + if(t_1!=NULL) + { + t_1->setlightvalue(green,red,ir); + } } //穿戴状态 diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp index 661f390d3..7120ce16f 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp @@ -4,32 +4,326 @@ #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" 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/"; //关机图片路径 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 36; // 图片帧数 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 + ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + 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 char **ShutDownPathsArray{nullptr}; // 关机图片路径数组 - // 展示充电图标 - UIViewGroup *ChargingStatuShow() + #define LOW_POWER_BUTTON "LOW_POWER_BUTTON" + // UIViewGroup *ChargingStatuShow() + // { + // // Add ImageView to App + // if (imageCharge == nullptr) + // { + // imageCharge = new UIImageView(); + // } + // imageCharge->SetPosition(186, 55); // widget's left position and top position + // imageCharge->Resize(100, 100); // widget's width and height + // imageCharge->SetViewId("image1"); // Set style + + // // Set additional property + // char *image1imagesPath = "/user/res/Battery/Charge_Icon.bin"; + // imageCharge->SetSrc(image1imagesPath); + + // // Add to rootView + // RootView::GetInstance()->Add(imageCharge); + + // if (view_->GetHorCurrentPage() == WATCH_FACE) + // { + // imageCharge->SetVisible(true); + // } + // } + static const char ** CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) { - // Add ImageView to App - if (imageCharge == nullptr) + const char **imagePaths = new const char *[numImages]; + char buffer[256]; + for (int i = 0; i < numImages; i++) + { + snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); + imagePaths[i] = strdup(buffer); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]); + } + return imagePaths; + } + + UIViewGroup * ShowUpShutDownAnimatorView() + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return nullptr; + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView"); + ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, "bin", 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 NULL; + } + for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + ShutDownImageInfo[i].imagePath = (ShutDownPathsArray[i]); + ShutDownImageInfo[i].imageType = IMG_SRC_FILE_PATH; + 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, 100); + ShutDownImageAnimatorView->SetRepeat(false); + ShutDownImageAnimatorView->SetRepeatTimes(1); + + } + ShutDownImageAnimatorView->SetVisible(true); + //ShutDownImageAnimatorView->Start(); + group->SetVisible(false); + group->Add(ShutDownImageAnimatorView); + return group; + } + + static bool battery_falg=false; + void set_lowpower_falg(bool 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) { - imageCharge = new UIImageView(); + delete alarm_labelbutton; + alarm_labelbutton = nullptr; } - imageCharge->SetPosition(186, 55); // widget's left position and top position - imageCharge->Resize(100, 100); // widget's width and height - imageCharge->SetViewId("image1"); // Set style + if(group) + { + group->RemoveAll(); + if(ShutDownImageAnimatorView) + { + delete ShutDownImageAnimatorView; + ShutDownImageAnimatorView = nullptr; + } + delete group; + group = nullptr; + + } + + RootView::GetInstance()->Remove(UIViewGroup_lowpower); + delete UIViewGroup_lowpower; + UIViewGroup_lowpower = nullptr; + } + } + + void low_power_TimerCallBack(int data) + { + //uapi_poweroff_device(); // 关机 + low_power_play_toUI(0); + } + void low_power_paly(void) + { + //uapi_poweroff_device(); // 关机 + group->SetVisible(true); + UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast(lowppowrAnimatorStopListener::GetInstance()); + ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); + if (stoplistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); + return ; + } + ShutDownImageAnimatorView->Start(); + + } + + 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(183, 62); // 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 - char *image1imagesPath = "/user/res/Battery/Charge_Icon.bin"; - imageCharge->SetSrc(image1imagesPath); + const char *imageimagesPath = "/user/res/FastTrainingAttentionVector.bin"; + alarm_img->SetSrc(imageimagesPath); // Add to rootView - RootView::GetInstance()->Add(imageCharge); + 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, 33); - if (view_->GetHorCurrentPage() == WATCH_FACE) + // Set additional property + if(battery_falg==false) { - imageCharge->SetVisible(true); + alarm_UILabel->SetText("请及时连接充电器"); + alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + alarm_UILabel->SetRollSpeed(0); + alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33); } + // Set additional property + if(battery_falg==true) + { + alarm_UILabel->SetPosition(84, 215); + alarm_UILabel->SetText("电量过低将自动关机"); + alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + alarm_UILabel->SetRollSpeed(0); + alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33); + osStatus_t retTimer; + low_power_timer = osTimerNew((osTimerFunc_t)low_power_TimerCallBack, osTimerOnce, NULL, NULL); + retTimer = osTimerStart(low_power_timer, 1000*5); + 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; + } + } + + // 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->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 44); + 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); + alarm_labelbutton->SetTouchable(true); + ShowUpShutDownAnimatorView(); + UIViewGroup_lowpower->Add(group); + + 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_paly(); + + } + else + { + NotificationManager::GetInstance()->StopNotify(); + } + + } + return true; + UNUSED(event); + } + + void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view) + { + //UNUSED(view); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop"); + + uapi_poweroff_device(); // 关机 + + //NotificationManager::GetInstance()->StopNotify(); + // + // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0) + // { + + // } + + } + + + } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp index 642847df4..21ea0dd73 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp @@ -822,12 +822,8 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) // The watch rejects the call if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) { - //#ifdef SUPPORT_CAT1_SERVICE - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MakephoneNotify 11111111 "); cat1_call_hungup(); addcalllog(); - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); NotificationManager::GetInstance()->StopNotify(); //#endif @@ -845,18 +841,13 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) } else if (strcmp(view.GetViewId(), "callingHandUp") == 0) { - - // The watch rejects the call + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) { - //#ifdef SUPPORT_CAT1_SERVICE - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MakephoneNotify 11111111 "); - cat1_call_hungup(); - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); - NotificationManager::GetInstance()->StopNotify(); - //#endif + cat1_call_hungup(); + NotificationManager::GetInstance()->StopNotify(); + } } return true; diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp index 4fe6130e4..7c20796ae 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp @@ -34,6 +34,7 @@ void NotificationManager::FreeNotifyViews() FreeCallingView(); FreeCalldialView(); FreeFindWatchView(); + FreelowPower(); #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION //Do Free notification view #endif