Merge #1137 into sdk602patch0626 from refs/changes/1137/head
author胡传军 <1224667075@qq.com>
Thu, 10 Oct 2024 02:44:19 +0000 (02:44 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Thu, 10 Oct 2024 02:44:19 +0000 (02:44 +0000)
Code review from 胡传军

* refs/changes/1137/head: (4 commits squashed)

  - 计算器修改,解决double计算精度不够,导致计算出现多余小数位,#963

  - sos增加适配HFP呼叫,呼叫备注显示#933 #932

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into 0626

  - 计算器修改,改为删除仅删除一位 #905 目标同步修改 #921

Signed-off-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1137
code/sdk/application/wearable/fd230app/nativeui/calculator/include/CalculatorModel.h
code/sdk/application/wearable/fd230app/nativeui/calculator/include/CalculatorView.h
code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorModel.cpp
code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/msg_center/include/notify/dial_sos_c.h
code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp

index cbb79ae..9412c33 100644 (file)
@@ -31,6 +31,7 @@ public:
     uint8_t get_stcak_size();
     void  symbol_stack_top_uddata(char data);
     void clean_stack();
+    void symbol_stack_pop(void);
 private:
     CalculatorModel();
     CalculatorModel(const CalculatorModel &);
index 3d27578..cee7cd0 100644 (file)
@@ -66,7 +66,7 @@ private:
     UILabel *number{nullptr};
     UILabelExt *hint{nullptr};
 
-    std::string number_string="";
+    std::string number_string=" ";
 
     UIView::OnClickListener* clickLeftListener{nullptr};
     UIView:: OnDragListener* dragListener{nullptr};
index a161d49..cdcaed1 100644 (file)
@@ -59,6 +59,15 @@ void CalculatorModel:: symbol_stack_top_uddata(char data)
     }
 }
 
+
+void CalculatorModel:: symbol_stack_pop(void)
+{
+    if(!symbolStack.empty())
+    {
+        symbolStack.pop();
+    }
+}
+
 uint8_t CalculatorModel::get_stcak_size()
 {
     return numberStack.size();
index 53eba1b..fb90e38 100644 (file)
@@ -10,6 +10,8 @@
 #include "calculator/include/CalculatorModel.h"
 #include "wearable_log.h"
 #include <math.h>
+#include <iostream>
+#include <iomanip>
 
 namespace OHOS {
 
@@ -241,6 +243,10 @@ void CalculatorView::symbol_text_updata_buf(const char *buf)
     double number_float=strtod(text_buf,NULL);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%lf %s",number_float,text_buf);
 
+    char new_buf_[64]={0};
+    sprintf_s(new_buf_,64,"%.010lf",number_float);
+    number_float=strtod(new_buf_,NULL);
+
     CalculatorModel::GetInstance()->number_push_stack(number_float);
 
     if( CalculatorModel::GetInstance()->get_stcak_size()>=2)
@@ -279,7 +285,7 @@ void CalculatorView::symbol_text_updata_single_buf(const char *buf)
 
     char new_buf[64]={0};
 
-    const char*text_buf=number_string.c_str();
+    char*text_buf=(char *)number_string.c_str();
    
     double number_float=strtod(text_buf,NULL);
     if(buf[0]=='C')
@@ -339,12 +345,22 @@ void CalculatorView::symbol_text_updata_single_buf(const char *buf)
     }
     else if (buf[0]=='D')
     {
-        number_float=0;
-        sprintf_s(new_buf,16,"%.00lf",number_float);
-
-        number_string=new_buf;
-        number->SetText(new_buf);
-        number_falg=2;
+        // number_float=0;
+        // sprintf_s(new_buf,16,"%.00lf",number_float);
+        text_buf[number_string.length()-1]='\0';
+        number_string=text_buf;
+        number->SetText(text_buf);
+        if(number_falg==0)
+        {
+            CalculatorModel::GetInstance()->symbol_stack_pop();
+            number_falg=1;
+        }
+        else 
+        {
+            number_falg=1;
+        }
+        
+       
         RootView::GetInstance()->Invalidate();
     }
 
@@ -362,13 +378,24 @@ void CalculatorView::symbol_text_updata_calculate_buf(const char *buf)
 
     char new_buf[64]={0};
     const char*text_buf=number_string.c_str();
+    double number_float=0;
 
-    double number_float=strtod(text_buf,NULL);
-
-    CalculatorModel::GetInstance()->number_push_stack(number_float);
+    if(text_buf[0]>='0' && text_buf[0]<='9')
+    {
+        number_float=strtod(text_buf,NULL);
+        char new_buf_[64]={0};
+        sprintf_s(new_buf_,64,"%.010lf",number_float);
+        number_float=strtod(new_buf_,NULL);
 
+        CalculatorModel::GetInstance()->number_push_stack(number_float);
+    }
+    
     number_float =CalculatorModel::GetInstance()->calculate_stack();
 
+    char new_buf_[64]={0};
+    sprintf_s(new_buf_,64,"%.010lf",number_float);
+    number_float=strtod(new_buf_,NULL);
+
     double number_float_=number_float;
     int decimal_places = 0;
     double frac;
index 754e78a..aafc868 100644 (file)
@@ -118,6 +118,8 @@ static void DisableCallingTimer()
     }
 }
 
+#include "dial_sos_c.h"
+
 /* 状态复位 */
 void StatusReset(void)
 {
@@ -134,12 +136,15 @@ void StatusReset(void)
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone);
     DisshakeTimer();
 
