pbap服务优化 1406/3
authorhcj <1224667075@qq.com>
Fri, 15 Nov 2024 03:46:29 +0000 (11:46 +0800)
committerhcj <1224667075@qq.com>
Fri, 15 Nov 2024 03:46:29 +0000 (11:46 +0800)
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/Bluetooyhpabpserver.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/Bluetooyhpabpserver.cpp
code/sdk/application/wearable/fd230app/nativeui/callerlog/include/CallerLogModel.h
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallerDisplayView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/CallingView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingView.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/WaitingHintsView.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp

index e6de15a..124f0cb 100644 (file)
@@ -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);
 
 
index 361e924..a696b6d 100644 (file)
@@ -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 */
index 515a179..d3f7ff9 100644 (file)
@@ -46,6 +46,9 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall);
 void UsingPhoneErrorCallback(PhoneServiceErrorType type);\r
 void CAT1_ChangeStatusScreendisplay(int lastStatus);\r
 void InitCallingTimer();\r
+\r
+void calllognameupdate(void);\r
+\r
 namespace OHOS {\r
 \r
 \r
@@ -74,6 +77,11 @@ typedef enum {
         return call_name;\r
     }\r
 \r
+    std::string Getphonenumberpbap(void)\r
+    {\r
+        return call_number;\r
+    }\r
+\r
     void Setphonebname(char *name,uint8_t name_len)\r
     {\r
         call_name.clear();\r
@@ -82,6 +90,12 @@ typedef enum {
         //printf("%s\r\n",call_name.c_str());\r
     }\r
 \r
+    void Setphonenumber(char *number,uint8_t number_len)\r
+    {\r
+        call_number.clear();\r
+        call_number.append(reinterpret_cast<const char*>(number), number_len);\r
+    }\r
+\r
     std::string GetPhoneNumber(void);\r
     void SetoperateNumber(const char *number, char number_len);\r
 \r
@@ -162,7 +176,7 @@ CallSource GetCallSource(void)
         return phoneNumberCAT1END;\r
     }\r
 \r
-\r
+    \r
 \r
 private:\r
     CallerLogModel();\r
@@ -177,6 +191,7 @@ private:
     std::string phoneNumberCAT1; // 4G电话号码\r
     std::string phoneNumberCAT1END; // 4G挂断电话号码\r
     std ::string call_name;\r
+    std ::string call_number;\r
     bool mulitplePhoneStatus{false}; // 判断是否多路通话界面\r
     bool waitingStatus{false}; // 判断是否等待提醒界面\r
     bool volumeStatus{false}; // 判断是否音量界面\r
index b2008b5..efcfb4f 100644 (file)
@@ -124,6 +124,14 @@ static void DisableCallingTimer()
 
 #include "dial_sos_c.h"
 
+void calllognameupdate()
+{
+    if(MainCallingView::GetInstance())
+    {
+        MainCallingView::GetInstance()->updataCallingname();
+    }
+}
+
 /* 状态复位 */
 void StatusReset(void)
 {
index cc778f5..0cf46bf 100644 (file)
@@ -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);
index 7c616b3..31e0f79 100644 (file)
@@ -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());
index feb2ef5..6c4f2fd 100644 (file)
@@ -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");
index 7298a82..0297439 100644 (file)
@@ -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);
index 2aae426..3c800e9 100644 (file)
@@ -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)
     {