Merge #700 into sdk602patch0626 from refs/changes/700/head
author胡传军 <1224667075@qq.com>
Fri, 16 Aug 2024 01:35:56 +0000 (01:35 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Fri, 16 Aug 2024 01:35:56 +0000 (01:35 +0000)
Code review from 胡传军

* refs/changes/700/head: (3 commits squashed)

  - 修改br连接接口 改用消息机制 增加回连判断 实际实现传统蓝牙开关关闭则br连接不上(有BUG)

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

  - 增加连接中 UI 及部分蓝牙问题修正

Signed-off-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/700
15 files changed:
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/BluetoothServiceOptionsView.h
code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp
code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/drivers/peripheral/utils/CMakeLists.txt
code/sdk/drivers/peripheral/utils/custom_cmd_service.c
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index ec7cdbe..28eb6ac 100644 (file)
@@ -56,7 +56,7 @@ namespace OHOS
         ~AiVoiceConnectingView();
         static AiVoiceConnectingView *GetInstance(void);
         UIScrollView *CreateAiVoiceConnectingView(void);
-
+        UIScrollView *CreateAiVoiceConnectingView(uint8_t);
     private:
         const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
         void FreeImagePathsArray(const char **imagePaths, const int numImages);
@@ -67,6 +67,7 @@ namespace OHOS
         bool CreateAiVoiceConnectingViewButton(void);
         bool CreateAivoiceConnectingImageAnimator(void);
         bool CreateAiVoiceConnectingScrollView(void);
+        bool CreateAiVoiceConnectingScrollView(uint8_t);
         void ClearAll(void);
         UIScrollView *scrollView{nullptr};
         UILabelExt *title{nullptr};
index 790abdc..29514a9 100644 (file)
@@ -16,7 +16,7 @@ namespace OHOS
     static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y = 153;
     static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W = 100;
     static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H = 120;
-    static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 200; // 图片更新间隔
+    static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 50; // 图片更新间隔
     static constexpr const char *AIVoiceListeningImagePaths = "/user/res/connect/";
 
     static AiVoiceConnectingView *g_pAiVoiceConnecting{nullptr};
@@ -283,6 +283,23 @@ namespace OHOS
         return true;
     }
 
+     bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(uint8_t type)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView");
+        scrollView = new UIScrollView();
+        if (scrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!");
+            return false;
+        }
+        scrollView->SetPosition(0, 0, 466, 466);
+        scrollView->SetTouchable(true);
+        scrollView->SetDraggable(true);
+
+        return true;
+    }
+
+
     UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
@@ -299,4 +316,16 @@ namespace OHOS
         return scrollView;
     }
 
+     UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(uint8_t type)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
+        if (!CreateAiVoiceConnectingScrollView(type) || !CreateAivoiceConnectingImageAnimator()|| !CreateAiVoiceConnectingViewLabel() )
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!");
+            return nullptr;
+        }
+        scrollView->Add(connectingAnimatorView);
+        return scrollView;
+    }
+
 }
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h
new file mode 100644 (file)
index 0000000..785a37a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: BluetoothModel view
+ * Author:
+ * Create: 2021-10-13
+ */
+
+#ifndef C_BLUETOOTH_MODEL_H_
+#define C_BLUETOOTH_MODEL_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uapi_a2dp_snk_connect_(void);
+int uapi_a2dp_snk_disconnect_(void);
+//int uapi_disconnect_remote_device_(void);
+
+int uapi_reconnect_(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
index 325e748..586115c 100644 (file)
@@ -6,6 +6,8 @@
  */\r
 #include <cstdint>\r
 #include "BluetoothModel.h"\r
+#include "BluetoothModelC.h"\r
+\r
 #include "BluetoothWrapper.h"\r
 #include "BluetoothPresenter.h"\r
 #include "ConnectPhonePresenter.h"\r
@@ -23,7 +25,8 @@
 #include "bts_spp.h"\r
 #include "osal_task.h"\r
 #include "bts_pbap.h"\r
-\r
+#include "ConfigModelC.h"\r
+#include "custom_utils.h"\r
 #ifdef SUPPORT_ALIPAY_SEC\r
 #include "alipay_feature.h"\r
 #endif\r
@@ -44,6 +47,8 @@
 #include "BluetoothWrapper.h"\r
 #endif\r
 #include "Bluetooyhpabpserver.h"\r
+#include "bletest.h"\r
+#include "ConfigModelC.h"\r
 namespace OHOS {\r
 \r
 #define BT_SPP_TASK_STACK_SIZE 2048\r
@@ -241,7 +246,7 @@ void bluetooth_close_all(void)
     \r
     /**TODO: 断开BR链接**/\r
     bd_addr_t bdaddr={0};\r
-    get_phone_addr(&bdaddr);\r
+    uapi_get_br_address(&bdaddr);\r
     if (bt_is_acl_connected(&bdaddr))\r
     {\r
        ret = gap_disconnect_remote_device(&bdaddr);\r
@@ -754,14 +759,25 @@ void BtGapPairStatusChangedCallback(const bd_addr_t *bdAddr, int status)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtGapPairStatusChangedCallback addr: ****%02x%02x%02x%02x status: %d\n",\r
         bdAddr->addr[3], bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0], status); /* addr下标 0 1 2 3 */\r
     memcpy(&BtGapPair_bdAddr,bdAddr,sizeof(bd_addr_t));\r
-    uapi_a2dp_snk_connect();\r
+    // if(status == GAP_PAIR_PAIRED)\r
+    // { \r
+   \r
+        \r
+    //}\r
     //uapi_a2dp_snk_connect();\r
     //a2dp_snk_connect(bdAddr);\r
-   \r
+    if(cm_custom_ble_service_on_flag() && !get_ble_pair())\r
+    {\r
+        if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
+        uapi_a2dp_snk_connect();\r
+        //uapi_reconnect();\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect");\r
+    }\r
     if (status == GAP_PAIR_PAIRED) {\r
         if (ConnectPhonePresenter::GetInstance() != nullptr) {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
         }\r
+       \r
     }\r
 }\r
 \r
@@ -994,6 +1010,11 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state,
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x",\r
         bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */\r
         bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */\r
+    //效果不好\r
+    if(!cm_custom_ble_service_on_flag())\r
+    {\r
+        gap_disconnect_remote_device(bdAddr);\r
+    }\r
 \r
     //ALC_State_flag=state;\r
 \r
@@ -1668,6 +1689,7 @@ int uapi_a2dp_snk_get_device_connect_state()
 \r
 void uapi_get_br_address(bd_addr_t *bdaddr)\r
 {\r
+ \r
     if(BtGapPair_bdAddr.addr[0]==0 && BtGapPair_bdAddr.addr[1]==0 &&\r
     BtGapPair_bdAddr.addr[2]==0 && BtGapPair_bdAddr.addr[3]==0 )\r
     get_phone_addr(bdaddr);\r
@@ -1675,7 +1697,17 @@ void uapi_get_br_address(bd_addr_t *bdaddr)
     memcpy(bdaddr,&BtGapPair_bdAddr,sizeof(bd_addr_t));\r
 \r
 }\r
+static uint8_t br_cmd=0;\r
 int uapi_a2dp_snk_connect()\r
+{\r
+    br_cmd=BR_A2DP_CONNECT;\r
+    do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+    return 0;\r
+\r
+}\r
+  \r
+\r
+int uapi_a2dp_snk_connect_()\r
 {\r
 \r
     bd_addr_t bdaddr={0};\r
@@ -1690,6 +1722,14 @@ int uapi_a2dp_snk_connect()
 }\r
 \r
 int uapi_a2dp_snk_disconnect()\r
+{\r
+    br_cmd=BR_A2DP_DISCONNECT;\r
+    do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+     return 0;\r
+}\r
+  \r
+\r
+int uapi_a2dp_snk_disconnect_()\r
 {\r
     \r
     bd_addr_t bdaddr={0};\r
@@ -1700,6 +1740,13 @@ int uapi_a2dp_snk_disconnect()
     return ret;\r
 }\r
 \r
+// int uapi_disconnect_remote_device_()\r
+// {\r
+//     do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+//     return 0;\r
+// }\r
+  \r
+\r
 int uapi_disconnect_remote_device()\r
 {\r
     bd_addr_t bdaddr={0};\r
@@ -1740,6 +1787,15 @@ int uapi_set_acl_connect_A2DP()
 }\r
 \r
 \r
+int uapi_reconnect_()\r
+{\r
+    \r
+    br_cmd=BR_RECONNECT;\r
+    do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));\r
+     return 0;\r
+}\r
+  \r
+\r
 int uapi_reconnect(void)\r
 {\r
     bd_addr_t bdaddr={0};\r
@@ -1750,6 +1806,8 @@ int uapi_reconnect(void)
     return 0;\r
 }\r
 \r
+\r
+\r
 // /////////////////////////////////////////HFP hf端 代码///////////////////////////////////////////////////\r
 \r
 // int uapi_HFP_hf_connect()\r
index eb20dde..6b6db05 100644 (file)
@@ -17,6 +17,7 @@
 #include "components/ui_button.h"
 #include "components/ui_image_view.h"
 #include "components/ui_toggle_button.h"
+#include "aivoice/include/AiVoiceConnectingView.h"
 namespace OHOS
 {
     // 返回setting视图界面
@@ -36,6 +37,15 @@ namespace OHOS
             uint16_t textId;      
             uint8_t lineBreakMode; // 断行模式。
         };
+
+        typedef enum 
+        {
+            CONNECT_HFP = 0,
+            DISCONNECT_HFP,
+            CONNECT_A2DP,
+            DISCONNECT_A2DP,
+        } BluetoothServiceOptionsView_state;
+
         BluetoothServiceOptionsView();
         virtual ~BluetoothServiceOptionsView();
         static BluetoothServiceOptionsView *GetInstance(void);
@@ -43,7 +53,10 @@ namespace OHOS
         void ClearAll(void);
         UIToggleButton *GetHFP_ToggleButton(void);
         UIToggleButton *GetA2DP_ToggleButton(void);
-
+        void show_connecting_view(bool data);
+        void Button_UPdata(void);
+        bool init_connect_timer(uint8_t type);
+        bool get_connectview_Visible(void);
     public:
         virtual void OnStart() override;
         virtual void OnSetUpView() override;
@@ -64,6 +77,9 @@ namespace OHOS
         UIImageView *A2DP_Image{nullptr};
         UIToggleButton *HFP_ToggleButton{nullptr};  // HFP
         UIToggleButton *A2DP_ToggleButton{nullptr}; // A2DP
+        UIScrollView * connectingScrollView{nullptr};
+        AiVoiceConnectingView* p_AiVoiceConnectingView{nullptr};
+        
         bool initViewStatus{false};
     };
 }
index 5fb38d7..1894432 100644 (file)
@@ -78,31 +78,36 @@ namespace OHOS
             UIToggleButton *toggleButton = dynamic_cast<UIToggleButton *>(&view);
             if (toggleButton != nullptr)
             {
+                classicBlueToothView->show_connecting_view(true);
                 if (toggleButton->GetState() == true)
                 {
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
+                    //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
                     if (it->second == "HFP")
                     {
                         ConfigModel::GetInstance()->SetHFPState(true);
                         //enable_hfp_service(true);
                         uapi_hfp_connect();
+                        classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP);
+
                     }
                     else if (it->second == "A2DP")
                     {
                         ConfigModel::GetInstance()->SetA2DPState(true);
                         uapi_a2dp_snk_connect();
+                        classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_A2DP);
                         
                         //enable_a2dp_service(true);
                     }
                 }
                 else
                 {
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
+                   // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
                     if (it->second == "HFP")
                     {
                         ConfigModel::GetInstance()->SetHFPState(false);
                         //enable_hfp_service(false);
                         uapi_hfp_disconnect();
+                        classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
                         // errcode_t ret = gap_ble_set_ctkd_enable(false);
                         // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
                     }
@@ -111,8 +116,9 @@ namespace OHOS
 
                         ConfigModel::GetInstance()->SetA2DPState(false);
                         uapi_a2dp_snk_disconnect();
+                        classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
                         // uapi_hfp_disconnect();
-                        // uapi_disconnect_remote_device();
+                    //uapi_disconnect_remote_device();
                         // errcode_t ret = gap_ble_set_ctkd_enable(false);
                         // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
                         //bluetooth_set_auto_reconnect(1);
@@ -138,6 +144,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::OnDragEnd");
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
+            if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
             NativeAbility::GetInstance().Back();
         }
 
