From: hcj <1224667075@qq.com> Date: Fri, 6 Sep 2024 06:43:13 +0000 (+0800) Subject: 增加hfp与4G来电判断处理 X-Git-Tag: release_V1.2.70_20241020_135402~539 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=111b970a436147a08e0314f67aed96eb49484d90;p=mirrors%2FFD230.git 增加hfp与4G来电判断处理 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index 9804b3e89..d22c58183 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -801,13 +801,7 @@ int AlarmClockModel::AlarmPlayerInit_BY_fir_name(char *str) // 本地播放文件路径和状态 sliceId = str; // 播放音乐的文件名 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayerInit start!"); - - std::string strSongName = sliceId; - std::string pureName = strSongName.substr(0, strSongName.rfind(".")); // 播放音乐的路径需要引用.号 - const char *songName = pureName.c_str(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayerInit, url:%s ", sliceId); - std::string strSrcMusic(APP_MUSIC_PATH); - std::string tempStr("/"); std::string strName = sliceId; uri =strName; // 创建 AM diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 02e9bb02c..971c7d263 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -1510,8 +1510,15 @@ static void sample_gap_state_changed_callback(const int transport, const int sta printf("gap_state_changed_callback transport: %d status: %d\n", transport, status); } +static void sample_gap_scan_mode_changed_callback(int mode) +{ + printf("gap_scan_mode_changed_callback mode: %d\n", mode); + +} + void BtInitCallBacks(void) { + g_btGapCallBacks .scan_mode_changed_callback=sample_gap_scan_mode_changed_callback; g_btGapCallBacks.state_change_callback=sample_gap_state_changed_callback; g_btGapCallBacks.discovery_result_callback = BtGapDiscoveryResultCallback; g_btGapCallBacks.discovery_state_changed_callback = BtGapDiscoveryStateChangedCallback; diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h index 364ad57cd..a81d20a15 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h @@ -41,7 +41,7 @@ void PhoneScoStatausCallback(hfp_sco_connect_state_t state); void PhoneChangeStatusCallback(const PhoneCallInfo *phoneCall); void PhoneErrorCallback(PhoneServiceErrorType type, int volume); void UsingPhoneScoStatausCallback(hfp_sco_connect_state_t state); -void StatusReset(); +void StatusReset(void); void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall); void UsingPhoneErrorCallback(PhoneServiceErrorType type); void CAT1_ChangeStatusScreendisplay(int lastStatus); @@ -51,10 +51,19 @@ namespace OHOS { class CallerLogModel { public: typedef enum { + callleisure, + CallphoneWait, + CallCat1Wait, CallSourcePhone, CallSourceCat1, } CallSource; - + +typedef enum { + HFP_WATCH_DIAL, + HFP_PHONE_DIAL, + } Calldial; + + void InitPhoneService(); static CallerLogModel *GetInstance(void); @@ -108,6 +117,41 @@ CallSource GetCallSource(void) { callsrc = source; } + + uint8_t GetCallDial(void) + { + return calldial; + } + void SetCallDial(uint8_t dial) + { + calldial = dial; + } + uint8_t get_RejectIncomingCall_falg() + { + return auto_RejectIncomingCall; + } + + void set_RejectIncomingCall_falg(uint8_t data) + { + auto_RejectIncomingCall=data; + } + + + /* 设置cat1临时来电号码显示 */ + void tempSetoperateNumberCAT1(const char *number, char number_len) + { + phoneNumberCAT1.clear(); + phoneNumberCAT1.append(reinterpret_cast(number), number_len); + } + + std::string GettempPhoneNumber(void) + { + return phoneNumberCAT1; + } + + + + private: CallerLogModel(); CallerLogModel(const CallerLogModel &); @@ -118,6 +162,7 @@ private: std::string timers; // 时间显示 std::string callDuration; // 通话时长 std::string phoneNumber; // 电话号码 + std::string phoneNumberCAT1; // 4G电话号码 std ::string call_name; bool mulitplePhoneStatus{false}; // 判断是否多路通话界面 bool waitingStatus{false}; // 判断是否等待提醒界面 @@ -127,6 +172,8 @@ private: bool notifyFlag{false}; // 判断是否来电呼入 由notify生成界面 CallSource callsrc{CallSourcePhone}; //电话来源 + uint8_t calldial{HFP_PHONE_DIAL}; + uint8_t auto_RejectIncomingCall{0}; }; } #ifdef __cplusplus 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 0fae7f624..5ef6ccc50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -14,6 +14,9 @@ #include "MainCallingPresenter.h" #include "PlayersModel.h" #include "graphic_service.h" +#include "notification_manager.h" +#include "osal_timer.h" +#include "cmsis_os2.h" #ifdef __cplusplus extern "C" { @@ -96,15 +99,25 @@ static void DisableCallingTimer() } /* 状态复位 */ -void StatusReset() +void StatusReset(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "状态复位"); + CallerLogModel::GetInstance()->SetCallStatus(false); CallerLogModel::GetInstance()->SetWaitingStatus(false); DisableCallingTimer(); CallerLogModel::GetInstance()->Setphonebname("0",0); + CallerLogModel::GetInstance()->SetCallDial(CallerLogModel::HFP_PHONE_DIAL); + CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(0); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::callleisure); + NotificationManager::GetInstance()->SetWatchCallStatus(false); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); + + PhoneServiceScreenCtr(false); + // If the call is handling in the notification, the slice is not switched if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); + NativeAbility::GetInstance().BackCountSlice(0); } else { g_isWatchCallView = false; } @@ -236,33 +249,44 @@ static int g_callOperate = OPERATE_NO_OPE; static void ExitMakePhoneSlice(void) { + + if( CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1 + && NotificationManager::GetInstance()->GetWatchCallStatus()==true) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4G 通话中不能结束"); + return; + } + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) { WEARABLE_LOGD(HILOG_MODULE_AAFWK, "ExitMakePhoneSlice"); if (GetCurrCallNum() == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + //NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); CallModelPostGraphicEvent(CallModelResumePlayer); } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + //NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } } - CallerLogModel::GetInstance()->SetCallStatus(false); - DisableCallingTimer(); - if (CallerLogModel::GetInstance()->GetNotifyFlag()) { - g_isWatchCallView = false; - } + StatusReset();//状态复位 + // CallerLogModel::GetInstance()->SetCallStatus(false); + // DisableCallingTimer(); + //if (CallerLogModel::GetInstance()->GetNotifyFlag()) { + g_isWatchCallView = false; + //} } static void DialingHandle(void) { CallerLogModel::GetInstance()->SetDialingStatus("正在拨号"); CallerLogModel::GetInstance()->SetMakePhoneStatus(true); + NotificationManager::GetInstance()->SetWatchCallStatus(true); } static void AlertingHandle(void) { CallerLogModel::GetInstance()->SetDialingStatus("正在响铃"); CallerLogModel::GetInstance()->SetMakePhoneStatus(true); + NotificationManager::GetInstance()->SetWatchCallStatus(true); } static void IncomingHandle(void) @@ -270,6 +294,18 @@ static void IncomingHandle(void) CallerLogModel::GetInstance()->SetMakePhoneStatus(false); } + +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() { @@ -277,6 +313,47 @@ static void WaitingOpreate() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[UsingPhoneChangeStatusCallback] is not complete call flow"); return; } + + if(NotificationManager::GetInstance()->GetWatchCallStatus()) + { + 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 ; + } + CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1); + + } + else + { + if(RejectIncomingCall() != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCallingPresenter::[HintsHandupClick] RejectIncomingCall error"); + return ; + } + return; + } + + } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[WaitingOpreate] WaitingOpreate"); CallerLogModel::GetInstance()->SetCallStatus(false); CallerLogModel::GetInstance()->SetWaitingStatus(true); @@ -442,8 +519,13 @@ static void NonWatchFinishHandle(int laststatus) static void WatchFinishHandle(void) { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchFinishHandle"); + if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL || - CallerLogModel::GetInstance()->GetNotifyFlag()) { + CallerLogModel::GetInstance()->GetNotifyFlag()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchFinishHandle"); if (GetCurrCallNum() == 0) { StatusReset(); CallerLogModel::GetInstance()->SetNotifyFlag(false); @@ -454,13 +536,17 @@ static void WatchFinishHandle(void) } } } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "??????????????????????"); + } g_phoneStatus = PHONE_SINGLE_STATUS; } void CAT1_ChangeStatusScreendisplay(int lastStatus) { // If the call is handling in the notification, the slice is not switched - if (lastStatus != OPERATE_PHONE_ACTIVE && (!CallerLogModel::GetInstance()->GetNotifyFlag())) { + if (lastStatus != OPERATE_PHONE_ACTIVE) { NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); } @@ -494,6 +580,7 @@ static void ChangeStatusScreendisplay(int lastStatus) } // If the call is handling in the notification, the slice is not switched if (g_callOperate != OPERATE_PHONE_ACTIVE && (!CallerLogModel::GetInstance()->GetNotifyFlag())) { + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, PRIORITY_ONE); } @@ -523,7 +610,9 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall) break; case OPERATE_INCOMING: // 显示电话呼入 - IncomingHandle(); + { + IncomingHandle(); + } break; case OPERATE_WAITING: // 震动一下,提示有新电话呼入 还未对齐 @@ -584,6 +673,7 @@ static void ScoConnectHandle(void) case HFP_HF_CALL_STATE_ACTIVE: if (g_callOperate == OPERATE_PHONE_ACTIVE) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoConnectHandle] OPERATE_PHONE_ACTIVE"); + TransCallToMobilePhone(); return; } CallerLogModel::GetInstance()->SetCallStatus(true); @@ -828,6 +918,8 @@ void CallerLogModel::SetoperateNumber(const char *number, char number_len) phoneNumber.append(reinterpret_cast(number), number_len); } + + std::string CallerLogModel::GetPhoneNumber(void) { return phoneNumber; diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/include/WaitingHintsView.h b/code/sdk/application/wearable/fd230app/nativeui/makephone/include/WaitingHintsView.h index 76e8d510b..015e45774 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/include/WaitingHintsView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/include/WaitingHintsView.h @@ -14,6 +14,9 @@ #include "components/ui_image_animator.h" #include "components/ui_view_group.h" #include "ohos_types.h" +#include "UiConfig.h" +#include "ChangeSliceListener.h" +#include "components/ui_label_button.h" namespace OHOS { class WaitingHintsView { @@ -23,15 +26,24 @@ public: UIViewGroup *CreateUIViewGroup(); static WaitingHintsView *GetInstance(); + void updataCallingname(); private: bool InitImageViewDisplay(void); bool InitUILabelDisplay(void); + bool InitAddOnclickevent(void); UIViewGroup *group{nullptr}; UIView::OnClickListener* clickLeftListener{nullptr}; + UIImageView *imageDissgree{nullptr}; + UILabel *callerDisplay{nullptr}; - UILabel *newcallHints{nullptr}; + UIImageView *imageAgreeing{nullptr}; + UIImageView *imageperson{nullptr}; + + UILabelExt *currentTimes{nullptr}; + UILabelExt *label_call_source{nullptr}; + UILabelExt *label_call_hint{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp index 22eedc53e..a8d08adaa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp @@ -8,7 +8,21 @@ #include "UiConfig.h" #include "CallerLogModel.h" #include "MainCallingPresenter.h" -#include "phone/include/phoneaddressmodel.h" +#include "ui_resource_string.h" +#include "bletest.h" +#include "custom_utils.h" + +#include "wearable_log.h" +#include "PhoneService.h" +#include "cat1_server.h" +#include "cat1_server_hal.h" +#include "phoneaddressmodel.h" + + + + +#define PHONE_DIR_GIRL_1 "/user/res/Phone/girl.bin" +#define PHONE_DIR_BOY_1 "/user/res/Phone/boy.bin" namespace OHOS { static constexpr uint16 MATH_ZERO = 0; // 挂断按钮位置 @@ -30,6 +44,11 @@ static constexpr uint16 LABEL_CALLERD_POSITION_X = 0; static constexpr uint16 LABEL_CALLERD_POSITION_Y = 180; static WaitingHintsView *g_pMainView = nullptr; + +// 字体大小 +static constexpr uint16 LABEL_TIME_FONT_SIZE = 25; + + WaitingHintsView::WaitingHintsView() { g_pMainView = this; @@ -37,24 +56,47 @@ WaitingHintsView::WaitingHintsView() WaitingHintsView::~WaitingHintsView() { - g_pMainView = nullptr; - group->RemoveAll(); + + delete imageAgreeing; + imageAgreeing = nullptr; + delete imageDissgree; imageDissgree = nullptr; + + delete imageperson; + imageperson = nullptr; + delete callerDisplay; callerDisplay = nullptr; - delete newcallHints; - newcallHints = nullptr; + delete label_call_source; + label_call_source = nullptr; + + delete currentTimes; + currentTimes = nullptr; + delete label_call_hint; + label_call_hint = nullptr; delete group; group = nullptr; + g_pMainView = nullptr; + +} + +void WaitingHintsView::updataCallingname(void) +{ + if(CallerLogModel::GetInstance()->Getphonename().length()>5) + { + callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } } + + UIViewGroup *WaitingHintsView::CreateUIViewGroup() { group = new UIViewGroup(); @@ -74,6 +116,17 @@ UIViewGroup *WaitingHintsView::CreateUIViewGroup() return group; } +bool WaitingHintsView::InitAddOnclickevent() +{ + clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); + if (clickLeftListener == nullptr) { + return false; + } + imageAgreeing->SetOnClickListener(clickLeftListener); + imageDissgree->SetOnClickListener(clickLeftListener); + return true; +} + WaitingHintsView *WaitingHintsView::GetInstance() { return g_pMainView; @@ -81,36 +134,60 @@ WaitingHintsView *WaitingHintsView::GetInstance() bool WaitingHintsView::InitImageViewDisplay() { + imageAgreeing = new UIImageView(); + if (imageAgreeing == nullptr) { + return false; + } + imageAgreeing->SetPosition(369, 207); // 30 : offset + imageAgreeing->SetSrc(PNG_ANSWER_230_TMAGE_PATH); + imageAgreeing->SetTouchable(true); + imageAgreeing->SetViewId("answer"); + //group->Add(imageAgreeing); + imageDissgree = new UIImageView(); if (imageDissgree == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new imageDissgree error"); return false; } - imageDissgree->SetPosition(IMAGE_HANDUP_POSITION_X, IMAGE_HANDUP_POSITION_Y); // 30 : offset - imageDissgree->SetSrc(PNG_DISSGREE_IMAGE_PATH); + imageDissgree->SetPosition(46, 207); // 30 : offset + imageDissgree->SetSrc(PNG_HANDUP_230_IMAGE_PATH); imageDissgree->SetTouchable(true); imageDissgree->SetViewId("hintsHandup"); + //group->Add(imageDissgree); - clickLeftListener = (UIView::OnClickListener*)OHOS::MainCallingPresenter::GetInstance(); - if (clickLeftListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new clickLeftListener error"); + imageperson = new UIImageView(); + if (imageperson == nullptr) { return false; } - imageDissgree->SetOnClickListener(clickLeftListener); - group->Add(imageDissgree); + imageperson->SetPosition(158, 158); // 30 : offset + imageperson->SetSrc(PNG_230_PERSON_IMAGE_PATH); + imageperson->SetTouchable(true); + imageperson->SetViewId("headset"); + + char name_buf[30]={0}; + uint8_t sex; + if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),&sex)) + { + if(sex) + imageperson->SetSrc(PHONE_DIR_BOY_1); + else + imageperson->SetSrc(PHONE_DIR_GIRL_1); + } + + group->Add(imageperson); + InitAddOnclickevent(); return true; } bool WaitingHintsView::InitUILabelDisplay() { - callerDisplay = new UILabel(); + callerDisplay = new UILabelExt(); if (callerDisplay == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new callerDisplay error"); return false; } - callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); + callerDisplay->SetPosition(LABEL_PERCENT_POSITION_X, LABEL_PERCENT_POSITION_Y, VIEW_DISTANCE_TO_LEFT_SIDE, + TITLE_LABEL_DEFAULT_HEIGHT); callerDisplay->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + char name_buf[30]={0}; if(get_phone_addrss_name(name_buf,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),NULL)) { @@ -120,25 +197,65 @@ bool WaitingHintsView::InitUILabelDisplay() { callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); } - + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + updataCallingname(); + callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); - callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); + callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); callerDisplay->SetTextColor(Color::White()); + callerDisplay->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); group->Add(callerDisplay); - newcallHints = new UILabel(); - if (newcallHints == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WaitingHintsView::new newcallHints error"); - return false; + if (label_call_hint == nullptr) { + label_call_hint = new UILabelExt(); + } + + label_call_hint->SetPosition(133, 353); // widget's left position and top position + label_call_hint->Resize(200, 35); // widget's width and height + label_call_hint->SetViewId("label3");// Set style + label_call_hint->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label_call_hint->SetText("挂断/接听"); + label_call_hint->SetTextId(STR_HANG_UP_OR_ANSWER); + + label_call_hint->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_hint->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_hint->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_hint->SetRollSpeed(0); + label_call_hint->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(label_call_hint); + + + if (label_call_source == nullptr) { + label_call_source = new UILabelExt(); } - newcallHints->SetPosition(LABEL_CALLERD_POSITION_X, LABEL_CALLERD_POSITION_Y, - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT); - newcallHints->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - newcallHints->SetText("新来电"); - newcallHints->SetAlign(TEXT_ALIGNMENT_CENTER); - newcallHints->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); - newcallHints->SetTextColor(Color::White()); - group->Add(newcallHints); + label_call_source->SetPosition(133, 34); // widget's left position and top position + label_call_source->Resize(200, 60); // widget's width and height + label_call_source->SetViewId("label1");// Set style + label_call_source->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1) + { + label_call_source->SetText("手表来电"); + label_call_source->SetTextId(STR_WATCH_CALL); + } + else + { + label_call_source->SetText("手机来电"); + label_call_source->SetTextId(STR_PHONE_CALL); + } + + + label_call_source->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label_call_source->SetTextColor(Color::GetColorFromRGBA(0xAA, 0xAA, 0xAA, 0xff)); + label_call_source->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_call_source->SetRollSpeed(0); + label_call_source->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(label_call_source); + return true; + } } \ No newline at end of file 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 a37d2d4c2..3d3a6741f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -345,7 +345,7 @@ namespace OHOS - button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color); + button_calllog_status[i] = TelephonyInitInterface::LabelViewInit(labelParam,color); if (button_calllog_status[i] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::MainPhoneViewTitleLabel new fail!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp index 1857c17f9..e3f0507aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -66,7 +66,7 @@ namespace OHOS { //NativeAbility::GetInstance().Back(); //NativeAbility::GetInstance().Back(); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE);// EnterSlice(VIEW_MAIN_PHONE); + NativeAbility::GetInstance().BackCountSlice(2);// EnterSlice(VIEW_MAIN_PHONE); } @@ -227,7 +227,7 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().BackCountSlice(2); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h index 6ec269518..61cd8539b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneService.h @@ -62,6 +62,12 @@ typedef enum { CALL_MISSED, // 未接来电 } CallFinishStatus; +typedef enum { + CALL_CAT1 = 0, // + CALL_HFP, // +} CalllogtypeStatus; + + #pragma pack(1) typedef struct { char name[NAME_SIZE]; @@ -71,9 +77,9 @@ typedef struct { CallFinishStatus status; uint32 creationTime; // 通话创建时间(不是接通时间) uint64 callDurTime; // 通话持续时间 + uint8_t calllogtype; } CallLogInfo; - -#pragma pack(0) +#pragma pack() // 通话状态改变回调函数 typedef void (*PhoneServiceCallChangedCb)(const PhoneCallInfo *phoneCall); // 电话服务失败回调函数 @@ -268,6 +274,10 @@ int uapi_hfp_connect_state(void); void uapi_hfp_send_DTMF_CODE(char code); +void Cat1_CallStateChanged(const hfp_hf_calls_info_t *call); + +void PhoneServiceScreenCtr(bool turnOnFlag); + #ifdef __cplusplus } #endif 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 7ea6e7cdc..6c2915c75 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -32,6 +32,10 @@ #include "CallerLogModel.h" #include "custom_utils.h" #include "Bluetooyhpabpserver.h" +#include "AlarmClockModel.h" +#include "ConfigModel.h" +#include "custom_runtime.h" +#include "vibrator_service.h" #ifdef __cplusplus extern "C" { #endif @@ -78,7 +82,7 @@ static int g_hdlDnSco = INVALID_PHONE_SERVICE_VALUE; PhoneServiceCb g_callChanged; void HfpIncomingEventPublish(uint16 topic, hfp_hf_calls_info_t callsInfo); -static void PhoneServiceScreenCtr(bool turnOnFlag) +void PhoneServiceScreenCtr(bool turnOnFlag) { if (turnOnFlag) { ScreenTurnOn(-1); @@ -555,7 +559,7 @@ static void CatBdAddr(const bd_addr_t *bdAddr) } WEARABLE_LOGD("",""); #else - UNUSED(bdAddr); + UNUSED(bdAddr); #endif } @@ -642,6 +646,17 @@ static void ScoConnectPro(void) { return; } + + // if(OHOS::CallerLogModel::GetInstance()->GetCallDial() == OHOS::CallerLogModel::HFP_PHONE_DIAL) + // { + // return; + // } + // else + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "手表拨号"); + // } + + ScoStatusCb(HFP_SCO_STATE_CONNECTED); if (g_currCallState == HFP_HF_CALL_STATE_ACTIVE && g_scoFlag == HFP_SCO_STATE_CONNECTED) { // The call is transferred from the phone to the watch. Need to show the call notification view. @@ -658,11 +673,16 @@ 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) + // { + // return; + // } ScoStatusCb(HFP_SCO_STATE_DISCONNECTED); if (g_currCallState == HFP_HF_CALL_STATE_ACTIVE && g_scoFlag == HFP_SCO_STATE_DISCONNECTED) { @@ -702,7 +722,7 @@ static void ScoStateChanged(const bd_addr_t *bdAddr, hfp_sco_connect_state_t sta case HFP_SCO_STATE_DISCONNECTED: WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ScoStateChanged] SCO disconnected!"); ScoDisconnectPro(); - PhoneServiceScreenCtr(0); + //PhoneServiceScreenCtr(0); break; default: @@ -1134,7 +1154,7 @@ void HfpIncomingEventPublish(uint16 topic, hfp_hf_calls_info_t callsInfo) BroadcastApi *broadcastApi = nullptr; IUnknown *api = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HfpIncomingEventPublish topic=%u!!", topic); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HfpIncomingEventPublish topic=%u!!", topic); void *publishData = malloc(size); if (publishData == nullptr) { @@ -1198,6 +1218,16 @@ static void CallChangeIncomePro(const hfp_hf_calls_info_t *call) } else { phoneCall->operate = OPERATE_WAITING; } + + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 + && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) + { + if(call->state==HFP_HF_CALL_STATE_INCOMING) + { + phoneCall->operate = OPERATE_WAITING; + } + } + phoneCall->lastStatus = call->state; phoneCall->creationTime = time(nullptr); @@ -1346,6 +1376,10 @@ static void CallChangeHeldPro(const hfp_hf_calls_info_t *call) static void PlayWatchRing(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PlayWatchRing] start"); + if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + OHOS::AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3"); + } } static void CallAudioHandle(const hfp_hf_calls_info_t *call) @@ -1363,6 +1397,12 @@ static void CallAudioHandle(const hfp_hf_calls_info_t *call) PostGraphicEvent(PlayWatchRing); } } + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + // 震动提醒 + ui_api_vibrate_once_func(); + } + } else if (state == HFP_HF_CALL_STATE_FINISHED) { return; } else if (g_scoFlag == HFP_SCO_STATE_CONNECTED) { @@ -1408,10 +1448,29 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "call is null or BT disconnected connStatus: 0x%X", g_btConnState); return; } + if(OHOS::CallerLogModel::GetInstance()->GetCallDial() == OHOS::CallerLogModel::HFP_PHONE_DIAL) + { + if(call->state==HFP_HF_CALL_STATE_DIALING||call->state==HFP_HF_CALL_STATE_ALERTING) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HFP_PHONE_DIAL 手机拨号"); + TransCallToMobilePhone(); + return; + } + } + if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1 && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus()) { - return; + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4G 电话中"); + if(call->state==HFP_HF_CALL_STATE_INCOMING||call->state==HFP_HF_CALL_STATE_WAITING) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hint 新电话"); + HfpIncomingEventPublish(TOPIC_EVENT_HFP_HINT,*call); + } + TransCallToMobilePhone(); + return; + } } SetCompleteCallFlag(call); @@ -1420,6 +1479,7 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t uapi_pbap_cmd_pull_vcard_listing((unsigned char *)call->number); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "CallStateChanged state:%d", call->state); + switch (call->state) { case HFP_HF_CALL_STATE_ACTIVE: // 正在通话 CallChangeActivePro(call); @@ -1445,7 +1505,7 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t break; case HFP_HF_CALL_STATE_FINISHED: // 拒接/结束电话 CallChangeFinishPro(call); - PhoneServiceScreenCtr(0); + //PhoneServiceScreenCtr(0); break; default: break; @@ -1621,6 +1681,7 @@ void PhoneServiceInit(void) // 手表主动拨打电话 int DialCall(unsigned char *number, unsigned char len) { + OHOS::CallerLogModel::GetInstance()->SetCallDial(OHOS::CallerLogModel::HFP_WATCH_DIAL); int ret; unsigned char *tel = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[DialCall] start"); @@ -1878,7 +1939,7 @@ int TransCallToWatch(void) int TransCallToMobilePhone(void) { int ret; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[TransCallToMobilePhone] start"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TransCallToMobilePhone] start"); if (g_btConnState != PROFILE_STATE_CONNECTED) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[TransCallToMobilePhone] BT connStatus: 0x%X", g_btConnState); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp index 68aeab844..9b3d5873c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp @@ -245,6 +245,7 @@ static void AlertingHandle(void) { CallerLogModel::GetInstance()->SetDialingStatus("正在响铃"); CallerLogModel::GetInstance()->SetMakePhoneStatus(true); + } static void IncomingHandle(void) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h index 594b9fd96..c5e5bbf0e 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/include/PhoneService.h @@ -62,6 +62,11 @@ typedef enum { CALL_MISSED, // 未接来电 } CallFinishStatus; +typedef enum { + CALL_CAT1 = 0, // + CALL_HFP, // +} CalllogtypeStatus; + typedef struct { char name[NAME_SIZE]; unsigned char nameLen; @@ -70,6 +75,7 @@ typedef struct { CallFinishStatus status; uint32 creationTime; // 通话创建时间(不是接通时间) uint64 callDurTime; // 通话持续时间 + uint8_t calllogtype; } CallLogInfo; // 通话状态改变回调函数 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp index a4f863e1c..9e1920f84 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/phoneservice/src/PhoneService.cpp @@ -614,6 +614,16 @@ uint32 GetBtConnectStatus(void) g_btConnState = (uint32)hfp_hf_get_device_connect_state(&g_bdAddr); return g_btConnState; } +//获取sco状态 +uint32 GetHFPSCOConnectStatus(void) +{ + int soc_state = (uint32)hfp_hf_get_sco_connect_state(&g_bdAddr); + if(PROFILE_STATE_DISCONNECTING==soc_state || PROFILE_STATE_DISCONNECTED==soc_state) + return 0; + else + return 1; +} + // SCO连接处理 static void ScoConnectPro(void) diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index d273b3f28..21cad6756 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -84,8 +84,8 @@ typedef struct ancs_data_info uint32_t time;//时间戳 int uid;//uid 消息唯一编号 int appid;//消息类型:1:微信 2:QQ 3:短信 4:其他 - char title[TITLE_BUF_LEN+1];//消息发送者 - char msg[MSG_BUF_LEN+1];//消息内容 + char *title;//消息发送者 + char *msg;//消息内容 int hasCode;//消息hash code int read;//是否已读 0 未读 1 已读 }ancs_data_info_t; diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 429c88922..6dc87712c 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -5812,15 +5812,18 @@ void message_data(int uid,int appid,char *title,char *msg,int hasCode) timestampe = 0; } ancs_data_info_t data; - memset_s(&data,sizeof(ancs_data_info_t),0,sizeof(ancs_data_info_t)); + //memset_s(&data,sizeof(ancs_data_info_t),0,sizeof(ancs_data_info_t)); data.appid=appid; - memcpy_s(data.title,TITLE_BUF_LEN+1,title,strlen(title)); - memcpy_s(data.msg,MSG_BUF_LEN+1,msg,strlen(msg)); + // memcpy_s(data.title,TITLE_BUF_LEN+1,title,strlen(title)); + // memcpy_s(data.msg,MSG_BUF_LEN+1,msg,strlen(msg)); + data.title=title; + data.msg=msg; data.uid=uid; data.time=timestampe; data.read=0; data.hasCode=hasCode; + printf("message_data\r\n"); CustomEventPublish_TOPIC_EVENT_MESSAGENOTE(&data); return ; diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index fcadf344e..53ee57257 100644 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -47,6 +47,7 @@ typedef enum { TOPIC_EVENT_HFP_FINISHED, TOPIC_EVENT_HFP_PHONE_TO_WATCH, TOPIC_EVENT_HFP_WATCH_TO_PHONE, + TOPIC_EVENT_HFP_HINT, #ifdef CYWEE_SPORT TOPIC_EVENT_ACTIVITY_UPDATE, TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE, diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index bb1897514..863760388 100644 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -53,6 +53,8 @@ static const TopicToCore topicToCoreArray[] = { {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}, 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 5616505be..a8d78f320 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 @@ -26,6 +26,7 @@ UIViewGroup* CreateMultiplePhoneView(void); UIViewGroup* CreateWaitingHintsView(void); UIViewGroup* CreateCalldialView(void); UIViewGroup* SOS_cant_dial(void); +UIViewGroup* CALL_INCOMING_HINT(void); void HonrsViewChange(void); VolumeSettingView *GetvolumeSetting(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 f5381c272..3da0b6de5 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 @@ -60,7 +60,7 @@ #include "cywee_service.h" #include "goalview.h" #include "goalother.h" - +#include "ConfigModelC.h" #include "heart_blood/health_service/health_service.h" #define DIALDATASET 1 @@ -95,6 +95,8 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE}, {TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE}, + {TOPIC_EVENT_HFP_HINT, PRIORITY_ONE}, + #ifdef SUPPORT_CAT1_MODEM {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE}, {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE}, @@ -153,6 +155,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_FINISHED); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_PHONE_TO_WATCH); MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_WATCH_TO_PHONE); + MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_HINT); #ifdef CYWEE_SPORT MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE); @@ -299,6 +302,12 @@ static OHOS::UIViewGroup* showSleepNotify(void) return OHOS::CreateSleepNotifyView(); } +//显示新来电 +static OHOS::UIViewGroup* showcallhintNotify(void) +{ + return OHOS::CALL_INCOMING_HINT(); +} + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { @@ -524,20 +533,10 @@ void MsgCenterNotifyHfpIncomingProc(const Topic topic, Request* req) if (ret != EOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!"); } else { - // Prevent this from happening: - // When the incoming call view is displayed, the calling number is not set in CallerLogModel. - CallerLogModel::GetInstance()->SetoperateNumber(callData.number, callData.number_len); - } - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); - - if (GetCurrCallNum() > 1) { - CallerLogModel::GetInstance()->SetNotifyFlag(true); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCurrCallNum %d",GetCurrCallNum()); - NotificationManager::GetInstance()->ShowNotify(ShowPhoneCallNotify, static_cast(topic), true); - } else { - EnableWaitingView(); } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyHfpIncomingProc"); + CallerLogModel::GetInstance()->SetoperateNumber(callData.number, callData.number_len); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); NotificationManager::GetInstance()->SetWatchCallStatus(true); } @@ -547,38 +546,57 @@ void MsgCenterNotifyHfpPhoneProc(const Topic topic, Request* req) // finish a single-channel call, or switch to phone, stop the notify if (CallerLogModel::GetInstance()->GetNotifyFlag()) { DisableWatingView(); - if ((topic == TOPIC_EVENT_HFP_FINISHED && GetCurrCallNum() == 0) || - topic == TOPIC_EVENT_HFP_PHONE_ACTIVE || topic == TOPIC_EVENT_HFP_WATCH_TO_PHONE) { - NotificationManager::GetInstance()->StopNotify(); + } + if ((topic == TOPIC_EVENT_HFP_FINISHED && GetCurrCallNum() == 0) || + topic == TOPIC_EVENT_HFP_PHONE_ACTIVE || topic == TOPIC_EVENT_HFP_WATCH_TO_PHONE) { + NotificationManager::GetInstance()->StopNotify(); + if( CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSource::CallSourcePhone) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetWatchCallStatus false"); NotificationManager::GetInstance()->SetWatchCallStatus(false); } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "无需结束"); + } + } - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); + // CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); } +void MsgCenterNotifyHfpWatchHintProc(const Topic topic, Request* req) +{ + unused(req); + //NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + NotificationManager::GetInstance()->ShowNotify(showcallhintNotify, + static_cast(topic), true); +} + + void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req) { unused(req); - if (CallerLogModel::GetInstance()->GetNotifyFlag()) { - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + if (CallerLogModel::GetInstance()->GetNotifyFlag()) + { // default not mute SetMicMute(false); if (CallerLogModel::GetInstance()->IsMulitplePhoneStatus()) { + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); NotificationManager::GetInstance()->ShowNotify(ShowMultiPhoneCallNotify, static_cast(topic), true); } else { - //NotificationManager::GetInstance()->ShowNotify(ShowCallingNotify, static_cast(topic), true); - //CallerLogModel::GetInstance()->SetCallStatus(true); + // NotificationManager::GetInstance()->ShowNotify(ShowCallingNotify, static_cast(topic), true); + // CallerLogModel::GetInstance()->SetCallStatus(true); // NotificationManager::GetInstance()->StopNotify(); // NativeAbility::GetInstance().ChangeSlice(AppViewId::VIEW_INCOMING_CALL); } - NotificationManager::GetInstance()->SetWatchCallStatus(true); - + } - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); + NotificationManager::GetInstance()->SetWatchCallStatus(true); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); } @@ -756,52 +774,69 @@ void MsgCenterNotifySleepProc(const Topic topic, Request* req) #endif #ifdef SUPPORT_CAT1_MODEM +//来电处理函数 void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) { unused(topic); unused(topic); if (req == NULL) return ; char* call_data = (char*)malloc(req->len); + if(call_data==NULL) + { + return; + } int32 ret = memcpy_s(call_data, req->len, req->data, req->len); if (ret != EOK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!"); } else { // Prevent this from happening: // When the incoming call view is displayed, the calling number is not set in CallerLogModel. - if( NotificationManager::GetInstance()->GetWatchCallStatus()) + //uapi_hfp_disconnect(); + + if(NotificationManager::GetInstance()->GetWatchCallStatus() && + (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) { - cat1_call_hungup(); + std::string hfp_number= CallerLogModel::GetInstance()->GetPhoneNumber(); + + CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(hfp_number.c_str(),hfp_number.length()); + + CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); + + cat1_phone_state_change_cb(OPERATE_WAITING); + + free(call_data); + return; } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "????????????????????"); + } + 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(10); - + { + display_api->turn_on_screen(); + } if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { - AlarmClockModel::GetInstance()->AlarmPlayerStart(); + AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3"); } - + CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - // hfp_hf_calls_info_t call; - // CallChangeIncomePro(&call); + + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + cat1_phone_state_change_cb(OPERATE_INCOMING); + NotificationManager::GetInstance()->SetWatchCallStatus(true); } free(call_data); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); - //CallerLogModel::GetInstance()->SetNotifyFlag(true); - //NotificationManager::GetInstance()->ShowNotify(ShowPhoneCallNotify, (uint16_t)topic, true); - cat1_phone_state_change_cb(OPERATE_INCOMING); - - NotificationManager::GetInstance()->SetWatchCallStatus(true); } +//开始通话处理函数 void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) { unused(topic); @@ -815,15 +850,13 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req) SetMicMute(false); AlarmClockModel::GetInstance()->AlarmPlayerStop(); NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); - //CallerLogModel::GetInstance()->SetNotifyFlag(true); - cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE); - //NotificationManager::GetInstance()->ShowNotify(CreateCallingView, (uint16_t)topic, true); CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); NotificationManager::GetInstance()->SetWatchCallStatus(true); } +//拨号处理函数 void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify MsgCenterNotifyCat1dialProc"); @@ -837,50 +870,27 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req) } 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); - + //uapi_hfp_disconnect(); 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(); - // if (display_api->get_screen_state() != SCREEN_ON) - // { - // display_api->turn_on_screen(); - // } - // display_api->set_screen_set_keepon_timeout(10); - - //AlarmClockModel::GetInstance()->AlarmPlayerStart(); - - + + cat1_call_dial(call_data); + + CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); + CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); - cat1_call_dial(call_data); - CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len); - CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1); + cat1_phone_state_change_cb(OPERATE_DIALING); + NotificationManager::GetInstance()->SetWatchCallStatus(true); - cat1_phone_state_change_cb(OPERATE_DIALING); - NotificationManager::GetInstance()->SetWatchCallStatus(true); - // hfp_hf_calls_info_t call; - // CallChangeIncomePro(&call); } free(call_data); NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); - //CallerLogModel::GetInstance()->SetNotifyFlag(true); - #ifdef FD230 - //NotificationManager::GetInstance()->ShowNotify(CalldialNotify, (uint16_t)topic, true); - #endif - } +//电话结束处理函数 void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) { unused(topic); @@ -892,15 +902,7 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req) return; } cat1_phone_state_change_cb(OPERATE_WATCH_FINISH); - - SetMicMute(false); - // if (CallerLogModel::GetInstance()->GetNotifyFlag() == true) { - // NotificationManager::GetInstance()->StopNotify(); - // addcalllog(); - // } - NotificationManager::GetInstance()->SetWatchCallStatus(false); - - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetWatchCallStatus false"); } @@ -934,9 +936,8 @@ void MsgCenterNotifyCat1SignalUpdateProc(const Topic topic, Request* req) // pview->setcat1msg(msg); // } // } - - } + void MsgCenterNotifyCat1PowerOffProc(const Topic topic, Request* req) { unused(topic); @@ -1434,6 +1435,8 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc}, {TOPIC_EVENT_HFP_WATCH_ACTIVE, MsgCenterNotifyHfpWatchProc}, {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc}, + {TOPIC_EVENT_HFP_HINT, MsgCenterNotifyHfpWatchHintProc}, + #ifdef CYWEE_SPORT {TOPIC_EVENT_ACTIVITY_UPDATE, MsgCenterNotifyActivityProc}, {TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE, MsgCenterNotifyActivityExtraInfoProc}, 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 01112b8bd..9d9d9cf3e 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 @@ -36,6 +36,10 @@ #include "string/osal_string.h" #include "components/ui_label_ext.h" #include "components/ui_label_button_ext.h" +#include "vibrator_service.h" +#include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h" +#include "osal_timer.h" +#include "cmsis_os2.h" // #define NOTIFY_THREE_SECONDS 3000 // #define NOTIFY_ONE_SECOND 1000 @@ -244,6 +248,8 @@ static UILabelExt *alarm_UILabel=nullptr; static UILabelExt *button_UILabel=nullptr; static UILabelButtonExt *alarm_labelbutton=nullptr; +UIViewGroup* HintView = nullptr; +static UILabelExt *Hint_UILabel=nullptr; // typedef struct { // char name[NAME_SIZE]; // unsigned char nameLen; @@ -282,6 +288,100 @@ void FreeSOSView(void) } } +void hintdialtimerCallBack(int data) +{ + NotificationManager::GetInstance()->StopNotify(); +} + + + +static osTimerId_t CALL_INCOMING_HINT_timer= NULL; + +void FreehintView(void) +{ + if (HintView != nullptr) { + + HintView->RemoveAll(); + if(Hint_UILabel) + { + delete Hint_UILabel; + Hint_UILabel=nullptr; + } + + if(CALL_INCOMING_HINT_timer) + { + osTimerStop(CALL_INCOMING_HINT_timer); + osStatus_t ret = osTimerDelete(CALL_INCOMING_HINT_timer); + if (ret != osOK) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed ret = %lx!", ret); + return; + } + CALL_INCOMING_HINT_timer = nullptr; + } + + + RootView::GetInstance()->Remove(HintView); + delete HintView; + HintView = nullptr; + } +} + + +UIViewGroup* CALL_INCOMING_HINT(void) +{ + HintView = new UIViewGroup(); + if (HintView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!"); + return nullptr; + } + HintView->SetPosition(MATH_ZERO, MATH_ZERO); + HintView->SetWidth(Screen::GetInstance().GetWidth()); + HintView->SetHeight(Screen::GetInstance().GetHeight()); + HintView->SetStyle(STYLE_BACKGROUND_OPA, 0); + + if (Hint_UILabel == nullptr) { + Hint_UILabel = new UILabelExt(); + } + Hint_UILabel->SetPosition(62, 199); // widget's left position and top position + Hint_UILabel->Resize(340, 30); // widget's width and height + Hint_UILabel->SetViewId("label3");// Set style + Hint_UILabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffAAAAAA); + Hint_UILabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + Hint_UILabel->SetStyle(STYLE_BORDER_RADIUS, 27); + Hint_UILabel->SetStyle(STYLE_TEXT_FONT, 33); + Hint_UILabel->SetStyle(STYLE_LINE_SPACE, 0); + + // Set additional property + Hint_UILabel->SetText("手机新来电"); + Hint_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + Hint_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Hint_UILabel->SetRollSpeed(0); + Hint_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33); + + HintView->Add(Hint_UILabel); + Hint_UILabel->SetVisible(true); + Hint_UILabel->LayoutCenterOfParent(); + + uint32_t tick; + osStatus_t retTimer; + + CALL_INCOMING_HINT_timer = osTimerNew((osTimerFunc_t)hintdialtimerCallBack, osTimerPeriodic, NULL, NULL); + tick =2000;// 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); + osTimerDelete(CALL_INCOMING_HINT_timer); + CALL_INCOMING_HINT_timer = NULL; + return NULL; + } + + NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreehintView); + + return HintView; + +} + + UIViewGroup* SOS_cant_dial(void) { SOSView = new UIViewGroup(); @@ -402,15 +502,74 @@ 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()) + { + 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; + } + + } CallerLogModel::GetInstance()->SetCallStatus(false); CallerLogModel::GetInstance()->SetWaitingStatus(true); - // If the call is handling in the notification, the slice is not switched + + NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID, - PRIORITY_ONE); - + PRIORITY_ONE); } static void WatchActiveHandle() @@ -418,6 +577,7 @@ static void WatchActiveHandle() DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY); CallerLogModel::GetInstance()->SetCallStatus(true); CallerLogModel::GetInstance()->SetWaitingStatus(false); + } @@ -433,10 +593,21 @@ static void WatchFinishHandle(void) sos_falg_add(); } else - StatusReset(); + { + if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone) + { + + } + else + { + PhoneServiceScreenCtr(false); + + addcalllog(); + StatusReset(); + } + } + } - - DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY); } @@ -447,6 +618,7 @@ void cat1_phone_state_change_cb(uint8_t state) switch (g_callOperate) { case OPERATE_DIALING: // 显示正在呼出界面 + PhoneServiceScreenCtr(true); DialingHandle(); call_stat=0; @@ -458,12 +630,20 @@ void cat1_phone_state_change_cb(uint8_t state) break; case OPERATE_INCOMING: // 显示电话呼入 + PhoneServiceScreenCtr(true); IncomingHandle(); calllog_info_init(); + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) + { + ui_api_vibrate_once_func(); + } call_stat=2; break; case OPERATE_WAITING: // 震动一下,提示有新电话呼入 还未对齐 + calllog_info_init(); + call_stat=2; + addcalllog(); WaitingOpreate(); return; @@ -471,6 +651,7 @@ void cat1_phone_state_change_cb(uint8_t state) // 手表接听,显示界面 if(call_stat==2) call_stat=1; + PhoneServiceScreenCtr(true); sos_falg_clean(); WatchActiveHandle(); break; @@ -479,7 +660,6 @@ void cat1_phone_state_change_cb(uint8_t state) return; case OPERATE_WATCH_FINISH: - addcalllog(); WatchFinishHandle(); return; case OPERATE_WATCH_REJECT: diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/ring.mp3 b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/ring.mp3 new file mode 100644 index 000000000..94085c2cb Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/ring.mp3 differ