From 3216a44ae27676667171bbfa72a7f1fe71e86369 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 15 Nov 2024 11:46:29 +0800 Subject: [PATCH] =?utf8?q?pbap=E6=9C=8D=E5=8A=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../bluetooth/include/Bluetooyhpabpserver.h | 2 +- .../bluetooth/src/Bluetooyhpabpserver.cpp | 22 ++++++++++++++++-- .../callerlog/include/CallerLogModel.h | 17 +++++++++++++- .../nativeui/callerlog/src/CallerLogModel.cpp | 8 +++++++ .../makephone/src/CallerDisplayView.cpp | 6 +++-- .../nativeui/makephone/src/CallingView.cpp | 6 ++--- .../makephone/src/MainCallingView.cpp | 23 +++++++++++++++++++ .../makephone/src/WaitingHintsView.cpp | 11 ++++++--- .../phoneservice/src/PhoneService.cpp | 5 +++- 9 files changed, 87 insertions(+), 13 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h index e6de15aed..124f0cbe9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h @@ -15,7 +15,7 @@ void uapi_pbap_pce_reg_callback(void); void uapi_pbap_cmd_start_client(void); void uapi_pbap_cmd_pull_phonebook(void); -void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell); +void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell,uint8_t len); void uapi_pbap_cmd_pull_vcard_entry(td_char *vcf_name); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp index 361e924c9..a696b6d8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp @@ -76,6 +76,11 @@ static void sample_pbap_receive_data(const bd_addr_t *bd_addr, const uint8_t* da char *name_=strtok(name_str,"\""); name_=strtok(NULL,"\""); OHOS:: CallerLogModel::GetInstance()->Setphonebname(name_,strlen(name_)); + printf("name_ : %s\r\n",name_); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(calllognameupdate)); + + } } @@ -460,7 +465,7 @@ static bool sample_pbap_set_vcard_listing_name(bd_addr_t* bd_addr, uint8_t folde } /* get phone vCard-Listing */ -void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell) +void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell,uint8_t len) { uint8_t folder=1; uint8_t vcf=PBAP_VCF_PB; @@ -470,6 +475,16 @@ void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell) OHOS:: CallerLogModel::GetInstance()->Setphonebname("0",1); + OHOS:: CallerLogModel::GetInstance()->Setphonenumber((char *)tell,len); + + unsigned char *tell_=(unsigned char *)malloc(len+1); + if(tell_==NULL) + { + return; + } + memset_s(tell_,30,0,len); + memcpy_s(tell_,30,tell,len); + if (!wstp_pbap_check_param_valid(folder, vcf, max_list_count, list_offset, 0)) { printf("pbap param invalid\n"); return; @@ -481,6 +496,7 @@ void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell) (pbap_pce_pull_vcard_listing_param_t*)(void *)malloc(sizeof(pbap_pce_pull_vcard_listing_param_t)); if (thr_par == NULL) { printf("pbap param malloc failed\n"); + free(tell_); return; } @@ -490,12 +506,13 @@ void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell) if (thr_par->name == NULL) { printf("pbap param name malloc failed\n"); free(thr_par); + free(tell_); return; } (void)memset_s(thr_par->name, PBAP_APP_FOLDER_MAXLENGTH, 0, PBAP_APP_FOLDER_MAXLENGTH); thr_par->search_property=PBAP_SEARCH_PROPERTY_NUMBER; - thr_par->search_value=tell; + thr_par->search_value=tell_; thr_par->max_list_count = max_list_count; thr_par->list_offset = list_offset; /* index = 5 */ /* 0:索引序 1:字典序 */ @@ -507,6 +524,7 @@ void uapi_pbap_cmd_pull_vcard_listing(unsigned char *tell) } free(thr_par->name); free(thr_par); + free(tell_); } /* get phone vCard-Listing */ 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 515a179a5..d3f7ff941 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h @@ -46,6 +46,9 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall); void UsingPhoneErrorCallback(PhoneServiceErrorType type); void CAT1_ChangeStatusScreendisplay(int lastStatus); void InitCallingTimer(); + +void calllognameupdate(void); + namespace OHOS { @@ -74,6 +77,11 @@ typedef enum { return call_name; } + std::string Getphonenumberpbap(void) + { + return call_number; + } + void Setphonebname(char *name,uint8_t name_len) { call_name.clear(); @@ -82,6 +90,12 @@ typedef enum { //printf("%s\r\n",call_name.c_str()); } + void Setphonenumber(char *number,uint8_t number_len) + { + call_number.clear(); + call_number.append(reinterpret_cast(number), number_len); + } + std::string GetPhoneNumber(void); void SetoperateNumber(const char *number, char number_len); @@ -162,7 +176,7 @@ CallSource GetCallSource(void) return phoneNumberCAT1END; } - + private: CallerLogModel(); @@ -177,6 +191,7 @@ private: std::string phoneNumberCAT1; // 4G电话号码 std::string phoneNumberCAT1END; // 4G挂断电话号码 std ::string call_name; + std ::string call_number; bool mulitplePhoneStatus{false}; // 判断是否多路通话界面 bool waitingStatus{false}; // 判断是否等待提醒界面 bool volumeStatus{false}; // 判断是否音量界面 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 b2008b50c..efcfb4f6f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -124,6 +124,14 @@ static void DisableCallingTimer() #include "dial_sos_c.h" +void calllognameupdate() +{ + if(MainCallingView::GetInstance()) + { + MainCallingView::GetInstance()->updataCallingname(); + } +} + /* 状态复位 */ void StatusReset(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp index cc778f5ca..0cf46bffa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp @@ -140,8 +140,10 @@ bool CallerDisplayView::InitImageViewDisplay() void CallerDisplayView::updataCallingname(void) { - if(CallerLogModel::GetInstance()->Getphonename().length()>5) + //if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); } } @@ -167,7 +169,7 @@ bool CallerDisplayView::InitUILabelDisplay() { callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); } - if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) updataCallingname(); callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); diff --git a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp index 7c616b33f..31e0f79b7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp @@ -142,8 +142,9 @@ UILabel *CallingView::GetCallingDurationLabel() void CallingView::updataCallingname(void) { - if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); } } @@ -255,10 +256,9 @@ bool CallingView::InitUILabelDisplay() callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); } - if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) updataCallingname(); - callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); callerDisplay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_DISPLAY_FONE_SIZE); callerDisplay->SetTextColor(Color::White()); 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 feb2ef553..6c4f2fd2e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp @@ -127,6 +127,29 @@ bool MainCallingView::InitPointerValue() return true; } +void MainCallingView::updataCallingname(void) +{ + //if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) + { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) + { + if(screenView) + screenView->updataCallingname(); + if(callView) + callView->updataCallingname(); + if(displayView) + displayView->updataCallingname(); + + RootView::GetInstance()->Invalidate(); + + //callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); + } + + + } +} + void MainCallingView::OnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::OnStart"); 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 7298a8253..029743951 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp @@ -89,10 +89,15 @@ WaitingHintsView::~WaitingHintsView() void WaitingHintsView::updataCallingname(void) { - if(CallerLogModel::GetInstance()->Getphonename().length()>5) + if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),CallerLogModel::GetInstance()->Getphonenumberpbap().c_str())==0) { + if(CallerLogModel::GetInstance()->Getphonename().length()!=0) callerDisplay->SetText(CallerLogModel::GetInstance()->Getphonename().c_str()); - } + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "updataCallingname 000000000000"); + } } @@ -197,7 +202,7 @@ bool WaitingHintsView::InitUILabelDisplay() { callerDisplay->SetText(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()); } - if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) + // if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourcePhone) updataCallingname(); callerDisplay->SetAlign(TEXT_ALIGNMENT_CENTER); 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 2aae4268e..3c800e987 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -666,6 +666,7 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st return; } #endif + uapi_pbap_cmd_start_client(); break; case PROFILE_STATE_CONNECTED: // 蓝牙连接成功 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT connected"); @@ -684,6 +685,7 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st #endif BtConnectedPro(bdAddr); SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); + uapi_pbap_cmd_start_client(); //SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); break; @@ -1610,10 +1612,11 @@ static void CallStateChanged(const bd_addr_t *bdAddr, const hfp_hf_calls_info_t SetCompleteCallFlag(call); CatCallStateChangedInfo(bdAddr, call); CallAudioHandle(call); + if(call->state==HFP_HF_CALL_STATE_INCOMING || call->state==HFP_HF_CALL_STATE_DIALING || call->state==HFP_HF_CALL_STATE_ALERTING) - uapi_pbap_cmd_pull_vcard_listing((unsigned char *)call->number); + uapi_pbap_cmd_pull_vcard_listing((unsigned char *)call->number,(uint8_t )call->number_len); if(HFP_HF_CALL_STATE_INCOMING!=call->state) { -- 2.17.1