+   
+
     // If the call is handling in the notification, the slice is not switched
     if (!CallerLogModel::GetInstance()->GetNotifyFlag())
     {
         PhoneServiceScreenCtr(false);
         if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL)
         {
+           
             NativeAbility::GetInstance().Back_CountSlice_make_phone();
         }
        
@@ -541,6 +546,11 @@ static void NonWatchFinishHandle(int laststatus)
     if (GetCurrCallNum() == 0) {
         g_phoneStatus = PHONE_SINGLE_STATUS;
     }
+
+    if(get_falg_SOS())
+    {
+        sos_falg_add();
+    }
 }
 
 static void WatchFinishHandle(void)
@@ -567,6 +577,11 @@ static void WatchFinishHandle(void)
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "??????????????????????");
     }
     g_phoneStatus = PHONE_SINGLE_STATUS;
+
+    if(get_falg_SOS())
+    {
+        sos_falg_add();
+    }
 }
 
 void CAT1_ChangeStatusScreendisplay(int lastStatus)
@@ -924,6 +939,8 @@ void CallerLogModel::SetWaitingStatus(bool status)
 void CallerLogModel::SetCallStatus(bool status)
 {
     callStatus = status;
+    if(status)
+    sos_falg_clean();
 }
 
 bool CallerLogModel::GetCallStatus()
index 9954351..578a873 100644 (file)
@@ -169,6 +169,19 @@ namespace OHOS
 
     bool get_phone_addrss_name(char *name,const char *phone,uint8_t *sex)
     {
+
+        for(int i=0;i<get_sos_number_count();i++)
+        {
+            if(addrss_strcmp((char *)phone,sos_number_data[i].number))
+            {
+                strcpy_s(name,NAME_LEN+1,sos_number_data[i].name);
+                if(sex!=NULL)
+                *sex= sos_number_data[i].sex==0 ? 1:2;
+                return true;
+            }
+        }
+
+
         for(int i=0;i<addressbook_t.num;i++)
         {
             //if(strcmp(phone,addressbook_t.Contact_t[i].phone_number_t[0].number)==0)
@@ -191,6 +204,7 @@ namespace OHOS
                 }   
             }
         }
+       
         strcpy_s(name,NAME_LEN+1,"未知");
         return false;
     }
index b3c44e5..431af41 100644 (file)
@@ -2430,6 +2430,8 @@ void SetsteptargetParamCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota
 \r
         printf("设置步数:%d %d %d %d \r\n",targetStep,ringOn,vibration,notify);\r
 \r
+        set_goal_stepcount(targetStep);\r
+        \r
 \r
         if(ringOn &&vibration &&  notify)\r
         set_goal_step_notification(1);\r
index 98ce870..d15f37b 100755 (executable)
@@ -50,7 +50,7 @@ static uint8_t sos_dail_falg=0;
 
 #define SOS_TEST_FLAG 0
 
-#define SOS_HFP_FALG 0
+#define SOS_HFP_FALG 1
 
 #define DIAL_TIME 30
 
@@ -66,7 +66,7 @@ void sos_falg_add(void)
 {
     if(sos_dail_falg)
     {
-
+        printf("sos dial %d\r\n",sos_dail_falg);
         #if SOS_TEST_FLAG
         if(1)
         #else
@@ -86,7 +86,7 @@ void sos_falg_add(void)
              calldial_event_sendmsg_toUI("SOS");
         }
         sos_dail_falg++;
-        if(sos_dail_falg>=9)
+        if(sos_dail_falg>=OHOS::get_sos_number_count()*3)
         {
             sos_dail_falg=0;
         }
@@ -112,7 +112,7 @@ void start_SOS_phone_dail(void)
     #if SOS_HFP_FALG
     else if(uapi_hfp_connect_state())
     {
-        DialCall((unsigned char *)sos_dail_buf,osal_strlen((const char*)sos_dail_buf));
+        DialCall((unsigned char *)OHOS::get_sos_number(0),osal_strlen((const char*)OHOS::get_sos_number(0)));
         sos_dail_falg=1;
     }
     #endif
@@ -545,31 +545,31 @@ static void WatchFinishHandle(void)
 {
     if (NotificationManager::GetInstance()->GetWatchCallStatus()) 
     {
-        if(get_falg_SOS())
+       if(get_falg_SOS())
         {
             addcalllog();
             sos_falg_add();
         }
         else
         {
-            if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)
-            {
-                addcalllog();
-            }
-            else if(uapi_dev_runtime_get_train_status() || transmittingISShow())
-            {
-                addcalllog();
-                StatusReset();
-            }
-            else
-            {
-                uapi_cat1_stop_volte_voice();
-
-                addcalllog();
-                StatusReset();
-            }   
+        if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)
+        {
+            addcalllog();
         }
-       
+        else if(uapi_dev_runtime_get_train_status() || transmittingISShow())
+        {
+            addcalllog();
+            StatusReset();
+        }
+        else
+        {
+            uapi_cat1_stop_volte_voice();
+
+            addcalllog();
+            StatusReset();
+}   
+        }   
+               
     }
     DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY);
 }
@@ -614,7 +614,6 @@ void cat1_phone_state_change_cb(uint8_t state)
             if(call_stat==2)
             call_stat=1;
             PhoneServiceScreenCtr(true);
-            sos_falg_clean();
             WatchActiveHandle();
             break;
         case OPERATE_PHONE_HOLD: