4G电话修改,通话记录有BUG
authorhcj <1224667075@qq.com>
Wed, 3 Sep 2025 06:59:46 +0000 (14:59 +0800)
committerhcj <1224667075@qq.com>
Wed, 3 Sep 2025 06:59:46 +0000 (14:59 +0800)
49 files changed:
code/sdk/application/wearable/fd230/nativeabilityfwk/src/Ability.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/include/CallerLogModel.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/callerlog/src/CallerLogModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/makephone/src/MainCallingView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/DialingMethodPresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/MainPhoneView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phone/src/PhoneCallPresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phoneservice/src/PhoneAGService.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phoneservice/src/PhoneAudio.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c
code/sdk/application/wearable/fd230/service/msg_center/CMakeLists.txt
code/sdk/application/wearable/fd230/service/msg_center/include/notify/phone_crt.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/fd230/service/msg_center/src/notify/phone_crt.cpp [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/config.py
code/sdk/middleware/services/media/foundation/sample/wrapper/CMakeLists.txt
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_bluetooth_wrapper.cpp [new file with mode: 0644]
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.h
code/sdk/zhihui/4g/CMakeLists.txt
code/sdk/zhihui/4g/cat1Service/CMakeLists.txt
code/sdk/zhihui/4g/cat1Service/Service/cat1_server.c
code/sdk/zhihui/4g/cat1Service/Service/cat1_server_hal.c
code/sdk/zhihui/4g/cat1Service/include/cat1_porting.h
code/sdk/zhihui/4g/cat1Service/include/cat1_server_hal.h
code/sdk/zhihui/4gTest/cat1_porting.c
code/sdk/zhihui/4gTestcpp/CMakeLists.txt [new file with mode: 0644]
code/sdk/zhihui/4gTestcpp/cat1_UI_hal.cpp [new file with mode: 0644]
code/sdk/zhihui/4gTestcpp/cat1_UI_hal.h [new file with mode: 0644]
code/sdk/zhihui/AI/AImain/AI_mian.c
code/sdk/zhihui/AI/AImain/uapi_ai_function.h
code/sdk/zhihui/AI/AIsdk/CMakeLists.txt
code/sdk/zhihui/AI/AIsdk/include/main_include.h
code/sdk/zhihui/AI/AIsdk/include/zj_syscall.h [new file with mode: 0644]
code/sdk/zhihui/AI/AIsdk/include/zj_syscall_prv.h [new file with mode: 0644]
code/sdk/zhihui/AI/AIsdk/include/zj_system.h
code/sdk/zhihui/AI/AIsdk/lib/libai.c [new file with mode: 0644]
code/sdk/zhihui/AI/AIsdk/lib/libcommon.a
code/sdk/zhihui/AI/AIsdk/lib/libcos.a
code/sdk/zhihui/AI/AIsdk/lib/libthirdparty.a
code/sdk/zhihui/AI/AIsyscall/CMakeLists.txt
code/sdk/zhihui/AI/AIsyscall/src/syscall.c
code/sdk/zhihui/AI/CMakeLists.txt
code/sdk/zhihui/CMakeLists.txt
code/sdk/zhihui/ai/example/CMakeLists.txt
code/sdk/zhihui/services/ble_service/blemoder/CMakeLists.txt
code/sdk/zhihui/utils/custom_cmd_service.c

index 9c21116..a0966f0 100644 (file)
@@ -290,4 +290,29 @@ void Ability::BackToPreSlice()
     PageTransitionMgr::GetInstance().BeginBackTransition(TransitionCaller::CHANGE_SLICE, target);
     SwitchSlice(sliceId, pageId);
 }
+
+bool Ability::Back_CountSlice_make_phone(const TransitionType transitionId,
+        const uint16_t priority ) { 
+        if(!backStack_.empty())
+        {
+            // 如果此时 backStack_ 栈不为空,取出栈顶的切片 ID ,并调用 ChangeSlice 切换到该切片,返回 true 。
+            uint16_t preSlice = backStack_.top();
+            backStack_.pop();
+
+            #ifdef FD230
+            if(preSlice!=VIEW_INCOMING_CALL)
+            ChangeSlice(preSlice);
+            else
+            ChangeSlice(defaultTargetId_);
+            #endif
+            return true;
+        }
+        else
+        {
+            //如果 backStack_ 栈为空,切换到默认切片,返回 false 。
+            ChangeSlice(defaultTargetId_);
+            return false; // 返回false表示无前一个slice,退回到默认slice
+        }
+    }
+
 } // namespace OHOS
index e533720..f156cb8 100644 (file)
@@ -46,7 +46,8 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall);
 void UsingPhoneErrorCallback(PhoneServiceErrorType type);\r
 void CAT1_ChangeStatusScreendisplay(int lastStatus);\r
 void InitCallingTimer();\r
-\r
+void DisshakeTimer();\r
+void InitshakeTimer();\r
 void calllognameupdate(void);\r
 \r
 void Call_headset_state_updata(int data);\r
index eb98835..a3a3040 100644 (file)
@@ -23,6 +23,8 @@
 #include "custom_runtime.h"
 #include "makephone/include/MainCallingView.h"
 
+// #include "PhoneAGService.h"
+
 #ifdef FD230_650
 #include "dial_sos_c.h"
 #endif
 #ifdef SUPPORT_CAT1_SERVICE
 #include "cat1_ctl.h"
 #include "cat1_server.h"
+#include "cat1_porting.h"
 #endif
 #include "alarm/include/AlarmClockModel.h"
 
-#ifdef SUPPORT_PHONE_SERVICE
+// #ifdef SUPPORT_PHONE_SERVICE
 #include "phoneservice/include/PhoneAGService.h"
-#endif
+// #endif
 
 #include "custom_save_runtime.h"
 
@@ -109,7 +112,7 @@ static void SetPriorityNumber()
 }
 
 
-static void DisshakeTimer()
+void DisshakeTimer()
 {
     if (g_shake != nullptr) {
         osStatus_t ret = osTimerDelete(g_shake);
@@ -175,13 +178,13 @@ void StatusReset(void)
     // If the call is handling in the notification, the slice is not switched
     //if (!CallerLogModel::GetInstance()->GetNotifyFlag())
 
-    #ifdef FD230_650
+    // #ifdef FD230_650
     if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)
     {
         if(headset_SCO_Is_connect()==false)
         {
             #ifdef SUPPORT_CAT1_HFP_AG_SERV
-            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_AUDIO_END, nullptr, 0);
+            // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_AUDIO_END, nullptr, 0);
             #endif
             do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
         }
@@ -190,7 +193,7 @@ void StatusReset(void)
             #ifdef SUPPORT_CAT1_HFP_AG_SERV
             if(headset_Is_connect())
             {
-                cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLENDED,NULL);
+                // cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLENDED,NULL);
             }
             #endif
         }
@@ -213,7 +216,7 @@ void StatusReset(void)
        
     }
 
-    #endif
+    // #endif
     // } else {
     //     g_isWatchCallView = false;
     // }
@@ -251,17 +254,17 @@ static void CallTimerCallbackProc(int data)
             if(!MainCallingView::GetInstance()->GetDisplayGroup()->IsVisible())
             {
                
-                if( headset_SCO_Is_connect()==false && volte_voice_state()!=1)
+                if( headset_SCO_Is_connect()==false && cat1_api_get_cat1_volte_voice_state()!=1)
                 {
-                    if(volte_voice_state()==2)
+                    if(cat1_api_get_cat1_volte_voice_state()==2)
                     {
                         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
                     }
                     do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
                 }
-                if(headset_SCO_Is_connect()==true && volte_voice_state()!=2)
+                if(headset_SCO_Is_connect()==true && cat1_api_get_cat1_volte_voice_state()!=2)
                 {
-                    if(volte_voice_state()==2)
+                    if(cat1_api_get_cat1_volte_voice_state()==2)
                     {
                         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
                     }
@@ -351,7 +354,7 @@ void InitCallingTimer()
     }
 }
 
-static void InitshakeTimer()
+void InitshakeTimer()
 {
     if (g_shake != nullptr) {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer already exists!!");
index 1da1807..b75fa2a 100644 (file)
@@ -34,9 +34,9 @@
 
 #include "NativeAbility.h"
 
-#ifdef FD230_650
+// #ifdef FD230_650
 #include "dial_sos_c.h"
-#endif
+// #endif
 
 #include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h"
 namespace OHOS {
@@ -193,7 +193,7 @@ bool MainCallingPresenter::HintsHandupClick()
 
 bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
 {
-    #ifdef FD230_650
+    // #ifdef FD230_650
     UNUSED(event);
      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",view.GetViewId());
     if (!InitPointerValue()) {
@@ -328,8 +328,6 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MakephoneNotify 11111111 ");
             cat1_call_answer();
-            //incomedcall_event_sendmsg_toUI("ok");
-
             return true;
 
             //#endif
@@ -447,7 +445,7 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event)
        NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE);
     }
 
-#endif
+// #endif
     return true;
 }
 
index 2710198..8f16e2e 100644 (file)
@@ -9,9 +9,13 @@
 #include "makephone/include/MainCallingView.h"
 #include "makephone/include/MainCallingPresenter.h"
 #include "callerlog/include/CallerLogModel.h"
+#include "NativeRegisterManager.h"
 
 namespace OHOS {
 static MainCallingView *g_pMainView = nullptr;
+
+REGIST_SLICE(VIEW_INCOMING_CALL, MainCallingView, MainCallingPresenter);
+
 MainCallingView::MainCallingView()
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCallingView::MainCallingView");
index 9e1dc32..8f84625 100644 (file)
@@ -17,7 +17,8 @@
 #include "custom_runtime.h"
 #ifdef SUPPORT_CAT1_SERVICE
 #include "cat1_ctl.h"
-#include "cat1_server_hal.h"
+#include "cat1_UI_hal.h"
+#include "cat1_pub_api.h"
 #endif
 #include "NativeRegisterManager.h"
 
@@ -50,7 +51,7 @@ namespace OHOS
 
     bool DialingMethodPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
-#ifdef FD230_650
+// #ifdef FD230_650
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnClick");
         std::string curViewId = view.GetViewId();
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str());
@@ -60,17 +61,21 @@ namespace OHOS
 
             if(get_address_number())
             {
-                if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0)
+                // if(uapi_cat1_get_power_stat()==0 || 
+                if(uapi_dev_runtime_get_cat1_simstat()==0)
                 {
                     DialingMethodView::GetInstance()->fail_Dial_show(0);
                 }
                 else
-                calldial_event_sendmsg_toUI(get_address_number());
+                {
+                    cat1_UI_call_dial(get_address_number());
+                }
                 
             }
             else
             {
-                if(uapi_cat1_get_power_stat()==0 || uapi_dev_runtime_get_cat1_simstat()==0)
+                // if(uapi_cat1_get_power_stat()==0 || 
+                if(uapi_dev_runtime_get_cat1_simstat()==0)
                 {
                     DialingMethodView::GetInstance()->fail_Dial_show(0);
                 }else
@@ -126,7 +131,7 @@ namespace OHOS
             DialingMethodView::GetInstance()->fail_Dial_hid(2);
         }
         
-#endif
+// #endif
         return true;
     }
 
index 9887e0e..da464a5 100644 (file)
@@ -196,7 +196,7 @@ namespace OHOS
         buttonconfig.w = 390;
         buttonconfig.h = 104;
         buttonconfig.ViewId="xxxx";
-        buttonconfig.str="xxx";
+        buttonconfig.str="ssss";
 
         UIView::OnClickListener *ButtonOnclickListen = static_cast<UIView::OnClickListener *>(MainPhonePresenter::GetInstance());
         if (ButtonOnclickListen == nullptr)
@@ -306,6 +306,7 @@ namespace OHOS
 
         char buf[20]={0};
         sprintf_s(buf,20,"%s",(const char*)(data)->tel);
+         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallLOGListitemView::%s",(const char*)(data)->tel);
         char name[NAME_LEN+1]={0};
         if(get_phone_addrss_name(name,buf,NULL))
         {
index 4c6784e..a6112dc 100644 (file)
@@ -6,7 +6,8 @@
 #include "phone/include/PhoneCallPresenter.h"\r
 #include <iostream>\r
 #ifdef SUPPORT_CAT1_SERVICE\r
-#include "cat1_server_hal.h"\r
+#include "cat1_UI_hal.h"\r
+#include "cat1_porting.h"\r
 #endif\r
 #include "phoneservice/include/PhoneService.h"\r
 #include "phone/include/PhoneCallView.h"\r
@@ -131,10 +132,6 @@ namespace OHOS
         // 根据控件id处理点击事件\r
         if (strcmp(viewId, BUTTONCALL) == 0)\r
         {\r
-            // 拨号键\r
-            //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING);\r
-            //calldial_event_sendmsg_toUI((char *)phoneNumber.c_str());\r
-            //PhoneCallView::GetInstance()->container_child_SetVisible(true);\r
 \r
             if(phoneNumber.length()<=2)\r
             {\r
@@ -144,9 +141,9 @@ namespace OHOS
             if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGWATCHSIM)\r
             {\r
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGWATCHSIM");\r
-                #ifdef FD230_650\r
-                calldial_event_sendmsg_toUI((char *)phoneNumber.c_str());\r
-                #endif\r
+                // #ifdef FD230_650\r
+                cat1_UI_call_dial((char *)phoneNumber.c_str());\r
+                // #endif\r
 \r
             }\r
             else if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGPHONE)\r
index 8c0592a..84a24fa 100644 (file)
-// /*
-//  * Copyright (c) @CompanyNameMagicTag 2021. All rights reserved.
-//  * Description: This module include test function of BT HFP Service module.
-//  */
-
-// #include "phoneservice/include/PhoneAGService.h"
-// #include <soc_osal.h>
-// #include <td_base.h>
-// #include <stdlib.h>
-// #include "securec.h"
-// #include "errcode.h"
-// #include "bts_br_gap.h"
-// #include "bts_hfp_ag.h"
-// // #include "sample_common.h"
-// #ifdef MEMORY_MINI
-// #include "audio_manager.h"
-// #else
-// // #include "sdk_private.h"
-// // /home/hcj/FD230/code/sdk/protocol/bt/host/bt/bts/brandy_service/bt_audio_wrapper/bt_audio_manager_wrapper.h
-// // #include "bt_audio_manager_wrapper.h"
-// #endif
+/*
+ * Copyright (c) @CompanyNameMagicTag 2021. All rights reserved.
+ * Description: This module include test function of BT HFP Service module.
+ */
+
+#include "phoneservice/include/PhoneAGService.h"
+#include <soc_osal.h>
+#include <td_base.h>
+#include <stdlib.h>
+#include "securec.h"
+#include "errcode.h"
+#include "bts_br_gap.h"
+#include "bts_hfp_ag.h"
+// #include "sample_common.h"
+#ifdef MEMORY_MINI
+#include "audio_manager.h"
+#else
+// #include "sdk_private.h"
+// /home/hcj/FD230/code/sdk/protocol/bt/host/bt/bts/brandy_service/bt_audio_wrapper/bt_audio_manager_wrapper.h
+// #include "bt_audio_manager_wrapper.h"
+#endif
+
+#include "wearable_log.h"
+#include "common_def.h"
 
-// #include "wearable_log.h"
-// #include "common_def.h"
 // #include "PhoneAudio.h"
-// #include "cat1_ctl.h"
-// #include "bluetooth/include/BluetoothHeadsetEvent.h"
+#include "cat1_ctl.h"
+#include "bluetooth/include/BluetoothHeadsetEvent.h"
 
-// #include "phoneservice/include/PhoneServiceC.h"
-// #include "notification_manager.h"
+#include "phoneservice/include/PhoneServiceC.h"
+#include "notification_manager.h"
 
 // #include "PhoneService.h"
-// #include "callerlog/include/CallerLogModel.h"
-// #include "custom_utils.h"
-// #include "voice_call_volte_sample_wrapper.h"
-// #include "bluetooth/include/BluetoothModel.h"
-// #include "BluetoothDeviceListView.h"
-// #include "ui_list.h"
-
-
-// #define SAMPLE_HFP_TASK_STACK_SIZE 0x1600
-// #define SAMPLE_HFP_TASK_PRI 20
-// #define HFP_MEDIA_STATUS_DEINIT 0
-// #define HFP_MEDIA_STATUS_INIT 1
-// #define HFP_MEDIA_STATUS_START 2
-// #define HFP_MEDIA_FLAG_IDLE 0
-// #define HFP_MEDIA_FLAG_BUSY 1
-
-// #define HFP_AG_IND_SIGNAL_DEFAULT 3
-// #define HFP_AG_IND_BATTERY_DEFAULT 5
-
-// typedef enum {
-//     SAMPLE_HFP_AG_CMD_INIT = 0,                          /* AG初始化 */
-//     SAMPLE_HFP_AG_CMD_DEINIT,                            /* AG去初始化 */
-//     SAMPLE_HFP_AG_CMD_REG_CALLBACK,                      /* 注册回调 */
-//     SAMPLE_HFP_AG_CMD_CONN_HFP,                          /* HFP连接 */
-//     SAMPLE_HFP_AG_CMD_DISCONN_HFP,                       /* HFP断开连接 */
-//     SAMPLE_HFP_AG_CMD_CONN_SCO = 5,                      /* 建立SCO连接 */
-//     SAMPLE_HFP_AG_CMD_DISCONN_SCO,                       /* 断开SCO连接 */
-//     SAMPLE_HFP_AG_CMD_GET_DEV_CONN_STATE,                /* 获取设备Profile连接状态 */
-//     SAMPLE_HFP_AG_CMD_GET_SCO_CONN_STATE,                /* 获取SCO连接状态 */
-//     SAMPLE_HFP_AG_CMD_ANSWER_CALL,                       /* 接听电话 */
-//     SAMPLE_HFP_AG_CMD_FINISH_CALL = 10,                  /* 挂断电话 */
-//     SAMPLE_HFP_AG_CMD_SET_VOLUME,                        /* 设置扬声器/麦克风音量 */
-//     SAMPLE_HFP_AG_CMD_SEND_INCOMING_EVENT,               /* 发送来电事件 */
-//     SAMPLE_HFP_AG_CMD_SEND_NETWORK_EVENT,                /* 发送网络事件 */
-//     SAMPLE_HFP_AG_CMD_SEND_CALL_LIST,                    /* 发送通话列表 */
-//     SAMPLE_HFP_AG_CMD_SEND_SUBSCRIBER_NUMBER = 15,       /* 发送订阅号码信息 */
-//     SAMPLE_HFP_AG_CMD_SEND_BATTERY_CHARGE,               /* 发送电量信息 */
-//     SAMPLE_HFP_AG_CMD_SEND_CMEE_ERROR,                   /* 发送扩展错误码信息 */
-//     SAMPLE_HFP_AG_CMD_SEND_NETWORK_OPERATOR,              /* 发送运营商信息 */
-//     SAMPLE_HFP_AG_CMD_SEND_INDICATOR_VAL,                 /* 发送指示器值 */
-//     SAMPLE_HFP_AG_CMD_ORIGINATE_CALL,                     /* 呼出电话 */
-// } sample_hfp_ag_cmd_id;
-
-// typedef void (*hfp_ag_sample_cmd_handle_func)(const char **params, int32_t params_cnt);
-
-// typedef struct {
-//     sample_hfp_ag_cmd_id id;
-//     hfp_ag_sample_cmd_handle_func func;
-// } sample_hfp_ag_hdl_info;
-
-// static hfp_cind_info_t g_sample_hfp_cind_info = {0};
-
-
-// static bd_addr_t AG_bd_addr={0};
-
-
-// static void sample_hfp_ag_print_addr(const bd_addr_t *bd_addr)
-// {
-//     if (bd_addr != NULL) {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"addr: %02x:%02x:**:**:**:%02x ",
-//             bd_addr->addr[5], bd_addr->addr[4], bd_addr->addr[0]); /* addr 只打印0,4,5位 */
-//     }
-// }
-
-// static int32_t g_hfp_media_status = 0;
-// static int32_t g_hfp_media_flag = 0;
-
-
-// static AudioCodecFormat g_hfp_codec = mSBC;
-// static int32_t g_hdl_up_mic = -1;
-// static int32_t g_hdl_up_sco = -1;
-// static int32_t g_hdl_dn_spk = -1;
-// static int32_t g_hdl_dn_sco = -1;
-// static int32_t g_hdl_up_modem = -1;
-// static int32_t g_hdl_dn_modem = -1;
-
-
-// static int8_t  AG_connect_state=0;
-
-
-// #ifndef MEMORY_MINI
-// static int32_t audio_stream_init(void)
-// {
-//     /* 请求音频焦点 */
-//     /* deactive响铃时申请的焦点后,重新申请通话焦点 */
-//     audio_manager_activate_interrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
-//     audio_manager_set_device_connection_state(IN_BLUETOOTH_SCO, AUDIO_DEVICE_CONNECTED);
-//     audio_manager_set_device_connection_state(OUT_BLUETOOTH_SCO, AUDIO_DEVICE_CONNECTED);
-//     audio_manager_set_device_connection_state(IN_MODEM_HEADSET, AUDIO_DEVICE_CONNECTED);
-//     audio_manager_set_device_connection_state(OUT_MODEM_HEADSET, AUDIO_DEVICE_CONNECTED);
-
-//     g_hdl_up_sco = audio_stream_in_init(AUDIO_UP_LINK, g_hfp_codec);
-//     g_hdl_up_modem = audio_stream_out_init(AUDIO_UP_LINK, g_hfp_codec);
-//     g_hdl_dn_sco = audio_stream_out_init(AUDIO_DOWN_LINK, g_hfp_codec);
-//     g_hdl_dn_modem = audio_stream_in_init(AUDIO_DOWN_LINK, g_hfp_codec);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"%d",g_hfp_codec);
-//     return 0;
-// }
-
-// static int32_t establish_audio_stream_pipeline(void)
-// {
-//     uint32_t modem_out_shm_id = 0;
-//     uint32_t modem_in_shm_id = 0;
-
-//     audio_stream_in_start(g_hdl_dn_modem);
-//     audio_stream_out_start(g_hdl_dn_sco);
-//     audio_stream_in_get_channel_id(g_hdl_dn_modem, &modem_in_shm_id);
-//     audio_stream_out_attach_frontend(g_hdl_dn_sco, modem_in_shm_id);
-//     audio_stream_in_start(g_hdl_up_sco);
-//     audio_stream_out_start(g_hdl_up_modem);
-//     audio_stream_out_get_channel_id(g_hdl_up_modem, &modem_out_shm_id);
-//     audio_stream_in_attach_backend(g_hdl_up_sco, modem_out_shm_id);
-
-//     return 0;
-// }
-
-// static int32_t abrogation_audio_stream_pipeline(void)
-// {
-//     /* 销毁上下行通路 */
-//     audio_stream_in_stop(g_hdl_up_sco);
-//     audio_stream_in_deinit(g_hdl_up_sco);
-//     audio_stream_out_stop(g_hdl_up_modem);
-//     audio_stream_out_deinit(g_hdl_up_modem);
-//     audio_stream_out_stop(g_hdl_dn_sco);
-//     audio_stream_out_deinit(g_hdl_dn_sco);
-//     audio_stream_in_stop(g_hdl_dn_modem);
-//     audio_stream_in_deinit(g_hdl_dn_modem);
-//     audio_manager_set_device_connection_state(IN_BLUETOOTH_SCO, AUDIO_DEVICE_DISCONNECTED);
-//     audio_manager_set_device_connection_state(OUT_BLUETOOTH_SCO, AUDIO_DEVICE_DISCONNECTED);
-//     audio_manager_set_device_connection_state(IN_MODEM_HEADSET, AUDIO_DEVICE_DISCONNECTED);
-//     audio_manager_set_device_connection_state(OUT_MODEM_HEADSET, AUDIO_DEVICE_DISCONNECTED);
-//     /* 释放音频焦点 */
-//     audio_manager_deactivate_interrupt();
-//     audio_manager_deinit();
-
-//     return 0;
-// }
-// #endif
-
-
-
-
-// static int32_t sample_audio_init_start_task_body(const void *data)
-// {
-
-//     unused(data);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample_audio_init_start enter\n");
-//     while ((g_hfp_media_flag != HFP_MEDIA_FLAG_IDLE) || (g_hfp_media_status != HFP_MEDIA_STATUS_DEINIT)) {
-//         osal_msleep(1);
-//     }
-//     /* 设置媒体状态繁忙 */
-//     g_hfp_media_flag = HFP_MEDIA_FLAG_BUSY;
-//     int ret;
-//     audio_stream_init();
-
-//     /* Init success */
-//     g_hfp_media_status = HFP_MEDIA_STATUS_INIT;
-
-//     /* 建立电话上下行通路 */
-//     establish_audio_stream_pipeline();
-
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample_audio_init_start end\n");
-//     /* Start success */
-//     g_hfp_media_status = HFP_MEDIA_STATUS_START;
-//     g_hfp_media_flag = HFP_MEDIA_FLAG_IDLE;
-//     return 0;
-// }
-
-// static int32_t sample_audio_deinit_task_body(const void *data)
-// {
-//     unused(data);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample_audio_deinit enter\n");
-//     while ((g_hfp_media_flag != HFP_MEDIA_FLAG_IDLE) || (g_hfp_media_status != HFP_MEDIA_STATUS_START)) {
-//         osal_msleep(1);
-//     }
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample_audio_deinit start\n");
-//     /* 设置媒体状态繁忙 */
-//     g_hfp_media_flag = HFP_MEDIA_FLAG_BUSY;
-//     abrogation_audio_stream_pipeline();
-
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample_audio_deinit end\n");
-//     /* Deinit success */
-//     g_hfp_media_status = HFP_MEDIA_STATUS_DEINIT;
-//     g_hfp_media_flag = HFP_MEDIA_FLAG_IDLE;
-//     return 0;
-// }
-
-// static void sample_hfp_ag_set_spk_volume(uint8_t volume)
-// {
-
-//     /* vol range [0, 100] */
-//     int32_t vol = volume * SAMPLE_HFP_MEDIA_VOL_LEVEL / SAMPLE_HFP_PROF_VOL_LEVEL;
-//     audio_manager_set_volume(AUDIO_STREAM_VOICE_CALL_VOLTE, vol);
-
-// }
-
-
-
-// static void sample_hfp_ag_conn_state_changed_callback(const bd_addr_t *bd_addr, profile_connect_state_t state)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"state: %d\n", state);
-//     //如果触发连接为电话状态,自动切到电话
-//     if(state==PROFILE_STATE_CONNECTED)
-//     {
-//         if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
-//         && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
-//         {
-//             // cat1_connect_sco_();
-//             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"电话状态\n");
-//             uint8_t sleep_time=500;
-//             do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, &sleep_time, sizeof(sleep_time));
-//         }
-//         else
-//         {
-//             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"未电话状态\n");
-//         }
-//     }
-
-//     if(state==PROFILE_STATE_DISCONNECTED)
-//     {
-//     }
-//     AG_connect_state=state;
-//     memcpy_s((void*)&AG_bd_addr,sizeof(bd_addr_t),bd_addr,sizeof(bd_addr_t));
+#include "callerlog/include/CallerLogModel.h"
+#include "custom_utils.h"
+#include "voice_call_volte_sample_wrapper.h"
+#include "bluetooth/include/BluetoothModel.h"
+#include "bluetooth/include/BluetoothDeviceListView.h"
+#include "ui_list.h"
+#include "broadcast_feature.h"
+#include "cat1_porting.h"
+
+#define SAMPLE_HFP_TASK_STACK_SIZE 0x1600
+#define SAMPLE_HFP_TASK_PRI 20
+#define HFP_MEDIA_STATUS_DEINIT 0
+#define HFP_MEDIA_STATUS_INIT 1
+#define HFP_MEDIA_STATUS_START 2
+#define HFP_MEDIA_FLAG_IDLE 0
+#define HFP_MEDIA_FLAG_BUSY 1
+
+#define HFP_AG_IND_SIGNAL_DEFAULT 3
+#define HFP_AG_IND_BATTERY_DEFAULT 5
+
+static hfp_cind_info_t g_sample_hfp_cind_info = {0};
+
+static int8_t  AG_connect_state=0;
+static bd_addr_t AG_bd_addr={0};
+
+static AudioCodecFormat g_hfp_codec = mSBC;
+
+
+static void sample_hfp_ag_print_addr(const bd_addr_t *bd_addr)
+{
+    if (bd_addr != NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"addr: %02x:%02x:**:**:**:%02x ",
+            bd_addr->addr[5], bd_addr->addr[4], bd_addr->addr[0]); /* addr 只打印0,4,5位 */
+    }
+}
+
+
+static void sample_hfp_ag_conn_state_changed_callback(const bd_addr_t *bd_addr, profile_connect_state_t state)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"state: %d\n", state);
+    //如果触发连接为电话状态,自动切到电话
+    if(state==PROFILE_STATE_CONNECTED)
+    {
+        if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
+        && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
+        {
+            // cat1_connect_sco_();
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"电话状态\n");
+            uint8_t sleep_time=500;
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_CONNECT, &sleep_time, sizeof(sleep_time));
+        }
+        else
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"未电话状态\n");
+        }
+    }
+
+    if(state==PROFILE_STATE_DISCONNECTED)
+    {
+    }
+    AG_connect_state=state;
+    memcpy_s((void*)&AG_bd_addr,sizeof(bd_addr_t),bd_addr,sizeof(bd_addr_t));
     
-// }
-
-
-// void cat1_start_SCO_audio_(void)
-// {
-//     uapi_cat1_start_SCO_volte_voice();
-// }
-
-
-// #ifdef __cplusplus
-// extern "C" {
-// #endif
-
-// static void PostGraphicEvent(void (*fun)(void))
-// {
-//     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PostGraphicEvent] start");
-//     GraphicService::GetInstance()->PostGraphicEvent(*fun);
-// }
-
-// #ifdef __cplusplus
-// }
-// #endif
-
-// static void connectedHandle()
-// {
-//     OHOS::BluetoothModel::GetInstance()->SetTagDisconnectView(false);
-//     OHOS::BluetoothDeviceListView *bluetoothDeviceListView =OHOS:: BluetoothDeviceListView::GetInstance();
-//     if (bluetoothDeviceListView == nullptr) {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothDeviceListView  == nullptr");
-//         return;
-//     }
-//     OHOS::UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList();
-//     if (deviceList == nullptr) {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisconnectedHandle deviceList nullptr");
-//         return;
-//     }
-//     deviceList->RefreshList();
-//     // BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();
-//     // if (bluetoothOptionsView == nullptr) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView  == nullptr");
-//     //     return;
-//     // }
-//     // bluetoothOptionsView->RefreshText();
-// }
-
-
-
-// void HFP_SCO_STATE_CONNECTEDPro(void)
-// {
-//      if(volte_voice_state()==0)
-//     {
-//             do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
-//     }
-//     else
-//     {
-//             if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
-//         && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
-//         {
-//             do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
-
-//             do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
-//         }
+}
+
+
+
+void cat1_start_SCO_audio_(void)
+{
+    cat1_cat1_start_SCO_volte_voice();
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static void PostGraphicEvent(void (*fun)(void))
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PostGraphicEvent] start");
+    GraphicService::GetInstance()->PostGraphicEvent(*fun);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+static void connectedHandle()
+{
+    OHOS::BluetoothModel::GetInstance()->SetTagDisconnectView(false);
+    OHOS::BluetoothDeviceListView *bluetoothDeviceListView =OHOS:: BluetoothDeviceListView::GetInstance();
+    if (bluetoothDeviceListView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothDeviceListView  == nullptr");
+        return;
+    }
+    OHOS::UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList();
+    if (deviceList == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisconnectedHandle deviceList nullptr");
+        return;
+    }
+    deviceList->RefreshList();
+    // BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();
+    // if (bluetoothOptionsView == nullptr) {
+    //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView  == nullptr");
+    //     return;
+    // }
+    // bluetoothOptionsView->RefreshText();
+}
+
+
+
+void HFP_SCO_STATE_CONNECTEDPro(void)
+{
+     if(cat1_api_get_cat1_volte_voice_state()==0)
+    {
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+    }
+    else
+    {
+            if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
+        && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
+        {
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
+
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+        }
         
-//     }
-//     connectedHandle();
+    }
+    connectedHandle();
    
-// }
+}
 
-// void HFP_SCO_STATE_DISCONNECTEDPro(void)
-// {
-//     if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
-//     && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
-//     {
-//         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
+void HFP_SCO_STATE_DISCONNECTEDPro(void)
+{
+    if(OHOS::CallerLogModel::GetInstance()->GetCallSource() == OHOS::CallerLogModel::CallSourceCat1
+    && OHOS::NotificationManager::GetInstance()->GetWatchCallStatus())
+    {
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
 
-//         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
-//     }
-//     else
-//     {
-//         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_AUDIO_END, nullptr, 0);
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
+    }
+    else
+    {
+        // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_AUDIO_END, nullptr, 0);
 
-//         do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
-//     }
-//     connectedHandle();
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0);
+    }
+    connectedHandle();
 
-// }
+}
 
 
 
-// static void sample_hfp_ag_sco_conn_state_changed_callback(const bd_addr_t *bd_addr, hfp_sco_connect_state_t state)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"state: %d\n", state);
-//     osal_kthread_handler task_body = NULL;
-//     switch (state) {
-//         case HFP_SCO_STATE_CONNECTING:
-//             break;
+static void sample_hfp_ag_sco_conn_state_changed_callback(const bd_addr_t *bd_addr, hfp_sco_connect_state_t state)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"state: %d\n", state);
+    osal_kthread_handler task_body = NULL;
+    switch (state) {
+        case HFP_SCO_STATE_CONNECTING:
+            break;
 
-//         case HFP_SCO_STATE_CONNECTED:
+        case HFP_SCO_STATE_CONNECTED:
            
-//             PostGraphicEvent(HFP_SCO_STATE_CONNECTEDPro);
-//             Call_headset_state_updata(1);
-//             break;
+            PostGraphicEvent(HFP_SCO_STATE_CONNECTEDPro);
+            Call_headset_state_updata(1);
+            break;
 
-//         case HFP_SCO_STATE_DISCONNECTING:
-//             break;
-//         case HFP_SCO_STATE_DISCONNECTED:
+        case HFP_SCO_STATE_DISCONNECTING:
+            break;
+        case HFP_SCO_STATE_DISCONNECTED:
             
-//             PostGraphicEvent(HFP_SCO_STATE_DISCONNECTEDPro);
-//             Call_headset_state_updata(0);
-//             break;
-
-//         default: {
-//             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"invalid state!\n");
-//             break;
-//         }
-//     }
-//     }
-
-// static void sample_hfp_ag_codec_changed_callback(const bd_addr_t *bd_addr, hfp_ag_codec_id_t codec)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"codec : %d\n", codec);
-//         if (codec == HFP_AG_CODEC_ID_CVSD) {
-
-//         g_hfp_codec = PCM;
-//         updata_Audio_code_hfp(0);
-
-//     } else if (codec == HFP_AG_CODEC_ID_MSBC) {
-
-//         g_hfp_codec = mSBC;
-//         updata_Audio_code_hfp(1);
-//     }
-
-
-
-// }
-
-// void hfp_ag_cmd_conn_last_hfp(void)
-// {
-//     bd_addr_t *lastAddr = OHOS::BluetoothModel::GetInstance()->GetLastConnedAddr();
-//     hfp_ag_cmd_conn_hfp(lastAddr);
-// }
-
-// static void sample_hfp_ag_volume_changed_callback(const bd_addr_t *bd_addr, hfp_volume_type_t type, uint8_t volume)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d, volume: %u\n", type, volume);
-//     if (type == HFP_VOLUME_SPEAKER) {
-//         // sample_hfp_ag_set_spk_volume(volume);
-//     }
-// }
-
-// static void sample_hfp_ag_dial_req_callback(const bd_addr_t *bd_addr, unsigned char *number, unsigned int len)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     for (unsigned int i = 0; i < len; i++) {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number: %d ", *((uint8_t *)number + i));
-//     }
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"len: %d.\n", len);
-// }
-
-// static void sample_hfp_ag_mem_dial_req_callback(const bd_addr_t *bd_addr, unsigned int index)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"index: %d.\n", index);
-// }
-
-// static void sample_hfp_ag_lastnum_dial_req_callback(const bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-// }
-
-// static void sample_hfp_ag_answer_call_req_callback(const bd_addr_t *bd_addr, hfp_ag_type_t type)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d.\n", type);
-// }
-
-// static void sample_hfp_ag_cancel_call_req_callback(const bd_addr_t *bd_addr, hfp_ag_type_t type)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d.\n", type);
-// }
-
-// static void sample_hfp_ag_dtmf_req_callback(const bd_addr_t *bd_addr, unsigned int code)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"code: 0x%x.\n", code);
-// }
-
-// static void sample_hfp_ag_subscriber_number_req_callback(const bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     /* TODO 造数据响应 */
-// }
-
-// static void sample_hfp_ag_current_calls_req_callback(const bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     /* TODO 造数据响应 */
-// }
-
-// static void sample_hfp_ag_current_indicator_req_callback(const bd_addr_t *bd_addr)
-// {
-//     g_sample_hfp_cind_info.service = 1;
-//     g_sample_hfp_cind_info.call = 0;
-//     g_sample_hfp_cind_info.callsetup = 0;
-//     g_sample_hfp_cind_info.callheld = 0;
-//     g_sample_hfp_cind_info.signal = HFP_AG_IND_SIGNAL_DEFAULT;
-//     g_sample_hfp_cind_info.roam = 0;
-//     g_sample_hfp_cind_info.battchg = HFP_AG_IND_BATTERY_DEFAULT;
-//     errcode_t ret = (errcode_t)hfp_ag_send_indicator_val(bd_addr, &g_sample_hfp_cind_info);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send cur indicator cbk ret=0x%x\n", ret);
-// }
-
-// static void sample_hfp_ag_network_operator_format_req_callback(const bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag AT+COPS= req cbk.\n");
-// }
-
-// static void sample_hfp_ag_network_operator_req_callback(const bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag AT+COPS? req cbk.\n");
-// }
-
-// static void sample_hfp_ag_init(const char **params, int32_t params_cnt)
-// {
-//     unused(params);
-//     unused(params_cnt);
-//     // hfp_ag_service_init();
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag init done.\n");
-// }
-
-// static void sample_hfp_ag_deinit(const char **params, int32_t params_cnt)
-// {
-//     unused(params);
-//     unused(params_cnt);
-//     // hfp_ag_service_deinit();
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag deinit done.\n");
-// }
-
-// void hfp_ag_reg_callback(void)
-// {
-
-//     errcode_t ret = ERRCODE_BT_SUCCESS;
-//     hfp_ag_callbacks_t callbacks = {
-//         sample_hfp_ag_conn_state_changed_callback,
-//         sample_hfp_ag_sco_conn_state_changed_callback,
-//         sample_hfp_ag_codec_changed_callback,
-//         sample_hfp_ag_volume_changed_callback,
-//         sample_hfp_ag_dial_req_callback,
-//         sample_hfp_ag_mem_dial_req_callback,
-//         sample_hfp_ag_lastnum_dial_req_callback,
-//         sample_hfp_ag_answer_call_req_callback,
-//         sample_hfp_ag_cancel_call_req_callback,
-//         sample_hfp_ag_dtmf_req_callback,
-//         sample_hfp_ag_subscriber_number_req_callback,
-//         sample_hfp_ag_current_calls_req_callback,
-//         sample_hfp_ag_current_indicator_req_callback,
-//         sample_hfp_ag_network_operator_format_req_callback,
-//         sample_hfp_ag_network_operator_req_callback,
-//     };
-//     ret = (errcode_t)hfp_ag_register_callbacks(&callbacks);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag reg cbk ret=0x%x\n", ret);
-// }
-
-// /* <addr> */
-// errcode_t hfp_ag_cmd_conn_hfp(const bd_addr_t *bd_addr)
-// {
-//     errcode_t ret = (errcode_t)hfp_ag_connect(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-//     return ret;
-// }
-
-// /* <addr> */
-// errcode_t hfp_ag_cmd_disconn_hfp(const bd_addr_t *bd_addr)
-// {
+            PostGraphicEvent(HFP_SCO_STATE_DISCONNECTEDPro);
+            Call_headset_state_updata(0);
+            break;
+
+        default: {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"invalid state!\n");
+            break;
+        }
+    }
+    }
+
+static void sample_hfp_ag_codec_changed_callback(const bd_addr_t *bd_addr, hfp_ag_codec_id_t codec)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"codec : %d\n", codec);
+        if (codec == HFP_AG_CODEC_ID_CVSD) {
+
+        g_hfp_codec = PCM;
+        // updata_Audio_code_hfp(0);
+
+    } else if (codec == HFP_AG_CODEC_ID_MSBC) {
+
+        g_hfp_codec = mSBC;
+        // updata_Audio_code_hfp(1);
+    }
+
+
+
+}
+
+void hfp_ag_cmd_conn_last_hfp(void)
+{
+    bd_addr_t *lastAddr = OHOS::BluetoothModel::GetInstance()->GetLastConnedAddr();
+    hfp_ag_cmd_conn_hfp(lastAddr);
+}
+
+static void sample_hfp_ag_volume_changed_callback(const bd_addr_t *bd_addr, hfp_volume_type_t type, uint8_t volume)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d, volume: %u\n", type, volume);
+    if (type == HFP_VOLUME_SPEAKER) {
+        // sample_hfp_ag_set_spk_volume(volume);
+    }
+}
+
+static void sample_hfp_ag_dial_req_callback(const bd_addr_t *bd_addr, unsigned char *number, unsigned int len)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    for (unsigned int i = 0; i < len; i++) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number: %d ", *((uint8_t *)number + i));
+    }
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"len: %d.\n", len);
+}
+
+static void sample_hfp_ag_mem_dial_req_callback(const bd_addr_t *bd_addr, unsigned int index)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"index: %d.\n", index);
+}
+
+static void sample_hfp_ag_lastnum_dial_req_callback(const bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+}
+
+static void sample_hfp_ag_answer_call_req_callback(const bd_addr_t *bd_addr, hfp_ag_type_t type)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d.\n", type);
+}
+
+static void sample_hfp_ag_cancel_call_req_callback(const bd_addr_t *bd_addr, hfp_ag_type_t type)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d.\n", type);
+}
+
+static void sample_hfp_ag_dtmf_req_callback(const bd_addr_t *bd_addr, unsigned int code)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"code: 0x%x.\n", code);
+}
+
+static void sample_hfp_ag_subscriber_number_req_callback(const bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    /* TODO 造数据响应 */
+}
+
+static void sample_hfp_ag_current_calls_req_callback(const bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    /* TODO 造数据响应 */
+}
+
+static void sample_hfp_ag_current_indicator_req_callback(const bd_addr_t *bd_addr)
+{
+    g_sample_hfp_cind_info.service = 1;
+    g_sample_hfp_cind_info.call = 0;
+    g_sample_hfp_cind_info.callsetup = 0;
+    g_sample_hfp_cind_info.callheld = 0;
+    g_sample_hfp_cind_info.signal = HFP_AG_IND_SIGNAL_DEFAULT;
+    g_sample_hfp_cind_info.roam = 0;
+    g_sample_hfp_cind_info.battchg = HFP_AG_IND_BATTERY_DEFAULT;
+    errcode_t ret = (errcode_t)hfp_ag_send_indicator_val(bd_addr, &g_sample_hfp_cind_info);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send cur indicator cbk ret=0x%x\n", ret);
+}
+
+static void sample_hfp_ag_network_operator_format_req_callback(const bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag AT+COPS= req cbk.\n");
+}
+
+static void sample_hfp_ag_network_operator_req_callback(const bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag AT+COPS? req cbk.\n");
+}
+
+static void sample_hfp_ag_init(const char **params, int32_t params_cnt)
+{
+    unused(params);
+    unused(params_cnt);
+    // hfp_ag_service_init();
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag init done.\n");
+}
+
+static void sample_hfp_ag_deinit(const char **params, int32_t params_cnt)
+{
+    unused(params);
+    unused(params_cnt);
+    // hfp_ag_service_deinit();
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag deinit done.\n");
+}
+
+void hfp_ag_reg_callback(void)
+{
+
+    errcode_t ret = ERRCODE_BT_SUCCESS;
+    hfp_ag_callbacks_t callbacks = {
+        sample_hfp_ag_conn_state_changed_callback,
+        sample_hfp_ag_sco_conn_state_changed_callback,
+        sample_hfp_ag_codec_changed_callback,
+        sample_hfp_ag_volume_changed_callback,
+        sample_hfp_ag_dial_req_callback,
+        sample_hfp_ag_mem_dial_req_callback,
+        sample_hfp_ag_lastnum_dial_req_callback,
+        sample_hfp_ag_answer_call_req_callback,
+        sample_hfp_ag_cancel_call_req_callback,
+        sample_hfp_ag_dtmf_req_callback,
+        sample_hfp_ag_subscriber_number_req_callback,
+        sample_hfp_ag_current_calls_req_callback,
+        sample_hfp_ag_current_indicator_req_callback,
+        sample_hfp_ag_network_operator_format_req_callback,
+        sample_hfp_ag_network_operator_req_callback,
+    };
+    ret = (errcode_t)hfp_ag_register_callbacks(&callbacks);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag reg cbk ret=0x%x\n", ret);
+}
+
+/* <addr> */
+errcode_t hfp_ag_cmd_conn_hfp(const bd_addr_t *bd_addr)
+{
+    errcode_t ret = (errcode_t)hfp_ag_connect(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
+    return ret;
+}
+
+/* <addr> */
+errcode_t hfp_ag_cmd_disconn_hfp(const bd_addr_t *bd_addr)
+{
  
-//     errcode_t ret = (errcode_t)hfp_ag_disconnect(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-//      return ret;
-// }
-
-// /* <addr> */
-// void hfp_ag_cmd_conn_sco(const bd_addr_t *bd_addr )
-// {
-//     // if(headset_Is_connect)
-//     errcode_t ret = (errcode_t)hfp_ag_audio_connect(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u %02X  %02X  %02X  %02X  %02X  %02X\n", ret,bd_addr->addr[5]
-//     ,bd_addr->addr[4],bd_addr->addr[3],bd_addr->addr[2],bd_addr->addr[1],bd_addr->addr[0]);
-// }
-
-// /* <addr> */
-// void hfp_ag_cmd_disconn_sco(const bd_addr_t *bd_addr )
-// {
-//     errcode_t ret = (errcode_t)hfp_ag_audio_disconnect(bd_addr);
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> */
-// static void sample_hfp_ag_cmd_get_dev_conn_state(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 1) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag dev conn state param is invalid.\n");
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag dev conn state decode addr error!\n");
-//     //     return;
-//     // }
-//     // int ret = hfp_ag_get_device_connect_state(&bd_addr);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %d\n", ret);
-// }
-
-// /* <addr> */
-// static void sample_hfp_ag_cmd_get_sco_conn_state(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 1) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag sco state param is invalid.\n");
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag sco state decode addr error!\n");
-//     //     return;
-//     // }
-//     // int ret = hfp_ag_get_sco_connect_state(&bd_addr);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %d\n", ret);
-// }
-
-// /* <addr> */
-// static void sample_hfp_ag_cmd_answer_call(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 1) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag answer call param is invalid.\n");
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag answer call decode addr error!\n");
-//     //     return;
-//     // }
-//     // errcode_t ret = (errcode_t)hfp_ag_send_answer_call_event(&bd_addr);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %d\n", ret);
-// }
-
-// /* <addr> <type> */
-// static void sample_hfp_ag_cmd_finish_call(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 2) { /* 2: param count */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag finish call param is invalid.\n");
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag finish call decode addr error!\n");
-//     //     return;
-//     // }
-//     // hfp_ag_action_t type = (hfp_ag_action_t)atoi(params[1]);
-//     // errcode_t ret = (errcode_t)hfp_ag_send_finish_call_event(&bd_addr, type);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d ret: %d\n", type, ret);
-// }
-
-// /* <addr> <volume_type> <volume> */
-// static void sample_hfp_ag_cmd_set_volume(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 3) { /* 3个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag set volume decode addr error!\n");
-//     //     return;
-//     // }
-//     // hfp_volume_type_t type = (hfp_volume_type_t)atoi(params[1]); /* 第1个参数 */
-//     // uint8_t volume = (uint8_t)atoi(params[2]); /* 第2个参数 */
-//     // errcode_t ret = (errcode_t)hfp_ag_set_volume(&bd_addr, type, volume);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d volume: %u ret: %u\n", type, volume, ret);
-// }
-
-// /* <addr> <event> <param> */
-// static void sample_hfp_ag_cmd_send_network_event(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 3) { /* 3个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag set volume decode addr error!\n");
-//     //     return;
-//     // }
-//     // hfp_ag_network_event_t event = (hfp_ag_network_event_t)atoi(params[1]); /* 第1个参数 */
-//     // uint8_t param = (uint8_t)atoi(params[2]); /* 第2个参数 */
-//     // errcode_t ret = (errcode_t)hfp_ag_send_network_event(&bd_addr, event, param);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"event: %d param: %u ret: %u\n", event, param, ret);
-// }
-
-// /* <addr> <type> <service> <number> <alpha_str> */
-// static void sample_hfp_ag_cmd_send_incoming_event(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 5) { /* 5个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag set volume decode addr error!\n");
-//     //     return;
-//     // }
-
-//     // uint8_t type = (uint8_t)atoi(params[1]); /* index:1 */
-//     // uint8_t service = (uint8_t)atoi(params[2]); /* index:2 */
-//     // char *number_str = params[3]; /* index:3 */
-//     // size_t str_len = strlen(number_str);
-//     // if (str_len > HFP_AG_PHONENUM_MAX_DIGITS) { /* number最大长度为32 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number len exceeds max limit! str_len = %u \n", str_len);
-//     //     return;
-//     // }
-//     // uint8_t number_len = (uint8_t)str_len;
-
-//     // char *name_str = params[4]; /* index:4 *//* index:4 */
-//     // size_t name_str_len = strlen(name_str);
-//     // if (name_str_len > 256) { /* name最大长度为256 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"name len exceeds max limit! str_len = %u \n", str_len);
-//     //     return;
-//     // }
-//     // uint8_t name_len = (uint8_t)name_str_len;
-
-//     // hfp_phone_info_t *info = bt_os_new(sizeof(hfp_phone_info_t) + name_len);
-//     // if (memset_s(info, sizeof(hfp_phone_info_t) + name_len, 0,
-//     //     sizeof(hfp_phone_info_t) + name_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->type = type;
-//     // info->service = service;
-//     // info->num_len = number_len;
-//     // if (memcpy_s(info->number, HFP_AG_PHONENUM_MAX_DIGITS, (uint8_t *)number_str, str_len) != EOK) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number memcpy error.\n");
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->name_len = name_len;
-//     // if (memcpy_s(info->alpha_str, name_len, (int8_t *)name_str, name_len) != EOK) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"name memcpy error.\n");
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // errcode_t ret = (errcode_t)hfp_ag_send_network_incoming_event(&bd_addr, info);
-//     // bt_os_free(info);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> <idx> <dir> <status> <mode> <mpty> <type> <number> <is_last> */
-// static void sample_hfp_ag_cmd_send_call_list(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 9) { /* 9个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag set volume decode addr error!\n");
-//     //     return;
-//     // }
-//     // uint8_t number_len = 0;
-//     // char *number_str = params[7]; /* 7:idx */
-//     // size_t str_len = strlen(number_str);
-//     // if (str_len > HFP_AG_PHONENUM_MAX_DIGITS) { /* number最大长度为32 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number len exceeds max limit! str_len = %u \n", str_len);
-//     //     return;
-//     // }
-//     // number_len = (uint8_t)str_len;
-//     // hfp_clcc_info_t *info = bt_os_new(sizeof(hfp_clcc_info_t) + number_len);
-//     // if (memset_s(info, sizeof(hfp_clcc_info_t) + number_len, 0,
-//     //     sizeof(hfp_clcc_info_t) + number_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->idx = (uint8_t)atoi(params[1]);
-//     // info->dir = (uint8_t)atoi(params[2]); /* 2:idx */
-//     // info->status = (uint8_t)atoi(params[3]); /* 3:idx */
-//     // info->mode = (uint8_t)atoi(params[4]); /* 4:idx */
-//     // info->mpty = (uint8_t)atoi(params[5]); /* 5:idx */
-//     // info->type = (uint8_t)atoi(params[6]); /* 6:idx */
-//     // info->num_len = number_len;
-//     // if (memcpy_s(info->number, number_len, (uint8_t *)number_str, str_len) != EOK) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number memcpy error.\n");
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-
-//     // hfp_ag_last_t is_last = (hfp_ag_last_t)atoi(params[8]); /* 8:idx */
-//     // errcode_t ret = (errcode_t)hfp_ag_send_current_calls(&bd_addr, info, is_last);
-//     // bt_os_free(info);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> <type> <service> <number> <alpha_str> <is_last> */
-// static void sample_hfp_ag_cmd_send_subscriber_number(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 6) { /* 6个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag set volume decode addr error!\n");
-//     //     return;
-//     // }
-
-//     // uint8_t type = (uint8_t)atoi(params[1]); /* index:1 */
-//     // uint8_t service = (uint8_t)atoi(params[2]); /* index:2 */
-//     // char *number_str = params[3]; /* index:3 */
-//     // size_t str_len = strlen(number_str);
-//     // if (str_len > 32) { /* number最大长度为32 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"number len exceeds max limit! str_len = %u \n", str_len);
-//     //     return;
-//     // }
-//     // uint8_t number_len = (uint8_t)str_len;
-
-//     // char *name_str = params[4]; /* index:4 *//* index:4 */
-//     // size_t name_str_len = strlen(name_str);
-//     // if (name_str_len > 256) { /* name最大长度为256 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"name len exceeds max limit! str_len = %u \n", str_len);
-//     //     return;
-//     // }
-//     // uint8_t name_len = (uint8_t)name_str_len;
-
-//     // hfp_phone_info_t *info = bt_os_new(sizeof(hfp_phone_info_t) + name_len);
-//     // if (memset_s(info, sizeof(hfp_phone_info_t) + name_len, 0,
-//     //     sizeof(hfp_phone_info_t) + name_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->type = type;
-//     // info->service = service;
-//     // info->num_len = number_len;
-//     // if (memcpy_s(info->number, HFP_AG_PHONENUM_MAX_DIGITS, (uint8_t *)number_str, str_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->name_len = name_len;
-//     // if (memcpy_s(info->alpha_str, name_len, (int8_t *)name_str, name_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // hfp_ag_last_t is_last = (hfp_ag_last_t)atoi(params[5]);
-//     // errcode_t ret = (errcode_t)hfp_ag_send_subscriber_number(&bd_addr, info, is_last);
-//     // bt_os_free(info);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> <value> */
-// static void sample_hfp_ag_cmd_send_battery_charge(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 2) { /* 2个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send battery charge decode addr error!\n");
-//     //     return;
-//     // }
-//     // uint8_t value = (uint8_t)atoi(params[1]); /* 第1个参数 */
-//     // errcode_t ret = (errcode_t)hfp_ag_send_battery_charge(&bd_addr, value);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"value: %d ret: %u\n", value, ret);
-// }
-
-// /* <addr> <error_code> */
-// static void sample_hfp_ag_cmd_send_cmee_error(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 2) { /* 2个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send cmee error decode addr error!\n");
-//     //     return;
-//     // }
-//     // hfp_ag_cmee_error_t error_code = (hfp_ag_cmee_error_t)atoi(params[1]); /* 第1个参数 */
-//     // errcode_t ret = (errcode_t)hfp_ag_send_cmee_error(&bd_addr, error_code);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"error_code: %d ret: %u\n", error_code, ret);
-// }
-
-// /* <addr> <mode> <format> <operator_name> */
-// static void sample_hfp_ag_cmd_send_network_operator(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 4) { /* 4个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send network operator decode addr error!\n");
-//     //     return;
-//     // }
-
-//     // char *operator_name = params[3]; /* index3 */
-//     // uint8_t operator_len = 0;
-//     // size_t name_str_len = strlen(operator_name);
-//     // if (name_str_len > HFP_AG_COPS_OPERATOR_MAXLEN) { /* name最大长度为16 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"name len exceeds max limit! str_len = %u \n", name_str_len);
-//     //     return;
-//     // }
-//     // operator_len = (uint8_t)name_str_len;
+    errcode_t ret = (errcode_t)hfp_ag_disconnect(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
+     return ret;
+}
+
+/* <addr> */
+void hfp_ag_cmd_conn_sco(const bd_addr_t *bd_addr )
+{
+    // if(headset_Is_connect)
+    errcode_t ret = (errcode_t)hfp_ag_audio_connect(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u %02X  %02X  %02X  %02X  %02X  %02X\n", ret,bd_addr->addr[5]
+    ,bd_addr->addr[4],bd_addr->addr[3],bd_addr->addr[2],bd_addr->addr[1],bd_addr->addr[0]);
+}
+
+/* <addr> */
+void hfp_ag_cmd_disconn_sco(const bd_addr_t *bd_addr )
+{
+    errcode_t ret = (errcode_t)hfp_ag_audio_disconnect(bd_addr);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
+}
+
+bool headset_Is_connect(void)
+{
+    // int state = hfp_ag_get_device_connect_state(&AG_bd_addr);
+    // sample_hfp_ag_print_addr(&AG_bd_addr);
+    if(AG_connect_state==PROFILE_STATE_CONNECTED)
+    {
+        return true;
+    }
+    else
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED");
+        return false;
+    }
+}
+
+
+bool headset_SCO_Is_connect(void)
+{
+    int state = hfp_ag_get_sco_connect_state(&AG_bd_addr);
+    if(state==PROFILE_STATE_CONNECTED)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+bool headset_SCO_Is_connect_extend(bd_addr_t *bd_addr)
+{
+    // sample_hfp_ag_print_addr(bd_addr);
+    int sco_state = hfp_ag_get_sco_connect_state(bd_addr);
+    int ag_state= hfp_ag_get_device_connect_state(bd_addr);
+    bool ACL_state= bt_is_acl_connected(bd_addr);
+    if(sco_state==PROFILE_STATE_CONNECTED && ag_state==PROFILE_STATE_CONNECTED && ACL_state==true)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"PROFILE_STATE_CONNECTED");
+        return true;
+    }
+    else
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED");
+        return false;
+    }
+}
+
+
+void cat1_connect_sco_(uint8_t time)
+{
+    //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
+    #ifdef SUPPORT_CAT1_HFP_AG_SERV
+    if(time)
+    osal_msleep(time);
+    hfp_ag_cmd_conn_sco(&AG_bd_addr);
+    #endif
+
+}
+
+
+void cat1_disconn_sco_(void)
+{
+    //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
+    #ifdef SUPPORT_CAT1_HFP_AG_SERV
+        hfp_ag_cmd_disconn_sco(&AG_bd_addr);
+    #endif
+
+}
+
+void cat1_set_headset_volume( unsigned char volume)
+{
+    //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
+    hfp_ag_set_volume(&AG_bd_addr,HFP_VOLUME_SPEAKER,volume);
+
+}
+
+
+// uint8_t type;      /*!< @if Eng The format of the phone number provided, the region of value is 128-175
+//                         @else 电话号码类型,值范围是128-175 @endif */
+// uint8_t service;   /*!< @if Eng Indicates which service this phone number relates to.
+//                         Shall be either 4 (voice) or 5 (fax). See @ref hfp_ag_cnum_service_t
+//                         @else 服务类型,协议支持4或5,见 @ref hfp_ag_cnum_service_t @endif */
+// uint8_t num_len;                             /*!< @if Eng The length of the phone number @else 电话号码长度 @endif */
+// int8_t  number[HFP_AG_PHONENUM_MAX_DIGITS];  /*!< @if Eng Subscriber number, the length shall be 32
+//                                                     @else 订阅号码,最大长度是32 @endif */
+// uint8_t name_len;                            /*!< @if Eng Length of subaddr @else 子地址长度 @endif */
+// int8_t  alpha_str[1];                    /*!< @if Eng string type subaddress of format specified by <cli_validity>
+//                                                 @else 子地址,协议默认是0 @endif */
+
+
+int cat1_ag_send_call_event( uint32_t event_topic, const char* info)
+{
+    //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
+    int ret=0;
+
+    hfp_phone_info_t phone_info={0};
+    if(info!=nullptr)
+    {
+        phone_info.type=128;
+        phone_info.service=4;
+        phone_info.num_len=strlen(info);
+        memcpy_s(phone_info.number,HFP_AG_PHONENUM_MAX_DIGITS,info,phone_info.num_len); 
+        phone_info.name_len=strlen(info);
+        phone_info.alpha_str[0]=0;
+    }
     
-//     // hfp_cops_info_t *info = bt_os_new(sizeof(hfp_cops_info_t) + operator_len);
-//     // if (memset_s(info, sizeof(hfp_cops_info_t) + operator_len, 0,
-//     //     sizeof(hfp_cops_info_t) + operator_len) != EOK) {
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-//     // info->mode = (uint8_t)atoi(params[1]);
-//     // info->format = (uint8_t)atoi(params[2]); /* index2 */
-//     // info->operator_len = operator_len;
-//     // if (memcpy_s(info->operator_name, operator_len, (int8_t *)operator_name, operator_len) != EOK) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"name memcpy error.\n");
-//     //     bt_os_free(info);
-//     //     return;
-//     // }
-
-//     // errcode_t ret = (errcode_t)hfp_ag_send_network_operator(&bd_addr, info);
-//     // bt_os_free(info);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> <service> <call> <callsetup> <callheld> <signal> <roam> <battchg> */
-// static void sample_hfp_ag_cmd_send_indicator_val(const char **params, int32_t params_cnt)
-// {
-//     // if (params_cnt != 8) { /* 8个参数 */
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"params cnt err: %d!\n", params_cnt);
-//     //     return;
-//     // }
-//     // bd_addr_t bd_addr;
-//     // if (decode_bd_addr_from_str(params[0], bd_addr.addr, BD_ADDR_LEN) != EXT_ERR_SUCCESS) {
-//     //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sample hfp ag send indicator val decode addr error!\n");
-//     //     return;
-//     // }
-
-//     // g_sample_hfp_cind_info.service = (uint8_t)atoi(params[1]);
-//     // g_sample_hfp_cind_info.call = (uint8_t)atoi(params[2]); /* index:2 */
-//     // g_sample_hfp_cind_info.callsetup = (uint8_t)atoi(params[3]); /* index:3 */
-//     // g_sample_hfp_cind_info.callheld = (uint8_t)atoi(params[4]); /* index:4 */
-//     // g_sample_hfp_cind_info.signal = (uint8_t)atoi(params[5]); /* index:5 */
-//     // g_sample_hfp_cind_info.roam = (uint8_t)atoi(params[6]); /* index:6 */
-//     // g_sample_hfp_cind_info.battchg = (uint8_t)atoi(params[7]); /* index:7 */
-
-//     // errcode_t ret = (errcode_t)hfp_ag_send_indicator_val(&bd_addr, &g_sample_hfp_cind_info);
-//     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ret: %u\n", ret);
-// }
-
-// /* <addr> */
-
-
-// bool headset_Is_connect(void)
-// {
-//     // int state = hfp_ag_get_device_connect_state(&AG_bd_addr);
-//     sample_hfp_ag_print_addr(&AG_bd_addr);
-//     if(AG_connect_state==PROFILE_STATE_CONNECTED)
-//     {
-//         return true;
-//     }
-//     else
-//     {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED");
-//         return false;
-//     }
-// }
-
-
-// bool headset_SCO_Is_connect(void)
-// {
-//     int state = hfp_ag_get_sco_connect_state(&AG_bd_addr);
-//     if(state==PROFILE_STATE_CONNECTED)
-//     {
-//         return true;
-//     }
-//     else
-//     {
-//         return false;
-//     }
-// }
-
-
-// bool headset_SCO_Is_connect_extend(bd_addr_t *bd_addr)
-// {
-//     sample_hfp_ag_print_addr(bd_addr);
-//     int sco_state = hfp_ag_get_sco_connect_state(bd_addr);
-//     int ag_state= hfp_ag_get_device_connect_state(bd_addr);
-//     bool ACL_state= bt_is_acl_connected(bd_addr);
-//     if(sco_state==PROFILE_STATE_CONNECTED && ag_state==PROFILE_STATE_CONNECTED && ACL_state==true)
-//     {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"PROFILE_STATE_CONNECTED");
-//         return true;
-//     }
-//     else
-//     {
-//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"NO PROFILE_STATE_CONNECTED");
-//         return false;
-//     }
+    switch (event_topic)
+    {
+        case TOPIC_EVENT_CAT1_INCOMMING:
+            ret=hfp_ag_send_network_incoming_event(&AG_bd_addr,&phone_info);
+            break;
+         case TOPIC_EVENT_CAT1_CALLCONNTED:
+            ret=hfp_ag_send_answer_call_event(&AG_bd_addr);
+            break;
+         case TOPIC_EVENT_CAT1_CALLENDED:
+            ret=hfp_ag_send_finish_call_event(&AG_bd_addr,HFP_AG_CANCELED_LASTCALL);
+            break;
+         case TOPIC_EVENT_CAT1_CALLDIAL:
+            ret=hfp_ag_send_originate_call_event(&AG_bd_addr);
+            break;
+        default:
+            ret=ERRCODE_BT_FAIL;
+            break;
+    }
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cat1_ag_send_call_event  %X %X %X %X %d %X\n",
+    AG_bd_addr.addr[5],AG_bd_addr.addr[4],
+    AG_bd_addr.addr[3],AG_bd_addr.addr[2],
+    event_topic,ret);
+    return ret;
+}
+
+
+
+// #ifdef  __cplusplus
 // }
-
-
-// void cat1_connect_sco_(uint8_t time)
-// {
-//     //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
-//     #ifdef SUPPORT_CAT1_HFP_AG_SERV
-//     if(time)
-//     osal_msleep(time);
-//     hfp_ag_cmd_conn_sco(&AG_bd_addr);
-//     #endif
-
-// }
-
-
-// void cat1_disconn_sco_(void)
-// {
-//     //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
-//     #ifdef SUPPORT_CAT1_HFP_AG_SERV
-//         hfp_ag_cmd_disconn_sco(&AG_bd_addr);
-//     #endif
-
-// }
-
-// void cat1_set_headset_volume( unsigned char volume)
-// {
-//     //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
-//     hfp_ag_set_volume(&AG_bd_addr,HFP_VOLUME_SPEAKER,volume);
-
-// }
-
-
-// // uint8_t type;      /*!< @if Eng The format of the phone number provided, the region of value is 128-175
-// //                         @else 电话号码类型,值范围是128-175 @endif */
-// // uint8_t service;   /*!< @if Eng Indicates which service this phone number relates to.
-// //                         Shall be either 4 (voice) or 5 (fax). See @ref hfp_ag_cnum_service_t
-// //                         @else 服务类型,协议支持4或5,见 @ref hfp_ag_cnum_service_t @endif */
-// // uint8_t num_len;                             /*!< @if Eng The length of the phone number @else 电话号码长度 @endif */
-// // int8_t  number[HFP_AG_PHONENUM_MAX_DIGITS];  /*!< @if Eng Subscriber number, the length shall be 32
-// //                                                     @else 订阅号码,最大长度是32 @endif */
-// // uint8_t name_len;                            /*!< @if Eng Length of subaddr @else 子地址长度 @endif */
-// // int8_t  alpha_str[1];                    /*!< @if Eng string type subaddress of format specified by <cli_validity>
-// //                                                 @else 子地址,协议默认是0 @endif */
-
-
-// int cat1_ag_send_call_event( uint32_t event_topic, const char* info)
-// {
-//     //AudioActInterrupt(AUDIO_STREAM_VOICE_CALL_VOLTE);
-//     int ret=0;
-
-//     hfp_phone_info_t phone_info={0};
-//     if(info!=nullptr)
-//     {
-//         phone_info.type=128;
-//         phone_info.service=4;
-//         phone_info.num_len=strlen(info);
-//         memcpy_s(phone_info.number,HFP_AG_PHONENUM_MAX_DIGITS,info,phone_info.num_len); 
-//         phone_info.name_len=strlen(info);
-//         phone_info.alpha_str[0]=0;
-//     }
-    
-//     switch (event_topic)
-//     {
-//         case TOPIC_EVENT_CAT1_INCOMMING:
-//             ret=hfp_ag_send_network_incoming_event(&AG_bd_addr,&phone_info);
-//             break;
-//          case TOPIC_EVENT_CAT1_CALLCONNTED:
-//             ret=hfp_ag_send_answer_call_event(&AG_bd_addr);
-//             break;
-//          case TOPIC_EVENT_CAT1_CALLENDED:
-//             ret=hfp_ag_send_finish_call_event(&AG_bd_addr,HFP_AG_CANCELED_LASTCALL);
-//             break;
-//          case TOPIC_EVENT_CAT1_CALLDIAL:
-//             ret=hfp_ag_send_originate_call_event(&AG_bd_addr);
-//             break;
-//         default:
-//             ret=ERRCODE_BT_FAIL;
-//             break;
-//     }
-//     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cat1_ag_send_call_event  %X %X %X %X %d %X\n",
-//     AG_bd_addr.addr[5],AG_bd_addr.addr[4],
-//     AG_bd_addr.addr[3],AG_bd_addr.addr[2],
-//     event_topic,ret);
-//     return ret;
-// }
-
-
-
-// // #ifdef  __cplusplus
-// // }
-// // #endif
+// #endif
index 9caea50..e021860 100644 (file)
@@ -25,6 +25,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_porting.h"
+#endif
 
 #ifndef UNUSED
 #define UNUSED(x) ((void)(x))
@@ -149,10 +152,12 @@ int32_t PhoneAudioSetMicMuteCat1(bool isMute)
 {
 
     int32_t ret;
-    // if(!volte_voice_state())
-    // {
-    //     return 0;
-    // }
+    #ifdef SUPPORT_CAT1_SERVICE
+    if(!cat1_api_get_cat1_volte_voice_state())
+    {
+        return 0;
+    }
+    #endif
     ret=AudioStreamOutSetMute(isMute);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[AudioStreamOutSetMute] end! ret = %d", ret);
     return 0;
index 5e530a7..d986c2f 100644 (file)
 #include "UiConfig.h"
 #include "phoneservice/include/PhoneAGService.h"
 #include "cmath"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
+#include "cat1_porting.h"
 #ifdef SUPPORT_BLE_SERVICE
 #include "bleService.h"
 #endif
@@ -396,14 +398,18 @@ void cat1_audio_AudioSetup(void)
         BtA2dpSnkAudioDestroy();
         sleep(1);//等待释放音频
     }
-    // uapi_cat1_start_volte_voice();
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_start_cat1_volte_voice();
+    #endif
     usleep(5000);//等待释放音频
 
 }
 
 void cat1_audio_AudioRelease(void)
 {
-    // uapi_cat1_stop_volte_voice();
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_stop_cat1_volte_voice();
+    #endif
 }
 
 void cat1_audio_stop(void)
@@ -468,10 +474,12 @@ static void AudioUp(void)
 static void AudioSetup(void)
 {
     //如果已经建立了cat1 媒体通路,不能再建立,SCO通路
-    // if(volte_voice_state())
-    // {
-    //     return;
-    // }
+    #ifdef SUPPORT_CAT1_SERVICE
+    if(cat1_api_get_cat1_volte_voice_state())
+    {
+        return;
+    }
+    #endif
     if (g_audioState < AUDIO_STREAM_START_DN) {
         AudioDn();
     }
@@ -755,7 +763,7 @@ static void ScoStateChanged(const bd_addr_t &bdAddr, hfp_sco_connect_state_t sta
         g_scoFlag, g_currCallNum);
 
     switch (state) {
-                case HFP_SCO_STATE_CONNECTING:
+        case HFP_SCO_STATE_CONNECTING:
             PhoneServiceScreenCtr(1);
             if (g_scoFlag != HFP_SCO_STATE_CONNECTED) {
                 g_scoFlag = HFP_SCO_STATE_CONNECTED;
index c3b661a..bc4e7be 100644 (file)
@@ -54,6 +54,18 @@ static const TopicToCore topicToCoreArray[] = {
     {TOPIC_EVENT_MESSAGENOTE,A_CORE_MASK, 1},
     {TOPIC_EVENT_MESSAGE_UPDATA,A_CORE_MASK, 1},
     {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,A_CORE_MASK, 1},
+    {TOPIC_EVENT_HFP_HINT,A_CORE_MASK, 1},
+    
+#ifdef SUPPORT_CAT1_MODEM
+    {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_CALLENDED, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_CALLDIAL, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_POWER_ON, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_POWER_OFF, A_CORE_MASK, 1},
+    {TOPIC_EVENT_CAT1_CALL_FAIL,A_CORE_MASK, 1},
+#endif
 };
 
 /* 所有的topic,其对应的位图 */
index 2200814..50cfdc2 100644 (file)
@@ -30,6 +30,9 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/zhihui/4g/cat1Service
     ${ROOT_DIR}/zhihui/4g/cat1Service/include
     ${ROOT_DIR}/zhihui/4g/cat1Service/Service
+    ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/phone/include
+    ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/player/include
+    # ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/player/include/PlayersModel.h
 )
 
 set(SOURCES
@@ -147,7 +150,8 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include
     ${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include
     ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits
-    
+    ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/phone/include
+    ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/player/include
 
     ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/
 
@@ -156,6 +160,13 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/zhihui/UI/producttest/include/
 )
 
+# if("FD230" IN_LIST DEFINES)
+# set(PRIVATE_HEADER
+#     ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/phone/include
+#     ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/player/include
+# )
+# endif()
+
 if("JS_ENABLE" IN_LIST DEFINES)
 set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/msg_center_customer.cpp
@@ -180,6 +191,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/goal_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/drinkReminder_notification.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sleep_notification.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/phone_crt.cpp
+    
 
 )
 else()
diff --git a/code/sdk/application/wearable/fd230/service/msg_center/include/notify/phone_crt.h b/code/sdk/application/wearable/fd230/service/msg_center/include/notify/phone_crt.h
new file mode 100644 (file)
index 0000000..ed73227
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef PHONE_CRT_H
+#define PHONE_CRT_H
+
+
+namespace OHOS {
+void addcalllog(void);
+void cat1_phone_state_change_cb(uint8_t state);
+void phone_paly_ring(void);
+void phone_VibratorFunc(void);
+
+UIViewGroup* SOS_cant_dial(void);
+UIViewGroup* CALL_INCOMING_HINT(void);
+UIViewGroup* CALL_FAIL_HINT(void);
+
+
+}
+
+#endif
\ No newline at end of file
index 3fe4ea5..6237663 100644 (file)
@@ -41,6 +41,9 @@
 #endif
 
 #ifdef FD230
+#include "ConfigModel.h"
+#include "PlayersModelC.h"
+#include "PlayersModel.h"
 #include "main/include/PullUpDownView.h"
 #include "custom_save_runtime.h"
 #include "transmitting.h"
@@ -50,6 +53,7 @@
 #include "findwatch_notification.h"
 #include "debug_output_notification/debug_output_notification.h"
 #include "pairing_notification.h"
+#include "phone_crt.h"
 #include "main/include/dial/DialModelChargeC.h"
 #include "saveele/include/SaveEleModel.h"
 #include "testchangingC.h"
@@ -60,6 +64,8 @@
 #include "sleep_notification.h"
 #include "sleep/include/SleepModel.h"
 
+#include "custom_utilscpp.h"
+#include "custom_utils.h"
 #ifdef SUPPORT_POWER_MANAGER
 #include "power_display_service.h"
 #endif
@@ -69,6 +75,8 @@
 #include "cywee_hal.h"
 #endif
 
+#include "cat1_pub_api.h"
+
 namespace OHOS {
 
 #ifdef __cplusplus
@@ -85,6 +93,20 @@ const PriorityMapper PRI_MAPPER[] = {
     {TOPIC_EVENT_HFP_WATCH_ACTIVE, PRIORITY_ONE},
     {TOPIC_EVENT_HFP_WATCH_TO_PHONE, PRIORITY_ONE},
     {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
+
+#ifdef SUPPORT_CAT1_MODEM
+    {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_CALLENDED, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_CALLDIAL,PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_SIGNAL_UPDATE, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_POWER_ON, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_POWER_OFF, PRIORITY_ONE},
+    {TOPIC_EVENT_CAT1_CALL_FAIL,PRIORITY_ONE},
+    {TOPIC_EVENT_HFP_HINT,PRIORITY_ONE},
+    
+#endif
+
     {TOPIC_EVENT_DEVICE_BIND, PRIORITY_ONE},
     {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE},
     // #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
@@ -154,6 +176,19 @@ void MsgCenterSubscribe()
     MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE);
     MsgCenterSubscribeTopic(TOPIC_EVENT_SHUTDOWN_ANIMATIOR);
     
+    MsgCenterSubscribeTopic(TOPIC_EVENT_HFP_HINT);
+#ifdef SUPPORT_CAT1_MODEM
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_INCOMMING);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLCONNTED);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLENDED);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLDIAL);
+    // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_SIGNAL_UPDATE);
+    // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_ON);
+    // MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_POWER_OFF);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALL_FAIL);
+   
+#endif
+    
 }
 
 static OHOS::UIViewGroup* ShowAlarmNotify(void)
@@ -251,6 +286,27 @@ static OHOS::UIViewGroup* showSleepNotify(void)
     return OHOS::CreateSleepNotifyView();
 }
 //关机动画
+
+
+//显示新来电
+static OHOS::UIViewGroup* showcallhintNotify(void)
+{
+    return OHOS::CALL_INCOMING_HINT();
+}
+
+static OHOS::UIViewGroup* showcallfailNotify(void)
+{
+    return OHOS::CALL_FAIL_HINT();
+}
+
+//无法呼叫sos
+static OHOS::UIViewGroup* showSOSNotify(void)
+{
+    return OHOS::SOS_cant_dial();
+}
+
+
+
 static OHOS::UIViewGroup* showShutdownAnimatorNotify(void)
 {
     return OHOS::showShutDownAnimation();
@@ -409,6 +465,9 @@ void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
     }
     #endif
 }
+
+
+
 void MsgCenterNotifybleTransmit(const Topic topic, Request* req)
 {
     #ifdef SUPPORT_BLE_SERVICE
@@ -579,6 +638,9 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
             NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
         }
     }
+   
+    #endif
+}
     //TODO: 亮屏弹窗倒计时5秒关机(不需要取消,强制关机)
     // DialModelCharge::GetInstance()->UpdatechargeStatus(0);
     // SaveEleModel::GetInstance()->SetChargeStatus(0);
@@ -588,9 +650,348 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     // {
         // t->ChangeViewcolor(false);
     // }
+
+#ifdef SUPPORT_CAT1_MODEM
+
+void MsgCenterNotifyHfpWatchHintProc(const Topic topic, Request* req)
+{
+    unused(req);
+
+    phone_VibratorFunc();
+    
+    if(NotificationManager::GetInstance()->HasNotifyShowing())
+    NotificationManager::GetInstance()->StopNotify();
+
+    NotificationManager::GetInstance()->ShowNotify(showcallhintNotify,
+                                                           static_cast<uint16_t>(topic), true);
+}
+
+//来电处理函数
+void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(topic);
+    if (req == NULL) return ;
+    char* call_data = (char*)malloc(req->len);
+    if(call_data==NULL)
+    {
+        return;
+    }
+    int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+    if (ret != EOK) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
+    } else {
+    // Prevent this from happening:
+    // When the incoming call view is displayed, the calling number is not set in CallerLogModel.
+
+        if(NotificationManager::GetInstance()->GetWatchCallStatus() &&
+        (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1))
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_REJECT %s!=%s??",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+            CallerLogModel::GetInstance()->tempSetoperateNumberCAT1END(call_data,req->len);
+            cat1_phone_state_change_cb(OPERATE_WATCH_REJECT);
+            free(call_data);                                
+            return;
+        }
+      
+        if((NotificationManager::GetInstance()->GetWatchCallStatus() &&
+        (CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone)) || uapi_dev_runtime_get_train_status() || transmittingISShow())
+        {
+
+            CallerLogModel::GetInstance()->tempSetoperateNumberCAT1(call_data,req->len);
+            cat1_phone_state_change_cb(OPERATE_WAITING);
+            free(call_data);
+            return;
+        }
+    
+        stopPlayingMusic();
+        PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐
+        uapi_set_screen_on_api();
+        phone_paly_ring();
+      
+        CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data));
+       
+        cat1_phone_state_change_cb(OPERATE_INCOMING);
+       
+    }
+    free(call_data);
+
+}
+//开始通话处理函数
+void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(req);
+
+    if (req == NULL) return ;
+    if(!NotificationManager::GetInstance()->GetWatchCallStatus())
+    {
+        return;
+    }
+    AlarmClockModel::GetInstance()->AlarmPlayerStop();
+    #ifdef SUPPORT_CAT1_HFP_AG_SERV
+     if(uapi_dev_runtime_get_earphone_connect_stat())
+     {
+        
+        if(headset_Is_connect())
+        {   
+            if(headset_SCO_Is_connect()==false)
+            {
+                cat1_ag_send_call_event(TOPIC_EVENT_CAT1_INCOMMING,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+            }
+            else
+            {
+                do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "headset_Is_connect is false");
+            }
+        
+        }
+        else
+        {
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
+        }
+        cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLCONNTED,NULL);
+    }
+    else
+    #endif
+    {
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
+    }
+    SetMicMutecat1(false);
+    cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE);
+
+}
+#include "BluetoothModelC.h"
+#include "audio_manager_c_wrapper.h"
+#include "PhoneService.h"
+//拨号处理函数
+void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify MsgCenterNotifyCat1dialProc");
+    unused(topic);
+    unused(req);
+     if (req == NULL) return ;
+    char* call_data = (char*)malloc(req->len);
+    if(call_data==NULL) return;
+    int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+    if (ret != EOK) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MsgCenterNotify memcpy_s request data fail!");
+    } else {
+
+    // int ret = PlayersModel::GetInstance()->PlayerStop();
+    stopPlayingMusic();
+
+    if(strcmp(call_data,"SOS")==0)
+    {
+        free(call_data);
+        NotificationManager::GetInstance()->ShowNotify(showSOSNotify, (uint16_t)topic, true);
+        return;
+    }
+    
+    cat1_cmd_send(CMD_4G_MAKE_CALL,call_data,strlen(call_data));
+
+    CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
+    cat1_phone_state_change_cb(OPERATE_DIALING);
+
+    #ifdef SUPPORT_CAT1_HFP_AG_SERV
+    if(uapi_dev_runtime_get_earphone_connect_stat())
+    {
+        if(headset_Is_connect())
+        {
+            cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLDIAL,NULL);
+        
+            if(headset_SCO_Is_connect())
+            {
+                do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START, nullptr, 0);
+            }
+        }
+        else
+        {
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0);
+        }
+    }
+    else
     #endif
+    {
+        do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_START, nullptr, 0);
+    }
+   
+    }
+    free(call_data);
 }
+//电话结束处理函数
+void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req)
+{
+    unused(topic);
+    unused(req);
+   
+    // just stop the notify
+    AlarmClockModel::GetInstance()->AlarmPlayerStop();
+
+
+    if(!NotificationManager::GetInstance()->GetWatchCallStatus())
+    {
+        return;
+    }
+
+    if (req == NULL) return ;
+    char* call_data = (char*)malloc(req->len);
 
+    if(call_data==NULL)
+    {
+        return;
+    }
+    int32 ret = memcpy_s(call_data, req->len, req->data, req->len);
+
+    if(strcmp("callfail",call_data)==0)
+    {
+        
+        // cat1_call_hungup();
+        cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
+        CustomEventPublish(TOPIC_EVENT_CAT1_CALL_FAIL,NULL,0);
+
+        free(call_data);
+        return;
+    }
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s %s",call_data,CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+    uint8_t offset_watch =0;
+    if(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()[0]=='+')
+    {
+        offset_watch++;
+    }
+
+    uint8_t offset_call =0;
+    if(call_data[0]=='+')
+    {
+        offset_call++;
+    }
+
+    if(strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str()+offset_watch,call_data+offset_call)!=0 && 
+        CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourceCat1)
+    {
+       
+       WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no OPERATE_WATCH_FINISH");
+        #ifdef SUPPORT_CAT1_HFP_AG_SERV
+        cat1_ag_send_call_event(TOPIC_EVENT_CAT1_CALLENDED,NULL);
+        #endif       
+    } 
+    else
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OPERATE_WATCH_FINISH");
+        cat1_phone_state_change_cb(OPERATE_WATCH_FINISH);
+        #ifdef SUPPORT_CAT1_HFP_AG_SERV
+
+        #endif
+    }
+
+    free(call_data);
+    
+}
+
+void MsgCenterNotifyCat1FailEProc(const Topic topic, Request* req)
+{
+    unused(req);
+
+    phone_VibratorFunc();
+
+    if(NotificationManager::GetInstance()->HasNotifyShowing())
+    NotificationManager::GetInstance()->StopNotify();
+
+    NotificationManager::GetInstance()->ShowNotify(showcallfailNotify,
+                                                           static_cast<uint16_t>(topic), true);
+}
+
+#endif
+
+
+
+//每日训练数据刷新
+void MsgCenterNotifyActivityProc(const Topic topic, Request* req)
+{
+//     unused(topic);
+//     cywee_activity_result_t* c_activity_result_t =  (cywee_activity_result_t *) malloc(req->len);
+//     if(c_activity_result_t==NULL)
+//     {
+//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+//         return;
+//     }
+
+//     int rets = memcpy_s(c_activity_result_t, req->len, (cywee_activity_result_t*)req->data, req->len);
+//     if (rets != EOK)
+//     {
+//         free(c_activity_result_t);
+//         c_activity_result_t = NULL;
+//         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_t failed, ret = %d", rets);
+//         return;
+//     }
+//     if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_NORMAL)
+//     {
+//         /*更新卡路里数据*/
+//         //if(c_activity_result_t->calories!=0)
+//         {
+//             set_calories_data(c_activity_result_t->calories);
+// #if DIALDATASET
+//             uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh();
+            
+//             DialModelCalorie::GetInstance()->UpdateCalorie(calories);
+// #endif
+//         }
+//         /*更新距离数据*/
+//         //if(c_activity_result_t->distance != 0)
+//         {
+//             set_distance_data(c_activity_result_t->distance);  
+// #if DIALDATASET
+//             float  distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh();
+//             DialModelDistance::GetInstance()->UpdateDistance(distance);
+// #endif 
+//         }
+//     }
+//     else if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_FREE_TRAINING && c_activity_result_t->MHR_zone >= 2)
+//     {
+//         /*更新燃脂时间数据*/
+//         set_fat_time_data(1);
+//     }
+    
+//     free(c_activity_result_t);
+//     c_activity_result_t = NULL;
+}
+
+static int train_fat_time = 0;
+
+void MsgCenterNotifyActivityExtraInfoProc(const Topic topic, Request* req)
+{
+    // unused(topic);
+    // cywee_activity_result_extre_info_t* c_activity_result_extre_info_t =  (cywee_activity_result_extre_info_t *) malloc(req->len);
+    // if(c_activity_result_extre_info_t==NULL)
+    // {
+    //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+    //     return;
+    // }
+
+    // int rets = memcpy_s(c_activity_result_extre_info_t, req->len, (cywee_activity_result_extre_info_t*)req->data, req->len);
+    // if (rets != EOK)
+    // {
+    //     free(c_activity_result_extre_info_t);
+    //     c_activity_result_extre_info_t = NULL;
+    //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_extre_info_t failed, ret = %d", rets);
+    //     return;
+    // }
+
+    // if(uapi_dev_runtime_get_train_status() && c_activity_result_extre_info_t->ativity_zone_high_duration)
+    // {
+    //     train_fat_time = c_activity_result_extre_info_t->ativity_zone_high_duration;
+    // }
+    // /*更新燃脂时间数据*/
+    // else if(uapi_dev_runtime_get_train_status() == 0 && train_fat_time)
+    // {
+    //     set_fat_time_data(train_fat_time);
+    //     train_fat_time = 0;
+    // }
+
+    // free(c_activity_result_extre_info_t);
+    // c_activity_result_extre_info_t = NULL;
+}
 /*运动识别*/
 void MsgCenterNotifyArAlertProc(const Topic topic, Request* req)
 {
@@ -707,11 +1108,8 @@ void MsgCenterNotifyGoalShowViewProc(const Topic topic, Request* req)
 
              const power_display_svr_api_t *display_api = power_display_svr_get_api();
 
-            if (display_api->get_screen_state() != SCREEN_ON)
-            {
-                display_api->turn_on_screen();
-            }
-
+            uapi_set_screen_on_api();
+            
             NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
             NotificationManager::GetInstance()->ShowNotify(ShowGoalNotify, static_cast<uint16_t>(topic), true);
         }