@@ -152,6 +159,7 @@ namespace OHOS
         // 如果是power键,且是亮屏状态,按键释放就返回上一级
         if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
         {
+            if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
             NativeAbility::GetInstance().Back();
         }
         return true;
index 7461ab1..b3570cb 100644 (file)
@@ -7,6 +7,8 @@
 #include "phoneservice/include/PhoneService.h"
 #include "BluetoothModel.h"
 #include "ui_resource_string.h"
+#include "cmsis_os2.h"
+
 namespace OHOS
 {
     static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr};
@@ -72,12 +74,128 @@ namespace OHOS
                     delete A2DP_ToggleButton;
                     A2DP_ToggleButton = nullptr;
                 }
+                if(p_AiVoiceConnectingView)
+                {
+                    delete p_AiVoiceConnectingView;
+                    p_AiVoiceConnectingView=nullptr;
+                }
+                if(connectingScrollView)
+                {
+                    delete connectingScrollView;
+                    connectingScrollView = nullptr;
+                }
                 delete BlueToothScrollView;
                 BlueToothScrollView = nullptr;
             }
         }
     }
 
+    static osTimerId_t  MG_TEST_timer=NULL;
+    static uint8_t button_state=0;
+    static uint8_t count_num=0;
+
+    bool BluetoothServiceOptionsView::get_connectview_Visible(void)
+    {
+        return connectingScrollView->IsVisible();
+    }
+
+    void connectTimerCallBack(int data)
+    {
+        bool connect_state=false;
+        count_num++;
+        switch (button_state)
+        {
+            case BluetoothServiceOptionsView::CONNECT_HFP:
+                if(uapi_hfp_connect_state())
+                {
+                    BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+                    connect_state=true;
+                }
+                break;
+            case BluetoothServiceOptionsView::DISCONNECT_HFP:
+                if(!uapi_hfp_connect_state())
+                {
+                    BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+                    connect_state=true;
+                }
+                break;
+            case BluetoothServiceOptionsView::CONNECT_A2DP:
+                if(uapi_a2dp_snk_get_device_connect_state())
+                {
+                    BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+                    connect_state=true;
+                }
+                break;
+            case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+                if(!uapi_a2dp_snk_get_device_connect_state())
+                {
+                    BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+                    connect_state=true;
+                }
+                break;
+            
+            default:
+                break;
+            
+        }
+        if(count_num==3 || connect_state)
+        {
+            if( BluetoothServiceOptionsView::GetInstance())
+            BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+            osTimerStop(MG_TEST_timer);
+            osTimerDelete(MG_TEST_timer);
+            MG_TEST_timer = NULL;
+        }
+        else if(count_num==2)
+        {
+            //仅尝试重连一次
+            switch (button_state)
+            {
+                case BluetoothServiceOptionsView::CONNECT_HFP:
+                    //uapi_hfp_connect();
+                break;
+                case BluetoothServiceOptionsView::DISCONNECT_HFP:
+                    //uapi_hfp_disconnect();
+                break;
+                case BluetoothServiceOptionsView::CONNECT_A2DP:
+                   // uapi_a2dp_snk_connect();
+                break;
+                case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+                   //uapi_a2dp_snk_disconnect();
+                break;
+                    default:
+                break;
+            }
+        }
+    }
+
+    bool BluetoothServiceOptionsView::init_connect_timer(uint8_t type)
+    {
+        uint32_t tick;
+        osStatus_t retTimer;
+        count_num=0;
+        button_state=type;
+
+        if(MG_TEST_timer)
+        {
+            osTimerStop(MG_TEST_timer);
+            osTimerDelete(MG_TEST_timer);
+            MG_TEST_timer = NULL;
+
+        }
+        MG_TEST_timer = osTimerNew((osTimerFunc_t)connectTimerCallBack, osTimerPeriodic, NULL, NULL);
+        tick =1500;
+        retTimer = osTimerStart(MG_TEST_timer, tick);
+        if (retTimer != osOK && MG_TEST_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+            osTimerDelete(MG_TEST_timer);
+            MG_TEST_timer = NULL;
+            return false;
+        }
+        return true;
+    }
+     
+
     bool BluetoothServiceOptionsView::SetUpBlueToothScrollView(void)
     {
         BlueToothScrollView = new UIScrollView();
@@ -262,6 +380,7 @@ namespace OHOS
         {
             BluetoothServiceOptionsViewInit();
             initViewStatus = true;
+
         }
 
         // 增加按键监听
@@ -269,6 +388,25 @@ namespace OHOS
         RootView::GetInstance()->SetOnKeyActListener(keyactListener);
     }
 
