电话综合修改,有所改善,但如果太快连续拨打电话易出错
authorhcj <1224667075@qq.com>
Tue, 15 Oct 2024 11:12:23 +0000 (19:12 +0800)
committerhcj <1224667075@qq.com>
Tue, 15 Oct 2024 11:12:23 +0000 (19:12 +0800)
12 files changed:
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230app/nativeui/makephone/src/MainCallingPresenter.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/makephone_notification.cpp
code/sdk/drivers/peripheral/config/include/ConfigModel.h
code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.h
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server_hal.cpp
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp

index a393d01..cb7ef4d 100644 (file)
@@ -23,6 +23,9 @@
 #include "custom_runtime.h"
 #include "MainCallingView.h"
 #include "dial_sos_c.h"
+#include "cat1_ctl.h"
+#include "cat1_server.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -136,7 +139,7 @@ void StatusReset(void)
     NotificationManager::GetInstance()->SetWatchCallStatus(false);
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone);
     DisshakeTimer();
-
+    set_call_hungup_flag(0);
    
 
     // If the call is handling in the notification, the slice is not switched
@@ -175,6 +178,22 @@ static void CallTimerCallbackProc(int data)
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::xxx");
         }
    }
+    if( CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1
+    && NotificationManager::GetInstance()->GetWatchCallStatus()==true)
+   {    
+        if(!volte_voice_state())
+        uapi_cat1_start_volte_voice();
+
+        if(get_call_hungup_flag()>=2)
+        {
+            cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+        }
+        else if(get_call_hungup_flag())
+        {
+            set_call_hungup_flag(get_call_hungup_flag()+1);
+
+        }
+   }
 
 //     if(MainCallingView::GetInstance()->GetScreenView())
 //    {
index f2d4347..95fa5fd 100644 (file)
@@ -230,9 +230,9 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
                     sos_falg_clean();
                 }
 
-                cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+                //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
 
-                cat1_call_hungup();
+                cat1_call_hungup_timer();
                 
 
             }