@@ -777,6 +1175,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
     {TOPIC_EVENT_HFP_WATCH_TO_PHONE, MsgCenterNotifyHfpPhoneProc},
     {TOPIC_EVENT_HFP_WATCH_ACTIVE,   MsgCenterNotifyHfpWatchProc},
     {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
+    {TOPIC_EVENT_HFP_HINT,           MsgCenterNotifyHfpWatchHintProc},
     {TOPIC_EVENT_BLE_TRANSMIT,       MsgCenterNotifybleTransmit},
     {TOPIC_EVENT_DEVICE_BIND,     MsgCenterNotifyDeviceBindProc},
     // #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
@@ -786,6 +1185,17 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
     // #endif
     // #ifdef SUPPORT_CYWEE_SERVICE
     {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,       MsgCenterNotifyArAlertProc},
+#ifdef SUPPORT_CAT1_MODEM
+    {TOPIC_EVENT_CAT1_INCOMMING,        MsgCenterNotifyCatIncomingCallProc},
+    {TOPIC_EVENT_CAT1_CALLCONNTED,      MsgCenterNotifyCat1CallConnectedProc},
+    {TOPIC_EVENT_CAT1_CALLENDED,        MsgCenterNotifyCat1CallEndedProc},
+    {TOPIC_EVENT_CAT1_CALLDIAL,         MsgCenterNotifyCat1dialProc},
+
+    // {TOPIC_EVENT_CAT1_SIGNAL_UPDATE,    MsgCenterNotifyCat1SignalUpdateProc},
+    // {TOPIC_EVENT_CAT1_POWER_ON,      MsgCenterNotifyCat1PowerOnProc},
+    // {TOPIC_EVENT_CAT1_POWER_OFF,      MsgCenterNotifyCat1PowerOffProc},
+     {TOPIC_EVENT_CAT1_CALL_FAIL, MsgCenterNotifyCat1FailEProc},
+#endif
     {TOPIC_EVENT_INACTIVITY_UPDATE,       MsgCenterNotifyInactivityProc},
     // #endif
     {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/phone_crt.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/phone_crt.cpp
new file mode 100644 (file)
index 0000000..d692535
--- /dev/null
@@ -0,0 +1,788 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.
+ * Description: makephone notification implement
+ * Author: CompanyName
+ * Create: 2023-08-11
+ */
+
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "CallerLogModel.h"
+#include "PhoneService.h"
+#include "cmsis_os.h"
+#include "UiConfig.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_button.h"
+#include "common/image_cache_manager.h"
+#include "VolumeSettingView.h"
+#include "VolumeSettingPresenter.h"
+#include "ui_resource_image.h"
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_server.h"
+#include "cat1_ctl.h"
+#include "cat1_porting.h"
+#endif
+#include "custom_runtime.h"
+
+#include "cat1_UI_hal.h"
+#include "custom_utils.h"
+#include "phoneaddressmodel.h"
+#include "components/ui_label_button.h"
+#include "NativeAbility.h"
+#include "dial_sos_c.h"
+#include <string>
+#include "string.h"
+#include "string/osal_string.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button_ext.h"  
+#include "vibrator_service.h"
+// #include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h"
+#include "osal_timer.h"
+#include "cmsis_os2.h"
+#include "custom_save_runtime.h"
+#include "ConfigModel.h"
+#include "transmitting.h"
+#include "custom_utilscpp.h"
+#include "alarm/include/AlarmClockModel.h"
+
+// #define NOTIFY_THREE_SECONDS 3000
+// #define NOTIFY_ONE_SECOND 1000
+// #define NOTIFY_THIRTY_SECONDS 30000
+// #define NOTIFY_ONE_MINUTE 60000
+// #define NOTOFY_NO_OPERATE_TIME 35000
+static uint8_t sos_dail_falg=0;
+
+#define SOS_TEST_FLAG 0
+
+#define SOS_HFP_FALG 1
+
+#define DIAL_TIME 30
+
+    
+
+
+
+uint8_t get_falg_SOS(void)
+{
+    return sos_dail_falg;
+}
+//结束通话运行
+void sos_falg_add(void)
+{
+    if(sos_dail_falg)
+    {
+        if(OHOS::get_sos_number_count()<=0)
+        {
+            cat1_UI_call_dial("SOS");
+            return;
+        }
+
+        printf("sos dial %d\r\n",sos_dail_falg);
+        #if SOS_TEST_FLAG
+        if(1)
+        #else
+        if( uapi_dev_runtime_get_cat1_simstat())
+        #endif
+        {
+            cat1_UI_call_dial(OHOS:: get_sos_number(sos_dail_falg));
+        }
+        #if SOS_HFP_FALG
+        else if(uapi_hfp_connect_state())
+        {
+            DialCall((unsigned char *)OHOS::get_sos_number(sos_dail_falg),osal_strlen((const char*)OHOS::get_sos_number(sos_dail_falg)));
+        }
+        #endif
+        else
+        {
+             cat1_UI_call_dial("SOS");
+        }
+        sos_dail_falg++;
+        if(sos_dail_falg>=OHOS::get_sos_number_count()*3)
+        {
+            sos_dail_falg=0;
+        }
+    }
+}
+
+void sos_falg_clean(void)
+{
+    sos_dail_falg=0;
+}
+
+void start_SOS_phone_dail(void)
+{
+    if(OHOS::get_sos_number_count()<=0)
+    {
+        cat1_UI_call_dial("SOS");
+        return;
+    }
+    #if SOS_TEST_FLAG
+    if(1)
+    #else
+    if(uapi_dev_runtime_get_cat1_simstat())
+    #endif
+    {
+        cat1_UI_call_dial(OHOS::get_sos_number(0));
+         sos_dail_falg=1;
+    }
+    #if SOS_HFP_FALG
+    else if(uapi_hfp_connect_state())
+    {
+        DialCall((unsigned char *)OHOS::get_sos_number(0),osal_strlen((const char*)OHOS::get_sos_number(0)));
+        sos_dail_falg=1;
+    }
+    #endif
+    else
+    {
+        cat1_UI_call_dial("SOS");
+    }
+    
+   
+}
+
+
+
+namespace OHOS {
+
+
+void phone_VibratorFunc(void);
+
+uint8 call_stat=0;
+PhoneCallInfo *phoneCall = NULL;
+
+
+UIViewGroup* SOSView = nullptr;
+static UIImageView *alarm_img=nullptr;
+static UILabelExt *alarm_UILabel=nullptr;
+static UILabelExt *button_UILabel=nullptr;
+static UILabelButtonExt *alarm_labelbutton=nullptr;
+
+UIViewGroup* HintView = nullptr;
+static UILabelExt *Hint_UILabel=nullptr;
+
+
+UIViewGroup* FAILHintView = nullptr;
+static UILabelExt *FAIL_Hint_UILabel=nullptr;
+
+// typedef struct {
+//     char name[NAME_SIZE];
+//     unsigned char nameLen;
+//     unsigned char tel[MAX_PHONE_NUM];
+//     unsigned char telLen;
+ //    CallFinishStatus status;
+//     uint64 creationTime; // 通话创建时间(不是接通时间)
+//     uint64 callDurTime; // 通话持续时间
+// } CallLogInfo;
+void FreeSOSView(void)
+{
+    if (SOSView != nullptr) {
+
+        SOSView->RemoveAll();
+        if(alarm_img)
+        {
+            delete alarm_img;
+            alarm_img=nullptr;
+        }
+
+        if(alarm_UILabel)
+        {
+            delete alarm_UILabel;
+            alarm_UILabel=nullptr;
+        }
+
+        if(alarm_labelbutton)
+        {
+            delete alarm_labelbutton;
+            alarm_labelbutton=nullptr;
+        }
+
+        RootView::GetInstance()->Remove(SOSView);
+        delete SOSView;
+        SOSView = nullptr;
+    }
+}
+
+
+uint8_t CALL_INCOMING_HINT_timer_FALG=0;
+void hintdialtimerCallBack(int data)
+{
+    CALL_INCOMING_HINT_timer_FALG--;
+    if(CALL_INCOMING_HINT_timer_FALG)
+    {
+        phone_VibratorFunc();
+    }
+    if(CALL_INCOMING_HINT_timer_FALG==0)
+    {
+        NotificationManager::GetInstance()->StopNotify();
+    }
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hintdialtimerCallBack ??????!");
+    
+}
+
+
+
+static  osTimerId_t  CALL_INCOMING_HINT_timer= NULL;
+
+void FreehintView(void)
+{
+    if (HintView != nullptr) {
+
+        HintView->RemoveAll();
+        if(Hint_UILabel)
+        {
+            delete Hint_UILabel;
+            Hint_UILabel=nullptr;
+        }
+
+        if(CALL_INCOMING_HINT_timer)
+        {
+            osTimerStop(CALL_INCOMING_HINT_timer);
+            osStatus_t  ret = osTimerDelete(CALL_INCOMING_HINT_timer);
+            if (ret != osOK) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed  ret = %lx!", ret);
+                return;
+            }
+            CALL_INCOMING_HINT_timer = nullptr;
+        }
+
+
+        RootView::GetInstance()->Remove(HintView);
+        delete HintView;
+        HintView = nullptr;
+    }
+}
+
+void hintdialfailtimerCallBack(int data)
+{
+    {
+        NotificationManager::GetInstance()->StopNotify();
+    }
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hintdialtimerCallBack ??????!");
+    
+}
+
+
+static  osTimerId_t  CALL_FAIl_HINT_timer= NULL;
+
+void FreeFAILhintView(void)
+{
+    if (FAILHintView != nullptr) {
+
+        FAILHintView->RemoveAll();
+        if(FAIL_Hint_UILabel)
+        {
+            delete FAIL_Hint_UILabel;
+            FAIL_Hint_UILabel=nullptr;
+        }
+
+        if(CALL_FAIl_HINT_timer)
+        {
+            osTimerStop(CALL_FAIl_HINT_timer);
+            osStatus_t  ret = osTimerDelete(CALL_FAIl_HINT_timer);
+            if (ret != osOK) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed  ret = %lx!", ret);
+                //return;
+            }
+            CALL_FAIl_HINT_timer = nullptr;
+        }
+
+
+        RootView::GetInstance()->Remove(FAILHintView);
+        delete FAILHintView;
+        FAILHintView = nullptr;
+    }
+}
+
+
+
+UIViewGroup* CALL_FAIL_HINT(void)
+{
+   
+    if (FAILHintView == nullptr) {
+        FAILHintView = new UIViewGroup();
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!");
+        
+    }
+    FAILHintView->SetPosition(0, 0);
+    FAILHintView->SetWidth(Screen::GetInstance().GetWidth());
+    FAILHintView->SetHeight(Screen::GetInstance().GetHeight());
+    FAILHintView->SetStyle(STYLE_BACKGROUND_OPA, 0);
+
+    if (FAIL_Hint_UILabel == nullptr) {
+        FAIL_Hint_UILabel = new UILabelExt();
+    }
+    FAIL_Hint_UILabel->SetPosition(62, 199);         // widget's left position and top position
+    FAIL_Hint_UILabel->Resize(340, 30);          // widget's width and height
+    FAIL_Hint_UILabel->SetViewId("label3");// Set style
+    FAIL_Hint_UILabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffAAAAAA);
+    FAIL_Hint_UILabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+    FAIL_Hint_UILabel->SetStyle(STYLE_BORDER_RADIUS, 27);
+    FAIL_Hint_UILabel->SetStyle(STYLE_TEXT_FONT, 40);
+    FAIL_Hint_UILabel->SetStyle(STYLE_LINE_SPACE, 0);
+
+    // Set additional property
+    FAIL_Hint_UILabel->SetText("网络异常");
+    FAIL_Hint_UILabel->SetTextId(STR_NET_ERROR);
+    FAIL_Hint_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+    FAIL_Hint_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    FAIL_Hint_UILabel->SetRollSpeed(0);
+    FAIL_Hint_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+
+    FAILHintView->Add(FAIL_Hint_UILabel);
+    FAIL_Hint_UILabel->SetVisible(true);
+    FAIL_Hint_UILabel->LayoutCenterOfParent();
+
+    uint32_t tick;
+    osStatus_t retTimer;
+    // CALL_INCOMING_HINT_timer_FALG=3;
+
+    if(CALL_FAIl_HINT_timer)
+    osTimerDelete(CALL_FAIl_HINT_timer);
+    CALL_FAIl_HINT_timer=NULL;
+    
+    CALL_FAIl_HINT_timer = osTimerNew((osTimerFunc_t)hintdialfailtimerCallBack, osTimerPeriodic, NULL, NULL);
+    tick =osMs2Tick(2000);// osMs2Tick(1000);
+    retTimer = osTimerStart(CALL_FAIl_HINT_timer, tick);
+    if (retTimer != osOK && CALL_FAIl_HINT_timer != NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+        osTimerDelete(CALL_FAIl_HINT_timer);
+        CALL_FAIl_HINT_timer = NULL;
+        return NULL;
+    }
+    
+    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeFAILhintView);
+
+    return FAILHintView;
+
+}
+
+
+
+
+UIViewGroup* CALL_INCOMING_HINT(void)
+{
+   
+    if (HintView == nullptr) {
+        HintView = new UIViewGroup();
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!");
+        //return nullptr;
+    }
+    HintView->SetPosition(0, 0);
+    HintView->SetWidth(Screen::GetInstance().GetWidth());
+    HintView->SetHeight(Screen::GetInstance().GetHeight());
+    HintView->SetStyle(STYLE_BACKGROUND_OPA, 0);
+
+    if (Hint_UILabel == nullptr) {
+        Hint_UILabel = new UILabelExt();
+    }
+    Hint_UILabel->SetPosition(62, 199);         // widget's left position and top position
+    Hint_UILabel->Resize(340, 30);          // widget's width and height
+    Hint_UILabel->SetViewId("label3");// Set style
+    Hint_UILabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffAAAAAA);
+    Hint_UILabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+    Hint_UILabel->SetStyle(STYLE_BORDER_RADIUS, 27);
+    Hint_UILabel->SetStyle(STYLE_TEXT_FONT, 40);
+    Hint_UILabel->SetStyle(STYLE_LINE_SPACE, 0);
+
+    // Set additional property
+    Hint_UILabel->SetText("新来电");
+    Hint_UILabel->SetTextId(STR_NEW_INCOM);
+    
+    Hint_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+    Hint_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    Hint_UILabel->SetRollSpeed(0);
+    Hint_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
+
+    HintView->Add(Hint_UILabel);
+    Hint_UILabel->SetVisible(true);
+    Hint_UILabel->LayoutCenterOfParent();
+
+    if(CALL_INCOMING_HINT_timer)
+    osTimerDelete(CALL_INCOMING_HINT_timer);
+    CALL_INCOMING_HINT_timer=NULL;
+
+    uint32_t tick;
+    osStatus_t retTimer;
+    CALL_INCOMING_HINT_timer_FALG=3;
+    CALL_INCOMING_HINT_timer = osTimerNew((osTimerFunc_t)hintdialtimerCallBack, osTimerPeriodic, NULL, NULL);
+    tick =osMs2Tick(1000);// osMs2Tick(1000);
+    retTimer = osTimerStart(CALL_INCOMING_HINT_timer, tick);
+    if (retTimer != osOK && CALL_INCOMING_HINT_timer != NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+        osTimerDelete(CALL_INCOMING_HINT_timer);
+        CALL_INCOMING_HINT_timer = NULL;
+        return NULL;
+    }
+    
+    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreehintView);
+
+    return HintView;
+
+}
+
+
+UIViewGroup* SOS_cant_dial(void)
+{
+    SOSView = new UIViewGroup();
+    if (SOSView == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateCallingView callingView null!");
+        return nullptr;
+    }
+    SOSView->SetPosition(0, 0);
+    SOSView->SetWidth(Screen::GetInstance().GetWidth());
+    SOSView->SetHeight(Screen::GetInstance().GetHeight());
+
+    if (alarm_img == nullptr) {
+            alarm_img = new UIImageView();
+    }
+    alarm_img->SetPosition(183, 62);         // widget's left position and top position
+    alarm_img->Resize(100, 100);          // widget's width and height
+    alarm_img->SetViewId("image1");// Set style
+    const char *imageimagesPath = "/user/res/Attention.bin";
+    alarm_img->SetSrc(imageimagesPath);
+    SOSView->Add(alarm_img);
+    alarm_img->SetVisible(true);
+
+    if (alarm_UILabel == nullptr) {
+        alarm_UILabel = new UILabelExt();
+    }
+    alarm_UILabel->SetPosition(46, 215);         // widget's left position and top position
+    alarm_UILabel->Resize(370, 40);          // widget's width and height
+    alarm_UILabel->SetViewId("label1");// Set style
+    alarm_UILabel->SetStyle(STYLE_TEXT_FONT, 33);
+    if(OHOS::get_sos_number_count()<=0)
+    {
+        alarm_UILabel->SetText("未设置SOS号码,请前往APP设置。");
+    }
+    else
+    {
+        alarm_UILabel->SetText("请检查SIM卡或者蓝牙连接");
+    }
+    
+    
+    alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+    alarm_UILabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    alarm_UILabel->SetRollSpeed(0);
+    alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33);
+    SOSView->Add(alarm_UILabel);
+    alarm_UILabel->SetVisible(true);
+
+       // Add LabelButtonExt to App
+    if (alarm_labelbutton == nullptr) {
+        alarm_labelbutton = new UILabelButtonExt();
+    }
+    alarm_labelbutton->SetViewId("SOS_FAIL");// Set style
+    alarm_labelbutton->SetPosition(0, 366, 466, 100);
+    const char *ImgSrc = "/user/res/466x100button.bin";
+    alarm_labelbutton->SetImageSrc(ImgSrc, ImgSrc);
+    alarm_labelbutton->SetText("关闭");
+    alarm_labelbutton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 44);
+    alarm_labelbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+    UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(CallViewEventListener::GetInstance());
+    alarm_labelbutton->SetOnClickListener(button1Click);
+
+    SOSView->Add(alarm_labelbutton);
+    alarm_labelbutton->SetVisible(true);
+    SOSView->SetTouchable(true);
+    alarm_labelbutton->SetTouchable(true);
+    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeSOSView);
+
+    return SOSView;
+
+}
+
+CallLogInfo info;
+
+void calllog_info_init(uint8_t type)
+{
+    strcpy(info.name,"xxx");
+    info.nameLen=3;
+    int len;
+    if(type==0)
+    {
+        len=strlen(CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+        memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),len+1);
+    }
+    else if(type==1)
+    {
+        len=strlen(CallerLogModel::GetInstance()->GettempPhoneNumber().c_str());
+        memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GettempPhoneNumber().c_str(),len+1);
+    }
+    
+
+    uint32_t tmptime=0;
+    uapi_get_timestampe_ss(&tmptime);
+    info.creationTime = tmptime;
+    info.callDurTime=0;
+    info.telLen=len;
+    info.calllogtype=CALL_CAT1;
+}
+
+void addcalllog()
+{
+    if(call_stat==0)
+    info.status=CALL_OUTGOING;
+    if(call_stat==1)
+    info.status=CALL_INCOMING;
+    if(call_stat==2)
+    info.status=CALL_MISSED;
+    if(call_stat<=2)
+    {
+        printf("写入:%s\r\b",info.tel);
+        AddToCallLog_CAT1(&info);
+        call_stat=3;
+    }
+     
+}
+void addcalllogend()
+{
+    CallLogInfo info;
+    strcpy(info.name,"xxx");
+    info.nameLen=3;
+    int len;
+    len=strlen(CallerLogModel::GetInstance()->GettempPhoneendNumber().c_str());
+    memcpy_s(info.tel,20,CallerLogModel::GetInstance()->GettempPhoneendNumber().c_str(),len+1);
+    uint32_t tmptime=0;
+    uapi_get_timestampe_ss(&tmptime);
+    info.creationTime = tmptime;
+    info.callDurTime=0;
+    info.telLen=len;
+    info.calllogtype=CALL_CAT1;
+    info.status=CALL_MISSED;
+    AddToCallLog_CAT1(&info);
+
+    return;
+}
+
+static int g_callOperate = OPERATE_NO_OPE;
+
+
+static void DialingHandle(void)
+{
+
+    CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
+    NotificationManager::GetInstance()->SetWatchCallStatus(true);
+
+    CallerLogModel::GetInstance()->SetDialingStatus("正在拨号");
+    CallerLogModel::GetInstance()->SetMakePhoneStatus(true);
+
+    InitCallingTimer();
+
+    // StartCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY, (int32_t)NOTIFY_ONE_SECOND);
+
+
+}
+
+static void AlertingHandle(void)
+{
+    CallerLogModel::GetInstance()->SetDialingStatus("正在响铃");
+    CallerLogModel::GetInstance()->SetMakePhoneStatus(true);
+}
+
+static void IncomingHandle(void)
+{
+    CallerLogModel::GetInstance()->SetMakePhoneStatus(false);
+
+    CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
+    NotificationManager::GetInstance()->SetWatchCallStatus(true);
+
+    InitCallingTimer();
+}
+
+static void WaitingOpreate()
+{
+    {
+        //  CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
+         NotificationManager::GetInstance()->SetWatchCallStatus(true);
+
+        cat1_call_hungup();
+        CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0);
+        CallerLogModel::GetInstance()->set_RejectIncomingCall_falg(1);
+        return;
+    }
+   
+}
+
+
+static void WatchActiveHandle()
+{
+    
+    CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
+    NotificationManager::GetInstance()->SetWatchCallStatus(true);
+
+    InitCallingTimer();
+    CallerLogModel::GetInstance()->SetCallStatus(true);
+    CallerLogModel::GetInstance()->SetWaitingStatus(false);
+   
+
+}
+
+
+
+static void WatchFinishHandle(void)
+{
+    if (NotificationManager::GetInstance()->GetWatchCallStatus()) 
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWatchCallStatus !!");
+
+        if(get_falg_SOS())
+        {
+            addcalllog();
+            sos_falg_add();
+        }
+        else
+        {
+            if(CallerLogModel::GetInstance()->GetCallSource()==CallerLogModel::CallSourcePhone
+             || uapi_dev_runtime_get_train_status() || transmittingISShow() )
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addcalllogend !!");
+
+                addcalllog();
+
+                if(uapi_dev_runtime_get_train_status() || transmittingISShow())
+                {
+                    StatusReset();
+                }
+
+            }
+            else
+            {
+            
+                addcalllog();
+                StatusReset();
+            }   
+        }   
+               
+    }
+}
+
+//  RUNTIME_LOG_PHONE_CAT1_DIALING,
+//     RUNTIME_LOG_PHONE_CAT1_INCOMING,
+//     RUNTIME_LOG_PHONE_CAT1_WAITING,
+//     RUNTIME_LOG_PHONE_CAT1_ACTIVE,
+//     RUNTIME_LOG_PHONE_CAT1_FINISH,
+//     RUNTIME_LOG_PHONE_CAT1_REJECT,
+
+//     RUNTIME_LOG_PHONE_RESET, //状态复位
+
+
+void  using_cat1_phone_state_change_cb(uint8_t state)
+{
+    g_callOperate = state;
+    // DisableCallTimer(CallTimerType::NOTIFY_PHONE_DIAL_DISPLAY);
+    DisshakeTimer();
+
+    switch (g_callOperate) {
+        case OPERATE_DIALING:
+            // 显示正在呼出界面
+            PhoneServiceScreenCtr(true);
+            DialingHandle();
+            
+            call_stat=0;
+            calllog_info_init(0);
+            uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_DIALING);
+            break;
+        case OPERATE_ALERTING:
+            // 显示对方响铃
+            AlertingHandle();
+            break;
+        case OPERATE_INCOMING:
+            // 显示电话呼入
+            PhoneServiceScreenCtr(true);
+            IncomingHandle();
+            calllog_info_init(0);
+            InitshakeTimer();
+            
+            call_stat=2;
+             uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_INCOMING);
+            break;
+        case OPERATE_WAITING:
+            WaitingOpreate();
+            call_stat=2;
+            calllog_info_init(1);
+            uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_WAITING);
+            return;
+        case OPERATE_WATCH_ACTIVE:
+            // 手表接听,显示界面
+            if(call_stat==2)
+            call_stat=1;
+            PhoneServiceScreenCtr(true);
+            WatchActiveHandle();
+             uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_ACTIVE);
+            break;
+        case OPERATE_PHONE_HOLD:
+            // 挂起状态,不做处理
+            return;
+        case OPERATE_WATCH_FINISH:
+        
+            WatchFinishHandle();
+            uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_FINISH);
+            return;
+        //手表不做任何处理仅记录
+        case OPERATE_WATCH_REJECT:
+            CustomEventPublish(TOPIC_EVENT_HFP_HINT,NULL,0);
+            addcalllogend();
+            uapi_save_runtime_log(RUNTIME_LOG_PHONE_CAT1_REJECT);
+
+            return;
+        default:
+            break;
+    }
+    CAT1_ChangeStatusScreendisplay(g_callOperate);
+}
+
+void cat1_phone_state_change_cb(uint8_t state)
+{
+    GraphicService::GetInstance()->PostGraphicEvent(
+            std::bind(using_cat1_phone_state_change_cb,state));
+}
+
+            
+
+
+
+uint16_t dail_falg=0;
+void CalldialTimerCallBackProc(int data)
+{
+    if(dail_falg<=DIAL_TIME)
+    dail_falg++;
+    
+    if(dail_falg>=DIAL_TIME &&
+     strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),"110")!=0
+      && strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),"112")!=0
+       && strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),"120")!=0
+        && strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),"119")!=0 
+         && strcmp(CallerLogModel::GetInstance()->GetPhoneNumber().c_str(),"122")!=0 )
+    {
+        cat1_call_hungup_timer();
+
+        // cat1_handle_call_disconnected((char *)CallerLogModel::GetInstance()->GetPhoneNumber().c_str());
+    }
+   
+}
+
+void phone_paly_ring(void)
+{
+    if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()) && true != ConfigModel::GetInstance()->GetSilentMode())
+    {
+        // dinit_ai_task();
+        LOS_Msleep(50);
+        AlarmClockModel::GetInstance()->testPlayerStart(RING_MUSIC);
+    }
+}
+
+void phone_VibratorFunc(void)
+{
+    if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+    {
+        custom_VibratorFunc_int(0);
+    }
+}
+ 
+  
+
+
+
+}  // namespace OHOS
\ No newline at end of file
index 366c61c..fe2d37e 100644 (file)
@@ -426,6 +426,7 @@ target = {
                         #   "-:lwip",
                           "cat1Service",
                           "cat1Test",
+                          "4gTestcpp",
                           "audio_manager",
                           "CustomUIcomponentTool",
                           "nativeabilityfwk",
@@ -1005,6 +1006,7 @@ target = {
             #cat1 相关配置
             "cat1Service",
             "cat1Test",
+            "4gTestcpp",
             #websocket 相关配置
             "zhihui_websocket",
             #ai 相关配置
index a8ad2a9..1bb76eb 100644 (file)
@@ -9,6 +9,7 @@ if ("${CHIP}" STREQUAL "brandy")
         set(SOURCES
             ${CMAKE_CURRENT_SOURCE_DIR}/player_sample_wrapper.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/audio_manager_c_wrapper.cpp
+            
         )
     else()
         set(SOURCE_COM ${SOURCES})
@@ -18,6 +19,7 @@ if ("${CHIP}" STREQUAL "brandy")
             ${CMAKE_CURRENT_SOURCE_DIR}/player_sample_wrapper.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/video_player_sample_wrapper.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/voice_call_volte_sample_wrapper.cpp
+            ${CMAKE_CURRENT_SOURCE_DIR}/voice_call_volte_bluetooth_wrapper.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/audio_manager_c_wrapper.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/audio_player_service.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/audio_player_test.cpp
diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_bluetooth_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_bluetooth_wrapper.cpp
new file mode 100644 (file)
index 0000000..1cf10cd
--- /dev/null
@@ -0,0 +1,577 @@
+/*
+ * Copyright (c) CompanyNameMagicTag. 2023-2023. All rights reserved.
+ * Description: voice call volte bluetooth sample wrapper (without LOCAL_VOICE_CALL)
+ * Author: Media Software Group
+ * Create: 2023-07-06
+ */
+
+#include "voice_call_volte_sample_wrapper.h"
+
+#include <climits>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string>
+#include <iostream>
+#include <unistd.h>
+#include "securec.h"
+
+#include "audio_manager.h"
+#include "audio_stream_in.h"
+#include "audio_stream_out.h"
+#include "audio_base_type.h"
+
+#include "media_log.h"
+#include "media_thread_adapt.h"
+#include "audio_manager_c_wrapper.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+using namespace::Audio;
+
+#define MEDIA_CMD_LEN_MAX 128
+#define MEDIA_UNUSED(x) ((void)(x))
+
+#define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0]))
+
+const int32_t NUMBER_BASE = 10;
+const int32_t CHANNEL_COUNT = 2;
+const int32_t SAMPLERATE_16000 = 16000;
+
+typedef struct {
+    AudioSession sessionId;
+    AudioInterrupt interrupt;
+    bool isVoiceCallVolteStopped;
+    MediaMutexHandle mutex;
+    MediaThreadCondHandle cond;
+    uint8_t *data;
+    uint32_t size;
+    MediaThreadIdHandle taskHandle;
+    int32_t type;
+} VoiceCallVolteContext;
+
+static MediaMutexHandle g_voiceCallVolteContextMutex = nullptr;
+static VoiceCallVolteContext *g_voiceCallVolteContext = nullptr;
+
+static AudioManager& g_amInstance = AudioManager::GetInstance();
+
+// Bluetooth voice call streams (without LOCAL_VOICE_CALL)
+static std::shared_ptr<AudioStreamIn> g_streamInUplink = nullptr;
+static std::shared_ptr<AudioStreamIn> g_streamInDwnink = nullptr;
+static std::shared_ptr<AudioStreamOut> g_streamOutUplink = nullptr;
+static std::shared_ptr<AudioStreamOut> g_streamOutDownink = nullptr;
+
+static int32_t StartVoiceCall(const char **param);
+static int32_t StopVoiceCall(const char **param);
+static int32_t VoiceCallSetVolume(const char **param);
+static int32_t VoiceCAllSeaEnable(const char **param);
+static int32_t VoiceCallMicMute(const char **param);
+static int32_t VoiceCallSetBitRate(const char **param);
+
+typedef struct {
+    char cmd[MEDIA_CMD_LEN_MAX];
+    int32_t (*func)(const char **param);
+} FuncsMap;
+
+static FuncsMap g_voiceCallVolteFuncs[] = {
+    { "start", StartVoiceCall },
+    { "stop", StopVoiceCall },
+    { "setvolume", VoiceCallSetVolume },
+    { "seaenable", VoiceCAllSeaEnable },
+    { "mute", VoiceCallMicMute },
+    { "bitrate", VoiceCallSetBitRate },
+};
+
+class VoiceCallVolteInterruptListener : public InterruptListener {
+public:
+    explicit VoiceCallVolteInterruptListener(VoiceCallVolteContext *in) : context(in)
+    {
+    }
+    ~VoiceCallVolteInterruptListener() override {};
+
+    void OnInterrupt(int32_t type, int32_t hint) override
+    {
+        MEDIA_INFO_LOG("OnInterrupt, type:%d, hint:%d", type, hint);
+
+        if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_PAUSE) {
+            MEDIA_INFO_LOG("voice call volte pause signal one");
+        }
+        if (type == INTERRUPT_TYPE_END && hint == INTERRUPT_HINT_RESUME) {
+            MEDIA_INFO_LOG("voice call volte resume signal one");
+        }
+        if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_STOP) {
+            MEDIA_INFO_LOG("voice call volte stop begin signal one");
+        }
+        if (type == INTERRUPT_TYPE_END && hint == INTERRUPT_HINT_STOP) {
+            MEDIA_INFO_LOG("voice call volte stop end signal one");
+            context->isVoiceCallVolteStopped = true;
+        }
+    }
+
+private:
+    VoiceCallVolteContext *context;
+};
+
+static void DeinitVoiceCallVolteResources(VoiceCallVolteContext *context)
+{
+    (void)g_streamInUplink.reset();
+    (void)g_streamOutUplink.reset();
+    (void)g_streamInDwnink.reset();
+    (void)g_streamOutDownink.reset();
+}
+
+static bool InitVoiceCallVolteResources(VoiceCallVolteContext *context)
+{
+    context->mutex = MediaMutexCreate(nullptr);
+    if (context->mutex == nullptr) {
+        MEDIA_ERR_LOG("create mutex failed");
+        return false;
+    }
+    context->cond = MediaThreadCondCreate();
+    if (context->cond == nullptr) {
+        MEDIA_ERR_LOG("create Voice Call Volte thread cond failed");
+        MediaMutexDestroy(&context->mutex);
+        return false;
+    }
+    return true;
+}
+
+static int32_t BluetoothVoiceCallVolteInit(VoiceCallVolteContext *context)
+{
+    g_streamInUplink = std::make_shared<AudioStreamIn>();
+    CapturerInputConfig captureConfig = {};
+    captureConfig.audioFormat = mSBC;
+    captureConfig.channelCount = 1;
+    captureConfig.linkDir = AUDIO_UP_LINK;
+    captureConfig.sampleRate = SAMPLERATE_16000;
+    captureConfig.sessionID = context->sessionId;
+    captureConfig.streamType = AUDIO_STREAM_VOICE_CALL_VOLTE;
+    int32_t ret = g_streamInUplink->Init(captureConfig);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in uplink init failed");
+    }
+    
+    g_streamOutUplink = std::make_shared<AudioStreamOut>();
+    AudioRendererConfig renderConfig = {};
+    renderConfig.audioFormat = mSBC;
+    renderConfig.channelCount = 1;
+    renderConfig.linkDir = AUDIO_UP_LINK;
+    renderConfig.sampleRate = SAMPLERATE_16000;
+    renderConfig.sessionID = context->sessionId;
+    renderConfig.streamType = AUDIO_STREAM_VOICE_CALL_VOLTE;
+    ret = g_streamOutUplink->Init(renderConfig);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out uplink init failed");
+    }
+    
+    g_streamInDwnink = std::make_shared<AudioStreamIn>();
+    captureConfig.linkDir = AUDIO_DOWN_LINK;
+    ret = g_streamInDwnink->Init(captureConfig);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in downink init failed");
+    }
+    
+    g_streamOutDownink = std::make_shared<AudioStreamOut>();
+    renderConfig.linkDir = AUDIO_DOWN_LINK;
+    ret = g_streamOutDownink->Init(renderConfig);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out downink init failed");
+    }
+    return ret;
+}
+
+static int32_t BluetoothVoiceCallVolteStart(void)
+{
+    int32_t ret = g_streamInUplink->Start();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in uplink start failed");
+    }
+
+    ret = g_streamOutUplink->Play();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out uplink play failed");
+    }
+
+    ret = g_streamInDwnink->Start();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in downink start failed");
+    }
+
+    ret = g_streamOutDownink->Play();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out downink play failed");
+    }
+
+    uint32_t asoUplinkChannelId = 0;
+    g_streamOutUplink->GetCurrentChannelId(asoUplinkChannelId);
+
+    MEDIA_INFO_LOG("asoUplinkChannelId: 0x%x", asoUplinkChannelId);
+
+    g_streamInUplink->AttachBackend(asoUplinkChannelId);
+
+    uint32_t asiDownlinkChannelId = 0;
+    g_streamInDwnink->GetCurrentChannelId(asiDownlinkChannelId);
+
+    MEDIA_INFO_LOG("asiDownlinkChannelId: 0x%x", asiDownlinkChannelId);
+
+    g_streamOutDownink->AttachFrontend(asiDownlinkChannelId);
+    return ret;
+}
+
+static int32_t BluetoothVoiceCallVolteStop(void)
+{
+    int32_t ret = g_streamInUplink->Stop();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in uplink stop failed");
+    }
+
+    if (g_streamOutUplink->Stop() != 0) {
+        MEDIA_ERR_LOG("audio stream out uplink stop failed");
+    }
+
+    if (g_streamInDwnink->Stop() != 0) {
+        MEDIA_ERR_LOG("audio stream in downink stop failed");
+    }
+
+    ret = g_streamOutDownink->Stop();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out downink stop failed");
+    }
+
+    ret = g_streamInUplink->Release();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in uplink release failed");
+    }
+
+    ret = g_streamOutUplink->Release();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out uplink release failed");
+    }
+
+    ret = g_streamInDwnink->Release();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream in downink release failed");
+    }
+
+    ret = g_streamOutDownink->Release();
+    if (ret != 0) {
+        MEDIA_ERR_LOG("audio stream out downink release failed");
+    }
+
+    ret = g_amInstance.SetDeviceConnectionState(IN_BLUETOOTH_SCO, AUDIO_DEVICE_DISCONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set sco in device disconnect failed");
+    }
+
+    ret = g_amInstance.SetDeviceConnectionState(OUT_BLUETOOTH_SCO, AUDIO_DEVICE_DISCONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set sco out device disconnect failed");
+    }
+
+    ret = g_amInstance.SetDeviceConnectionState(IN_MODEM_HEADSET, AUDIO_DEVICE_DISCONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set modem headset in device disconnect failed");
+    }
+
+    ret = g_amInstance.SetDeviceConnectionState(OUT_MODEM_HEADSET, AUDIO_DEVICE_DISCONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set modem headset out device disconnect failed");
+    }
+    return ret;
+}
+
+static int32_t RunVoiceCallVolte(VoiceCallVolteContext *context)
+{
+    bool success = InitVoiceCallVolteResources(context);
+    if (!success) {
+        MEDIA_ERR_LOG("init voice call volte resources failed");
+        return -1;
+    }
+    
+    int32_t ret = 0;
+    
+    // Set up Bluetooth SCO and modem headset connections
+    ret = g_amInstance.SetDeviceConnectionState(IN_BLUETOOTH_SCO, AUDIO_DEVICE_CONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set sco in device connect failed");
+    }
+    
+    ret = g_amInstance.SetDeviceConnectionState(OUT_BLUETOOTH_SCO, AUDIO_DEVICE_CONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set sco out device connect failed");
+    }
+    
+    ret = g_amInstance.SetDeviceConnectionState(IN_MODEM_HEADSET, AUDIO_DEVICE_CONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set modem headset in device connect failed");
+    }
+    
+    ret = g_amInstance.SetDeviceConnectionState(OUT_MODEM_HEADSET, AUDIO_DEVICE_CONNECTED);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set modem headset out device connect failed");
+    }
+    
+    ret = BluetoothVoiceCallVolteInit(context);
+    if (ret != 0) {
+        return ret;
+    }
+    
+    BluetoothVoiceCallVolteStart();
+    
+    MediaMutexLock(context->mutex);
+    while (!context->isVoiceCallVolteStopped) {
+        MediaThreadCondWait(context->cond, context->mutex);
+    }
+    MediaMutexUnLock(context->mutex);
+
+    BluetoothVoiceCallVolteStop();
+    DeinitVoiceCallVolteResources(context);
+    return 0;
+}
+
+static bool RequsetAudioFocus(VoiceCallVolteContext *context)
+{
+    bool success = g_amInstance.Initialize();
+    if (!success) {
+        MEDIA_ERR_LOG("audiomanager init failed");
+        return false;
+    }
+
+    AudioSession sessionId = g_amInstance.MakeSessionId();
+    if (sessionId == AUDIO_SESSION_ID_NONE) {
+        MEDIA_ERR_LOG("audio session id invalid");
+        return false;
+    }
+
+    std::shared_ptr<VoiceCallVolteInterruptListener> interruptListener =
+        std::make_shared<VoiceCallVolteInterruptListener>(context);
+    if (interruptListener == nullptr || interruptListener.get() == nullptr) {
+        MEDIA_ERR_LOG("voice call volte interrupt listener is nullptr");
+        return false;
+    }
+
+    AudioInterrupt interrupt = { AUDIO_STREAM_VOICE_CALL_VOLTE, sessionId, interruptListener };
+    if (g_amInstance.ActivateAudioInterrupt(interrupt) == INTERRUPT_FAILED) {
+        MEDIA_ERR_LOG("activate audio interrupt failed");
+        return false;
+    }
+
+    context->sessionId = sessionId;
+    context->interrupt = interrupt;
+
+    return true;
+}
+
+static bool ReleaseAudioFocus(VoiceCallVolteContext *context)
+{
+    if (g_amInstance.DeactivateAudioInterrupt(context->interrupt) != 0) {
+        MEDIA_ERR_LOG("deactivate audio interrupt failed");
+        return false;
+    }
+    return true;
+}
+
+static void *VoiceCallVolteThread(void *priv)
+{
+    VoiceCallVolteContext *context = (VoiceCallVolteContext *)priv;
+
+    bool success = RequsetAudioFocus(context);
+    if (!success) {
+        MEDIA_ERR_LOG("requset audio focus failed");
+        return nullptr;
+    }
+
+    int32_t ret = RunVoiceCallVolte(context);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("run voice call volte failed");
+        (void)ReleaseAudioFocus(context);
+        return nullptr;
+    }
+
+    success = ReleaseAudioFocus(context);
+    if (!success) {
+        MEDIA_ERR_LOG("release audio focus failed");
+        return nullptr;
+    }
+
+    return nullptr;
+}
+
+static int32_t StartVoiceCall(const char **param)
+{
+    MediaMutexLock(g_voiceCallVolteContextMutex);
+    int32_t type = strtol(param[0x1], nullptr, NUMBER_BASE);
+    if (g_voiceCallVolteContext != nullptr) {
+        MEDIA_ERR_LOG("invalid operation");
+        goto EXIT;
+    }
+    
+    g_voiceCallVolteContext = (VoiceCallVolteContext *)malloc(sizeof(VoiceCallVolteContext));
+    if (g_voiceCallVolteContext == nullptr) {
+        MEDIA_ERR_LOG("malloc failed");
+        goto EXIT;
+    }
+    
+    if (memset_s(g_voiceCallVolteContext, sizeof(VoiceCallVolteContext), 0, sizeof(VoiceCallVolteContext)) != EOK) {
+        MEDIA_ERR_LOG("memset_s failed");
+        goto EXIT;
+    }
+    
+    MediaMutexUnLock(g_voiceCallVolteContextMutex);
+    MediaThreadJoin(&g_voiceCallVolteContext->taskHandle);
+    g_voiceCallVolteContext->type = type;
+    
+    // For Bluetooth voice call, we only support type 0 (normal voice call)
+    if (type == 0) {
+        MediaThreadattr attr = { "VoiceCallVolteThread", 0x2000, THREAD_SCHED_INVALID, 0, true };
+        MediaThreadIdHandle taskHandle = MediaThreadCreate(VoiceCallVolteThread, g_voiceCallVolteContext, &attr);
+        if (taskHandle == nullptr) {
+            MEDIA_ERR_LOG("create voice call volte thread failed");
+            free(g_voiceCallVolteContext);
+            g_voiceCallVolteContext = nullptr;
+            return -1;
+        }
+        g_voiceCallVolteContext->taskHandle = taskHandle;
+    } else {
+        MEDIA_ERR_LOG("unsupported voice call type: %d", type);
+        free(g_voiceCallVolteContext);
+        g_voiceCallVolteContext = nullptr;
+        return -1;
+    }
+    
+    return 0;
+EXIT:
+    MediaMutexUnLock(g_voiceCallVolteContextMutex);
+    return -1;
+}
+
+static int32_t StopVoiceCall(const char **param)
+{
+    MEDIA_UNUSED(param);
+    MediaMutexLock(g_voiceCallVolteContextMutex);
+    if (g_voiceCallVolteContext == nullptr) {
+        MEDIA_ERR_LOG("voice call volte context is null, execute start command first");
+        MediaMutexUnLock(g_voiceCallVolteContextMutex);
+        return -1;
+    }
+    
+    if (g_voiceCallVolteContext->isVoiceCallVolteStopped) {
+        MEDIA_ERR_LOG("voice call volte already stopped");
+    }
+    
+    MediaMutexLock(g_voiceCallVolteContext->mutex);
+    g_voiceCallVolteContext->isVoiceCallVolteStopped = true;
+    MediaThreadCondSignal(g_voiceCallVolteContext->cond);
+    MediaMutexUnLock(g_voiceCallVolteContext->mutex);
+    
+    MediaThreadJoin(&g_voiceCallVolteContext->taskHandle);
+    (void)MediaThreadCondDestroy(&g_voiceCallVolteContext->cond);
+    (void)MediaMutexDestroy(&g_voiceCallVolteContext->mutex);
+
+    if (g_voiceCallVolteContext != nullptr) {
+        free(g_voiceCallVolteContext);
+        g_voiceCallVolteContext = nullptr;
+    }
+    
+    MediaMutexUnLock(g_voiceCallVolteContextMutex);
+    return 0;
+}
+
+static int32_t VoiceCAllSeaEnable(const char **param)
+{
+    if (g_voiceCallVolteContext->type != 0) {
+        MEDIA_ERR_LOG("not support set sae enable!");
+        return -1;
+    }
+    
+    int32_t enable = strtol(param[0x1], nullptr, NUMBER_BASE);
+    int32_t ret = 0;
+    if (enable == 0) {
+        ret = AudioManagerSetSeaEnable(false);
+    } else {
+        ret = AudioManagerSetSeaEnable(true);
+    }
+    
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set sae enable failed");
+        return -1;
+    }
+    return 0;
+}
+
+static int32_t VoiceCallMicMute(const char **param)
+{
+    if (g_voiceCallVolteContext->type != 0) {
+        MEDIA_ERR_LOG("not support set mic mute!");
+        return -1;
+    }
+    
+    int32_t mute = strtol(param[0x1], nullptr, NUMBER_BASE);
+    int32_t ret = 0;
+    if (mute == 0) {
+        ret = AudioStreamOutSetMute(false);
+    } else {
+        ret = AudioStreamOutSetMute(true);
+    }
+    
+    if (ret != 0) {
+        MEDIA_ERR_LOG("set mic mute failed");
+        return -1;
+    }
+    return 0;
+}
+
+static int32_t VoiceCallSetBitRate(const char **param)
+{
+    // Bluetooth voice call doesn't support bit rate setting
+    MEDIA_ERR_LOG("bluetooth voice call doesn't support Set Bit Rate!");
+    return -1;
+}
+
+static int32_t VoiceCallSetVolume(const char **param)
+{
+    if (g_voiceCallVolteContext->type != 0) {
+        MEDIA_ERR_LOG("not support set volume!");
+        return -1;
+    }
+    
+    int32_t linearVolume = strtol(param[0x1], nullptr, NUMBER_BASE);
+    int32_t ret = AudioManagerSetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, linearVolume);
+    if (ret != 0) {
+        MEDIA_ERR_LOG("SetVolume:%d failed", linearVolume);
+        return -1;
+    }
+    
+    MEDIA_ERR_LOG("SetVolume:%d success", linearVolume);
+    return 0;
+}
+
+int32_t VoiceCallVolteBluetoothSample(int32_t argc, const char *argv[])
+{
+    MEDIA_UNUSED(argc);
+    MEDIA_INFO_LOG("enter bluetooth voice call volte sample");
+
+    MEDIA_INFO_LOG("input param:%s", argv[0]);
+
+    int32_t ret = -1;
+    for (uint32_t i = 0; i < ARRAY_SIZE(g_voiceCallVolteFuncs); i++) {
+        if (strcmp(g_voiceCallVolteFuncs[i].cmd, argv[0]) == 0) {
+            ret = g_voiceCallVolteFuncs[i].func(argv);
+        } else {
+            continue;
+        }
+        MEDIA_INFO_LOG("%s execute %s", g_voiceCallVolteFuncs[i].cmd, (ret != 0) ? "failed" : "success");
+    }
+
+    // will free g_voiceCallVolteContext when voice call volte exit
+    MEDIA_INFO_LOG("exit");
+    return 0;
+}
+
+#ifdef __cplusplus
+};
+#endif
index 57b5a14..8b5b58a 100644 (file)
@@ -221,7 +221,7 @@ static int32_t LocalVoiceCallVolteStop(void)
     if (ret != 0) {
         MEDIA_ERR_LOG("audio stream out release failed");
     }