+    void BluetoothServiceOptionsView::show_connecting_view(bool data)
+    {
+        
+        connectingScrollView->SetVisible(data);
+        if(data==false)
+        {
+            A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+            HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+        }
+    }
+
+    void BluetoothServiceOptionsView::Button_UPdata(void)
+    {
+        
+        A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+        HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+        
+    }
+
     void BluetoothServiceOptionsView::OnSetUpView()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnSetUpView");
@@ -280,6 +418,13 @@ namespace OHOS
         BlueToothScrollView->Add(A2DP_Label);
         BlueToothScrollView->Add(HFP_ToggleButton);
         BlueToothScrollView->Add(A2DP_ToggleButton);
+        p_AiVoiceConnectingView = new AiVoiceConnectingView();
+
+        connectingScrollView= p_AiVoiceConnectingView->CreateAiVoiceConnectingView(1);
+        connectingScrollView->SetVisible(false);
+        connectingScrollView->SetDraggable(false);
+        BlueToothScrollView->Add(connectingScrollView);
+
         RootView::GetInstance()->Add(BlueToothScrollView);
         Draw();
     }
diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h
new file mode 100644 (file)
index 0000000..458fbb4
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: PhoneService
+ * Create: 2021-09-22
+ */
+
+#ifndef PHONE_SERVICE_H
+#define PHONE_SERVICE_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uapi_hfp_disconnect_(void);
+
+int uapi_hfp_connect_(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // PHONE_SERVICE_H
index b89b2c6..584f819 100644 (file)
@@ -5,6 +5,8 @@
  */
 
 #include "PhoneService.h"
+#include "PhoneServiceC.h"
+
 #include "PhoneAudio.h"
 #include "securec.h"
 #include <cstdio>
@@ -28,6 +30,7 @@
 #include "BluetoothModel.h"
 #include "notification_manager.h"
 #include "CallerLogModel.h"
+#include "custom_utils.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -599,6 +602,8 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st
         case PROFILE_STATE_CONNECTED: // 蓝牙连接成功
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT connected");
             BtConnectedPro(bdAddr);
+            SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0);
+            //SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);
             break;
         case PROFILE_STATE_DISCONNECTING: // 蓝牙连接断连
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[ConnStateChanged] BT disconnecting");
@@ -608,7 +613,8 @@ static void ConnStateChanged(const bd_addr_t *bdAddr, profile_connect_state_t st
             BtDisconnectedPro();
             if(0==OHOS::uapi_a2dp_snk_get_device_connect_state() && 0==uapi_hfp_connect_state())
             {
-                       // remove by merge patch
+                SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0);
+                //SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);
             }
            
             break;
@@ -1888,11 +1894,11 @@ int TransCallToMobilePhone(void)
     }
 }
 