@@ -249,8 +249,8 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
         {
             if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1)
             {
-                    cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
-                    cat1_call_hungup();
+                    //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+                    cat1_call_hungup_timer();
                     return true;
                 //#endif
 
@@ -278,8 +278,8 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
 
             if (CallerLogModel::GetInstance()->GetCallSource() == CallerLogModel::CallSourceCat1)
             {
-                    cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
-                    cat1_call_hungup();
+                    //cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+                    cat1_call_hungup_timer();
                     
                     return true;
                 //#endif
index 46eaaee..3729a4a 100644 (file)
@@ -360,8 +360,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req)
    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数");
    step_history_save();
    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据");
-   stand_history_save();
-   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
+        stand_history_save();
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据");
    calories_history_save();
    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据");
    distances_history_save();
@@ -999,6 +999,9 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req)
 
     if(strcmp("callfail",call_data)==0)
     {
+        
+        cat1_call_hungup();
+
         cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
         free(call_data);
         return;
index 8149122..c4e6446 100755 (executable)
@@ -695,7 +695,7 @@ void CalldialTimerCallBackProc(int data)
     dail_falg++;
     if(dail_falg>=DIAL_TIME)
     {
-        cat1_call_hungup();
+        cat1_call_hungup_timer();
         cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
     }
    
index fa41ad7..c0bf2fb 100644 (file)
@@ -64,6 +64,7 @@ namespace OHOS
             CONFIGMODEL_ITEM_CUSTOM_DATA_SEX,    //用户数据性别
             CONFIGMODEL_ITEM_CUSTOM_DATA_AGE,    //用户数据年龄
             CONFIGMODEL_ITEM_CUSTOM_DATA_WEARING_MODE,    //用户数据佩戴方式
+
             CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT,    //运动目标步数
             CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES,    //运动目标卡路里
             CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES,    //运动目标站立次数
@@ -333,7 +334,7 @@ namespace OHOS
             {ConfigDataType::DATATYPE_INT,     "goal_calories",             "300"   },// CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES,    //运动目标卡路里  300(kcal)
             {ConfigDataType::DATATYPE_INT,     "goal_standup_times",         "10"    },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES,    //运动目标站立次数 10
             {ConfigDataType::DATATYPE_INT,     "goal_duration",             "30"    },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION,    //运动目标时长   30(分钟)
-            {ConfigDataType::DATATYPE_INT,     "goal_distance",             "8"   },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离   8.0(km)
+            {ConfigDataType::DATATYPE_INT,     "goal_distance",             "3"   },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离   8.0(km)
             {ConfigDataType::DATATYPE_INT,     "goal_step_notification",             "1"   },//CONFIGMODEL_ITEM_SPORTS_GOAL_STEP,  //步数目标
             {ConfigDataType::DATATYPE_INT,     "goal_other_notification",             "1"   },//CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER,    //其他目标
             {ConfigDataType::DATATYPE_BOOL,    "dnotdisturb",              "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭
index 03cf2be..9b362e5 100644 (file)
@@ -334,6 +334,30 @@ static uint32_t VoiceCallSetVolume(uint8_t *para, uint32_t paraLen, char *strCom
     return 0;
 }
 
+static uint32_t VoiceCallcontrol(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+    UNUSED(strCommonCmd);
+    uint8_t argv[PPG_MAX_ARGC][PPG_MAX_ARGV_LEN] = { 0 };
+    uint32_t argc = 0;
+
+    int ret = ConvertCmdToParam(para, paraLen, argv, &argc);
+    if (ret != PPG_SUCCESS) {
+        printf("CAT1TEST ATCMD Convert Command Failed\n");
+        return ERRCODE_FAIL;
+    }
+
+    int32_t linearVolume = atoi((char *)argv[0]);
+    if(linearVolume)
+    {
+        uapi_cat1_start_volte_voice();
+    }
+    else
+    {
+        uapi_cat1_stop_volte_voice();
+    }
+    return 0;
+}
+
 
 
 static const at_cmd_table_t g_cat1_cmd[] = {
@@ -354,6 +378,7 @@ static const at_cmd_table_t g_cat1_cmd[] = {
     { (char *)"AT^CALL_ADD_ADRESSBOOK",      ADD_ADDRESS, (char *)"1" },
     { (char *)"AT^CALL_READ_ADRESSBOOK",      read_ADDRESS, (char *)"1" },
     { (char *)"AT^CALLVOLUME",      VoiceCallSetVolume, (char *)"1" },
+    { (char *)"AT^CALLVOICE",      VoiceCallcontrol, (char *)"1" },
 
 };
 
index 70b417e..01a3830 100644 (file)
@@ -67,15 +67,48 @@ bool uapi_cat1_get_power_stat(void)
    return (  GPIO_LEVEL_HIGH == uapi_gpio_get_output_val(S_AGPIO_L23));
 
 }
-void uapi_cat1_start_volte_voice(void)
+
+static uint8_t cat1_voice=0;
+
+uint8_t volte_voice_state(void)
 {
-    char *argv[]={"start"};
-    VoiceCallVolteSample(1,(const char**)argv);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"volte_voice_state %d \n",cat1_voice);
+    return cat1_voice;
 }
-void uapi_cat1_stop_volte_voice(void)
+
+int32_t uapi_cat1_start_volte_voice(void)
 {
-    char *argv[]={"stop"};
-    VoiceCallVolteSample(1,(const char**)argv);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_cat1_start_volte_voice\n");
+
+    int32_t ret = ERRCODE_FAIL;
+    int32_t argc = 1;
+    uint8_t *argv = (uint8_t *)"start";
+
+    ret = VoiceCallVolteSample(argc, (const char **)&argv);
+    if(ret==0) 
+    cat1_voice=1;
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret %d %d ",ret, cat1_voice);
+    
+    return ret;   
+}
+
+
+int32_t uapi_cat1_stop_volte_voice(void)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_cat1_stop_volte_voice\n");
+
+    int32_t ret = ERRCODE_FAIL;
+    int32_t argc = 1;
+    uint8_t *argv = (uint8_t *)"stop";
+
+    ret = VoiceCallVolteSample(argc, (const char **)&argv);
+    if(ret==0) 
+    cat1_voice=0;
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret %d %d ",ret, cat1_voice);
+
+    return ret;   
+
 }
 
 void uapi_cat1_remove_cat1_vote(void)
index 07d99b2..083799a 100644 (file)
@@ -17,14 +17,18 @@ uint32_t uapi_cat1_power_on(uint32_t pwron);
 /**set resetpin 0/1*/\r
 uint32_t uapi_cat1_reset(uint32_t pwron);\r
 \r
-/**¸´ºÏº¯Êý£¬set powerpin 1 £¬set resetpin 0*/\r
+/**���Ϻ�����set powerpin 1 ��set resetpin 0*/\r
 void power_on_cat1(void);\r