-    if (g_voiceCallVolteContext->type == 0) {\r
+    if (g_voiceCallVolteContext->type == 0) {
         ret = AudioManagerSetDeviceConnectionState(IN_MODEM, AUDIO_DEVICE_DISCONNECTED);
         if (ret != 0) {
             MEDIA_ERR_LOG("set modem in device disconnect failed");
@@ -230,7 +230,7 @@ static int32_t LocalVoiceCallVolteStop(void)
         ret = AudioManagerSetDeviceConnectionState(OUT_MODEM, AUDIO_DEVICE_DISCONNECTED);
         if (ret != 0) {
             MEDIA_ERR_LOG("set modem out device disconnect failed");
-        }\r
+        }
     }
     return ret;
 }
@@ -419,28 +419,28 @@ static int32_t RunLocalVoiceCallVolte(VoiceCallVolteContext *context)
         MEDIA_ERR_LOG("audio stream out play failed");
         return ret;
     }
-    while (true) {\r
-        MediaMutexLock(context->mutex);\r
-        if (context->isVoiceCallVolteStopped) {\r
-            MediaMutexUnLock(context->mutex);\r
-            break;\r
-        }\r
-        MediaMutexUnLock(context->mutex);\r
-        context->size = 0x800;\r
-        ret = AudioStreamInObtainBuffer(context->data, &context->size);\r
-        if (ret != 0) {\r
-            usleep(10000);\r
-            continue;\r
-        }\r
-        while (true) {\r
-            ret = AudioStreamOutStreamWrite(context->data, context->size);\r
-            if (ret != 0) {\r
-                MEDIA_ERR_LOG("audio stream out send data failed");\r
-                usleep(10000);\r
-                continue;\r
-            }\r
-            break;\r
-        }\r
+    while (true) {
+        MediaMutexLock(context->mutex);
+        if (context->isVoiceCallVolteStopped) {
+            MediaMutexUnLock(context->mutex);
+            break;
+        }
+        MediaMutexUnLock(context->mutex);
+        context->size = 0x800;
+        ret = AudioStreamInObtainBuffer(context->data, &context->size);
+        if (ret != 0) {
+            usleep(10000);
+            continue;
+        }
+        while (true) {
+            ret = AudioStreamOutStreamWrite(context->data, context->size);
+            if (ret != 0) {
+                MEDIA_ERR_LOG("audio stream out send data failed");
+                usleep(10000);
+                continue;
+            }
+            break;
+        }
     }
     ret = LocalVoiceCallVolteStop();
     DeinitVoiceCallVolteResources(context);
@@ -628,8 +628,10 @@ static void *VoiceCallVolteThread(void *priv)
 
 static int32_t StartVoiceCall(const char **param)
 {
+    MEDIA_ERR_LOG("StartVoiceCall");
+    
     MediaMutexLock(g_voiceCallVolteContextMutex);
-    int32_t type = strtol(param[0x1], nullptr, NUMBER_BASE);
+    int32_t type = 0;//strtol(param[0x1], nullptr, NUMBER_BASE);
     if (g_voiceCallVolteContext != nullptr) {
         MEDIA_ERR_LOG("invalid operation");
         goto EXIT;
@@ -643,10 +645,13 @@ static int32_t StartVoiceCall(const char **param)
         MEDIA_ERR_LOG("memset_s failed");
         goto EXIT;
     }
-    MediaMutexUnLock(g_voiceCallVolteContextMutex);\r
+    MediaMutexUnLock(g_voiceCallVolteContextMutex);
     MediaThreadJoin(&g_voiceCallVolteContext->taskHandle);
     g_voiceCallVolteContext->type = type;
-    if (type == 0) {\r
+
+    MEDIA_ERR_LOG("g_voiceCallVolteContext->taskHandle");
+
+    if (type == 0) {
         MediaThreadattr attr = { "VoiceCallVolteThread", 0x2000, THREAD_SCHED_INVALID, 0, true };
         MediaThreadIdHandle taskHandle = MediaThreadCreate(VoiceCallVolteThread, g_voiceCallVolteContext, &attr);
         if (taskHandle == nullptr) {
@@ -654,10 +659,10 @@ static int32_t StartVoiceCall(const char **param)
             free(g_voiceCallVolteContext);
             g_voiceCallVolteContext = nullptr;
             return -1;
-        }\r
-    } else {\r
-        g_voiceCallVolteContext->data = (uint8_t *)malloc(0x400);\r
-        g_voiceCallVolteContext->size = 0x400;\r
+        }
+    } else {
+        g_voiceCallVolteContext->data = (uint8_t *)malloc(0x400);
+        g_voiceCallVolteContext->size = 0x400;
         MediaThreadattr attr = { "LocalVoiceCallVolteThread", 0x2000, THREAD_SCHED_INVALID, 0, false };
         MediaThreadIdHandle taskHandle = MediaThreadCreate(LocalVoiceCallVolteThread, g_voiceCallVolteContext, &attr);
         if (taskHandle == nullptr) {
@@ -665,8 +670,8 @@ static int32_t StartVoiceCall(const char **param)
             free(g_voiceCallVolteContext);
             g_voiceCallVolteContext = nullptr;
             return -1;
-        }\r
-        g_voiceCallVolteContext->taskHandle = taskHandle;\r
+        }
+        g_voiceCallVolteContext->taskHandle = taskHandle;
     }
     return 0;
 EXIT:
@@ -704,11 +709,12 @@ static int32_t StopVoiceCall(const char **param)
 
 static int32_t VoiceCAllSeaEnable(const char **param)
 {
-    if (g_voiceCallVolteContext->type != 0) {\r
+    if (g_voiceCallVolteContext->type != 0) {
         MEDIA_ERR_LOG("not support set sae enable!");
-        return -1;\r
+        return -1;
     }
-    int32_t enable = strtol(param[0x1], nullptr, NUMBER_BASE);
+    int32_t enable = 1;//strtol(param[0x1], nullptr, NUMBER_BASE);
+    MEDIA_ERR_LOG("enable %d",enable);
     int32_t ret = 0;
     if (enable == 0) {
         ret = AudioManagerSetSeaEnable(false);
@@ -724,9 +730,9 @@ static int32_t VoiceCAllSeaEnable(const char **param)
 
 static int32_t VoiceCallMicMute(const char **param)
 {
-    if (g_voiceCallVolteContext->type != 0) {\r
+    if (g_voiceCallVolteContext->type != 0) {
         MEDIA_ERR_LOG("not support set mic mute!");
-        return -1;\r
+        return -1;
     }
     int32_t mute = strtol(param[0x1], nullptr, NUMBER_BASE);
     int32_t ret = 0;
@@ -744,9 +750,9 @@ static int32_t VoiceCallMicMute(const char **param)
 
 static int32_t VoiceCallSetBitRate(const char **param)
 {
-    if (g_voiceCallVolteContext->type == 0) {\r
+    if (g_voiceCallVolteContext->type == 0) {
         MEDIA_ERR_LOG("not support Set Bit Rate!");
-        return -1;\r
+        return -1;
     }
     uint32_t bitRate = (uint32_t)strtol(param[0x1], nullptr, NUMBER_BASE);
     int32_t ret = AudioStreamInSetBitRate(bitRate);
@@ -760,9 +766,9 @@ static int32_t VoiceCallSetBitRate(const char **param)
 
 static int32_t VoiceCallSetVolume(const char **param)
 {
-    if (g_voiceCallVolteContext->type != 0) {\r
+    if (g_voiceCallVolteContext->type != 0) {
         MEDIA_ERR_LOG("not support set volume!");
-        return -1;\r
+        return -1;
     }
     int32_t linearVolume = strtol(param[0x1], nullptr, NUMBER_BASE);
     int32_t ret = AudioManagerSetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, linearVolume);
index 32a126d..89c5469 100644 (file)
@@ -1,3 +1,4 @@
 add_subdirectory_if_exist(cat1Service)
 add_subdirectory_if_exist(cat1Test)
 
+
index 8deef22..72db1ba 100644 (file)
@@ -30,6 +30,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/Service/cat1_utils.c
 ${CMAKE_CURRENT_SOURCE_DIR}/Service/api_shell.c
 ${CMAKE_CURRENT_SOURCE_DIR}/Service/http_client.c
 ${CMAKE_CURRENT_SOURCE_DIR}/Service/sntp.c
+${CMAKE_CURRENT_SOURCE_DIR}/Service/cat1_server_hal.c
 # ${CMAKE_CURRENT_SOURCE_DIR}/slip/uart_slip.c
 )
 # message(WARNING "lwipport_SRCS" ${lwipport_SRCS} "\n")
index 980c634..82d6bfa 100644 (file)
@@ -132,7 +132,7 @@ void ble_get_cat1_at_msg(char *buffer,uint8_t len)
 
 
 
-static f_cat1_msg_callback g_msg_callback_func=NULL;
+f_cat1_msg_callback g_msg_callback_func=NULL;
 /**
  * @brief 注册消息回调函数,需要用户自己实现回调函数处理逻辑
  * @return 成功 ERRCODE_SUCC 或者其他失败ERRCODE .
@@ -1437,22 +1437,20 @@ static int udp_packet_parse(char *rx_buffer, int len)
             if(strstr(msg_buffer,"callanswer_success")!=NULL)
             {
                 osTimerStop(g_timer_time_answer);
-                // callconnected_event_sendmsg_toUI("callanswer_success");
+                callconnected_event_sendmsg_toUI("callanswer_success");
                 if (g_msg_callback_func!=NULL)
                     g_msg_callback_func(MESSAGE_4G_CALL_CONNECTED,"0",1);
                
             }
             if(strstr(msg_buffer,"callcmd_fail")!=NULL)
             {
-                // osTimerStop(g_timer_time_Dial);
-                // cat1_handle_call_disconnected("callfail");
+                osTimerStop(g_timer_time_Dial);
+                cat1_handle_call_disconnected("callfail");
             }
 
             if(strstr(msg_buffer,"callcmd_success")!=NULL)
             {
-                //cat1_handle_call_disconnected("callfail");
                 osTimerStop(g_timer_time_Dial);
-                
             }
             // uapi_save_runtime_log(RUNTIME_LOG_CAT1_UDP_MSG_REPLY);
             break;
index a001f97..d366e32 100644 (file)
@@ -20,6 +20,8 @@ extern "C" {
 #include "cat1_porting.h"
 #include "cat1_pub_api.h"
 
+ 
+extern f_cat1_msg_callback g_msg_callback_func;
 
     //    MESSAGE_4G_POWERON,//无参数 (BOOTUP)
     // MESSAGE_4G_POWEROFF,//无参数
index 995b646..6312d02 100644 (file)
@@ -57,8 +57,12 @@ uint8_t cat1_api_need_update_signal(void);
 errcode_t cat1_api_porting_init(void);
 
 
+int32_t cat1_cat1_start_SCO_volte_voice(void);
+
+void cat1_UI_call_dial(char *tell);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#endif
\ No newline at end of file
+#endif
index 45b3aa2..a35cd2f 100644 (file)
 extern "C" {
 #endif /* __cplusplus */
 
-// int callconnected_event_sendmsg_toUI(char* callno);
-// int callend_event_sendmsg_toUI(char* callno);
-// int incomingcall_event_sendmsg_toUI(char* callno);
-// int cat1_msg_event_sendmsg_toUI(char* callno);
+int callconnected_event_sendmsg_toUI(char* callno);
+int callend_event_sendmsg_toUI(char* callno);
+int incomingcall_event_sendmsg_toUI(char* callno);
+int cat1_msg_event_sendmsg_toUI(char* callno);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 385552e..fe97fef 100644 (file)
@@ -20,7 +20,7 @@ struct timezone {
     int tz_dsttime;
 };
 
-uint8_t g_cat1_enable_debug=CAT1_LOG_LEVEL_INFO;
+uint8_t g_cat1_enable_debug=CAT1_LOG_LEVEL_MAX;
 
 static uint16_t g_timezone_quarters = 0xFFFF;
 /**
@@ -110,21 +110,29 @@ int32_t cat1_api_start_cat1_volte_voice(void)
 {
     cat1_print_dbg("cat1_api_start_cat1_volte_voice\n");
 
+    // 使用正确的类型声明
+    // const char *argv_seaenable[] = {"seaenable", "1"};
+    // int32_t ret = ERRCODE_FAIL;
+    // int32_t argc = 2;
+
+    // ret = VoiceCallVolteSample(2, argv_seaenable);
+
+    // cat1_print_dbg("ret seaenable %d %d ", ret, cat1_voice);
+
+    const char *argv_start[] = {"start", "1"};
+
     int32_t ret = ERRCODE_FAIL;
-    int32_t argc = 1;
-    uint8_t *argv = (uint8_t *)"start";
 
-    if(cat1_voice==0)
+    if(cat1_voice == 0)
     {
-        ret = VoiceCallVolteSample(argc, (const char **)&argv);
-        if(ret==0) 
-        cat1_voice=1;
+        ret = VoiceCallVolteSample(2, argv_start);
+        if(ret == 0) 
+        cat1_voice = 1;
     }
-    
- 
-    cat1_print_dbg("ret %d %d ",ret, cat1_voice);
-    
-    return ret;   
+
+    cat1_print_dbg("start ret %d %d ", ret, cat1_voice);
+
+    return ret;
 }
 
 int32_t cat1_api_stop_cat1_volte_voice(void)
@@ -144,10 +152,29 @@ int32_t cat1_api_stop_cat1_volte_voice(void)
 
     cat1_print_dbg("ret %d %d ",ret, cat1_voice);
 
+    return ret;   
+}
+
+int32_t cat1_cat1_start_SCO_volte_voice(void)
+{
+    int32_t ret = ERRCODE_FAIL;
+    int32_t argc = 1;
+    uint8_t *argv = (uint8_t *)"start";
+
+    if(cat1_voice!=0)
+    {
+        ret = VoiceCallVolteBluetoothSample(argc, (const char **)&argv);
+        if(ret==0) 
+        cat1_voice=2;
+    }
+
+    cat1_print_dbg("ret %d %d ",ret, cat1_voice);
+
     return ret;   
 
 }
 
+
 #include "power_display_service.h"
 /*获取屏幕状态: return 1 need update */
 
@@ -163,6 +190,9 @@ uint8_t cat1_api_need_update_signal(void)
         return 0;
     }
 }
+
+
+
 errcode_t cat1_msg_callback(MESSAGE_4G_T msg, void *msg_buf, uint16_t msglen)
 {
 
@@ -196,12 +226,15 @@ errcode_t cat1_msg_callback(MESSAGE_4G_T msg, void *msg_buf, uint16_t msglen)
             break;
         case MESSAGE_4G_CALL_COMMING: //带电话号
             cat1_print_warning("MESSAGE_4G_CALL_COMMING %s",msg_buf);
+            uapi_incomingcall_event_sendmsg_toUI(msg_buf);
             break;
         case MESSAGE_4G_CALL_CONNECTED: //带电话号
             cat1_print_warning("MESSAGE_4G_CALL_CONNECTED %s",msg_buf);
+            uapi_incomedcall_event_sendmsg_toUI(msg_buf);
             break;
         case MESSAGE_4G_CALL_DISCONNECTED: //带电话号
             cat1_print_warning("MESSAGE_4G_CALL_DISCONNECTED %s",msg_buf);
+            uapi_callend_event_sendmsg_toUI(msg_buf);
             break;
         case MESSAGE_4G_SMS_RECEIVED: //返回值为字符串
             cat1_print_warning("MESSAGE_4G_SMS_RECEIVED %s",msg_buf);
@@ -279,3 +312,12 @@ errcode_t cat1_api_porting_init(void)
 
     return ERRCODE_SUCC;
 }
+
+void cat1_UI_call_dial(char *tell)
+{
+    uapi_calldial_event_sendmsg_toUI(tell);
+}
+
+
+
+
diff --git a/code/sdk/zhihui/4gTestcpp/CMakeLists.txt b/code/sdk/zhihui/4gTestcpp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..58b1050
--- /dev/null
@@ -0,0 +1,67 @@
+#===============================================================================
+# @brief    cmake file
+# Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved.
+#===============================================================================
+
+set(COMPONENT_NAME "4gTestcpp")
+
+
+set(PUBLIC_HEADER
+${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+
+set(PRIVATE_HEADER
+    ${ROOT_DIR}/zhihui/4g/cat1Service/include
+    ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits
+    ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits
+    ${ROOT_DIR}/application/wearable/nativeapp/nativeui/heartrate/include
+)
+
+set(SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/cat1_UI_hal.cpp
+)
+
+set(PRIVATE_DEFINES
+    TARGET_NAME="${TARGET_COMMAND}"
+    BUILD_TIME="${BUILD_TIME}"
+)
+
+set(PUBLIC_DEFINES
+)
+
+# use this when you want to add ccflags like -include xxx
+set(COMPONENT_PUBLIC_CCFLAGS
+)
+
+
+set(COMPONENT_CCFLAGS
+    -std=c++11
+    -Wno-error
+    -Wno-unused-parameter
+    -fno-exceptions
+    -fno-unwind-tables
+    -fno-asynchronous-unwind-tables
+    -Wno-undef
+    -Wno-bitwise-op-parentheses
+    -Wno-shift-op-parentheses
+    # -nostdlibinc
+    # -nostdinc
+    # -nostdlib
+    -Wno-c++11-narrowing
+    -Wno-error=unused-function
+)
+
+    # -nostdlibinc
+    # -nostdinc  
+    # -nostdlib
+set(WHOLE_LINK
+    true
+)
+
+set(MAIN_COMPONENT
+    false
+)
+
+build_component()
+
diff --git a/code/sdk/zhihui/4gTestcpp/cat1_UI_hal.cpp b/code/sdk/zhihui/4gTestcpp/cat1_UI_hal.cpp
new file mode 100644 (file)
index 0000000..fbcc91e
--- /dev/null
@@ -0,0 +1,135 @@
+/* BSD Socket API Example
+
+   This example code is in the Public Domain (or CC0 licensed, at your option.)
+
+   Unless required by applicable law or agreed to in writing, this
+   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+   CONDITIONS OF ANY KIND, either express or implied.
+*/
+
+#include <string.h>
+
+#include "wearable_log.h"
+#include "securec.h"
+#include "broadcast_service.h"
+#include "broadcast_feature.h"
+#include "service_id_define.h"
+#include "samgr_lite.h"
+#include "thread_adapter.h"
+#include "graphic_service.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <string.h>
+
+#include "errcode.h"
+#include "errno.h"
+
+#include "cat1_server_hal.h"
+#include "custom_utils.h"
+
+
+static errcode_t calldial_event_notify(char* callno)
+{
+
+    CustomEventPublish(TOPIC_EVENT_CAT1_CALLDIAL,(uint8_t*)callno,strlen(callno)+1);
+    return 0;
+}
+
+
+static errcode_t incomingcall_event_notify(char* callno)
+{
+    CustomEventPublish(TOPIC_EVENT_CAT1_INCOMMING,(uint8_t*)callno,strlen(callno)+1);
+    return 0;
+}
+
+static errcode_t incomed_call_event_notify(char* callno)
+{
+    CustomEventPublish(TOPIC_EVENT_CAT1_CALLCONNTED,(uint8_t*)callno,strlen(callno)+1);
+    return 0;
+}
+
+static errcode_t callend_event_notify(char* callno)
+{
+    CustomEventPublish(TOPIC_EVENT_CAT1_CALLENDED,(uint8_t*)callno,strlen(callno)+1);
+    return 0;
+}
+
+static errcode_t cat1msg_event_notify(char* callno)
+{
+    CustomEventPublish(TOPIC_EVENT_CAT1_SIGNAL_UPDATE,(uint8_t*)callno,strlen(callno)+1);
+    return 0;
+}
+//传地址应设置固定内存,否则异进程内存安全没法保证
+
+// 将 std::string 改为 char 数组
+static char call_number_end[64] = {0};
+static char incomedcall_number_end[64] = {0};
+static char incomingcall_number[64] = {0};
+static char call_number[64] = {0};
+
+int uapi_callend_event_sendmsg_toUI(char* callno)
+{
+    /**通过UI事件发送Notify*/
+    strncpy(call_number_end, callno, sizeof(call_number_end) - 1);
+    call_number_end[sizeof(call_number_end) - 1] = '\0';
+    
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(callend_event_notify, call_number_end));
+    return ERRCODE_SUCC;
+}
+
+int uapi_incomedcall_event_sendmsg_toUI(char* callno)
+{
+    /**通过UI事件发送Notify*/
+    strncpy(incomedcall_number_end, callno, sizeof(incomedcall_number_end) - 1);
+    incomedcall_number_end[sizeof(incomedcall_number_end) - 1] = '\0';
+    
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomed_call_event_notify, incomedcall_number_end));
+    return ERRCODE_SUCC;
+}
+
+int uapi_incomingcall_event_sendmsg_toUI(char* callno)
+{
+    /**通过UI事件发送Notify*/
+    strncpy(incomingcall_number, callno, sizeof(incomingcall_number) - 1);
+    incomingcall_number[sizeof(incomingcall_number) - 1] = '\0';
+    
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(incomingcall_event_notify, incomingcall_number));
+    return ERRCODE_SUCC;
+}
+
+int uapi_calldial_event_sendmsg_toUI(char* callno)
+{
+    /**通过UI事件发送Notify*/
+    strncpy(call_number, callno, sizeof(call_number) - 1);
+    call_number[sizeof(call_number) - 1] = '\0';
+    
+    // 移除空格
+    char* p = call_number;
+    char* q = call_number;
+    while (*p) {
+        if (*p != ' ') {
+            *q++ = *p;
+        }
+        p++;
+    }
+    *q = '\0';
+    
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(calldial_event_notify, call_number));
+    return ERRCODE_SUCC;
+}
+
+int uapi_cat1_msg_event_sendmsg_toUI(char* callno)
+{
+    /**通过UI事件发送Notify*/
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(cat1msg_event_notify, callno));
+    return ERRCODE_SUCC;
+}
+
+
+#ifdef __cplusplus
+
+}
+
+#endif /* __cplusplus */
diff --git a/code/sdk/zhihui/4gTestcpp/cat1_UI_hal.h b/code/sdk/zhihui/4gTestcpp/cat1_UI_hal.h
new file mode 100644 (file)
index 0000000..1e1121b
--- /dev/null
@@ -0,0 +1,29 @@
+/* BSD Socket API Example
+
+   This example code is in the Public Domain (or CC0 licensed, at your option.)
+
+   Unless required by applicable law or agreed to in writing, this
+   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+   CONDITIONS OF ANY KIND, either express or implied.
+*/
+#ifndef __CAT1_SERVER_HAL_H
+#define __CAT1_SERVER_HAL_H
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+int uapi_incomedcall_event_sendmsg_toUI(char* callno);
+int uapi_callend_event_sendmsg_toUI(char* callno);
+int uapi_incomingcall_event_sendmsg_toUI(char* callno);
+int uapi_calldial_event_sendmsg_toUI(char* callno);
+int uapi_cat1_msg_event_sendmsg_toUI(char* callno);
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#endif
index 33bc02e..7aaf225 100644 (file)
@@ -1,10 +1,17 @@
 #include "main_include.h"
 #include "uapi_ai_function.h"
+#include "errcode.h"
 
 /*******************************************************************************************************/
 #define SYSTEM_PATH            "/user/userdata/System"
 #define CONFIG_PATH            "/user/userdata/Config"
 #define LOG_PATH               "/user/userdata/Log"
+#include "thread_init.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <sys/stat.h>
 
 static int create_new_session_rsp_cb(int iReqId, unsigned char* pucSessionID, int iRspCode);
 
@@ -18,23 +25,31 @@ static int directory_exists(const char* path)
 
 static void make_path(void)
 {
-       char command[256] = { 0 };
-       if (directory_exists(SYSTEM_PATH) != 0)
-       {
-               snprintf(command, sizeof(command), "mkdir -p \"%s\"", SYSTEM_PATH);
-               system(command);
-       }
-       if (directory_exists(CONFIG_PATH) != 0)
-       {
-               snprintf(command, sizeof(command), "mkdir -p \"%s\"", CONFIG_PATH);
-               system(command);
-       }
-       if (directory_exists(LOG_PATH) != 0)
-       {
-               snprintf(command, sizeof(command), "mkdir -p \"%s\"", LOG_PATH);
-               system(command);
-       }
-       return;
+     struct stat info;
+
+     if (stat(SYSTEM_PATH, &info) != 0)
+    {
+        if (mkdir(SYSTEM_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
+        {
+            return ; // Failed to create folder
+        }
+    }
+     if (stat(CONFIG_PATH, &info) != 0)
+    {
+        if (mkdir(CONFIG_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
+        {
+            return ; // Failed to create folder
+        }
+    }
+     if (stat(LOG_PATH, &info) != 0)
+    {
+        if (mkdir(LOG_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
+        {
+            return ; // Failed to create folder
+        }
+    }
+
+       return ;
 }
 
 /***********************************************************
@@ -354,23 +369,52 @@ static int create_new_session_rsp_cb(int iReqId, unsigned char* pucSessionID, in
     return 0;
 }
 
-void uapi_CT_ai_init(void)
+
+void uapi_CT_ai_init_func(void)
 {
     make_path();
 
-    // syscall_init();
+    syscall_init();
+    printf("ZJ_InitEx syscall_init\r\n");
+
     ZJ_InitEx(SYSTEM_PATH, CONFIG_PATH, LOG_PATH);
+    printf("ZJ_InitEx end\r\n");
+    
        system_init();
+
     ota_init();
 
        agent_init();
     
        system_start();
     ota_start();
-       agent_start();
+       // agent_start();
        ZJ_Start();
 
     // Sleep(3000);
 
 }
 
+
+void uapi_CT_ai_init(void)
+{
+
+
+    // UINT32 taskId;
+    app_task_definition_t taskcfg={0};
+    taskcfg.create_queue_handle = NULL;
+    taskcfg.attr.name="ai_init";
+    taskcfg.attr.priority = 16;
+    taskcfg.attr.stack_size = 0x2000;
+    taskcfg.func = uapi_CT_ai_init_func;
+    taskcfg.use_mem = USE_EXTEND_MEM;
+    
+    errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+}
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
index 55ebe19..99d1999 100644 (file)
@@ -1,8 +1,14 @@
 #ifndef AI_FUNCTION_H
 #define AI_FUNCTION_H
 
-
+#ifdef __cplusplus
+extern "C" {
+#endif
 void uapi_CT_ai_init(void);
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
\ No newline at end of file
index f453741..3062dc0 100644 (file)
@@ -5,6 +5,7 @@
 set(COMPONENT_NAME "AIsdk")
 
 set(SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/lib/libai.c
 )
 
 set(PUBLIC_HEADER
@@ -14,6 +15,7 @@ set(PUBLIC_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/../AIagent
     ${CMAKE_CURRENT_SOURCE_DIR}/../AIota
 )
+
 set(PRIVATE_HEADER
     ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include
     ${ROOT_DIR}/middleware/utils/update/inner_include
@@ -38,6 +40,7 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/zhihui/4g/cat1Service/include
     ${ROOT_DIR}/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/include
     ${ROOT_DIR}/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include
+    ${ROOT_DIR}/kernel/osal/include/schedule
     # /home/hcj/615/FD230/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h
     # /home/hcj/615/FD230/code/sdk/middleware/services/gui/uikit/ui/frameworks/font/glyphs_manager.h
     # /home/hcj/615/FD230/code/sdk//UiServersMsg.h
@@ -84,6 +87,6 @@ find_library(LIB_PATH_COMMONA_LIB libcommon.a ${CMAKE_CURRENT_SOURCE_DIR}/lib)
 find_library(LIB_PATH_COS_LIB libcos.a ${CMAKE_CURRENT_SOURCE_DIR}/lib)
 find_library(LIB_PATH_THIRD_LIB libthirdparty.a ${CMAKE_CURRENT_SOURCE_DIR}/lib)
 
-target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_COMMONA_LIB} ${LIB_PATH_COS_LIB} ${LIB_PATH_THIRD_LIB} PRIVATE -Wl,--whole-archive)
+target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_COMMONA_LIB}  ${LIB_PATH_THIRD_LIB} ${LIB_PATH_COS_LIB} PRIVATE -Wl,--whole-archive)
 
 build_component()
index b24fdee..69d466f 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef MAIN_INCLUDE_H
 #define MAIN_INCLUDE_H
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdio.h>
 
 #include <stdlib.h>
@@ -12,7 +17,7 @@
 #include <errno.h>
 #include "osal_task.h"
 #include "lwip/arch.h"
-#include "lwip/sockets.h"
+// #include "lwip/sockets.h"
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include "securec.h"
 #include "zj_system.h"
 #include "zj_network.h"
 #include "zj_log.h"
-#ifdef NEED_IMPLEMENT_SYSCALL
+// #ifdef NEED_IMPLEMENT_SYSCALL
 #include "zj_syscall_prv.h"
 #include "zj_syscall.h"
-#endif
+// #endif
 
 #include "system.h"
 #include "agent.h"
-#ifndef WIN_TEST
 #include "ota.h"
+
+
+uint32_t ntohl(uint32_t netlong);
+
+uint32_t htonl(uint32_t hostlong);
+
+uint16_t ntohs(uint16_t netshort);
+
+uint16_t htons(uint16_t hostshort);
+
+#ifdef __cplusplus
+}
 #endif
 
 #endif
\ No newline at end of file
diff --git a/code/sdk/zhihui/AI/AIsdk/include/zj_syscall.h b/code/sdk/zhihui/AI/AIsdk/include/zj_syscall.h
new file mode 100644 (file)
index 0000000..7fbc2eb
--- /dev/null
@@ -0,0 +1,427 @@
+
+#ifndef ZJ_SYSCALL_H
+#define ZJ_SYSCALL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "zj_type.h"
+
+
+// file
+/**
+ * @brief 文件打开回调注册函数
+ * @param pFunFileOpenCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileOpenCb(PFN_FILEOPEN pFunFileOpenCb);
+
+/**
+ * @brief 文件关闭回调注册函数
+ * @param pFunFileCloseCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileCloseCb(PFN_FILECLOSE pFunFileCloseCb);
+
+/**
+ * @brief 文件删除回调注册函数
+ * @param pFunFileRmvCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileRmvCb(PFN_FILERMV pFunFileRmvCb);
+
+/**
+ * @brief 文件偏移回调注册函数
+ * @param pFunFileEofCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileEofCb(PFN_FILEEOF pFunFileEofCb);
+
+/**
+ * @brief 文件写回调注册函数
+ * @param pFunFileWriteCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileWriteCb(PFN_FILEWRITE pFunFileWriteCb);
+
+/**
+ * @brief 文件读回调注册函数
+ * @param pFunFileReadCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileReadCb(PFN_FILEREAD pFunFileReadCb);
+
+/**
+ * @brief 文件刷新回调注册函数
+ * @param pFunFileFlushCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileFlushCb(PFN_FILEFLUSH pFunFileFlushCb);
+
+/**
+ * @brief 文件偏移定位回调注册函数
+ * @param pFunFileSeekCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileSeekCb(PFN_FILESEEK pFunFileSeekCb);
+
+/**
+ * @brief 文件大小回调注册函数
+ * @param pFunFileSizeCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileSizeCb(PFN_FILESIZE pFunFileSizeCb);
+
+/**
+ * @brief 文件末尾回调注册函数
+ * @param pFunFileTellCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileTellCb(PFN_FILETELL pFunFileTellCb);
+
+/**
+ * @brief 文件状态回调注册函数
+ * @param pFunFileStatCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetFileStatCb(PFN_FILESTAT pFunFileStatCb);
+
+/**
+ * @brief 目录打开回调注册函数
+ * @param pFunDirOpenCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetDirOpenCb(PFN_DIROPEN pFunDirOpenCb);
+
+/**
+ * @brief 目录关闭回调注册函数
+ * @param pFunDirCloseCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetDirCloseCb(PFN_DIRCLOSE pFunDirCloseCb);
+
+/**
+ * @brief 目录读取回调注册函数
+ * @param pFunDirReadCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetDirReadCb(PFN_DIRREAD pFunDirReadCb);
+
+/**
+ * @brief 目录创建回调注册函数
+ * @param pFunDirMakeCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetDirMakeCb(PFN_DIRMAKE pFunDirMakeCb);
+
+
+// mutex  sem
+/**
+ * @brief 互斥锁创还能回调注册函数
+ * @param pFunMutexCreateCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetMutexCreateCb(PFN_MUTEXCREATE pFunMutexCreateCb);
+
+/**
+ * @brief 互斥锁删除回调注册函数
+ * @param pFunMutexDeleteCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API void ZJ_SetMutexDeleteCb(PFN_MUTEXDELETE pFunMutexDeleteCb);
+
+/**
+ * @brief  互斥锁上锁回调注册函数
+ * @param  pFunMutexLockCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetMutexLockCb(PFN_MUTEXLOCK pFunMutexLockCb);
+
+/**
+ * @brief 互斥锁释放回调注册函数
+ * @param pFunMutexUnlockCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetMutexUnLockCb(PFN_MUTEXUNLOCK pFunMutexUnlockCb);
+
+/**
+ * @brief 信号量创建回调注册函数
+ * @param pFunSemCreateCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetSemCreateCb(PFN_SEMCREATE pFunSemCreateCb);
+
+/**
+ * @brief 信号量删除回调注册函数
+ * @param pFunSemDeleteCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API void ZJ_SetSemDeleteCb(PFN_SEMDELETE pFunSemDeleteCb);
+
+/**
+ * @brief P操作 回调注册函数 
+ * @param pFunSemWaitCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetSemWaitCb(PFN_SEMWAIT pFunSemWaitCb);
+
+/**
+ * @brief V操作 回调注册函数
+ * @param pFunSemPostCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetSemPostCb(PFN_SEMPOST pFunSemPostCb);
+
+// socket
+/**
+ * @brief ip地址转换回调注册函数
+ * @param pFunInetAddrCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetAddrCb(PFUN_INETADDR pFunInetAddrCb);
+
+/**
+ * @brief 字节序转换回调注册函数
+ * @param pFunInetNtoHLCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetNtoHLCb(PFUN_INETNTOHL pFunInetNtoHLCb);
+
+/**
+ * @brief 字节序转换回调注册函数
+ * @param pFunInetHtoNLCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetHtoNLCb(PFUN_INETHTONL pFunInetHtoNLCb);
+
+/**
+ * @brief 字节序转换回调注册函数
+ * @param pFunInetNtoHSCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetNtoHSCb(PFUN_INETNTOHS pFunInetNtoHSCb);
+
+/**
+ * @brief 字节序转换回调注册函数
+ * @param pFunInetHtoNSCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetHtoNSCb(PFUN_INETHTONS pFunInetHtoNSCb);
+
+/**
+ * @brief 创建描述符集合回调注册函数
+ * @param pFunInetFdCreateCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdCreateCb(PFUN_INETFDCREATE pFunInetFdCreateCb);
+
+/**
+ * @brief 删除描述符集合回调注册函数
+ * @param pFunInetFdDeleteCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdDeleteCb(PFUN_INETFDDELETE pFunInetFdDeleteCb);
+
+/**
+ * @brief 清空描述符集合回调注册函数
+ * @param pFunInetFdZeroCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdZeroCb(PFUN_INETFDZERO pFunInetFdZeroCb);
+
+/**
+ * @brief 设置描述符到集合中回调注册函数
+ * @param pFunInetFdSetCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdSetCb(PFUN_INETFDSET pFunInetFdSetCb);
+
+/**
+ * @brief 检查描述符是否在集合中回调注册函数
+ * @param pFunInetFdIsSetCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdIsSetCb(PFUN_INETFDISSET pFunInetFdIsSetCb);
+
+/**
+ * @brief 从集合中移除描述符回调注册函数
+ * @param pFunInetFdClearCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetFdClearCb(PFUN_INETFDCLR pFunInetFdClearCb);
+
+/**
+ * @brief 通过域名获取ip信息回调函数注册
+ * @param pFunInetGetHostByNameCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetGetHostByNameCb(PFUN_INETGETHOSTBYNAME pFunInetGetHostByNameCb);
+
+/**
+ * @brief 获取ip地址信息回调函数注册
+ * @param pFunInetGetaddrInfoCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetGetAddrInfoCb(PFUN_INETGETADDRINFO pFunInetGetaddrInfoCb);
+
+/**
+ * @brief 创建socket回调注册函数
+ * @param pFunInetSocketOpenCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketOpenCb(PFUN_SOCKETOPEN pFunInetSocketOpenCb);
+
+/**
+ * @brief 关闭socket回调注册函数
+ * @param pFunInetSocketCloseCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketCloseCb(PFUN_SOCKETCLOSE pFunInetSocketCloseCb);
+
+/**
+ * @brief 销毁socket回调函数注册
+ * @param pFunInetSocketShutdownCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketShutDownCb(PFUN_SOCKETSHUTDOWN pFunInetSocketShutdownCb);
+
+/**
+ * @brief 多路复用select回调函数注册
+ * @param pFunInetSocketSelectCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketSelectCb(PFUN_SOCKETSELECT pFunInetSocketSelectCb);
+
+/**
+ * @brief socket连接回调函数注册
+ * @param pFunInetSocketConnectCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketConnectCb(PFUN_SOCKETCONNECT pFunInetSocketConnectCb);
+
+/**
+ * @brief udp socket发送回调函数注册
+ * @param pFunInetSocketSendToCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketSendToCb(PFUN_SOCKETSENDTO pFunInetSocketSendToCb);
+
+/**
+ * @brief udp socket接收回调函数注册
+ * @param pFunInetSocketRecvFromCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketRecvFromCb(PFUN_SOCKETRECVFROM pFunInetSocketRecvFromCb);
+
+/**
+ * @brief socket发送回调函数注册
+ * @param pFunInetSocketSendCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketSendCb(PFUN_SOCKETSEND pFunInetSocketSendCb);
+
+/**
+ * @brief socket接收回调函数注册
+ * @param pFunInetSocketRecvCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketRecvCb(PFUN_SOCKETRECV pFunInetSocketRecvCb);
+
+/**
+ * @brief 设置socket接收缓冲大小回调函数注册
+ * @param pFunInetSocketSetRecvBufCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketSetRecvBufCb(PFUN_SOCKETSETRECVBUF pFunInetSocketSetRecvBufCb);
+
+/**
+ * @brief 设置socket发送缓冲大小回调函数注册
+ * @param pFunInetSocketSetSendBufCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketSetSendBufCb(PFUN_SOCKETSETSENDBUF pFunInetSocketSetSendBufCb);
+
+/**
+ * @brief 获取socket最后状态回调函数注册
+ * @param pFunInetSocketGetLastErrCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketGetLastErrCb(PFUN_SOCKETGETLASTERR pFunInetSocketGetLastErrCb);
+
+/**
+ * @brief 检测socket连接状态回调函数注册
+ * @param pFunInetSocketCheckConnCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetInetSocketCheckConnCb(PFUN_SOCKETCHECKCONN pFunInetSocketCheckConnCb);
+
+// thread
+/**
+ * @brief 创建线程回调函数注册
+ * @param pFunThreadCreateCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetThreadCreateCb(PFN_THREADCREATE pFunThreadCreateCb);
+
+/**
+ * @brief 线程销毁回调函数注册
+ * @param pFunThreadDeleteCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetThreadDeleteCb(PFN_THREADDELETE pFunThreadDeleteCb);
+
+/**
+ * @brief 获取当前线程ID回调函数注册
+ * @param pFunThreadGetCurIdCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetThreadGetCurIdCb(PFN_THREADGETCURID pFunThreadGetCurIdCb);
+
+/**
+ * @brief 设置线程名称回调函数注册
+ * @param pFunThreadSetNameCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetThreadSetNameCb(PFUN_SETTHREADNAME pFunThreadSetNameCb);
+
+/**
+ * @brief 休眠回调函数注册
+ * @param pFunSleepCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetSleepCb(PFN_SLEEP pFunSleepCb);
+// time
+/**
+ * @brief 获取时间戳回调函数注册
+ * @param pFunTimeGetTimeCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetTimeGetTimeCb(PFN_GETTIME pFunTimeGetTimeCb);
+
+/**
+ * @brief 获取设备本地当前时间回调函数注册
+ * @param pFunTimeGetLocalTimeCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetTimeGetLocalTimeCb(PFN_LOCALTIME pFunTimeGetLocalTimeCb);
+
+/**
+ * @brief 获取距离系统运行时间的秒数回调函数注册
+ * @param pFunTimeGetTickCountCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetTimeGetTickCountCb(PFN_GETTICKCOUNT pFunTimeGetTickCountCb);
+
+/**
+ * @brief 时间戳转本地时间回调函数注册
+ * @param pFunTimeSysTimeToTimeCb 回调函数
+ * @return 0 成功 -1 失败
+ */
+_ZJ_API int ZJ_SetTimeSysTimetoTimeCb(PFN_SYSTIMETOTIME pFunTimeSysTimeToTimeCb);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/code/sdk/zhihui/AI/AIsdk/include/zj_syscall_prv.h b/code/sdk/zhihui/AI/AIsdk/include/zj_syscall_prv.h
new file mode 100644 (file)
index 0000000..88d6bf7
--- /dev/null
@@ -0,0 +1,269 @@
+#ifndef ZJ_SYSCALL_PRV_H
+#define ZJ_SYSCALL_PRV_H
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************************************
+ * file
+ ***********************************************************************************************/
+#define COS_FILE_O_RDONLY     0x0001   /*file open only for read*/
+#define COS_FILE_O_WRONLY     0x0002   /*file open only for write,file truncate to 0 lenth**/
+#define COS_FILE_O_RDWR       0x0004   /*file open for read write*/
+
+#define COS_FILE_O_CREAT      0x0008   /*file creat if exist truncate to 0 lenth*/
+#define COS_FILE_O_TRUNC      0x0010   /*file open for truncate to 0 lenth*/
+#define COS_FILE_O_APPEND     0x0020   /*file open for append to the end of the file*/
+#define COS_FILE_O_BIN        0x0040   /*file open by binary mode*/
+
+#define COS_FILE_UREAD     0x0001   /*user can read*/
+#define COS_FILE_UWRITE    0x0002   /*user can write*/
+#define COS_FILE_UEXEC     0x0004   /*user can execute*/
+#define COS_FILE_GREAD     0x0008   /*group can read*/
+#define COS_FILE_GWRITE    0x0010   /*group can write*/
+#define COS_FILE_GEXEC     0x0020   /*group can execute*/
+#define COS_FILE_OREAD     0x0040   /*others can read*/
+#define COS_FILE_OWRITE    0x0080   /*others can write*/
+#define COS_FILE_OEXEC     0x0100   /*others can execute*/
+
+#define COS_FILE_SEEK_BEGIN     0
+#define COS_FILE_SEEK_CUR       1
+#define COS_FILE_SEEK_END       2
+
+typedef struct stru_COS_FILE_INF
+{
+    unsigned char ucType;
+    unsigned char aucReserved[3];
+    unsigned int uiMode;
+    unsigned int uiSize;
+    time_t utlastAccTime;
+    time_t utlastMdfyTime;
+    time_t utlastChangeTime;  
+}ST_COS_FILE_INF;
+
+typedef enum enum_CFILE_TYPE
+{
+    EN_CFILE_REG,           /*regular file*/
+    EN_CFILE_DIR,           /*directory*/
+    EN_CFILE_CHR,           /*character device*/
+    EN_CFILE_BLK,           /*block device*/
+    EN_CFILE_PIPE,          /*FIFO/pipe*/
+    EN_CFILE_LINK,          /*symbolic link*/
+    EN_CFILE_SOCK,          /*[unix domain] so*/
+    EN_CFILE_UNKNOW = 100
+}EN_CFILE_TYPE;
+
+typedef struct stru_DIR
+{
+       void*       pstDir;
+       void*       pstEntry;
+       unsigned char   aucName[256];
+}ST_DIR;
+
+typedef void* (*PFN_FILEOPEN)(unsigned char *pucFielName, unsigned int uiFlag);
+
+typedef int (*PFN_FILECLOSE)(void* hFile);
+
+typedef int (*PFN_FILERMV)(unsigned char *pucFileName);
+
+// typedef int  (*PFN_FILERENAME)(unsigned char *pucOldFileName, unsigned char *pucNewFileName);
+
+typedef int  (*PFN_FILEEOF)(void* hFile);
+
+typedef int  (*PFN_FILEWRITE)(void* hFile, unsigned char *pucBuf, int iLen);
+
+typedef int  (*PFN_FILEREAD)(void* hFile, unsigned char *pucBuf, int iLen);
+
+typedef int  (*PFN_FILEFLUSH)(void* hFile);
+
+typedef int  (*PFN_FILESEEK)(void* hFile, unsigned short usFlag, int iOffSet);
+
+typedef int  (*PFN_FILESIZE)(void* hFile);
+
+typedef int  (*PFN_FILETELL)(void* hFile);
+
+typedef int  (*PFN_FILESTAT)(unsigned char *pucFileName, ST_COS_FILE_INF *pstInf);
+
+// typedef int (*PFN_FILETRUNCATE)(unsigned char* pucFileName,int iFileLen);
+
+typedef void*  (*PFN_DIROPEN)(unsigned char *pucDirName);
+
+typedef int  (*PFN_DIRCLOSE)(void* hDir);
+
+typedef int  (*PFN_DIRREAD)(void* hDir, unsigned char *pucEntryName, int iMaxLen, ST_COS_FILE_INF *pstInf);
+
+typedef int  (*PFN_DIRMAKE)(unsigned char *pucDirName, unsigned int uiFlag);
+
+typedef int  (*PFN_DIRRMV)(unsigned char *pucDirName);
+
+// typedef int  (*PFN_DISKSIZE)(unsigned char *pucDisk, unsigned long long *pxxlFreeSpace, unsigned long long *pxxlTotalSpace);
+
+/************************************************************************************************
+ * mutex
+ ***********************************************************************************************/
+typedef int   (*PFN_MUTEXCREATE)(void **phOutMutex);
+typedef void  (*PFN_MUTEXDELETE)(void *phMutex);
+typedef int   (*PFN_MUTEXLOCK)(void *phMutex);
+typedef int   (*PFN_MUTEXUNLOCK)(void *phMutex);
+
+typedef int   (*PFN_SEMCREATE)(void **phOutSem);
+typedef void  (*PFN_SEMDELETE)(void *phSem);
+typedef int   (*PFN_SEMWAIT)(void *phSem);
+typedef int   (*PFN_SEMPOST)(void *phSem);
+
+/************************************************************************************************
+ * socket
+ ***********************************************************************************************/
+#define  COS_INET_IPV4_ADDR_SIZE         4
+#define  COS_INET_ADDR_MAX_NUM           32
+
+#define  COS_INET_IPV6_ADDR_SIZE         16
+
+#define  COS_INET_DEFAULT_TTL             128
+
+typedef enum enum_COS_INET_SHTDWN_TYPE
+{
+    EN_CINET_SHTDWN_RECV, 
+    EN_CINET_SHTDWN_SEND,
+    EN_CINET_SHTDWN_BOTH
+}EN_COS_INET_SHTDWN_TYPE;
+
+typedef enum enum_COS_INET_PRTL
+{
+    EN_CINET_PRTL_UDP, 
+    EN_CINET_PRTL_TCP,
+    EN_CINET_PRTL_RAW
+}EN_COS_INET_PRTL;
+
+typedef enum enum_COS_INET_TYPE
+{
+    EN_CINET_TYPE_IPV4, 
+    EN_CINET_TYPE_IPV6
+}EN_COS_INET_TYPE;
+
+typedef struct stru_COS_INET_IP
+{
+    unsigned short usType; // EN_COS_INET_TYPE
+    unsigned short usPort;
+    union
+    {
+        unsigned int uiIp;
+        unsigned char aucIp[COS_INET_IPV4_ADDR_SIZE];
+        unsigned char aucIpv6[COS_INET_IPV6_ADDR_SIZE];
+    }u;
+}ST_COS_INET_IP;
+
+typedef struct stru_COS_INET_IPARRAY
+{
+    unsigned int uiCount;
+    ST_COS_INET_IP astIps[COS_INET_ADDR_MAX_NUM];
+}ST_COS_INET_IPARRAY;
+
+typedef int    (*PFUN_INETADDR)(unsigned char *pucAddrStr, unsigned int *puiDstAddr);
+
+typedef unsigned int    (*PFUN_INETNTOHL)(unsigned int uiVal);
+typedef unsigned int    (*PFUN_INETHTONL)(unsigned int uiVal);
+typedef unsigned short  (*PFUN_INETNTOHS)(unsigned short usVal);
+typedef unsigned short  (*PFUN_INETHTONS)(unsigned short usVal);
+
+typedef int    (*PFUN_INETFDCREATE)(void * *pFds);
+typedef int    (*PFUN_INETFDDELETE)(void * fds);
+// typedef int    (*PFUN_INETFDCOPY)(void * dstFds, void * srcFds);
+typedef int    (*PFUN_INETFDZERO)(void * fds);
+typedef int    (*PFUN_INETFDSET)(int iFd, void * fds);
+typedef int    (*PFUN_INETFDISSET)(int iFd, void * fds);
+typedef int    (*PFUN_INETFDCLR)(int iFd, void * fds);
+
+typedef int    (*PFUN_INETGETHOSTBYNAME)(unsigned char *pucName, ST_COS_INET_IPARRAY *pstIpArrayInfo);
+
+typedef int    (*PFUN_INETGETADDRINFO)(unsigned char *pucHostName, unsigned short usPort, int iProtoType, int bPassive, ST_COS_INET_IPARRAY *pstIpArrayInfo);
+
+// typedef int    (*PFUN_INETGETDNSIPS)(ST_COS_INET_IPARRAY *pstIpArrayInfo);
+// typedef int    (*PFUN_INETGETLOCALIPS)(ST_COS_INET_IPARRAY *pstIpArrayInfo);
+// typedef int    (*PFUN_INETGETLOCALMAC)(unsigned char *pucMacStr);
+// typedef int    (*PFUN_INETGETREMOTEMAC)(unsigned char *pucSrcAddr, unsigned char *pucDstAddr, unsigned char *pucDstMac);
+
+typedef int    (*PFUN_SOCKETOPEN)(int iNetType, int iProtoType, int bBlock, int bReuseAddr);
+typedef int    (*PFUN_SOCKETCLOSE)(int sock);
+typedef int    (*PFUN_SOCKETSHUTDOWN)(int sock, int iHowTo);
+typedef int    (*PFUN_SOCKETSELECT)(int imaxFd, void * readFds, void * writeFds, void * exceptFds, int iMillSecWait);
+// typedef int    (*PFUN_SOCKETBIND)(int sock, ST_COS_INET_IP *pstLocalIp);
+// typedef int    (*PFUN_SOCKETLISTEN)(int sock);
+// typedef int    (*PFUN_SOCKETACCEPT)(int sock, ST_COS_INET_IP *pstRmtAddr, int bBlock);
+typedef int    (*PFUN_SOCKETCONNECT)(int sock, ST_COS_INET_IP *pstRmtAddr,int *bConnect);
+typedef int    (*PFUN_SOCKETSENDTO)(int sock, ST_COS_INET_IP *pstRmtAddr, void * pBuf, int ilen, int *pbOutWait);
+typedef int    (*PFUN_SOCKETRECVFROM)(int sock, ST_COS_INET_IP *pstIORmtAddr, void * pOutBuf, int iLen,int *pbOutClosed);
+typedef int    (*PFUN_SOCKETSEND)(int sock, void * pBuf, int iLen, int *pbOutWait);
+typedef int    (*PFUN_SOCKETRECV)(int sock, void * pOutBuf, int iLen, int *pbOutClosed);
+// typedef int    (*PFUN_SOCKETGETLOCALIP)(int sock, ST_COS_INET_IP *pstOutLclIp);
+// typedef int    (*PFUN_SOCKETGETREMOTEIP)(int sock, ST_COS_INET_IP *pstOutRmtIp);
+
+// typedef int    (*PFUN_SOCKETSETOPTBLK)(int sock, int bBlock);
+// typedef int    (*PFUN_SOCKETSETOPTREUSEADDR)(int sock, int bReuseAddr);
+// typedef int    (*PFUN_SOCKETSETOPTNODELAY)(int sock, int bNodelay); /*close nagle,set send no delay*/
+// typedef int    (*PFUN_SOCKETSETOPTCORK)(int sock, int bNodelay); /*close nagle,set cork*/
+typedef int    (*PFUN_SOCKETSETRECVBUF)(int sock, int iBufSize);
+typedef int    (*PFUN_SOCKETSETSENDBUF)(int sock, int iBufSize);
+// typedef int    (*PFUN_SOCKETSETSENDTIMEOUT)(int sock, int iTimeOutSec);
+// typedef int    (*PFUN_SOCKETSETRECVTIMEOUT)(int sock, int iTimeOutSec);
+typedef int    (*PFUN_SOCKETGETLASTERR)(void);
+
+typedef int    (*PFUN_SOCKETCHECKCONN)(int sock, int *piErr);
+
+/************************************************************************************************
+ * thread
+ ***********************************************************************************************/
+typedef enum enum_THREAD_PRIORITY
+{
+   EN_THREAD_PRIORITY_LOWEST          = 0,
+   EN_THREAD_PRIORITY_LOWER           = 1,
+   EN_THREAD_PRIORITY_NORMAL          = 2,
+   EN_THREAD_PRIORITY_HIGHER          = 3,
+   EN_THREAD_PRIORITY_HIGHEST         = 4,
+   EN_THREAD_PRIORITY_IVALID          = 100
+}EN_THREAD_PRIORITY;
+
+// typedef int (*PFN_THREADDELWAKE)(void);
+
+typedef int (*PFN_THREADPROC)(void *pParam);
+
+typedef int (*PFN_THREADCREATE)(unsigned char *pucName, int iPriority, unsigned int uiStackSize, PFN_THREADPROC pfunProc, void *pParam, void **phOutOSThread);
+
+typedef int (*PFN_THREADDELETE)(void *hOSThread, int bForce);
+
+typedef int (*PFN_SLEEP)(unsigned int uiMilliSecond);
+
+typedef int (*PFUN_SETTHREADNAME)(unsigned char *pucName);
+
+typedef unsigned int  (*PFN_THREADGETCURID)(void);
+
+/************************************************************************************************
+ * time
+ ***********************************************************************************************/
+typedef struct stru_COS_SYS_TIME
+{
+    unsigned short usYear;
+    unsigned short usMonth;
+    unsigned short usDay;
+    unsigned short usWeekDay;
+    unsigned short usHour;
+    unsigned short usMinute;
+    unsigned short usSecond;
+    unsigned short usIsdst;
+}ST_COS_SYS_TIME;
+
+typedef time_t (*PFN_GETTIME)(time_t *ptmTime);
+typedef struct tm* (*PFN_LOCALTIME)(time_t *ptmTime,struct tm *ptTm);
+// typedef struct tm *(*PFN_GMTIME)(time_t *ptmTime,struct tm *ptTm);
+typedef unsigned int (*PFN_GETTICKCOUNT)(void);
+typedef time_t (*PFN_SYSTIMETOTIME)(ST_COS_SYS_TIME *pstTime);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
\ No newline at end of file
index 842bbbe..3964934 100644 (file)
@@ -5,8 +5,6 @@
 extern "C" {
 #endif
 
-#include "osal_task.h"
-
 /**
 * @brief 设备初始化接口
 * @param pucSystemPath 系统路径
diff --git a/code/sdk/zhihui/AI/AIsdk/lib/libai.c b/code/sdk/zhihui/AI/AIsdk/lib/libai.c
new file mode 100644 (file)
index 0000000..59a287a
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdint.h>
+#include "osal_task.h"
+
+uint32_t ntohl(uint32_t netlong) {
+    return ((netlong & 0xFF) << 24) |
+           ((netlong & 0xFF00) << 8) |
+           ((netlong & 0xFF0000) >> 8) |
+           ((netlong & 0xFF000000) >> 24);
+}
+
+uint32_t htonl(uint32_t hostlong) {
+    return ntohl(hostlong);
+}
+
+uint16_t ntohs(uint16_t netshort) {
+    return ((netshort & 0xFF) << 8) | ((netshort & 0xFF00) >> 8);
+}
+
+uint16_t htons(uint16_t hostshort) {
+    return ntohs(hostshort);
+}
+
+int osal_get_current_tgid(void)
+{
+    // 在 LiteOS 中,tgid 通常等于 tid
+    // 或者返回一个固定值,因为 LiteOS 不支持进程组概念
+    return (int)osal_get_current_tid();
+}
+
+
index 2caf57a..2cae275 100644 (file)
Binary files a/code/sdk/zhihui/AI/AIsdk/lib/libcommon.a and b/code/sdk/zhihui/AI/AIsdk/lib/libcommon.a differ
index 59bc592..ca3a0a2 100644 (file)
Binary files a/code/sdk/zhihui/AI/AIsdk/lib/libcos.a and b/code/sdk/zhihui/AI/AIsdk/lib/libcos.a differ
index bb4215f..887f234 100644 (file)
Binary files a/code/sdk/zhihui/AI/AIsdk/lib/libthirdparty.a and b/code/sdk/zhihui/AI/AIsdk/lib/libthirdparty.a differ
index d1d7eab..61f82bd 100644 (file)
@@ -15,27 +15,6 @@ set(PUBLIC_HEADER
 
 )
 set(PRIVATE_HEADER
-    ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include
-    ${ROOT_DIR}/middleware/utils/update/inner_include
-    ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits
-    ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits
-    ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include
-    ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits
-    ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include
-    ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits
-    ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits
-    ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils
-    ${ROOT_DIR}/middleware/services/media/foundation/player/interfaces/kits
-    ${ROOT_DIR}/application/wearable/nativeapp/nativeui/key/include
-    ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits
-    ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits/font
-    ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks/font
-    ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks
-   
-    ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits
-    ${ROOT_DIR}/zhihui/services/factorytest_service
-    ${ROOT_DIR}/zhihui/drivers/
-    ${ROOT_DIR}/zhihui/4g/cat1Service/include
     ${ROOT_DIR}/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/include
     ${ROOT_DIR}/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include
     # /home/hcj/615/FD230/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h
index 07fe4e4..4172dad 100644 (file)
@@ -1,23 +1,37 @@
+#include "zj_syscall_prv.h"
+#include "zj_syscall.h"
+#include "zj_type.h"
+#include "zj_err.h"
+#include "zj_syscall.h"
+
+#include "lwip/ip.h"
+#include "lwip/netif.h"
+#include "lwip/init.h"
+#include "lwip/inet_chksum.h"
+#include "lwip/err.h"
+#include "lwip/sys.h"
+#include <lwip/netdb.h>
+// #include <netinet/in.h>
+#include "lwip/inet.h"
+#include "sys/stat.h"
+#include "sys/statfs.h"
+#include <dirent.h>
+#include "errcode.h"
+#include "thread_init.h"
+#include "los_task.h"
+#include "los_mux.h"
+#include "los_sem.h"
+#include "los_memory.h"
+#include "los_tick.h"
+#include "los_sys.h"
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <sys/select.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/ioctl.h>
-#include <sched.h>
-#include <sys/prctl.h>
-#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include "wearable_log.h"
+
+// #include <sys/time.h>
 
-#include "zj_type.h"
-#include "zj_err.h"
-// #include "zj_syscall.h"
 
 // ÒÔÏÂÉùÃ÷µÄϵͳµ÷Óûص÷º¯Êý¾ùÓɳ§ÉÌʵÏÖ  ³§ÉÌʵÏÖ±ê¼Ç
 /***********************************************************************************/
@@ -64,9 +78,9 @@ static int inet_socket_open(int iNetType, int iProtoType, int bBlock, int bReuse
 static int inet_socket_close(int sock);
 static int inet_socket_shutdown(int sock, int iHowTo);
 static int inet_socket_select(int imaxFd, void * readFds, void * writeFds, void * exceptFds, int iMillSecWait);
-static int inet_socket_connect(int sock, ST_COS_INET_IP *pstRmtAddr,int *bConnect);
+static int inet_socket_connect(int sock, ST_COS_INET_IP *pstRmtAddr, int *bConnect);
 static int inet_socket_sendTo(int sock, ST_COS_INET_IP *pstRmtAddr, void * pBuf, int ilen, int *pbOutWait);
-static int inet_socket_recvfrom(int sock, ST_COS_INET_IP *pstIORmtAddr, void * pOutBuf, int iLen,int *pbOutClosed);
+static int inet_socket_recvfrom(int sock, ST_COS_INET_IP *pstIORmtAddr, void * pOutBuf, int iLen, int *pbOutClosed);
 static int inet_socket_send(int sock, void * pBuf, int iLen, int *pbOutWait);
 static int inet_socket_recv(int sock, void * pOutBuf, int iLen, int *pbOutClosed);
 static int inet_socket_setRecvBuff(int sock, int iBufSize);
@@ -217,6 +231,11 @@ void syscall_start()
 /***********************************************************************************/
 static ZJ_HANDLE file_open_cb(unsigned char *pucFileName, unsigned int uiFlag)
 {
+    if (!pucFileName) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_open_cb: pucFileName is NULL");
+        return NULL;
+    }
+    
     unsigned char aucOpenType[10];
     unsigned int uiLen = 0;
     FILE *pstFile = NULL;
@@ -254,6 +273,7 @@ static ZJ_HANDLE file_open_cb(unsigned char *pucFileName, unsigned int uiFlag)
     }
     else
     {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_open_cb: invalid flag 0x%x for file %s", uiFlag, pucFileName);
         return NULL;
     }
     
@@ -264,18 +284,38 @@ static ZJ_HANDLE file_open_cb(unsigned char *pucFileName, unsigned int uiFlag)
     aucOpenType[uiLen] = '\0';
 
     pstFile = fopen((char*)pucFileName, (char *)aucOpenType);
+    if (!pstFile) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_open_cb: fopen failed for file %s with mode %s, errno=%d (%s)", 
+               pucFileName, aucOpenType, errno, strerror(errno));
+    }
     return pstFile;
 }
 
 static int file_close_cb(ZJ_HANDLE hFile)
 {
-    return fclose((FILE *)hFile);
+    if (!hFile) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_close_cb: hFile is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    int ret = fclose((FILE *)hFile);
+    if (ret != 0) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_close_cb: fclose failed, errno=%d (%s)", errno, strerror(errno));
+        return EN_ZJ_ERR;
+    }
+    return EN_ZJ_ERR_OK;
 }
 
 static int file_rmv_cb(unsigned char *pucFileName)
 {
+    if (!pucFileName) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_rmv_cb: pucFileName is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
     if (unlink((char *)pucFileName) != 0)
     {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_rmv_cb: unlink failed for file %s, errno=%d (%s)", 
+               pucFileName, errno, strerror(errno));
         return EN_ZJ_ERR;
     }
 
@@ -284,6 +324,11 @@ static int file_rmv_cb(unsigned char *pucFileName)
 
 static int file_eof(ZJ_HANDLE hFile)
 {
+    if (!hFile) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_eof: hFile is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
     if (feof((FILE *)hFile) != 0)
         return 1;
 
@@ -292,28 +337,44 @@ static int file_eof(ZJ_HANDLE hFile)
 
 static int file_write(ZJ_HANDLE hFile, unsigned char *pucBuf, int iLen)
 {
-    if (!hFile || !pucBuf || !iLen)
+    if (!hFile || !pucBuf || iLen <= 0) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_write: invalid parameters - hFile=%p, pucBuf=%p, iLen=%d", 
+               hFile, pucBuf, iLen);
         return EN_ZJ_ERR_PARAM;
+    }
 
-    return fwrite((char *)pucBuf, sizeof(char), (size_t)iLen, (FILE *)hFile);
+    size_t written = fwrite((char *)pucBuf, sizeof(char), (size_t)iLen, (FILE *)hFile);
+    if (written != (size_t)iLen) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file_write: fwrite failed, expected=%d, written=%zu, errno=%d (%s)", 
+               iLen, written, errno, strerror(errno));
+        return EN_ZJ_ERR;
+    }
+    return iLen;
 }
 
 static int file_read(ZJ_HANDLE hFile, unsigned char *pucBuf, int iLen)
 {
-    if (!hFile || !pucBuf || !iLen)
+    if (!hFile || !pucBuf || iLen <= 0)
         return EN_ZJ_ERR_PARAM;
 
-    return fread((char *)pucBuf, sizeof(char), iLen,(FILE *)hFile);
+    size_t read = fread((char *)pucBuf, sizeof(char), iLen, (FILE *)hFile);
+    return (int)read;
 }
 
 static int file_flush(ZJ_HANDLE hFile)
 {
+    if (!hFile) return EN_ZJ_ERR_PARAM;
+    
     if (fflush((FILE *)hFile) == EOF)
         return EN_ZJ_ERR;
+    
+    return EN_ZJ_ERR_OK;
 }
 
 static int file_seek(ZJ_HANDLE hFile, unsigned short usFlag, int iOffSet)
 {
+    if (!hFile) return EN_ZJ_ERR_PARAM;
+    
     int iOrigin;
 
     switch(usFlag)
@@ -331,17 +392,24 @@ static int file_seek(ZJ_HANDLE hFile, unsigned short usFlag, int iOffSet)
         return EN_ZJ_ERR_PARAM;
     }
 
-    return fseek((FILE *)hFile, iOffSet, iOrigin);
+    int ret = fseek((FILE *)hFile, iOffSet, iOrigin);
+    return (ret == 0) ? EN_ZJ_ERR_OK : EN_ZJ_ERR;
 }
 
 static int file_size(ZJ_HANDLE hFile)
 {
+    if (!hFile) return EN_ZJ_ERR_PARAM;
+    
     unsigned int uiCurPos = 0;
     unsigned int uiSize = 0;
 
     uiCurPos = file_tell(hFile);
+    if (uiCurPos == EN_ZJ_ERR) return EN_ZJ_ERR;
+    
     file_seek(hFile, COS_FILE_SEEK_END, 0);   
     uiSize = file_tell(hFile);
+    if (uiSize == EN_ZJ_ERR) return EN_ZJ_ERR;
+    
     file_seek(hFile, COS_FILE_SEEK_BEGIN, uiCurPos);
     
     return uiSize;
@@ -349,14 +417,19 @@ static int file_size(ZJ_HANDLE hFile)
 
 static int file_tell(ZJ_HANDLE hFile)
 {
-    return ftell((FILE *)hFile);
+    if (!hFile) return EN_ZJ_ERR_PARAM;
+    
+    long pos = ftell((FILE *)hFile);
+    return (pos >= 0) ? (int)pos : EN_ZJ_ERR;
 }
 
 static int file_stat(unsigned char *pucFileName, ST_COS_FILE_INF *pstInf)
 {
+    if (!pucFileName || !pstInf) return EN_ZJ_ERR_PARAM;
+    
     struct stat stStatInfo;
 
-    memset(pstInf,0,sizeof(ST_COS_FILE_INF));
+    memset(pstInf, 0, sizeof(ST_COS_FILE_INF));
 
     if (stat((char *)pucFileName, &stStatInfo) != 0)
     {
@@ -412,17 +485,18 @@ static int file_stat(unsigned char *pucFileName, ST_COS_FILE_INF *pstInf)
     if (stStatInfo.st_mode & S_IXOTH)
         pstInf->uiMode |= COS_FILE_OEXEC;
 
-
     pstInf->uiSize = (unsigned int)(unsigned long long)(stStatInfo.st_size);
     pstInf->utlastAccTime = stStatInfo.st_atime;
     pstInf->utlastMdfyTime = stStatInfo.st_mtime;
     pstInf->utlastChangeTime = stStatInfo.st_ctime;
 
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static ZJ_HANDLE dir_open(unsigned char *pucDirName)
 {   
+    if (!pucDirName) return NULL;
+    
     ST_DIR *pstDir;
 
     pstDir = (ST_DIR *)malloc(sizeof(ST_DIR));
@@ -433,6 +507,7 @@ static ZJ_HANDLE dir_open(unsigned char *pucDirName)
     if (!pstDir->pstDir)
     {
         free(pstDir);
+        return NULL;
     }
     
     return pstDir;
@@ -440,31 +515,32 @@ static ZJ_HANDLE dir_open(unsigned char *pucDirName)
 
 static int dir_close(ZJ_HANDLE hDir)
 {
-    ST_DIR *pstDir;
-
-    pstDir = (ST_DIR *)hDir;
+    if (!hDir) return EN_ZJ_ERR_PARAM;
+    
+    ST_DIR *pstDir = (ST_DIR *)hDir;
 
     if (pstDir && pstDir->pstDir)
         closedir(pstDir->pstDir);
 
     free(pstDir);
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int dir_read(ZJ_HANDLE hDir, unsigned char *pucEntryName, int iMaxLen, ST_COS_FILE_INF *pstInf)
 {
+    if (!hDir || !pucEntryName || iMaxLen <= 0) return EN_ZJ_ERR_PARAM;
+    
     unsigned char aucAbsPath[256] = {0};
     unsigned char *pucName;
     ST_DIR *pstDir;
     struct dirent *pstDirent;
-    if(!hDir)   return EN_ZJ_ERR_PARAM;
-
+    
     pstDir = (ST_DIR *)hDir;
 
-    
 RETRY:
     pstDir->pstEntry = (struct dirent *)readdir((DIR *)pstDir->pstDir);
-    if(!pstDir->pstEntry)  return EN_ZJ_ERR;
+    if(!pstDir->pstEntry) return EN_ZJ_ERR;
+    
     pstDirent = (struct dirent *)pstDir->pstEntry;
     pucName = (unsigned char *)pstDirent->d_name;
 
@@ -472,18 +548,23 @@ RETRY:
     {
         goto RETRY;
     }
+    
     strncpy(pucEntryName, pucName, iMaxLen);
+    pucEntryName[iMaxLen - 1] = '\0';  // 确保字符串结束
+    
     if (pstInf)
     {
         snprintf(aucAbsPath, 256 - 1, (unsigned char *)"%s/%s", pstDir->aucName, pucName);
         return file_stat(aucAbsPath, pstInf);
     }
 
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int dir_make(unsigned char *pucDirName, unsigned int uiFlag)
 {
+    if (!pucDirName) return EN_ZJ_ERR_PARAM;
+    
     mode_t tMode = 0;
 
     if (uiFlag & COS_FILE_UREAD)  tMode |= S_IRUSR;
@@ -502,86 +583,202 @@ static int dir_make(unsigned char *pucDirName, unsigned int uiFlag)
     {
         return EN_ZJ_ERR;
     }
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
 /***********************************************************************************/
 static int mutex_create(void **phOutMutex)
 {
-    if (phOutMutex == NULL) return -1;
-
-    pthread_mutex_t *pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
-    if (!pMutex) return -1;
-
-    pthread_mutexattr_t attr;
-    pthread_mutexattr_init(&attr);
-    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-    pthread_mutex_init(pMutex, &attr);
-    pthread_mutexattr_destroy(&attr);
-
-    *phOutMutex = (void *)pMutex;
-       return 0;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_create: called with phOutMutex=%p", phOutMutex);
+    
+    if (phOutMutex == NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_create: phOutMutex is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    // 动态分配内存存储 mutexId
+    UINT32 *pMutexId = (UINT32*)malloc(sizeof(UINT32));
+    if (!pMutexId) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_create: malloc failed, size=%d", (int)sizeof(UINT32));
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_create: malloc success, pMutexId=%p", pMutexId);
+    
+    UINT32 ret = LOS_MuxCreate(pMutexId);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_create: LOS_MuxCreate failed, ret=0x%x", ret);
+        free(pMutexId);
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_create: LOS_MuxCreate success, mutexId=0x%x, pMutexId=%p", *pMutexId, pMutexId);
+    
+    *phOutMutex = (void *)pMutexId;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_create: success, *phOutMutex=%p", *phOutMutex);
+    return EN_ZJ_ERR_OK;
 }
 
 static void mutex_delete(void *phMutex)
 {
-    if (!phMutex) return;
-
-    pthread_mutex_t *pMutex = (pthread_mutex_t *)phMutex;
-    pthread_mutex_destroy(pMutex);
-    free(pMutex);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_delete: called with phMutex=%p", phMutex);
+    
+    if (phMutex == NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_delete: phMutex is NULL");
+        return;
+    }
+    
+    UINT32 *pMutexId = (UINT32*)phMutex;
+    UINT32 mutexId = *pMutexId;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_delete: pMutexId=%p, mutexId=0x%x", pMutexId, mutexId);
+    
+    UINT32 ret = LOS_MuxDelete(mutexId);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_delete: LOS_MuxDelete failed, mutexId=0x%x, ret=0x%x", mutexId, ret);
+    } else {
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_delete: LOS_MuxDelete success, mutexId=0x%x", mutexId);
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_delete: about to free pMutexId=%p", pMutexId);
+    free(pMutexId);  // 释放动态分配的内存
 }
 
 static int mutex_lock(void *phMutex)
 {
-    if (!phMutex) return -1;
-    return pthread_mutex_lock((pthread_mutex_t *)phMutex);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_lock: called with phMutex=%p", phMutex);
+    
+    if (!phMutex) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_lock: phMutex is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    UINT32 *pMutexId = (UINT32*)phMutex;
+    UINT32 mutexId = *pMutexId;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_lock: pMutexId=%p, mutexId=0x%x, attempting to lock", pMutexId, mutexId);
+    
+    UINT32 ret = LOS_MuxPend(mutexId, LOS_WAIT_FOREVER);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_lock: LOS_MuxPend failed, mutexId=0x%x, ret=0x%x", mutexId, ret);
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_lock: success, mutexId=0x%x locked", mutexId);
+    return EN_ZJ_ERR_OK;
 }
 
 static int mutex_unlock(void *phMutex)
 {
-    if (!phMutex) return -1;
-    return pthread_mutex_unlock((pthread_mutex_t *)phMutex);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_unlock: called with phMutex=%p", phMutex);
+    
+    if (!phMutex) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_unlock: phMutex is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    UINT32 *pMutexId = (UINT32*)phMutex;
+    UINT32 mutexId = *pMutexId;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_unlock: pMutexId=%p, mutexId=0x%x, attempting to unlock", pMutexId, mutexId);
+    
+    UINT32 ret = LOS_MuxPost(mutexId);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mutex_unlock: LOS_MuxPost failed, mutexId=0x%x, ret=0x%x", mutexId, ret);
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "mutex_unlock: success, mutexId=0x%x unlocked", mutexId);
+    return EN_ZJ_ERR_OK;
 }
 
 static int sem_create(void **phOutSem)
 {   
-    if (!phOutSem) return -1;
-
-    sem_t *pSem = (sem_t *)malloc(sizeof(sem_t));
-    if (!pSem) return EN_ZJ_ERR;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_create: called with phOutSem=%p", phOutSem);
+    
+    if (!phOutSem) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_create: phOutSem is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
 
-    if (sem_init(pSem, 0, 0) != 0) {  // 0 表示进程内使用,初值为 0
-        free(pSem);
+    UINT32 semId;
+    UINT32 ret = LOS_SemCreate(0, &semId);  // 初始值为0
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_create: LOS_SemCreate failed, ret=0x%x", ret);
         return EN_ZJ_ERR;
     }
 
-    *phOutSem = (void *)pSem;
-    return 0;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_create: LOS_SemCreate success, semId=0x%x", semId);
+    
+    *phOutSem = (void *)(UINTPTR)semId;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_create: success, *phOutSem=%p", *phOutSem);
+    return EN_ZJ_ERR_OK;
 }
 
 static void sem_delete(void *phSem)
 {
-    if (!phSem) return;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_delete: called with phSem=%p", phSem);
+    
+    if (!phSem) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_delete: phSem is NULL");
+        return;
+    }
 
-    sem_t *pSem = (sem_t *)phSem;
-    sem_destroy(pSem);
-    free(pSem);
+    UINT32 semId = (UINT32)(UINTPTR)phSem;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_delete: semId=0x%x", semId);
+    
+    UINT32 ret = LOS_SemDelete(semId);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_delete: LOS_SemDelete failed, semId=0x%x, ret=0x%x", semId, ret);
+    } else {
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_delete: LOS_SemDelete success, semId=0x%x", semId);
+    }
 }
 
 static int sem_s_wait(void *phSem)
 {
-    if (!phSem) return -1;
-    return sem_wait((sem_t *)phSem);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_wait: called with phSem=%p", phSem);
+    
+    if (!phSem) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_s_wait: phSem is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    UINT32 semId = (UINT32)(UINTPTR)phSem;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_wait: semId=0x%x, attempting to wait", semId);
+    
+    UINT32 ret = LOS_SemPend(semId, LOS_WAIT_FOREVER);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_s_wait: LOS_SemPend failed, semId=0x%x, ret=0x%x", semId, ret);
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_wait: success, semId=0x%x acquired", semId);
+    return EN_ZJ_ERR_OK;
 }
 
 static int sem_s_post(void *phSem)
 {
-    if (!phSem) return -1;
-    return sem_post((sem_t *)phSem);
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_post: called with phSem=%p", phSem);
+    
+    if (!phSem) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_s_post: phSem is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    UINT32 semId = (UINT32)(UINTPTR)phSem;
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_post: semId=0x%x, attempting to post", semId);
+    
+    UINT32 ret = LOS_SemPost(semId);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sem_s_post: LOS_SemPost failed, semId=0x%x, ret=0x%x", semId, ret);
+        return EN_ZJ_ERR;
+    }
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "sem_s_post: success, semId=0x%x posted", semId);
+    return EN_ZJ_ERR_OK;
 }
 /***********************************************************************************/
 static int inet_get_addr(unsigned char *pucAddrStr, unsigned int *puiDstAddr)
 {
+    if (!pucAddrStr || !puiDstAddr) return EN_ZJ_ERR_PARAM;
+    
     unsigned int uiAddr;
     uiAddr = inet_addr((char *)pucAddrStr);
     *puiDstAddr = (unsigned int)uiAddr;
@@ -591,7 +788,7 @@ static int inet_get_addr(unsigned char *pucAddrStr, unsigned int *puiDstAddr)
         if(strcmp(pucAddrStr,"255.255.255.255"))
             return EN_ZJ_ERR;
     }
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static unsigned int inet_net_to_host_long(unsigned int uiVal)
@@ -616,63 +813,82 @@ static unsigned short inet_host_to_net_short(unsigned short usVal)
 
 static int inet_fd_create(void **pFds)
 {
+    if (!pFds) return EN_ZJ_ERR_PARAM;
+    
     *pFds = (void **)malloc(sizeof(fd_set));
-       return *pFds ? 0 : EN_ZJ_ERR;
+    if (!*pFds) return EN_ZJ_ERR;
+    
+    FD_ZERO((fd_set *)*pFds);  // 初始化fd_set
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_fd_delete(void *fds)
 {
+    if (!fds) return EN_ZJ_ERR_PARAM;
+    
     free(fds);
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_fd_zero(void *fds)
 {
+    if (!fds) return EN_ZJ_ERR_PARAM;
+    
     FD_ZERO((fd_set *)fds);
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_fd_set(int iFd, void *fds)
 {
+    if (!fds || iFd < 0) return EN_ZJ_ERR_PARAM;
+    
     FD_SET((unsigned int)iFd, (fd_set *)fds);
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_fd_is_set(int iFd, void *fds)
 {
+    if (!fds || iFd < 0) return 0;
+    
     return (FD_ISSET(iFd, (fd_set *)fds)) ? 1 : 0;
 }
 
 static int inet_fd_clr(int iFd, void *fds)
 {
+    if (!fds || iFd < 0) return EN_ZJ_ERR_PARAM;
+    
     FD_CLR(iFd, (fd_set *)fds);
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_get_host_by_name(unsigned char *pucName, ST_COS_INET_IPARRAY *pstIpArrayInfo)
 {
+    if (!pucName || !pstIpArrayInfo) return EN_ZJ_ERR_PARAM;
+    
     struct hostent *pstHostid;
-       ST_COS_INET_IP *pstIp;
-       int i = 0;
+    ST_COS_INET_IP *pstIp;
+    int i = 0;
 
-       pstIpArrayInfo->uiCount = 0;
-       pstHostid = gethostbyname((char *)pucName);
-       if (!pstHostid || pstHostid->h_addrtype != AF_INET)
-               return EN_ZJ_ERR;
+    pstIpArrayInfo->uiCount = 0;
+    pstHostid = gethostbyname((char *)pucName);
+    if (!pstHostid || pstHostid->h_addrtype != AF_INET)
+        return EN_ZJ_ERR;
 
-       while(i < COS_INET_ADDR_MAX_NUM && pstHostid->h_addr_list[i])
-       {
-               pstIp = &pstIpArrayInfo->astIps[pstIpArrayInfo->uiCount++];
-               pstIp->usType = EN_CINET_TYPE_IPV4;
-               pstIp->u.uiIp = *((unsigned int *)pstHostid->h_addr_list[i]);
-               i++;
-       }
+    while(i < COS_INET_ADDR_MAX_NUM && pstHostid->h_addr_list[i])
+    {
+        pstIp = &pstIpArrayInfo->astIps[pstIpArrayInfo->uiCount++];
+        pstIp->usType = EN_CINET_TYPE_IPV4;
+        pstIp->u.uiIp = *((unsigned int *)pstHostid->h_addr_list[i]);
+        i++;
+    }
 
-       return 1;
+    return (pstIpArrayInfo->uiCount > 0) ? EN_ZJ_ERR_OK : EN_ZJ_ERR;
 }
 
 static int inet_get_addr_info(unsigned char *pucHostName, unsigned short usPort, int iProtoType, int bPassive, ST_COS_INET_IPARRAY *pstIpArrayInfo)
 {
+    if (!pucHostName || !pstIpArrayInfo) return EN_ZJ_ERR_PARAM;
+    
     int iRet;
     unsigned char aucService[8];
     unsigned char *pucService = NULL;
@@ -686,7 +902,7 @@ static int inet_get_addr_info(unsigned char *pucHostName, unsigned short usPort,
     if(bPassive == 1)
     {
         aiHint.ai_flags = AI_PASSIVE;
-        snprintf(aucService, 8, "%u",usPort);
+        snprintf(aucService, 8, "%u", usPort);
         pucService = aucService;
     }
 
@@ -700,7 +916,7 @@ static int inet_get_addr_info(unsigned char *pucHostName, unsigned short usPort,
         }
         if(pucHostName)
         {
-            printf("get host %s failed errno %u\n",pucHostName,errno);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get host %s failed errno %u", pucHostName, errno);
         }
         return EN_ZJ_ERR;
     }
@@ -712,37 +928,46 @@ static int inet_get_addr_info(unsigned char *pucHostName, unsigned short usPort,
         if(pstCur->ai_family == AF_INET){
             pstIp->usType = EN_CINET_TYPE_IPV4;
             pstIp->u.uiIp = ((struct sockaddr_in *)(pstCur->ai_addr))->sin_addr.s_addr;
-        }else if(pstCur->ai_family == AF_INET6){
+        }
+        #if LWIP_IPV6
+        else if(pstCur->ai_family == AF_INET6){
             pstIp->usType = EN_CINET_TYPE_IPV6;
             memcpy(pstIp->u.aucIpv6, &(((struct sockaddr_in6*)(pstCur->ai_addr))->sin6_addr), 16);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no support EN_CINET_TYPE_IPV6");
         }
+        #endif
         pstIpArrayInfo->uiCount++;
     }
 
     freeaddrinfo(pstAddr);
 
-    return pstIpArrayInfo->uiCount > 0 ? 0 : EN_ZJ_ERR;
+    return pstIpArrayInfo->uiCount > 0 ? EN_ZJ_ERR_OK : EN_ZJ_ERR;
 }
 
 static int inet_SocketSetOptBlk(int sock, int bBlock)
 {
-       int iDisable = 0;
-       int iEnable  = 1;
-       int iRet;
+    if (sock < 0) return EN_ZJ_ERR_PARAM;
+    
+    int iDisable = 0;
+    int iEnable  = 1;
+    int iRet;
 
-       if (bBlock)
-               iRet = ioctl(sock, FIONBIO, &iDisable);
-       else
-               iRet = ioctl(sock, FIONBIO,&iEnable);
+    if (bBlock)
+        iRet = ioctl(sock, FIONBIO, &iDisable);
+    else
+        iRet = ioctl(sock, FIONBIO, &iEnable);
 
     if (iRet == -1)
     {  
         return EN_ZJ_ERR;
     }
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
+
 static int Clin_SocketSetOptTtl(int sock, unsigned int uiTtlVal)
 {
+    if (sock < 0) return EN_ZJ_ERR_PARAM;
+    
     int  iRet;
     int iTtlVal;
 
@@ -754,10 +979,13 @@ static int Clin_SocketSetOptTtl(int sock, unsigned int uiTtlVal)
         return EN_ZJ_ERR;
     }
 
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
+
 static int Clin_SocketSetOptReuseAddr(int sock, int bReuseAddr)
 {
+    if (sock < 0) return EN_ZJ_ERR_PARAM;
+    
     int bDisable = 0;
     int bEnable  = 1;
     int iRet;
@@ -771,43 +999,51 @@ static int Clin_SocketSetOptReuseAddr(int sock, int bReuseAddr)
     {
         return EN_ZJ_ERR;
     }
-    return 0;
+    return EN_ZJ_ERR_OK;
 }
+
 static int inet_socket_open(int iNetType, int iProtoType, int bBlock, int bReuseAddr)
 {
     int iSockType;
     int cSock;
 
-       if (iNetType == EN_CINET_TYPE_IPV4)
-               iNetType = AF_INET;
-       else if (iNetType == EN_CINET_TYPE_IPV6)
-               iNetType = AF_INET6;     
-       else
-               return EN_ZJ_ERR;
+    if (iNetType == EN_CINET_TYPE_IPV4)
+        iNetType = AF_INET;
+    else if (iNetType == EN_CINET_TYPE_IPV6)
+        iNetType = AF_INET6;    
+    else {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "inet_socket_open: invalid netType=%d\n", iNetType);
+        return EN_ZJ_ERR_PARAM;
+    }
 
-       if (iProtoType == EN_CINET_PRTL_UDP)
-       {
-               iProtoType = IPPROTO_UDP;
-               iSockType  = SOCK_DGRAM;
-       } 
-       else if (iProtoType == EN_CINET_PRTL_TCP)
-       {
-               iProtoType = IPPROTO_TCP;
-               iSockType  = SOCK_STREAM;
-       }
+    if (iProtoType == EN_CINET_PRTL_UDP)
+    {
+        iProtoType = IPPROTO_UDP;
+        iSockType  = SOCK_DGRAM;
+    } 
+    else if (iProtoType == EN_CINET_PRTL_TCP)
+    {
+        iProtoType = IPPROTO_TCP;
+        iSockType  = SOCK_STREAM;
+    }
     else if (iProtoType == EN_CINET_PRTL_RAW)
     {
         iProtoType = IPPROTO_ICMP;
         iSockType  = SOCK_RAW;
     }
-    else
-               return EN_ZJ_ERR;
+    else {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "inet_socket_open: invalid protoType=%d\n", iProtoType);
+        return EN_ZJ_ERR_PARAM;
+    }
 
-       cSock = socket(iNetType, iSockType, iProtoType);
-       if (cSock == -1)
-       {
-               return EN_ZJ_ERR;
-       }
+    cSock = socket(iNetType, iSockType, iProtoType);
+    if (cSock == -1)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "inet_socket_open: socket failed, netType=%d, sockType=%d, protoType=%d, errno=%d (%s)\n", 
+               iNetType, iSockType, iProtoType, errno, strerror(errno));
+        return EN_ZJ_ERR;
+    }
+    
     inet_SocketSetOptBlk(cSock, bBlock);
     
     if (iProtoType != EN_CINET_PRTL_RAW)
@@ -821,42 +1057,50 @@ static int inet_socket_open(int iNetType, int iProtoType, int bBlock, int bReuse
 
 static int inet_socket_close(int sock)
 {
+    if (sock < 0) return EN_ZJ_ERR_PARAM;
+    
     int iRet;
     iRet = close(sock);
     if(iRet == -1) 
     {
         return EN_ZJ_ERR;
     }
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_socket_shutdown(int sock, int iHowTo)
 {
+    if (sock < 0) return EN_ZJ_ERR_PARAM;
+    
     int iRet;
 
-       if (iHowTo == EN_CINET_SHTDWN_RECV)
-               iHowTo = SHUT_RD;
-       else if(iHowTo == EN_CINET_SHTDWN_SEND)
-               iHowTo = SHUT_WR;
+    if (iHowTo == EN_CINET_SHTDWN_RECV)
+        iHowTo = SHUT_RD;
+    else if(iHowTo == EN_CINET_SHTDWN_SEND)
+        iHowTo = SHUT_WR;
     else if(iHowTo == EN_CINET_SHTDWN_BOTH)
-               iHowTo = SHUT_RDWR;
+        iHowTo = SHUT_RDWR;
+    else
+        return EN_ZJ_ERR_PARAM;
 
-       iRet = shutdown(sock, iHowTo);
-       if (iRet == -1 && errno != ENOTCONN)
-       {
-               return EN_ZJ_ERR;
-       }
+    iRet = shutdown(sock, iHowTo);
+    if (iRet == -1 && errno != ENOTCONN)
+    {
+        return EN_ZJ_ERR;
+    }
 
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_socket_select(int imaxFd, void * readFds, void * writeFds, void * exceptFds, int iMillSecWait)
 {
+    if (imaxFd < 0) return EN_ZJ_ERR_PARAM;
+    
     struct timeval *pstTimeOut;
     struct timeval  stTimeout;
-       int iRet;
+    int iRet;
 
-    if (iMillSecWait)
+    if (iMillSecWait > 0)
     {
        stTimeout.tv_sec = (long)(iMillSecWait / 1000);
        stTimeout.tv_usec = (iMillSecWait % 1000) * 1000;
@@ -866,215 +1110,249 @@ static int inet_socket_select(int imaxFd, void * readFds, void * writeFds, void
     {
        pstTimeOut = NULL;
     }    
-       iRet = select(imaxFd, readFds, writeFds, exceptFds, pstTimeOut);
+    iRet = select(imaxFd, readFds, writeFds, exceptFds, pstTimeOut);
 
-       return iRet;
+    return iRet;
 }
 
-static int inet_socket_connect(int sock, ST_COS_INET_IP *pstRmtAddr,int *bConnect)
+static int inet_socket_connect(int sock, ST_COS_INET_IP *pstRmtAddr, int *bConnect)
 {
+    if (sock < 0 || !pstRmtAddr || !bConnect) return EN_ZJ_ERR_PARAM;
+    
     struct sockaddr *pstSockAddr;
-       struct sockaddr_in6  stIn6Addr;
-       struct sockaddr_in   stIn4Addr;
-       int iSize;
-       int iRet,iErrCode;
+    #if LWIP_IPV6
+    struct sockaddr_in6  stIn6Addr;
+    #endif
+   
+    struct sockaddr_in   stIn4Addr;
+    int iSize;
+    int iRet, iErrCode;
+    
     *bConnect = 0;
-       if (pstRmtAddr->usType == EN_CINET_TYPE_IPV4)
-       {
-               iSize = sizeof(struct sockaddr_in);
-               memset(&stIn4Addr, 0, iSize);
-               stIn4Addr.sin_family      = AF_INET;
-               stIn4Addr.sin_port        = htons(pstRmtAddr->usPort);
-               stIn4Addr.sin_addr.s_addr = pstRmtAddr->u.uiIp;
-               pstSockAddr               = (struct sockaddr *)&stIn4Addr;
-       } 
-       else if (pstRmtAddr->usType == EN_CINET_TYPE_IPV6)
-       {
-               iSize = sizeof(struct sockaddr_in6);
-               memset(&stIn6Addr, 0, iSize);
-               stIn6Addr.sin6_family     = AF_INET6;
-               stIn6Addr.sin6_port       = htons(pstRmtAddr->usPort);
-               memcpy(&stIn6Addr.sin6_addr, pstRmtAddr->u.aucIpv6, COS_INET_IPV6_ADDR_SIZE);
-               pstSockAddr = (struct sockaddr *)&stIn6Addr;
-       }
-       else
-               return EN_ZJ_ERR_PARAM;
+    
+    if (pstRmtAddr->usType == EN_CINET_TYPE_IPV4)
+    {
+        iSize = sizeof(struct sockaddr_in);
+        memset(&stIn4Addr, 0, iSize);
+        stIn4Addr.sin_family      = AF_INET;
+        stIn4Addr.sin_port        = htons(pstRmtAddr->usPort);
+        stIn4Addr.sin_addr.s_addr = pstRmtAddr->u.uiIp;
+        pstSockAddr               = (struct sockaddr *)&stIn4Addr;
+    } 
+    #if LWIP_IPV6
+    else if (pstRmtAddr->usType == EN_CINET_TYPE_IPV6)
+    {
+        iSize = sizeof(struct sockaddr_in6);
+        memset(&stIn6Addr, 0, iSize);
+        stIn6Addr.sin6_family     = AF_INET6;
+        stIn6Addr.sin6_port       = htons(pstRmtAddr->usPort);
+        memcpy(&stIn6Addr.sin6_addr, pstRmtAddr->u.aucIpv6, COS_INET_IPV6_ADDR_SIZE);
+        pstSockAddr = (struct sockaddr *)&stIn6Addr;
+    }
+    #endif
+    else
+        return EN_ZJ_ERR_PARAM;
 
-       iRet = connect(sock, pstSockAddr, iSize);
-       if (iRet == -1)
-       {
-               iErrCode = inet_socket_getLastErr();
-               if (iErrCode != EWOULDBLOCK && iErrCode != EISCONN 
-                       && iErrCode != EALREADY && iErrCode != EINPROGRESS)
-               {
-                       return iRet;
-               }
-           if(iErrCode == EISCONN) *bConnect = 1;
-       }else{
-               *bConnect = 1;
-       }
-       return 0;
+    iRet = connect(sock, pstSockAddr, iSize);
+    if (iRet == -1)
+    {
+        iErrCode = inet_socket_getLastErr();
+        if (iErrCode != EWOULDBLOCK && iErrCode != EISCONN 
+            && iErrCode != EALREADY && iErrCode != EINPROGRESS)
+        {
+            return EN_ZJ_ERR;
+        }
+        if(iErrCode == EISCONN) *bConnect = 1;
+    } else {
+        *bConnect = 1;
+    }
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_socket_sendTo(int sock, ST_COS_INET_IP *pstRmtAddr, void * pBuf, int ilen, int *pbOutWait)
 {
+    if (sock < 0 || !pstRmtAddr || !pBuf || ilen <= 0 || !pbOutWait) return EN_ZJ_ERR_PARAM;
+    
     struct sockaddr *pstSockAddr;
-       struct sockaddr_in6  stIn6Addr = {0};
-       struct sockaddr_in   stIn4Addr = {0};
-       int iSize;
-       int iRet,iErrCode;
+    #if LWIP_IPV6
+    struct sockaddr_in6  stIn6Addr = {0};
+    #endif
+    struct sockaddr_in   stIn4Addr = {0};
+   
+    int iSize;
+    int iRet, iErrCode;
 
-       *pbOutWait   = 0;
+    *pbOutWait = 0;
 
-       if (pstRmtAddr->usType == EN_CINET_TYPE_IPV4)
-       {
-               iSize = sizeof(struct sockaddr_in);
-               memset(&stIn4Addr, 0, iSize);
-               stIn4Addr.sin_family      = AF_INET;
-               stIn4Addr.sin_port        = htons(pstRmtAddr->usPort);
-               stIn4Addr.sin_addr.s_addr = pstRmtAddr->u.uiIp;
-               pstSockAddr               = (struct sockaddr *)&stIn4Addr;
-       } 
-       else if (pstRmtAddr->usType == EN_CINET_TYPE_IPV6)
-       {
-               iSize = sizeof(struct sockaddr_in6);
-               memset(&stIn6Addr, 0, iSize);
-               stIn6Addr.sin6_family     = AF_INET6;
-               stIn6Addr.sin6_port       = htons(pstRmtAddr->usPort);
-               memcpy(&stIn6Addr.sin6_addr, pstRmtAddr->u.aucIpv6, COS_INET_IPV6_ADDR_SIZE);
-               pstSockAddr = (struct sockaddr *)&stIn6Addr;
-       }
-       else
-               return EN_ZJ_ERR_PARAM;
+    if (pstRmtAddr->usType == EN_CINET_TYPE_IPV4)
+    {
+        iSize = sizeof(struct sockaddr_in);
+        memset(&stIn4Addr, 0, iSize);
+        stIn4Addr.sin_family      = AF_INET;
+        stIn4Addr.sin_port        = htons(pstRmtAddr->usPort);
+        stIn4Addr.sin_addr.s_addr = pstRmtAddr->u.uiIp;
+        pstSockAddr               = (struct sockaddr *)&stIn4Addr;
+    } 
+    #if LWIP_IPV6
+    else if (pstRmtAddr->usType == EN_CINET_TYPE_IPV6)
+    {
+        iSize = sizeof(struct sockaddr_in6);
+        memset(&stIn6Addr, 0, iSize);
+        stIn6Addr.sin6_family     = AF_INET6;
+        stIn6Addr.sin6_port       = htons(pstRmtAddr->usPort);
+        memcpy(&stIn6Addr.sin6_addr, pstRmtAddr->u.aucIpv6, COS_INET_IPV6_ADDR_SIZE);
+        pstSockAddr = (struct sockaddr *)&stIn6Addr;
+    }
+    #endif
+    else
+        return EN_ZJ_ERR_PARAM;
 
-       iRet = sendto(sock, (char *)pBuf, ilen, 0, pstSockAddr, iSize);
-       if (iRet == -1)
-       {
-       iErrCode = inet_socket_getLastErr();
-       if (EINTR == iErrCode || EAGAIN == iErrCode || EWOULDBLOCK == iErrCode)
+    iRet = sendto(sock, (char *)pBuf, ilen, 0, pstSockAddr, iSize);
+    if (iRet == -1)
+    {
+        iErrCode = inet_socket_getLastErr();
+        if (EINTR == iErrCode || EAGAIN == iErrCode || EWOULDBLOCK == iErrCode)
         {
             *pbOutWait = 1;
         }
     }
-       return iRet;
+    return iRet;
 }
 
-static int inet_socket_recvfrom(int sock, ST_COS_INET_IP *pstIORmtAddr, void * pOutBuf, int iLen,int *pbOutClosed)
+static int inet_socket_recvfrom(int sock, ST_COS_INET_IP *pstIORmtAddr, void * pOutBuf, int iLen, int *pbOutClosed)
 {
+    if (sock < 0 || !pOutBuf || iLen <= 0 || !pbOutClosed) return EN_ZJ_ERR_PARAM;
+    
     struct sockaddr *pstSockAddr = NULL;
-       struct sockaddr_in6  stIn6Addr;
-       struct sockaddr_in   stIn4Addr;
-       int iSize;
-       int iRet,iErrCode;
-
-       if (pstIORmtAddr)
-       {
-               if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV4)
-               {
-                       iSize = sizeof(struct sockaddr_in);
-                       memset(&stIn4Addr, 0, iSize);
-                       pstSockAddr = (struct sockaddr *)&stIn4Addr;
-               } 
-               else if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV6)
-               {
-                       iSize = sizeof(struct sockaddr_in6);
-                       memset(&stIn6Addr, 0, iSize);
-                       pstSockAddr = (struct sockaddr *)&stIn6Addr;
-               }
-               else
-                       return EN_ZJ_ERR_PARAM;
-       }
+    #if LWIP_IPV6
+    struct sockaddr_in6  stIn6Addr;
+    #endif
+    struct sockaddr_in   stIn4Addr;
+    int iSize;
+    int iRet, iErrCode;
+
+    if (pstIORmtAddr)
+    {
+        if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV4)
+        {
+            iSize = sizeof(struct sockaddr_in);
+            memset(&stIn4Addr, 0, iSize);
+            pstSockAddr = (struct sockaddr *)&stIn4Addr;
+        } 
+        #if LWIP_IPV6
+        else if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV6)
+        {
+            iSize = sizeof(struct sockaddr_in6);
+            memset(&stIn6Addr, 0, iSize);
+            pstSockAddr = (struct sockaddr *)&stIn6Addr;
+        }
+        #endif
+        else
+            return EN_ZJ_ERR_PARAM;
+    }
 
-       iRet = recvfrom(sock, (char *)pOutBuf, iLen, 0, pstSockAddr, (socklen_t*)&iSize);
-       if (iRet == -1)
-       {
-               iErrCode = inet_socket_getLastErr();
-               if ( EINTR != iErrCode && EAGAIN != iErrCode && EWOULDBLOCK != iErrCode)
+    iRet = recvfrom(sock, (char *)pOutBuf, iLen, 0, pstSockAddr, (socklen_t*)&iSize);
+    if (iRet == -1)
+    {
+        iErrCode = inet_socket_getLastErr();
+        if (EINTR != iErrCode && EAGAIN != iErrCode && EWOULDBLOCK != iErrCode)
         {   
             *pbOutClosed = 1;
         }
-               return iRet;
-       }
-       if (pstIORmtAddr && iSize > 0)
-       {
-               if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV4)
-               {
-                       pstIORmtAddr->usPort = htons(stIn4Addr.sin_port);
-                       pstIORmtAddr->u.uiIp = stIn4Addr.sin_addr.s_addr;
-               } 
-               else if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV6)
-               {
-                       pstIORmtAddr->usPort = htons(stIn6Addr.sin6_port);
-                       memcpy(pstIORmtAddr->u.aucIpv6, &stIn6Addr.sin6_addr, 16);
-               }
-       }
+        return iRet;
+    }
+    
+    if (pstIORmtAddr && iSize > 0)
+    {
+        if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV4)
+        {
+            pstIORmtAddr->usPort = htons(stIn4Addr.sin_port);
+            pstIORmtAddr->u.uiIp = stIn4Addr.sin_addr.s_addr;
+        } 
+        #if LWIP_IPV6
+        else if (pstIORmtAddr->usType == EN_CINET_TYPE_IPV6)
+        {
+            pstIORmtAddr->usPort = htons(stIn6Addr.sin6_port);
+            memcpy(pstIORmtAddr->u.aucIpv6, &stIn6Addr.sin6_addr, 16);
+        }
+        #endif
+    }
 
-       return iRet;
+    return iRet;
 }
 
 static int inet_socket_send(int sock, void * pBuf, int iLen, int *pbOutWait)
 {
-    int iRet,iErrCode;
+    if (sock < 0 || !pBuf || iLen <= 0 || !pbOutWait) return EN_ZJ_ERR_PARAM;
+    
+    int iRet, iErrCode;
 
-    *pbOutWait   = 0;
-       iRet = send(sock, (char *)pBuf, iLen, 0);
-       if (iRet == -1)
-       {       
-       iErrCode = inet_socket_getLastErr();
+    *pbOutWait = 0;
+    iRet = send(sock, (char *)pBuf, iLen, 0);
+    if (iRet == -1)
+    {  
+        iErrCode = inet_socket_getLastErr();
         if(EINTR == iErrCode || EAGAIN == iErrCode || EWOULDBLOCK == iErrCode)
-       {
-               *pbOutWait = 1;
-       }
+        {
+            *pbOutWait = 1;
+        }
     }
-       return iRet;
+    return iRet;
 }
 
 static int inet_socket_recv(int sock, void * pOutBuf, int iLen, int *pbOutClosed)
 {
+    if (sock < 0 || !pOutBuf || iLen <= 0 || !pbOutClosed) return EN_ZJ_ERR_PARAM;
+    
     int iRet;
     int iErrCode;
+    
     *pbOutClosed = 0;
-       iRet = recv(sock, (char *)pOutBuf, iLen, 0);
-       if (iRet <= 0)
-       {
-               iErrCode = inet_socket_getLastErr();
-        if ( EINTR != iErrCode && EAGAIN != iErrCode && EWOULDBLOCK != iErrCode)
+    iRet = recv(sock, (char *)pOutBuf, iLen, 0);
+    if (iRet <= 0)
+    {
+        iErrCode = inet_socket_getLastErr();
+        if (EINTR != iErrCode && EAGAIN != iErrCode && EWOULDBLOCK != iErrCode)
         {   
             *pbOutClosed = 1;
         }
-       }
-       return iRet ;
+    }
+    return iRet;
 }
 
 static int inet_socket_setRecvBuff(int sock, int iBufSize)
 {
+    if (sock < 0 || iBufSize <= 0) return EN_ZJ_ERR_PARAM;
+    
     int *piOptVal;
-       int  iRet;
+    int  iRet;
 
-       piOptVal = (int *)&iBufSize;
-       iRet = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)piOptVal, sizeof(piOptVal));
+    piOptVal = (int *)&iBufSize;
+    iRet = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)piOptVal, sizeof(piOptVal));
 
-       if (iRet == -1)
-       {
-               return EN_ZJ_ERR;
-       }
+    if (iRet == -1)
+    {
+        return EN_ZJ_ERR;
+    }
 
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_socket_setSendBuff(int sock, int iBufSize)
 {
-    int *piOptVal,iRet;
-       piOptVal = (int *)&iBufSize;
+    if (sock < 0 || iBufSize <= 0) return EN_ZJ_ERR_PARAM;
     
-       iRet = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)piOptVal, sizeof(piOptVal));
+    int *piOptVal, iRet;
+    piOptVal = (int *)&iBufSize;
+    
+    iRet = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)piOptVal, sizeof(piOptVal));
 
-       if (iRet == -1)
-       {
-               return EN_ZJ_ERR;
-       }
+    if (iRet == -1)
+    {
+        return EN_ZJ_ERR;
+    }
 
-       return 0;
+    return EN_ZJ_ERR_OK;
 }
 
 static int inet_socket_getLastErr(void)