-int uapi_hfp_disconnect(void)
+int uapi_hfp_disconnect_(void)
 {
     int ret;
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS:: uapi_get_br_address(&bdaddr);
     ret = hfp_hf_disconnect(&bdaddr);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: ****%02x %02x %02x %02x g_bdAddr.type: %x\n",
     bdaddr.addr[3], bdaddr.addr[2], bdaddr.addr[1], bdaddr.addr[0], bdaddr.type); /* 3 2 1 0 idx */
@@ -1901,12 +1907,13 @@ int uapi_hfp_disconnect(void)
     return ret;   
 }
 
-int uapi_hfp_connect(void)
+int uapi_hfp_connect_(void)
 {
     int ret;
-     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
-    if(false==OHOS::uapi_get_acl_connect_state())
+    bd_addr_t bdaddr={0};
+    OHOS:: uapi_get_br_address(&bdaddr);
+
+    if(0==OHOS::uapi_a2dp_snk_get_device_connect_state() && 0==uapi_hfp_connect_state())
     {
         //  ret= gap_connect_remote_device(&bdaddr);
         //  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_connect_remote_device] ret:%X", ret);
@@ -1933,7 +1940,8 @@ int uapi_hfp_connect_state(void)
 {
     int ret;
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS:: uapi_get_br_address(&bdaddr);
+
     ret = hfp_hf_get_device_connect_state(&bdaddr);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_connect_hfp] ret:%d", ret);
     if(PROFILE_STATE_CONNECTED==ret || PROFILE_STATE_CONNECTING ==ret)
@@ -1946,11 +1954,31 @@ int uapi_hfp_connect_state(void)
 void uapi_hfp_send_DTMF_CODE(char code)
 {
     bd_addr_t bdaddr={0};
-    get_phone_addr(&bdaddr);
+    OHOS:: uapi_get_br_address(&bdaddr);
+
     int ret= hfp_hf_send_dtmf_tone(&bdaddr,code);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[hfp_hf_send_dtmf_tone] ret:%d", ret);
 }
 
+
+static uint8_t br_cmd=0;
+int uapi_hfp_connect()
+{
+    br_cmd=BR_HFP_CONNECT;
+    do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));
+    return 0;
+}
+  
+
+int uapi_hfp_disconnect()
+{
+    br_cmd=BR_HFP_DISCONNECT;
+    do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&br_cmd,sizeof(br_cmd));
+    return 0;
+}
+
+
+
 #ifdef __cplusplus
 }
 #endif
index 19ba3ac..f8fc69b 100644 (file)
@@ -8,6 +8,7 @@
 #include "settings/include/SettingModel.h"
 #include "main/include/PullUpDownView.h"
 #include "ui_resource_string.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
 namespace OHOS
 {
     SettingModel::SettingModel() {}
@@ -80,6 +81,10 @@ namespace OHOS
         {
             PullUpDownView::GetInstance()->UpdateEarPhoneStatus(status);
         }
+        if(BluetoothServiceOptionsView::GetInstance())
+        {
+            BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+        }
     }
 
     // 更新蓝牙连接状态
@@ -90,5 +95,9 @@ namespace OHOS
         {
             PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);
         }
+        if(BluetoothServiceOptionsView::GetInstance())
+        {
+            BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+        }
     }
 }
index 68c3e55..0f40874 100644 (file)
@@ -304,8 +304,10 @@ void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_bl
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! \r\n");\r
         // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status());\r
         // if(AdverFlag == true){\r
