修复 因通讯录协议数据改动导致的备注不生效BUG
authorhcj <1224667075@qq.com>
Tue, 10 Sep 2024 07:43:56 +0000 (15:43 +0800)
committerhcj <1224667075@qq.com>
Tue, 10 Sep 2024 07:43:56 +0000 (15:43 +0800)
code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp

index 90254c3..4d317e3 100644 (file)
@@ -130,11 +130,49 @@ namespace OHOS
         // }
     }
 
+    bool addrss_strcmp(char *buf_1,char *buf_2)
+    {
+        int len= osal_strlen(buf_1)>osal_strlen(buf_2)? osal_strlen(buf_1):osal_strlen(buf_2);
+        int j=0;
+        char *p_1=NULL;
+        char *p_2=NULL;
+        p_1=osal_strlen(buf_1)>=osal_strlen(buf_2)? (buf_1):(buf_2);
+        p_2=osal_strlen(buf_1)<osal_strlen(buf_2)?  (buf_1):(buf_2);
+        while (*p_2 !='\0')
+        {
+            if(*p_1==' ')
+            {
+                p_1++;
+                continue;
+            }
+            if(*p_2==' ')
+            {
+                p_2++;
+                continue;
+            }
+            if(*p_2!=*p_1)
+            {
+                return false;
+            }
+            else
+            {
+                p_1++;
+                p_2++;
+            }
+        }
+        if(*p_2=='\0' && *p_1=='\0')
+        return true;
+        else
+        return false;
+        
+    }
+
     bool get_phone_addrss_name(char *name,const char *phone,uint8_t *sex)
     {
         for(int i=0;i<addressbook_t.num;i++)
         {
-            if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
+            //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
+            if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[0].number))
             {
                 strcpy(name,addressbook_t.Contact_t[i].name);
                 if(sex!=NULL)
@@ -143,7 +181,8 @@ namespace OHOS
             }
             else if(phone,addressbook_t.Contact_t[i].phone_num==2)
             {
-                if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0)
+                //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[1].number)==0)
+                if(addrss_strcmp((char *)phone,addressbook_t.Contact_t[i].phone_number_t[1].number))
                 {
                     strcpy(name,addressbook_t.Contact_t[i].name);
                     if(sex!=NULL)