@@ -1084,10 +1362,13 @@ static int inet_socket_getLastErr(void)
 
 static int inet_socket_checkConn(int sock, int *piErr)
 {
+    if (sock < 0 || !piErr) return EN_ZJ_ERR_PARAM;
+    
     int iLen = 0;
     int iCode = -1;
-    iCode = getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)piErr, (socklen_t*)&iLen );
-    if(iCode < 0 || *piErr){
+    
+    iCode = getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)piErr, (socklen_t*)&iLen);
+    if (iCode < 0 || *piErr) {
         return 0;
     }
     return 1;
@@ -1096,74 +1377,110 @@ static int inet_socket_checkConn(int sock, int *piErr)
 /***********************************************************************************/
 static int thread_create(unsigned char *pucName, int iPriority, unsigned int uiStackSize, PFN_THREADPROC pfunProc, void *pParam, void **phOutOSThread)
 {
-    typedef void * (*startRoutine)(void *);
-    pthread_attr_t     attr;
-    int iOSPriority = 0;
-       *phOutOSThread = NULL;
-       switch(iPriority)
+    if (!pfunProc || !phOutOSThread) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_create: invalid parameters - pfunProc=%p, phOutOSThread=%p\n", 
+               pfunProc, phOutOSThread);
+        return EN_ZJ_ERR_PARAM;
+    }
+    uint8_t LOSPriority=24;
+
+    switch(iPriority)
        {
-       case EN_THREAD_PRIORITY_LOWEST:
-               iOSPriority = 30;
-               break;
-       case EN_THREAD_PRIORITY_LOWER:
-               iOSPriority = 40;
-               break;
-       case EN_THREAD_PRIORITY_NORMAL:
-               iOSPriority = 45;
-               break;
-       case EN_THREAD_PRIORITY_HIGHER:
-               iOSPriority = 50;
-               break;
-       case EN_THREAD_PRIORITY_HIGHEST:
-               iOSPriority = 60;
-               break;
-       default:
-               return EN_ZJ_ERR_PARAM;
+        case EN_THREAD_PRIORITY_LOWEST:
+            LOSPriority = 24;
+            break;
+        case EN_THREAD_PRIORITY_LOWER:
+            LOSPriority = 23;
+            break;
+        case EN_THREAD_PRIORITY_NORMAL:
+            LOSPriority = 22;
+            break;
+        case EN_THREAD_PRIORITY_HIGHER:
+            LOSPriority = 20;
+            break;
+        case EN_THREAD_PRIORITY_HIGHEST:
+            LOSPriority = 16;
+            break;
+        default:
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_create: invalid parameters iPriority\r\n");
+            return EN_ZJ_ERR_PARAM;
        }