-            free_ble_data();            \r
-            svr_ble_adv_start();       \r
+            free_ble_data(); \r
+            if(cm_custom_ble_service_on_flag())           \r
+            svr_ble_adv_start();\r
+\r
             ble_disconnect_ok();                 \r
         // }    \r
     } else {\r
@@ -363,13 +365,17 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s
                 \r
             \r
             }else{\r
-                if(false==(bt_is_acl_connected(addr)))\r
+                \r
+                bd_addr_t bdaddr={0};\r
+                uapi_get_br_address(&bdaddr);\r
+                if(false==(bt_is_acl_connected(&bdaddr)))\r
                 {\r
-                    int ret=gap_reconnect_media_device(&phone_addr);\r
+                    int ret=gap_reconnect_media_device(&bdaddr);\r
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_reconnect_media_device!!! %X\r\n",ret);\r
                 }\r
                 else\r
                 {\r
+                    if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
                     uapi_a2dp_snk_connect();\r
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n");\r
                 }\r
index 1977a4e..f9ca05e 100644 (file)
@@ -15,6 +15,7 @@ set(SOURCES
 
 set(PUBLIC_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}
+    ${ROOT_DIR}/application/wearable/fd230app/nativeui/phoneservice/include
 )
 
 set(PRIVATE_HEADER
index ca43334..b35c2ea 100644 (file)
 
 #include "custom_utils.h"
 
+#include "BluetoothModelC.h"
+
+#include "PhoneServiceC.h"
+
+
 typedef struct
 {
     uint8_t cmd;
@@ -194,6 +199,34 @@ static void custom_cmd_service_check_task(void const *arg)
         case CUSTOM_CMD_MSG_TYPE_VIBRATOR_TEST:
             uapi_vibrator_test(2 * 60 * 60);
             break;
+        case CUSTOM_CMD_MSG_BR_CONNECT:
+
+            switch (mail.data[0])
+            {
+                //hfp connect 
+                case BR_HFP_CONNECT:
+                    uapi_hfp_connect_();
+                    break;
+                //hfp disconnect
+                case BR_HFP_DISCONNECT:
+                    uapi_hfp_disconnect_();
+                    break;
+                //a2dp connect
+                case BR_A2DP_CONNECT:
+                    uapi_a2dp_snk_connect_();
+                    break;
+                //a2dp disconnect
+                case BR_A2DP_DISCONNECT:
+                    uapi_a2dp_snk_disconnect_();
+                    break;
+                case BR_RECONNECT:
+                    uapi_reconnect_();
+                    break;
+                default:
+                    break;
+            }
+            break;
+
         default:
             PRINT("Unknown CUSTOM_CMD_MSG cmd 0x%02X \r\n", mail.cmd);
             break;
index 0ad7f73..2349a7e 100644 (file)
@@ -205,6 +205,17 @@ uint32_t uapi_calendar_store_date(void);
 #define CUSTOM_CMD_MSG_TYPE_CROWN_TEST 0x0A
 #define CUSTOM_CMD_MSG_TYPE_VIBRATOR_TEST 0x0B
 
+#define CUSTOM_CMD_MSG_BR_CONNECT 0x0C
+
+typedef enum {
+    BR_HFP_CONNECT=1,
+    BR_HFP_DISCONNECT,
+    BR_A2DP_CONNECT,
+    BR_A2DP_DISCONNECT,
+    BR_RECONNECT,
+   
+} CUSTOM_CMD_MSG_BR_CONNECT_TYPE;
+
 errcode_t uapi_custom_cmd_service_init(void);
 void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen);
 int uapi_delete_files(const char *file_path);
index a81a165..14871c9 100644 (file)
@@ -1052,29 +1052,25 @@ static uint32_t BLE_TEST(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
     case 1:
         uapi_reconnect();
         break;
-    // case 2:
-    //     custom_ble_service_start();
-    //     break;
+    case 2:
+        custom_ble_service_start();
+        break;
     case 3:
         custom_ble_service_start_(atoi( (char *)argv[1]));
         break;
     case 4:
         uapi_a2dp_snk_connect();
         break;
-    // case 5:
-    //     svr_ble_adv_stop();
-    //     break;
-    // case 6:
-    //     uapi_disconnect_remote_device();
-    //     break;
-    // case 7:
-    //     uapi_ble_disconnect_device();
-    //     break;
+    case 5:
+        svr_ble_adv_stop();
+        break;
+    case 6:
+        uapi_disconnect_remote_device();
+        break;
+    case 7:
+        uapi_ble_disconnect_device();
+        break;
         
-    //  case 3:
-    //     gap_br_set_bt_scan_mode(GAP_SCAN_MODE_NONE, 20);;
-    //     break;
-     
     default:
         break;
     }