From 97dc96399130916689249b8194a95ba6720d1910 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 21 Sep 2024 10:26:29 +0800 Subject: [PATCH] =?utf8?q?=E7=94=B5=E8=AF=9Dbug=E7=BB=BC=E5=90=88=E4=BF=AE?= =?utf8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/callerlog/src/CallerLogModel.cpp | 51 ++----- .../makephone/include/MainCallingPresenter.h | 2 + .../makephone/src/MainCallingPresenter.cpp | 5 + .../makephone/src/MainCallingView.cpp | 2 + .../phoneservice/src/PhoneService.cpp | 10 +- .../msg_center/src/msg_center_customer.cpp | 31 ++--- .../src/notify/makephone_notification.cpp | 131 +++++++----------- 7 files changed, 79 insertions(+), 153 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index a48fbb3de..13cfe6eac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -17,6 +17,10 @@ #include "notification_manager.h" #include "osal_timer.h" #include "cmsis_os2.h" +#include "custom_utils.h" +#include "ConfigModel.h" +#include "vibrator_service.h" +#include "custom_runtime.h" #ifdef __cplusplus extern "C" { @@ -301,17 +305,6 @@ static void IncomingHandle(void) } -static osTimerId_t Waiting_timer=NULL; - -static void RejectIncomingCall_Timer_CallBack(int data) -{ - if(RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); - return ; - } - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; -} // 来电等待界面 static void WaitingOpreate() { @@ -325,30 +318,12 @@ static void WaitingOpreate() if(!CallerLogModel::GetInstance()->get_RejectIncomingCall_falg()) { - uint32_t tick; - osStatus_t retTimer; - if(Waiting_timer!=NULL) - { - if(RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); - return ; - } - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; - return; - } - - Waiting_timer = osTimerNew((osTimerFunc_t)RejectIncomingCall_Timer_CallBack, osTimerOnce, NULL, NULL); - tick =3000;// osMs2Tick(1000); - retTimer = osTimerStart(Waiting_timer, tick); - if (retTimer != osOK && Waiting_timer != NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; - return ; + if(RejectIncomingCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); + return ; } CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1); - + CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0); } else { @@ -358,18 +333,8 @@ static void WaitingOpreate() } return; } - } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[WaitingOpreate] WaitingOpreate"); - CallerLogModel::GetInstance()->SetCallStatus(false); - CallerLogModel::GetInstance()->SetWaitingStatus(true); - // If the call is handling in the notification, the slice is not switched - if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - } else { - g_isWatchCallView = true; - } } static void WatchActiveHandle(const PhoneCallInfo *phoneCall) diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/include/MainCallingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/makephone/include/MainCallingPresenter.h index b2093b61d..ecae95120 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/include/MainCallingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/include/MainCallingPresenter.h @@ -17,6 +17,7 @@ namespace OHOS { class MainCallingView; class MainCallingPresenter : public Presenter, + public RootView::OnKeyActListener, public UIView::OnClickListener , public UIView::OnDragListener{ public: @@ -33,6 +34,7 @@ public: bool CallingViewDisplay(); bool InitPointerValue(); bool OnClick(UIView& view, const ClickEvent& event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 bool OnDragEnd(UIView &view, const DragEvent &event) override; VolumeSettingView *GetvolumeSetting(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp index 089543701..574e098e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp @@ -413,6 +413,11 @@ bool MainCallingPresenter::OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& return true; } +bool MainCallingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 +{ + return true; +} + VolumeSettingView *MainCallingPresenter::GetvolumeSetting() { return volumeSetting; diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp index d759215a7..0ac5cdf46 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp @@ -135,6 +135,8 @@ void MainCallingView::OnStart() if (InitPointerValue() == false) { return; } + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainCallingPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); RootView::GetInstance()->Add(displayGroup); RootView::GetInstance()->Add(callingGroup); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index 2b024baf7..197d537e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -674,11 +674,11 @@ static void ScoDisconnectPro(void) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[ScoDisconnectPro] start CallState:%d", g_currCallState); - // if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 - // && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) - // { - // return; - // } + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + return; + } // if(OHOS::CallerLogModel::GetInstance()->GetCallDial() == OHOS::CallerLogModel::HFP_PHONE_DIAL) // { 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 f0dfda271..d457d074f 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 @@ -567,7 +567,7 @@ void MsgCenterNotifyHfpPhoneProc(const Topic topic, Request* req) } if ((topic == TOPIC_EVENT_HFP_FINISHED && GetCurrCallNum() == 0) || topic == TOPIC_EVENT_HFP_PHONE_ACTIVE || topic == TOPIC_EVENT_HFP_WATCH_TO_PHONE) { - NotificationManager::GetInstance()->StopNotify(); + //NotificationManager::GetInstance()->StopNotify(); if( CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSource::CallSourcePhone) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetWatchCallStatus false"); @@ -816,27 +816,12 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) // Prevent this from happening: // When the incoming call view is displayed, the calling number is not set in CallerLogModel. //uapi_hfp_disconnect(); - - if(uapi_dev_runtime_get_train_status()) + if((NotificationManager::GetInstance()->GetWatchCallStatus() && + (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) || uapi_dev_runtime_get_train_status()) { - CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); - cat1_call_hungup(); - free(call_data); - - return; - } - - if(NotificationManager::GetInstance()->GetWatchCallStatus() && - (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) - { - std::string hfp_number= CallerLogModel::GetInstance()->GetPhoneNumber(); - - CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(hfp_number.c_str(),hfp_number.length()); - - CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); + CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len); cat1_phone_state_change_cb(OPERATE_WAITING); - free(call_data); return; @@ -881,8 +866,8 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) return; } SetMicMute(false); - // AlarmClockModel::GetInstance()->AlarmPlayerStop() - AlarmViewEventListener::GetInstance()->CancelAlarmRing(); + AlarmClockModel::GetInstance()->AlarmPlayerStop(); + //AlarmViewEventListener::GetInstance()->CancelAlarmRing(); NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE); CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); @@ -930,8 +915,8 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) unused(topic); unused(req); // just stop the notify - // AlarmClockModel::GetInstance()->AlarmPlayerStop(); - AlarmViewEventListener::GetInstance()->CancelAlarmRing(); + AlarmClockModel::GetInstance()->AlarmPlayerStop(); + // AlarmViewEventListener::GetInstance()->CancelAlarmRing(); if(!NotificationManager::GetInstance()->GetWatchCallStatus()) { return; 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 aacbabaa4..13da94aad 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 @@ -287,10 +287,23 @@ void FreeSOSView(void) SOSView = nullptr; } } - +uint8_t CALL_INCOMING_HINT_timer_FALG=0; void hintdialtimerCallBack(int data) { - NotificationManager::GetInstance()->StopNotify(); + CALL_INCOMING_HINT_timer_FALG--; + if(CALL_INCOMING_HINT_timer_FALG) + { + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + ui_api_vibrate_once_func(); + } + } + if(CALL_INCOMING_HINT_timer_FALG==0) + { + NotificationManager::GetInstance()->StopNotify(); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hintdialtimerCallBack ??????!"); + } @@ -364,9 +377,9 @@ UIViewGroup* CALL_INCOMING_HINT(void) uint32_t tick; osStatus_t retTimer; - + CALL_INCOMING_HINT_timer_FALG=3; CALL_INCOMING_HINT_timer = osTimerNew((osTimerFunc_t)hintdialtimerCallBack, osTimerPeriodic, NULL, NULL); - tick =2000;// osMs2Tick(1000); + tick =osMs2Tick(1000);// osMs2Tick(1000); retTimer = osTimerStart(CALL_INCOMING_HINT_timer, tick); if (retTimer != osOK && CALL_INCOMING_HINT_timer != NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); @@ -446,12 +459,23 @@ UIViewGroup* SOS_cant_dial(void) } CallLogInfo info; -void calllog_info_init() +void calllog_info_init(uint8_t type) { strcpy(info.name,"xxx"); info.nameLen=3; - int len=strlen(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); - memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),len+1); + int len; + if(type==0) + { + len=strlen(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); + memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),len+1); + } + else + { + len=strlen(CallerLogModel::GetInstance()->GettempPhoneNumber().c_str()); + memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GettempPhoneNumber().c_str(),len+1); + } + + uint32_t tmptime=0; uapi_get_timestampe_ss(&tmptime); info.creationTime = tmptime; @@ -503,74 +527,21 @@ static void IncomingHandle(void) } -static osTimerId_t Waiting_timer=NULL; - -static void RejectIncomingCall_Timer_CallBack(int data) -{ - if(RejectIncomingCall() != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); - return ; - } - cat1_call_hungup(); - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); - CallerLogModel::GetInstance()->SetCallStatus(true); - CallerLogModel::GetInstance()->SetWaitingStatus(false); - - std::string hfp_number= CallerLogModel::GetInstance()->GettempPhoneNumber(); - CallerLogModel::GetInstance()->SetoperateNumber(hfp_number.c_str(),hfp_number.length()); - - NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); -} - static void WaitingOpreate() { - - if(NotificationManager::GetInstance()->GetWatchCallStatus()) + + if(!CallerLogModel::GetInstance()->get_RejectIncomingCall_falg()) { - if(!CallerLogModel::GetInstance()->get_RejectIncomingCall_falg()) - { - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - uint32_t tick; - osStatus_t retTimer; - if(Waiting_timer!=NULL) - { - cat1_call_hungup(); - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; - return; - } - Waiting_timer = osTimerNew((osTimerFunc_t)RejectIncomingCall_Timer_CallBack, osTimerOnce, NULL, NULL); - tick =3000;// osMs2Tick(1000); - retTimer = osTimerStart(Waiting_timer, tick); - if (retTimer != osOK && Waiting_timer != NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); - osTimerDelete(Waiting_timer); - Waiting_timer = NULL; - return ; - } - CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1); - - } - else - { - cat1_call_hungup(); - std::string hfp_number= CallerLogModel::GetInstance()->GettempPhoneNumber(); - CallerLogModel::GetInstance()->SetoperateNumber(hfp_number.c_str(),hfp_number.length()); - - return; - } - + cat1_call_hungup(); + CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0); + CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1); + return; + } + else + { + cat1_call_hungup(); + return; } - - CallerLogModel::GetInstance()->SetCallStatus(false); - CallerLogModel::GetInstance()->SetWaitingStatus(true); - - - NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); } static void WatchActiveHandle() @@ -598,12 +569,10 @@ static void WatchFinishHandle(void) { if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone) { - + addcalllog(); } else if(uapi_dev_runtime_get_train_status()) { - calllog_info_init(); - call_stat=2; addcalllog(); } else @@ -630,7 +599,7 @@ void cat1_phone_state_change_cb(uint8_t state) DialingHandle(); call_stat=0; - calllog_info_init(); + calllog_info_init(0); break; case OPERATE_ALERTING: // 显示对方响铃 @@ -640,7 +609,7 @@ void cat1_phone_state_change_cb(uint8_t state) // 显示电话呼入 PhoneServiceScreenCtr(true); IncomingHandle(); - calllog_info_init(); + calllog_info_init(0); if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); @@ -649,11 +618,9 @@ void cat1_phone_state_change_cb(uint8_t state) break; case OPERATE_WAITING: // 震动一下,提示有新电话呼入 还未对齐 - calllog_info_init(); - call_stat=2; - addcalllog(); WaitingOpreate(); - + call_stat=2; + calllog_info_init(1); return; case OPERATE_WATCH_ACTIVE: // 手表接听,显示界面 @@ -1240,7 +1207,7 @@ UIViewGroup* CreatePhoneCallView(void) g_phoneView->SetDraggable(true); g_phoneView->SetTouchable(true); call_stat=2; - calllog_info_init(); + calllog_info_init(0); NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreePhoneCallView); return g_phoneView; } @@ -1385,7 +1352,7 @@ UIViewGroup* CreateCalldialView(void) StartCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY, (int32_t)NOTIFY_ONE_SECOND); call_stat=0; - calllog_info_init(); + calllog_info_init(0); NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeCalldialView); -- 2.17.1