-
-       pthread_attr_init(&attr);
-       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-       pthread_attr_setstacksize(&attr, uiStackSize);
-    pthread_attr_setschedpolicy(&attr, SCHED_RR);
-
-    if (pthread_create((pthread_t *)phOutOSThread, &attr, (startRoutine)pfunProc, pParam) != 0)
+    UINT32 taskId;
+    app_task_definition_t taskcfg={0};
+    taskcfg.create_queue_handle = NULL;
+    taskcfg.attr.name=pucName;
+    taskcfg.attr.priority = LOSPriority;
+    taskcfg.attr.stack_size = uiStackSize;
+    taskcfg.func = pfunProc;
+    taskcfg.use_mem = USE_EXTEND_MEM;
+    
+    errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+    taskId =taskcfg.task_handle;
+    if(ret==ERRCODE_SUCC)
     {
-        pthread_attr_destroy(&attr);
-        return EN_ZJ_ERR;
-       }
-
-       pthread_attr_destroy(&attr);
-       return 0;
+         *phOutOSThread = (void *)(UINTPTR)taskId;
+        return EN_ZJ_ERR_OK;
+    }
+    
+   
 }
 
 static int thread_delete(void *hOSThread, int bForce)
 {
-    pthread_t thread = *(pthread_t*)hOSThread;
-    if (!bForce) return EN_ZJ_ERR_OK;
-
-    if(hOSThread == NULL)   return EN_ZJ_ERR;
-
-       if (pthread_detach(thread) != 0)
-               return EN_ZJ_ERR;
-
-       return EN_ZJ_ERR_OK;
+    if (hOSThread == NULL) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_delete: hOSThread is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    UINT32 taskId = (UINT32)(UINTPTR)hOSThread;
+    
+    if (!bForce) {
+        // 非强制删除,先尝试分离
+        UINT32 ret = LOS_TaskDetach(taskId);
+        if (ret == LOS_OK || ret == LOS_ERRNO_TSK_IS_DETACHED || 
+            ret == LOS_ERRNO_TSK_ALREADY_JOIN) {
+            return EN_ZJ_ERR_OK;
+        }
+    }
+    
+    // 强制删除任务
+    UINT32 ret = LOS_TaskDelete(taskId);
+    if (ret == LOS_OK || ret == LOS_ERRNO_TSK_NOT_CREATED) {
+        return EN_ZJ_ERR_OK;
+    }
+    
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_delete: LOS_TaskDelete failed, taskId=0x%x, ret=0x%x, bForce=%d\n", 
+           taskId, ret, bForce);
+    return EN_ZJ_ERR;
 }
 
 static int thread_sleep(unsigned int uiMilliSecond)
 {
-    usleep(uiMilliSecond*1000);
-       return EN_ZJ_ERR_OK;
+    UINT32 ticks = LOS_MS2Tick(uiMilliSecond);
+    UINT32 ret = LOS_TaskDelay(ticks);
+    if (ret != LOS_OK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_sleep: LOS_TaskDelay failed, uiMilliSecond=%u, ticks=%u, ret=0x%x\n", 
+               uiMilliSecond, ticks, ret);
+        return EN_ZJ_ERR;
+    }
+    return EN_ZJ_ERR_OK;
 }
 
 static int thread_SetName(unsigned char *pucName)
 {
-    prctl(PR_SET_NAME,pucName);
+    if (!pucName) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "thread_SetName: pucName is NULL");
+        return EN_ZJ_ERR_PARAM;
+    }
+    
+    // LiteOS 不支持动态修改任务名称,返回成功
+    // 如果需要修改名称,需要在创建任务时设置
     return EN_ZJ_ERR_OK;
 }
 
 static unsigned int thread_GetCurID(void)
 {
-    return (unsigned int)pthread_self();
+    return (unsigned int)LOS_CurTaskIDGet();
 }
 
 /***********************************************************************************//***********************************************************************************/
