From: hcj <1224667075@qq.com> Date: Mon, 26 Aug 2024 01:53:33 +0000 (+0800) Subject: 增加无法呼叫sos弹窗 X-Git-Tag: release_V1.2.70_20241020_135402~593 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=48be761d740e2da2dfc5e20c7a7484afe852315a;p=mirrors%2FFD230.git 增加无法呼叫sos弹窗 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp index caac42c1e..d02fa0629 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -52,6 +52,7 @@ namespace OHOS button->SetAlign(TEXT_ALIGNMENT_LEFT); button->SetLabelPosition(50,-23); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + button->SetStyleForState(STYLE_BACKGROUND_COLOR,0xff191919, UIButton::PRESSED); return button; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index 1f313968e..6dddc0bfd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -56,7 +56,7 @@ namespace OHOS button->SetImageSrc(defaultImgSrc, triggeredImgSrc); button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); button->SetStyleForState(STYLE_BORDER_WIDTH, 0, UIButton::PRESSED); - //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); // Add the callback for events UIView::OnClickListener *buttonClick = static_cast(PhoneCallPresenter::GetInstance()); button->SetOnClickListener(buttonClick); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index f2868aa40..3d338ee3a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -51,7 +51,7 @@ namespace OHOS button->SetAlign(TEXT_ALIGNMENT_LEFT); button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); - //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); button->SetImagePosition(30, 25); return button; diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h index 29010aaeb..5616505be 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/makephone_notification.h @@ -25,12 +25,14 @@ UIViewGroup* CreateCallingView(void); UIViewGroup* CreateMultiplePhoneView(void); UIViewGroup* CreateWaitingHintsView(void); UIViewGroup* CreateCalldialView(void); +UIViewGroup* SOS_cant_dial(void); void HonrsViewChange(void); VolumeSettingView *GetvolumeSetting(void); void FreeCallingView(void); void FreePhoneCallView(void); void FreeCalldialView(void); +void FreeSOSView(void); void FreeMultiplePhoneCallView(void); void FreeWaitingHintsView(void); 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 64b84fb9e..6029f6008 100644 --- 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 @@ -282,6 +282,12 @@ static OHOS::UIViewGroup* showtransmitNotify(void) return OHOS::transmittingShow(); } +//无法呼叫sos +static OHOS::UIViewGroup* showSOSNotify(void) +{ + return OHOS::SOS_cant_dial(); +} + /*显示消息提醒*/ static OHOS::UIViewGroup* showMessageNotify(void) { @@ -828,6 +834,22 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) if (ret != EOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!"); } else { + + int ret = PlayersModel::GetInstance()->PlayerStop(); + + 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(10000); + + if(strcmp(call_data,"SOS")==0) + { + free(call_data); + NotificationManager::GetInstance()->ShowNotify(showSOSNotify, (uint16_t)topic, true); + return; + } // Prevent this from happening: // When the incoming call view is displayed, the calling number is not set in CallerLogModel. // const power_display_svr_api_t *display_api = power_display_svr_get_api(); @@ -838,15 +860,7 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) // display_api->set_screen_set_keepon_timeout(10); //AlarmClockModel::GetInstance()->AlarmPlayerStart(); - int ret = PlayersModel::GetInstance()->PlayerStop(); - - 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(10000); - + cat1_call_dial(call_data); 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 31a367bb0..deab92b1b 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 @@ -34,6 +34,9 @@ #include #include "string.h" #include "string/osal_string.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button_ext.h" + // #define NOTIFY_THREE_SECONDS 3000 // #define NOTIFY_ONE_SECOND 1000 // #define NOTIFY_THIRTY_SECONDS 30000 @@ -48,6 +51,46 @@ static char*sos_dail_buf[]={"10085","10086","10084"}; #define DIAL_TIME 30 +#define SOS_NUMBER_PATH "user/userdata/sos_number.bin" + +void SOS_number_save(void) +{ + FILE *fp=fopen(SOS_NUMBER_PATH,"wb+"); + if(fp) + { + for(int i=0;i<3;i++) + { + char W_buf[20]={0}; + memcpy_s(W_buf,20,sos_dail_buf[i],osal_strlen((const char*)sos_dail_buf[i])); + fwrite(W_buf,1,20,fp); + } + fclose(fp); + } +} + +void SOS_number_init(void) +{ + FILE *fp=fopen(SOS_NUMBER_PATH,"rb+"); + if(fp) + { + for(int i=0;i<3;i++) + { + char r_buf[20]={0}; + fread(r_buf,1,20,fp); + sos_dail_buf[i]=(char *)malloc(osal_strlen((const char*)r_buf)); + memcpy_s(sos_dail_buf[i],20,r_buf,osal_strlen((const char*)r_buf)); + } + fclose(fp); + } +} + + + + +uint8_t get_falg_SOS(void) +{ + return sos_dail_falg; +} //结束通话运行 void sos_falg_add(void) { @@ -57,20 +100,20 @@ void sos_falg_add(void) #if SOS_TEST_FLAG if(1) #else - if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0) + if(uapi_cat1_get_power_stat() && uapi_dev_runtime_get_cat1_simstat()) #endif { calldial_event_sendmsg_toUI(sos_dail_buf[(sos_dail_falg)%3]); } #if SOS_HFP_FALG - else if(uapi_hfp_connect_state()==0) + else if(uapi_hfp_connect_state()) { DialCall((unsigned char *)sos_dail_buf[sos_dail_falg],osal_strlen((const char*)sos_dail_buf[sos_dail_falg])); } #endif else { - //show 没连接也没卡UI + calldial_event_sendmsg_toUI("SOS"); } sos_dail_falg++; if(sos_dail_falg>=9) @@ -90,14 +133,14 @@ void start_SOS_phone_dail(void) #if SOS_TEST_FLAG if(1) #else - if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0) + if(uapi_cat1_get_power_stat()|| uapi_dev_runtime_get_cat1_simstat()) #endif { calldial_event_sendmsg_toUI(sos_dail_buf[(0)%3]); sos_dail_falg=1; } #if SOS_HFP_FALG - else if(uapi_hfp_connect_state()==0) + else if(uapi_hfp_connect_state()) { DialCall((unsigned char *)sos_dail_buf,osal_strlen((const char*)sos_dail_buf)); sos_dail_falg=1; @@ -105,7 +148,7 @@ void start_SOS_phone_dail(void) #endif else { - //show 没连接也没卡UI + calldial_event_sendmsg_toUI("SOS"); } @@ -195,6 +238,12 @@ UIButton *button1dial = nullptr; uint8 call_stat=0; PhoneCallInfo *phoneCall = NULL; +UIViewGroup* SOSView = nullptr; +static UIImageView *alarm_img=nullptr; +static UILabelExt *alarm_UILabel=nullptr; +static UILabelExt *button_UILabel=nullptr; +static UILabelButtonExt *alarm_labelbutton=nullptr; + // typedef struct { // char name[NAME_SIZE]; // unsigned char nameLen; @@ -204,6 +253,97 @@ PhoneCallInfo *phoneCall = NULL; // uint64 creationTime; // 通话创建时间(不是接通时间) // uint64 callDurTime; // 通话持续时间 // } CallLogInfo; +void FreeSOSView(void) +{ + if (SOSView != nullptr) { + + SOSView->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; + } + + RootView::GetInstance()->Remove(SOSView); + delete SOSView; + SOSView = nullptr; + } +} + +UIViewGroup* SOS_cant_dial(void) +{ + SOSView = new UIViewGroup(); + if (SOSView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!"); + return nullptr; + } + SOSView->SetPosition(MATH_ZERO, MATH_ZERO); + SOSView->SetWidth(Screen::GetInstance().GetWidth()); + SOSView->SetHeight(Screen::GetInstance().GetHeight()); + + 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 + const char *imageimagesPath = "/user/res/Attention.bin"; + alarm_img->SetSrc(imageimagesPath); + SOSView->Add(alarm_img); + alarm_img->SetVisible(true); + + if (alarm_UILabel == nullptr) { + alarm_UILabel = new UILabelExt(); + } + alarm_UILabel->SetPosition(46, 215); // widget's left position and top position + alarm_UILabel->Resize(370, 40); // widget's width and height + alarm_UILabel->SetViewId("label1");// Set style + alarm_UILabel->SetStyle(STYLE_TEXT_FONT, 33); + + alarm_UILabel->SetText("请检查SIM卡或者蓝牙连接"); + 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, 33); + SOSView->Add(alarm_UILabel); + alarm_UILabel->SetVisible(true); + + // Add LabelButtonExt to App + if (alarm_labelbutton == nullptr) { + alarm_labelbutton = new UILabelButtonExt(); + } + alarm_labelbutton->SetViewId("SOS_FAIL");// Set style + alarm_labelbutton->SetPosition(0, 366, 466, 100); + const char *ImgSrc = "/user/res/466x100button.bin"; + alarm_labelbutton->SetImageSrc(ImgSrc, ImgSrc); + 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(CallViewEventListener::GetInstance()); + alarm_labelbutton->SetOnClickListener(button1Click); + + SOSView->Add(alarm_labelbutton); + alarm_labelbutton->SetVisible(true); + SOSView->SetTouchable(true); + alarm_labelbutton->SetTouchable(true); + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeSOSView); + + return SOSView; + +} CallLogInfo info; void calllog_info_init() @@ -288,9 +428,15 @@ static void WatchFinishHandle(void) if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL || CallerLogModel::GetInstance()->GetNotifyFlag()) { + if(get_falg_SOS()) + { + sos_falg_add(); + } + else StatusReset(); } - sos_falg_add(); + + DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY); } @@ -1604,6 +1750,11 @@ bool CallViewEventListener::OnClick(UIView& view, const ClickEvent& event) { text_updata_buf(view.GetViewId()); } + else if (strcmp(view.GetViewId(), "SOS_FAIL")==0) + { + NotificationManager::GetInstance()->StopNotify(); + } +