-/**¸´ºÏº¯Êý£¬set powerpin 0 £¬set resetpin 1*/\r
+/**���Ϻ�����set powerpin 0 ��set resetpin 1*/\r
 void power_off_cat1(void);\r
 \r
 void cat1_ring_isr_callback(pin_t pin, uintptr_t param);\r
-void uapi_cat1_start_volte_voice(void);\r
-void uapi_cat1_stop_volte_voice(void);\r
+int32_t uapi_cat1_start_volte_voice(void);\r
+\r
+int32_t uapi_cat1_stop_volte_voice(void);\r
+\r
+uint8_t volte_voice_state(void);\r
+\r
 void uapi_cat1_remove_cat1_vote(void);\r
 void uapi_cat1_add_cat1_vote(void);\r
 void uapi_cat1_wakeup_cat1(uint8_t wakeup);\r
index 9b5fbbd..df9c7fe 100644 (file)
@@ -379,6 +379,7 @@ void udp_send_msg_toCat1(uint8_t cmd,char *content)
     if( sourceAddr.sin_port != 0 ) {
         
         udp_send_response(station_tx_buffer, cmd, content);
+
         if(cmd==UDP_CMD_DIAL_NUMB || cmd== UDP_CMD_ANSWER )
         uapi_cat1_start_volte_voice();
     }
@@ -755,6 +756,37 @@ static int decodeNetStat(char* msg)
     else 
         return -3;
 }
+
+
+static uint8_t call_hungup_flag=0;
+
+
+uint8_t get_call_hungup_flag(void)
+{
+    return call_hungup_flag;
+}
+
+uint8_t set_call_hungup_flag(uint8_t data)
+{
+    call_hungup_flag=data;
+
+    return 0;
+
+}
+
+//先挂断电话,并同时做记号,避免出现实际挂断了,但没有传出挂断消息的情况
+
+void cat1_call_hungup_timer(void)
+{
+    call_hungup_flag++;
+    udp_send_msg_toCat1(UDP_CMD_HUNGUP,"0");
+}
+
+
+
+
+
+
 void cat1_call_hungup(void)
 {
     udp_send_msg_toCat1(UDP_CMD_HUNGUP,"0");
index 196c1db..adef5d6 100644 (file)
@@ -44,6 +44,11 @@ void send_dtfm_number_toCat1(char ch);//发送dtfm
 void send_volte_switch_toCat1(void); //发送VOLTE开关标识到CAT1
 int cat1_handle_call_disconnected(char* phonenum);
 
+uint8_t get_call_hungup_flag(void);
+uint8_t set_call_hungup_flag(uint8_t data);
+
+void cat1_call_hungup_timer(void);
+
 #ifdef __cplusplus
 #if __cplusplus
 }
index 0510731..3148c38 100644 (file)
@@ -64,8 +64,9 @@ static errcode_t cat1msg_event_notify(char* callno)
     CustomEventPublish(TOPIC_EVENT_CAT1_SIGNAL_UPDATE,(uint8_t*)callno,strlen(callno)+1);
     return 0;
 }
-std::string call_number_end;
+//传地址应设置固定内存,否则异进程内存安全没法保证
 
+std::string call_number_end;
 int callend_event_sendmsg_toUI(char* callno)
 {
     /**通过UI事件发送Notify*/
@@ -76,19 +77,23 @@ int callend_event_sendmsg_toUI(char* callno)
     return ERRCODE_SUCC;
 }
 
-
+std::string incomedcall_number_end;
 int incomedcall_event_sendmsg_toUI(char* callno)
 {
     /**通过UI事件发送Notify*/
-    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomed_call_event_notify, callno));
+    incomedcall_number_end=std::string(callno);
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomed_call_event_notify, (char *)incomedcall_number_end.c_str()));
     return ERRCODE_SUCC;
 }
 
+std::string incomingcall_number;
 
 int incomingcall_event_sendmsg_toUI(char* callno)
 {
     /**通过UI事件发送Notify*/
-    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomingcall_event_notify, callno));
+    incomingcall_number=std::string(callno);
+
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomingcall_event_notify, (char *)incomingcall_number.c_str()));
     return ERRCODE_SUCC;
 }
 
index 2584aa9..33ace63 100755 (executable)
@@ -643,7 +643,7 @@ int32_t VoiceCallVolteSample(int32_t argc, const char *argv[])
 
     // will free g_voiceCallVolteContext when voice call volte exit
     MEDIA_INFO_LOG("exit");
-    return 0;
+    return ret;
 }
 
 #ifdef __cplusplus