@@ -1179,9 +1496,7 @@ static struct tm* time_localTime(time_t *ptmTime,struct tm *ptTm)
 
 static unsigned int time_getTickCount(void)
 {
-    struct timespec stTime;
-       clock_gettime(CLOCK_MONOTONIC, &stTime);
-       return (stTime.tv_sec * 1000 + stTime.tv_nsec/1000000);
+    return LOS_TickCountGet();
 }
 
 static time_t time_sysTimeToTime(ST_COS_SYS_TIME *pstTime)
index 62370a0..543ecc4 100644 (file)
@@ -3,3 +3,4 @@ add_subdirectory_if_exist(AIagent)
 add_subdirectory_if_exist(AIota)
 add_subdirectory_if_exist(AIsdk)
 add_subdirectory_if_exist(AImain)
+add_subdirectory_if_exist(AIsyscall)
index 1ad204a..bebe894 100644 (file)
@@ -21,3 +21,4 @@ add_subdirectory_if_exist(4gTest)
 add_subdirectory_if_exist(ai)
 add_subdirectory_if_exist(ai/media)
 add_subdirectory_if_exist(websocket)
+add_subdirectory_if_exist(4gTestcpp)
index c6dd881..ceb17d1 100644 (file)
@@ -17,6 +17,8 @@ ${ROOT_DIR}/zhihui/4gTest
 set(AI_SOURCES
 ${CMAKE_CURRENT_SOURCE_DIR}/ai_at_test.c
 ${CMAKE_CURRENT_SOURCE_DIR}/ai_at_test_example.c
+${CMAKE_CURRENT_SOURCE_DIR}/ai_service_usage_example.c
+
 )
 
 set(SOURCES
index f86dee0..19621c3 100644 (file)
@@ -57,6 +57,8 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/player/include
     ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativelauncher/include
     ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks
+    ${ROOT_DIR}/zhihui/AI/AImain
+    # ${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/schedule/include/ScheduleModel.h
     # ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits
 # /home/hcj/FD230/code/sdk/middleware/services/gui/uikit/surface/interfaces/kits/ibuffer_consumer_listener.h
 # /home/hcj/FD230/code/sdk/middleware/services/gui/uikit/ui/frameworks/common/typed_text.h
index 48aa169..98495cb 100644 (file)
@@ -55,9 +55,9 @@
 // void cat1_audio_AudioSetup(void){}
 // void cat1_audio_AudioRelease(void){}
 // int32_t PhoneAudioSetMicMuteCat1(bool isMute){return 0;}
-void cat1_connect_sco_(void){}
-void cat1_disconn_sco_(void){}
-void cat1_start_SCO_audio_(void){}
+// void cat1_connect_sco_(void){}
+// void cat1_disconn_sco_(void){}
+// void cat1_start_SCO_audio_(void){}
 #endif
 
 #ifdef SUPPORT_BLE_SERVICE