蓝牙br同步到0521patch
authorSnickerSun <snickersun@163.com>
Wed, 12 Jun 2024 12:57:57 +0000 (20:57 +0800)
committerSnickerSun <snickersun@163.com>
Wed, 12 Jun 2024 12:57:57 +0000 (20:57 +0800)
15 files changed:
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothEarPhoneView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothItemView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModel.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/MainBluetoothView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceListView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarPhoneView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothOptionsView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsSuccMessageView.cpp

index aa99600..c42ee95 100644 (file)
@@ -43,7 +43,7 @@ private:
 extern "C" {\r
 #endif\r
 // void ScanTimerCallback(int data);\r
-void CancelBrScanHandle(void);\r
+// void CancelBrScanHandle(void);\r
 // void EndScanHandle(void);\r
 #ifdef __cplusplus\r
 }\r
index b6eea1e..602897b 100644 (file)
@@ -23,11 +23,11 @@ namespace OHOS {
 class BluetoothItemView : public UIViewGroup {\r
 public:\r
     explicit BluetoothItemView();\r
-    virtual ~BluetoothItemView();\r
-    virtual void SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList);\r
+    ~BluetoothItemView() override;\r
+    void SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList);\r
     BluetoothCaseInfo *GetItemInfo(void);\r
     void SetConnectionstatus(const BluetoothCaseInfo& infoData);\r
-    virtual void SetUpChild();\r
+    void SetUpChild();\r
     void ConnectAnimatorStart(void);\r
     void ConnectAnimatorStop(void);\r
     bool IsConnectAnimator(void);\r
index 6e0539d..9c7da57 100644 (file)
@@ -9,7 +9,7 @@
 #define BLUETOOTH_MODEL_H_\r
 \r
 #include <list>\r
-#include "stdio.h"\r
+#include <cstdio>\r
 #include "gfx_utils/list.h"\r
 \r
 #include "bts_def.h"\r
@@ -29,18 +29,6 @@ typedef struct {
     int16_t temp;\r
 } BluetoothCaseInfo;\r
 \r
-typedef struct {\r
-    void *stream_hdl;\r
-    uint8_t loc_volume;\r
-    uint8_t play_stat;\r
-    uint8_t dir_forward;\r
-    uint8_t avrcp_button_flag;\r
-    bd_addr_t bd_addr;\r
-    uint8_t reg_cap_auto;\r
-    uint8_t resrv;\r
-    profile_connect_state_t avrcp_srv_conn_stat;\r
-} BtAvrcpTgInftrerface;\r
-\r
 class BluetoothItemView;\r
 class BluetoothModel {\r
 public:\r
index a8703af..a3fd9af 100644 (file)
@@ -32,7 +32,7 @@ class MainBluetoothView;
 class MainBluetoothView : public View<BluetoothPresenter> {\r
 public:\r
     MainBluetoothView();\r
-    virtual ~MainBluetoothView();\r
+    ~MainBluetoothView() override;\r
 \r
     void OnStart() override;\r
     void OnSetUpView() override;\r
index 6047989..9bd3eac 100644 (file)
@@ -11,7 +11,7 @@
 #include "PlayersPresenter.h"
 #include "wearable_log.h"
 #include "UiConfig.h"
-#include "bluetooth/include/BluetoothModel.h"
+#include "BluetoothModel.h"
 
 namespace OHOS {
 BluetoothCaseListAdapter::~BluetoothCaseListAdapter()
@@ -106,7 +106,7 @@ void BluetoothCaseListAdapter::ClickAnimation(BluetoothCaseInfo &itemData, Bluet
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothCaseListAdapter::ClickAnimation");
     bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked();
-    if (ret == true) {
+    if (ret) {
         BluetoothCaseInfo *clickInfo = BluetoothModel::GetInstance()->GetTempMacValue();
         if ((clickInfo->addr[0] == itemData.addr[0]) && (clickInfo->addr[1] == itemData.addr[1]) &&
             (clickInfo->addr[2] == itemData.addr[2]) && (clickInfo->addr[3] == itemData.addr[3]) &&
index 8e0c806..94ef720 100644 (file)
@@ -185,7 +185,7 @@ void BluetoothDeviceListView::RefreshText(void)
     List<BluetoothCaseInfo> &bluetoothConnedList = BluetoothModel::GetInstance()->GetConnedDevicesCase();\r
     bool ret = bluetoothConnedList.IsEmpty();\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshText bluetoothConnedList.IsEmpty ret = %d", ret);\r
-    if (ret == true) {\r
+    if (ret) {\r
         emptyLabel->SetVisible(true);\r
     } else {\r
         emptyLabel->SetVisible(false);\r
index 2cfca9c..808ae50 100644 (file)
@@ -23,7 +23,7 @@ static BluetoothEarPhoneView *g_pBluetoothEarPhoneView{nullptr};
 #define BLUETOOTH_IMAGE_HEIGHT 104\r
 #define BLUETOOTH_DELAY 200\r
 \r
-osTimerId_t g_stopScanHandle = NULL;\r
+osTimerId_t g_stopScanHandle = nullptr;\r
 static constexpr uint64_t MS_SCAN_TIME = 25000;\r
 \r
 BluetoothEarPhoneView::BluetoothEarPhoneView()\r
@@ -141,15 +141,15 @@ UIViewGroup *BluetoothEarPhoneView::InitShowUpView()
     return group;\r
 }\r
 \r
-void CancelBrScanHandle(void)\r
+static void CancelBrScanHandle(void)\r
 {\r
-    if (g_stopScanHandle != NULL) {\r
+    if (g_stopScanHandle != nullptr) {\r
         osStatus_t ret = osTimerDelete(g_stopScanHandle);\r
         if (ret != osOK) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);\r
             return;\r
         }\r
-        g_stopScanHandle = NULL;\r
+        g_stopScanHandle = nullptr;\r
     }\r
     bool results = gap_br_cancel_discovery();\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results);\r
@@ -224,19 +224,19 @@ void BluetoothEarPhoneView::BtEnable()
     setScanStatus(true); // 开始扫描标记\r
     BluetoothModel::GetInstance()->SetCaseListClear(); // 扫描list清空\r
     ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
-    if (ret == true) {\r
+    if (ret) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable Bt is Discovering");\r
         return;\r
     } else {\r
         results = gap_br_start_discovery();\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable StartBtDiscovery results %d", results);\r
     }\r
-    if (g_stopScanHandle != NULL) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopScanHandle != NULL");\r
+    if (g_stopScanHandle != nullptr) {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopScanHandle != nullptr");\r
         return;\r
     }\r
-    g_stopScanHandle = osTimerNew((osTimerFunc_t)ScanTimerCallback, osTimerPeriodic, NULL, NULL);\r
-    if (g_stopScanHandle == NULL) {\r
+    g_stopScanHandle = osTimerNew((osTimerFunc_t)ScanTimerCallback, osTimerPeriodic, nullptr, nullptr);\r
+    if (g_stopScanHandle == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerNew failed!!");\r
         return;\r
     }\r
@@ -244,13 +244,13 @@ void BluetoothEarPhoneView::BtEnable()
     osStatus_t retTimer = osTimerStart(g_stopScanHandle, tick);\r
     if (retTimer != osOK) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerStart failed, ret = %lx!!", retTimer);\r
-        if (g_stopScanHandle != NULL) {\r
+        if (g_stopScanHandle != nullptr) {\r
             retTimer = osTimerDelete(g_stopScanHandle);\r
             if (retTimer != osOK) {\r
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerDelete  ret = %lx!!", retTimer);\r
                 return;\r
             }\r
-            g_stopScanHandle = NULL;\r
+            g_stopScanHandle = nullptr;\r
         }\r
         return;\r
     }\r
@@ -260,7 +260,7 @@ void BluetoothEarPhoneView::BtEnable()
 void BluetoothEarPhoneView::StopBtDiscovery(void)\r
 {\r
     bool ret = is_bt_discovering(BT_TRANSPORT_BR_EDR);\r
-    if (ret == false) {\r
+    if (!ret) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Bt is not Discovering");\r
         return;\r
     }\r
index 6b1d6e7..00057bc 100644 (file)
@@ -26,11 +26,14 @@ bt_avrcp_tg_bts_cbk g_avrcp_tg_audio_cb;
 avrcp_ct_callbacks_t g_avrcp_ct_cb;\r
 avrcp_tg_callbacks_t g_avrcp_tg_cb;\r
 BtAvrcpTgInf g_avrcp_srv_inf;\r
-static profile_connect_state_t g_avrcpTgStat = {};\r
 \r
-static profile_connect_state_t BtAvrcpStat()\r
+void BtAvrcpVolumeChangedSyncMedia(uint8_t a2dp_volume)\r
 {\r
-    return g_avrcpTgStat;\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[BtAvrcpVolumeChangedSyncMedia]::a2dp_volume = 0x%x\r\n", a2dp_volume);\r
+    int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100;\r
+    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_A2DP_MUSIC, audio_volume); /* 设置增益音量 */\r
+    g_avrcp_tg_local_media_vol = a2dp_volume;\r
+    avrcp_tg_notify_volume_changed(a2dp_volume);\r
 }\r
 \r
 /* tg通知媒体状态 */\r
@@ -74,9 +77,10 @@ static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEvent
             avrcp_tg_notify_uid_changed(*(td_u16 *)notifyEventStatusParam->event_status);\r
             break;\r
         case AVRCP_NOTIFY_EVENT_VOLUME_CHANGED:\r
-            avrcp_tg_notify_volume_changed(*(td_u8 *)notifyEventStatusParam->event_status);\r
+            BtAvrcpVolumeChangedSyncMedia(notifyEventStatusParam->event_status[0]);\r
             break;\r
         case AVRCP_NOTIFY_EVENT_RESERVED:\r
+            break;\r
         default:\r
             break;\r
     }\r
@@ -84,7 +88,7 @@ static void BtAvrcpTgNotifyMeidaStatus(bt_avrcp_tg_evt_status_param *notifyEvent
 \r
 void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PressButtonStatusCallback]::keyValue = %x  keyOperation = %x",\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[PressButtonStatusCallback]::keyValue = 0x%x  keyOperation = 0x%x",\r
         keyValue, keyOperation);\r
     GraphicService::GetInstance()->PostGraphicEvent(std::bind(UsingPressButtonStatusCallback, keyOperation, keyValue));\r
 }\r
@@ -92,7 +96,8 @@ void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)
 void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume)\r
 {\r
     int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100;\r
-    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume);\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyVolume = %d", audio_volume);\r
+    AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume); // 耳机连接手表场景调节手表音量\r
 }\r
 \r
 void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)\r
@@ -145,10 +150,15 @@ void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue)
 \r
 uint8_t BtAvrcpTgGetLocMediaVolume(void)\r
 {\r
-    uint32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC);\r
-    uint8_t a2dp_volume = audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL;\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", a2dp_volume);\r
-    return a2dp_volume;\r
+    if (g_avrcp_tg_local_media_vol == AVRCP_ABSOLUTE_VOLUME_INVALID) {\r
+        int32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_A2DP_MUSIC);\r
+        uint8_t a2dp_volume = (uint8_t)(audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL);\r
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio_volume 0x%x, a2dp_volume 0x%x\n", audio_volume, a2dp_volume);\r
+        g_avrcp_tg_local_media_vol = a2dp_volume;\r
+    }\r
+\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", g_avrcp_tg_local_media_vol);\r
+    return g_avrcp_tg_local_media_vol;\r
 }\r
 \r
 void MediaStatusCallback(bt_avrcp_tg_evt_status_param *eventStatusParam)\r
@@ -221,7 +231,7 @@ void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_stat
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr");\r
         return;\r
     }\r
-    g_avrcpTgStat = state;\r
+\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnCtStateChangedCallback addr: %02x%02x%02x%02x%02x%02x ",\r
         bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* 5 4 3 idx */\r
         bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* 2 1 0 idx */\r
@@ -236,7 +246,7 @@ void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_stat
 \r
 static void BtAvrcpCtPressButtonRspCallback(const bd_addr_t *bd_addr, int32_t key_operation)\r
 {\r
-    if (bd_addr == NULL) {\r
+    if (bd_addr == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n");\r
         return;\r
     }\r
@@ -299,7 +309,7 @@ static void BtAvrcpCtReleaseButtonRspCallback(const bd_addr_t *bd_addr, int32_t
 \r
 static void BtAvrcpCtSupportCompanyCallback(const bd_addr_t *bd_addr, avrcp_ct_support_company_para_t *company)\r
 {\r
-    if (bd_addr == NULL || company == NULL || company->company_id == NULL) {\r
+    if (bd_addr == nullptr || company == nullptr || company->company_id == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,  "null pointer\n");\r
         return;\r
     }\r
@@ -311,7 +321,7 @@ static void BtAvrcpCtSupportCompanyCallback(const bd_addr_t *bd_addr, avrcp_ct_s
 \r
 static void BtAvrcpCtSupportEventCallback(const bd_addr_t *bd_addr, avrcp_ct_support_event_para_t *event)\r
 {\r
-    if (bd_addr == NULL || event == NULL || event->event_id == NULL) {\r
+    if (bd_addr == nullptr || event == nullptr || event->event_id == nullptr) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "null pointer\n");\r
         return;\r
     }\r
@@ -329,7 +339,7 @@ static void BtAvrcpCtSupportEventCallback(const bd_addr_t *bd_addr, avrcp_ct_sup
 \r
 static void BtAvrcpCtGetElementAttriCallback(const bd_addr_t *bd_addr, avrcp_ct_element_attr_para_cb_t *attr_cb_para)\r
 {\r
-    if (bd_addr == NULL || attr_cb_para == NULL || attr_cb_para->attr_value == NULL) {\r
+    if (bd_addr == nullptr || attr_cb_para == nullptr || attr_cb_para->attr_value == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n");\r
         return;\r
     }\r
@@ -367,7 +377,7 @@ static void BtAvrcpCtGetElementAttriCallback(const bd_addr_t *bd_addr, avrcp_ct_
         }\r
 \r
         uint8_t *value = (uint8_t *)(void *)malloc(attr_cb_para->attr_value[i].value_len + 1);\r
-        if (attr_cb_para->attr_value[i].value_len > 0 &&  attr_cb_para->attr_value[i].value != NULL) {\r
+        if (attr_cb_para->attr_value[i].value_len > 0 &&  attr_cb_para->attr_value[i].value != nullptr) {\r
             if (memcpy_s(value, attr_cb_para->attr_value[i].value_len,\r
                 attr_cb_para->attr_value[i].value, attr_cb_para->attr_value[i].value_len) != EOK) {\r
                 free(value);\r
@@ -383,7 +393,7 @@ static void BtAvrcpCtGetElementAttriCallback(const bd_addr_t *bd_addr, avrcp_ct_
 \r
 static void BtAvrcpCtGetPlayStatusCallback(const bd_addr_t *bd_addr, avrcp_ct_play_status_cb_t *status)\r
 {\r
-    if (bd_addr == NULL || status == NULL) {\r
+    if (bd_addr == nullptr || status == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n");\r
         return;\r
     }\r
@@ -400,7 +410,7 @@ static void BtAvrcpCtHdlNotifyVolumeRspCbk(avrcp_ct_notification_value_cb_t *not
 static void BtAvrcpCtNotificationCallback(\r
     const bd_addr_t *bd_addr, avrcp_notify_event_t event_id, avrcp_ct_notification_value_cb_t *notification)\r
 {\r
-    if (bd_addr == NULL || notification == NULL) {\r
+    if (bd_addr == nullptr || notification == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "null pointer\n");\r
         return;\r
     }\r
index 5f668e7..676c018 100644 (file)
@@ -76,9 +76,9 @@ void BluetoothItemView::SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCa
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetItemInfo");\r
     itemInfo_ = itemInfo;\r
     namelabel.SetText(reinterpret_cast<const char *>(itemInfo_.deviceName));\r
-    if (isCaseList == true) {\r
+    if (isCaseList) {\r
         bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked();\r
-        if ((IsConnectAnimator() == false) && (ret == true)) {\r
+        if ((!IsConnectAnimator()) && (ret)) {\r
             namelabel.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full);\r
             button.SetTouchable(false);\r
             SetTouchable(false);\r
index f285c17..fb3f7ae 100644 (file)
@@ -4,7 +4,7 @@
  * Author:\r
  * Create: 2021-10-13\r
  */\r
-#include "stdint.h"\r
+#include <cstdint>\r
 #include "BluetoothModel.h"\r
 #include "BluetoothPresenter.h"\r
 #include "ConnectPhonePresenter.h"\r
 #include "PlayersModel.h"\r
 #include "PhoneAudio.h"\r
 #include "graphic_service.h"\r
-#include "ui_service.h"\r
-\r
 #include "msg_center.h"\r
-\r
 #include "bts_def.h"\r
 #include "bts_gatt_stru.h"\r
 #include "bts_a2dp_source.h"\r
 #include "bts_gatt_server.h"\r
 #include "bts_le_gap.h"\r
 #include "bts_spp.h"\r
-\r
-// #include "bleService.h"\r
-\r
 #include "osal_task.h"\r
 #ifdef SUPPORT_ALIPAY_SEC\r
 #include "alipay_feature.h"\r
 #include "bt_audio_hal_interface.h"\r
 #include "audio_manager_c_wrapper.h"\r
 #include "bts_avrcp_target.h"\r
+#include "msg_center_msg.h"\r
 \r
 namespace OHOS {\r
-#define BLE_SERVICE_UUID 0x18E0\r
-#define BLE_RX_UUID 0x2ae3\r
-#define BLE_TX_UUID 0x2ae5\r
-#define BLE_BAE_UUID  {0xfb,0x34,0x9b,0x5f,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0xE3,0x2A,0x00,0x00}\r
 \r
 #define BT_SPP_TASK_STACK_SIZE 2048\r
 #define BT_SPP_TASK_PRI        20\r
@@ -48,11 +39,9 @@ namespace OHOS {
 constexpr uint16_t BLUETOOTH_MAX_NUM = 20;\r
 \r
 #define MEDIA_A2DP_SNK_INTERFACE 1\r
-osal_timer g_a2dp_stream_accept_timer = {NULL, NULL, 0, 0};\r
+osal_timer g_a2dp_stream_accept_timer = {nullptr, nullptr, 0, 0};\r
 #define A2DP_STREAM_ACCEPT_TIMER_PERIOD 500\r
 AudioFormatConfig g_audio_format_config = {AUDIO_DEFAULT, 0, 0};\r
-BtAvrcpTgInftrerface g_avrcp_srv_infterface;\r
-\r
 \r
 void BluetoothModel::SetBluetoothCalleridStatus(int16_t value)\r
 {\r
@@ -77,30 +66,19 @@ BluetoothModel *BluetoothModel::GetInstance(void)
 \r
 void BluetoothModel::Init()\r
 {\r
-\r
-/**\r
- *  由于 是否开启蓝牙,并不确认,需要根据客户选择来执行,\r
- * 因此此处只做 基本数据的初始化,以及某些不会变动的 callback函数注册\r
- */\r
 #if 0\r
     bool ret = enable_bt_stack();\r
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt enable_bt_stack ret = %d", ret);\r
-    //gatt ble 信息在 支付宝和私有 ble协议中都会用到,因此在对应的应用里进行初始化。\r
+\r
+    BtInitCallBacks();\r
 #ifdef SUPPORT_ALIPAY_SEC\r
     svr_alipay_bluetooth_init();\r
 #else\r
     BtInitCallBacksEx();\r
     BtInitGatts();\r
 #endif\r
-\r
+    BtInitSpp();\r
 #endif\r
-\r
-    // /**初始化 经典蓝牙callback  经典蓝牙不改动,因此启动就初始化好 */\r
-    // BtInitCallBacks();\r
-\r
-    // /**启动spp服务 */\r
-    // BtInitSpp();\r
-\r
     SetUpListCase();\r
     SetUpConnedDevicesList();\r
 }\r
@@ -211,7 +189,7 @@ void BluetoothModel::SetUpConnedDevicesList()
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Setup GetPariedDevicesNum ret = %d, num = %d", ret, connedDevicesNum);\r
 \r
         gap_paired_device_info_t *devInfo = (gap_paired_device_info_t*)malloc(sizeof(gap_paired_device_info_t) *connedDevicesNum);\r
-        if (devInfo ==  NULL) {\r
+        if (devInfo ==  nullptr) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DevInfo malloc failed %u", sizeof(gap_paired_device_info_t) *connedDevicesNum);\r
             return;\r
         }\r
@@ -668,8 +646,8 @@ static void ACLConnectionSuss(const bd_addr_t &bdAddr)
 {\r
     // 判断是否已退出蓝牙模块(无需跳转)\r
     bool tagConnectView = BluetoothModel::GetInstance()->IsTagConnectView();\r
-    if (tagConnectView == false) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagConnectView == false");\r
+    if (!tagConnectView) {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagConnectView fail");\r
         return;\r
     }\r
     // 成功提示\r
@@ -705,8 +683,8 @@ static void ACLConnectionFail(const bd_addr_t &bdAddr)
     bool tagConnectView = BluetoothModel::GetInstance()->IsTagConnectView();\r
     // 判断是否无需跳转到失败界面\r
     bool tagDisconnectView = BluetoothModel::GetInstance()->IsTagDisconnectView();\r
-    if (tagConnectView == false || tagDisconnectView == false) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagDisconnectView == false");\r
+    if ((!tagConnectView) || (!tagDisconnectView)) {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback tagDisconnectView fail");\r
         return;\r
     }\r
     // 失败提示页\r
@@ -736,39 +714,8 @@ static void ACLConnectionFail(const bd_addr_t &bdAddr)
     tipsConnFailMessageView->RefreshNameLabel(bdAddr);\r
 }\r
 \r
-static void DisconnectBluetoothPause()\r
-{\r
-    int64_t playerCurrentTime;\r
-    int64_t playerMusicDuration;\r
-    int64_t playerProgressVlaue;\r
-    if (PlayersModel::GetInstance()->GetPlayerCtr() == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback GetPlayerCtr() == nullptr");\r
-        return;\r
-    }\r
-    PlayersModel::GetInstance()->GetPlayerCtr()->Pause();\r
-    PlayersModel::GetInstance()->SetPlayButtonState(false);\r
-    PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime);\r
-    PlayersModel::GetInstance()->GetPlayerCtr()->GetDuration(playerMusicDuration);\r
-    if (playerMusicDuration == 0) { // 0:除数保护\r
-        playerProgressVlaue = 100; // 100:进度条系数\r
-    } else {\r
-        playerProgressVlaue = (playerCurrentTime * 100) / playerMusicDuration; // 100:百分比系数\r
-    }\r
-    PlayersModel::GetInstance()->SetCircleProgress(playerProgressVlaue);\r
-    PlayersView *playersView = PlayersView::GetInstance();\r
-    if (playersView != nullptr) {\r
-        playersView->SetPlayerButtonState(UICheckBox::UICheckBoxState::UNSELECTED);\r
-        if (playersView->GetPlaybackProgress() == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback playersView->GetPlaybackProgress() == nullptr");\r
-            return;\r
-        }\r
-        playersView->GetPlaybackProgress()->SetValue(playerProgressVlaue);\r
-    }\r
-}\r
-\r
 static void DisconnectedHandle()\r
 {\r
-    DisconnectBluetoothPause();\r
     BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
     BluetoothDeviceListView *bluetoothDeviceListView = BluetoothDeviceListView::GetInstance();\r
     if (bluetoothDeviceListView == nullptr) {\r
@@ -791,14 +738,8 @@ static void DisconnectedHandle()
 \r
 void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned int reason, const bd_addr_t &bdAddr)\r
 {\r
-    if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) {\r
-        SendMsgToUIService(BT_CONNECTED_TO_UI, 0, NULL, 0);\r
-    } else {\r
-        SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, NULL, 0);\r
-    }\r
-\r
     bool tag = BluetoothModel::GetInstance()->IsTagScanDeviceClicked();\r
-    if ((reason == 0x13) || (reason == 0x14) || (reason == 0x15) || (reason == 0x3D) || (reason == 0x08 && tag == false)) { // 连接断开\r
+    if ((reason == 0x13) || (reason == 0x14) || (reason == 0x15) || (reason == 0x3D) || (reason == 0x08 && (!tag))) { // 连接断开\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "The peer end is disconnected.");\r
         DisconnectedHandle();\r
     } else if (reason == 0x16) { // 主动断开连接\r
@@ -818,19 +759,21 @@ void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned
     if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) {\r
         SetLastConnedAddr(&bdAddr);\r
         // 将数据存入设备列表\r
-        bool tag = CheckExistConnedList(*onClickBtCaseInfo);\r
+        tag = CheckExistConnedList(*onClickBtCaseInfo);\r
         if (!tag) {\r
             AddConnedDevicesCase(*onClickBtCaseInfo);\r
         }\r
-        ACLConnectionSuss(bdAddr);\r
     } else {\r
         ACLConnectionFail(bdAddr);\r
     }\r
 \r
     if ((state == GAP_ACL_STATE_CONNECTED) || (state == GAP_ACL_STATE_LE_CONNECTED)) {\r
         if (BluetoothModel::GetInstance()->ConnectRemoteCheck(&bdAddr)) {\r
-            bool retA2dp = a2dp_src_connect(&bdAddr);\r
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connect result %d", retA2dp);\r
+            int32_t retA2dp = a2dp_src_connect(&bdAddr);\r
+            if (retA2dp) {\r
+                ACLConnectionFail(bdAddr);\r
+            }\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "a2dp_src_connect result 0x%x", retA2dp);\r
         } else {\r
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ingore a2dp_src_connect");\r
         }\r
@@ -848,8 +791,8 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state,
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device");\r
         return;\r
     }\r
-    GraphicService::GetInstance()->PostGraphicEvent(std::bind(&BluetoothModel::BtGapAclStateChangedHandle,\r
-                                                    BluetoothModel::GetInstance(), state, reason, *bdAddr));\r
+    GraphicService::GetInstance()->PostGraphicEvent(\r
+        std::bind(&BluetoothModel::BtGapAclStateChangedHandle, BluetoothModel::GetInstance(), state, reason, *bdAddr));\r
 }\r
 \r
 // 回调:远端设备名称变化\r
@@ -897,10 +840,12 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState)
     if (connState == PROFILE_STATE_CONNECTED) {\r
         avrcp_ct_connect(bdAddr);\r
         PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_CONNECTED);\r
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr));\r
     }\r
 \r
     if (connState == PROFILE_STATE_DISCONNECTED) {\r
         PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED);\r
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr));\r
     }\r
 }\r
 \r
@@ -928,9 +873,12 @@ static void BleConnStateChangeCallback(unsigned short connId, bd_addr_t *addr, g
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleConnStateChangeCallback connId 0x%x, connState 0x%x, pairState 0x%x",\r
                   connId, connState, pairState);\r
     if (GAP_BLE_STATE_DISCONNECTED == connState) { // restart ble adv when disconnected\r
+        /* 通知msg_center,ble状态仍用bt状态,此处不区分 */\r
+        SendMsgToMsgCenterService(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
         BleAdvStart();\r
     } else {\r
         BluetoothModel::GetInstance()->SetAdvStartState(false);\r
+        SendMsgToMsgCenterService(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0);\r
     }\r
 }\r
 \r
@@ -951,8 +899,8 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsServiceAddCallback 0x%x 0x%x 0x%x",\r
         status, serverId, srvcHandle);\r
 \r
-    if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == BLE_SERVICE_UUID)) {\r
-        uint16_t id = BLE_RX_UUID;\r
+    if ((uuid->uuid_len == sizeof(uint16_t)) && (*((uint16_t*)uuid->uuid) == 0x1FF0)) {\r
+        uint16_t id = 0x1FF1;\r
         gatts_add_chara_info_t character;\r
         uint16_t value = 0;\r
 \r
@@ -960,27 +908,12 @@ static void BtGattsServiceAddCallback(uint8_t serverId, bt_uuid_t *uuid, uint16_
         character.chara_uuid.uuid_len = sizeof(id);\r
         memcpy_s(character.chara_uuid.uuid, sizeof(character.chara_uuid.uuid), (char *)&id, sizeof(id));\r
         character.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE;\r
-        character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ |GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP|GATT_CHARACTER_PROPERTY_BIT_NOTIFY;\r
+        character.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE;\r
         character.value_len = (uint16_t)sizeof(value);\r
         character.value = (uint8_t *)(&value);\r
 \r
         ret = gatts_add_characteristic(serverId, srvcHandle, &character);\r
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic ret 0x%x", ret);\r
-\r
-        uint16_t tx_uuid[16] = BLE_BAE_UUID;\r
-        gatts_add_chara_info_t txcharacter;\r
-        uint16_t txvalue = 0;\r
-\r
-        memset_s(&txcharacter, sizeof(gatts_add_chara_info_t), 0, sizeof(gatts_add_chara_info_t));\r
-        txcharacter.chara_uuid.uuid_len = sizeof(tx_uuid);\r
-        memcpy_s(txcharacter.chara_uuid.uuid, sizeof(txcharacter.chara_uuid.uuid), (char *)&tx_uuid, sizeof(tx_uuid));\r
-        txcharacter.permissions = GATT_ATTRIBUTE_PERMISSION_WRITE;\r
-        txcharacter.properties = GATT_CHARACTER_PROPERTY_BIT_WRITE | GATT_CHARACTER_PROPERTY_BIT_READ |GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP|GATT_CHARACTER_PROPERTY_BIT_NOTIFY;\r
-        txcharacter.value_len = (uint16_t)sizeof(txvalue);\r
-        txcharacter.value = (uint8_t *)(&txvalue);\r
-\r
-        ret = gatts_add_characteristic(serverId, srvcHandle, &txcharacter);\r
-        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "gatts_add_characteristic ret 0x%x", ret);\r
     }\r
 }\r
 \r
@@ -1023,16 +956,16 @@ static void BtGattsRequestReadCallback(uint8_t serverId, uint16_t connId, gatts_
 \r
 static void BtGattsRequestWriteCallback(uint8_t serverId, uint16_t connId, gatts_req_write_cb_t *writeCbPara,  errcode_t status)\r
 {\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback2 %s length:%d",writeCbPara->value,writeCbPara->length);\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback");\r
 }\r
 \r
 static void BtA2dpSnkAcceptTimerStop(void)\r
 {\r
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "stop timer\n");\r
-    if (g_a2dp_stream_accept_timer.timer != NULL) {\r
+    if (g_a2dp_stream_accept_timer.timer != nullptr) {\r
         (void)osal_timer_stop(&g_a2dp_stream_accept_timer);\r
         (void)osal_timer_destroy(&g_a2dp_stream_accept_timer);\r
-        g_a2dp_stream_accept_timer.timer = NULL;\r
+        g_a2dp_stream_accept_timer.timer = nullptr;\r
     }\r
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "stop timer success!\n");\r
 }\r
@@ -1048,7 +981,7 @@ static void BtA2dpSnStartAcceptHandler(unsigned long data)
 static errcode_t BtA2dpSnkStartAcceptTimer(void)\r
 {\r
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "start timer\n");\r
-    if (g_a2dp_stream_accept_timer.timer != NULL) {\r
+    if (g_a2dp_stream_accept_timer.timer != nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timer is running");\r
         return ERRCODE_SUCC;\r
     }\r
@@ -1096,11 +1029,9 @@ static int32_t BtA2dpSnkAudioDestroy()
     return 0;\r
 }\r
 \r
-\r
-\r
 static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state)\r
 {\r
-    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr22222: ****%02x%02x%02x%02x conn_state: %x\n",\r
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x conn_state: %x\n",\r
         bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], conn_state); /* 3 2 1 0 idx */\r
 }\r
 \r
@@ -1196,8 +1127,8 @@ void BtInitCallBacks(void)
     g_btGapCallBacks.pair_confiremed_callback = BtGapPairConfirmedCallback;\r
     gap_register_callbacks(&g_btGapCallBacks);\r
 \r
-   \r
-}\r
+    \r
+    }\r
 \r
 void BtInitCallBacksEx()\r
 {\r
@@ -1214,13 +1145,13 @@ void BtInitCallBacksEx()
     g_btGattsCallbacks.delete_service_cb = BtGattsServiceDeleteCallback;\r
     g_btGattsCallbacks.read_request_cb = BtGattsRequestReadCallback;\r
     g_btGattsCallbacks.write_request_cb = BtGattsRequestWriteCallback;\r
-    g_btGattsCallbacks.mtu_changed_cb = NULL;\r
+    g_btGattsCallbacks.mtu_changed_cb = nullptr;\r
     gatts_register_callbacks(&g_btGattsCallbacks);\r
 }\r
 \r
 void BtInitGatts(void)\r
 {\r
-    uint16_t id = BLE_SERVICE_UUID;\r
+    uint16_t id = 0x1FF0;\r
     uint16_t ser_id = 0x1FFF;\r
     uint8_t serverId = 0;\r
     bt_uuid_t uuid;\r
@@ -1254,7 +1185,7 @@ static uint32_t GenerateUuidFromString(const char *str, uint8_t len, bt_uuid_t *
 {\r
     int slen = (int)strnlen(str, len);\r
     bool new_uuid = false;\r
-    if (uuid_out == NULL) {\r
+    if (uuid_out == nullptr) {\r
         return ERRCODE_INVALID_PARAM;\r
     }\r
 \r
@@ -1311,7 +1242,7 @@ void BtSppServerAccept(uint8_t server_id)
 {\r
     osal_task *task = osal_kthread_create(BtSppServerAcceptTaskBody, (void *)(uintptr_t)server_id,\r
         "spp_server_accept_task", BT_SPP_TASK_STACK_SIZE);\r
-    if (task == NULL) {\r
+    if (task == nullptr) {\r
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "create task fail\n");\r
         return;\r
     }\r
@@ -1339,7 +1270,6 @@ void BtInitSpp(void)
 \r
 void BleAdvStart(void)\r
 {\r
-    return;\r
     int advId = 1;\r
     if (BluetoothModel::GetInstance()->GetAdvStartState()) {\r
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStart already started");\r
index 86ea73e..a2c3671 100644 (file)
@@ -46,7 +46,7 @@ void BluetoothOptionsView::RefreshText(void)
 {\r
     // 刷新状态和文字\r
     BluetoothModel::GetInstance()->SetBtStatus();\r
-    if (BluetoothModel::GetInstance()->GetAclConnected() == true) {\r
+    if (BluetoothModel::GetInstance()->GetAclConnected()) {\r
         connectStateLabel->SetText("已连接");\r
         optionsOneButton->SetText("断开连接");\r
     } else {\r
index fd2c47b..18b5bae 100644 (file)
@@ -11,7 +11,7 @@
 #include "BluetoothReconnectView.h"\r
 #include "MainBluetoothView.h"\r
 #include "UiConfig.h"\r
-#include "bluetooth/include/BluetoothModel.h"\r
+#include "BluetoothModel.h"\r
 #include "custom_utils.h"\r
 #include "common/key_code.h"\r
 \r
@@ -145,7 +145,7 @@ void BluetoothPresenter::ClickOptionsOneButton(void)
         return;\r
     }\r
     bluetoothMode_->SetBtStatus();\r
-    if (bluetoothMode_->GetAclConnected() == true) {\r
+    if (bluetoothMode_->GetAclConnected()) {\r
         bluetoothMode_->SetTagConnectNew(false);\r
         bluetoothOptionsView->SetBtDisconnect();\r
         view_->ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW);\r
index f2294ce..4792a68 100644 (file)
@@ -76,7 +76,7 @@ void MainBluetoothView::OnStart()
     BluetoothModel::GetInstance()->SetTagReturnToDeviceListView(false);\r
     int16_t unusedValue = BLUETOOTHEVIEW_MAX;\r
     bool ret = bluetoothCaseList.IsEmpty();\r
-    if (ret != true) {\r
+    if (!ret) {\r
         ChangeView(unusedValue, BLUETOOTHDEVICELISTVIEW);\r
     } else {\r
         ChangeView(unusedValue, BLUETOOTHEARPHONEVIEW);\r
@@ -140,11 +140,6 @@ bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t
         }\r
         deviceList->RefreshList();\r
     }\r
-    BluetoothDeviceListView *bluetoothDeviceListView = BluetoothDeviceListView::GetInstance();\r
-    if (bluetoothDeviceListView == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothDeviceListView new fail");\r
-        return false;\r
-    }\r
     bluetoothDeviceListView->RefreshText();\r
     return true;\r
 }\r
@@ -190,7 +185,6 @@ bool MainBluetoothView::ChangeTipsConnFailMessageView(int16_t hideView, int16_t
         container[thisView] = group;\r
         RootView::GetInstance()->Add(container[thisView]);\r
     }\r
-    BluetoothReconnectView *bluetoothReconnectView = BluetoothReconnectView::GetInstance();\r
     if (bluetoothReconnectView == nullptr) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback bluetoothReconnectView == nullptr");\r
     } else {\r
@@ -317,8 +311,8 @@ bool MainBluetoothView::ChangeBluetoothReconnectView(int16_t hideView, int16_t t
         RootView::GetInstance()->Add(container[thisView]);\r
     }\r
     BluetoothModel::GetInstance()->SetTagDisconnectView(true);\r
-    BluetoothReconnectView::GetInstance()->RefreshBluetoothNameLabel();\r
-    BluetoothReconnectView::GetInstance()->BtReconnectStart();\r
+    bluetoothReconnectView->RefreshBluetoothNameLabel();\r
+    bluetoothReconnectView->BtReconnectStart();\r
     return true;\r
 }\r
 \r
@@ -329,12 +323,12 @@ void MainBluetoothView::CorrespondingJump(int16_t hideView)
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothModel == nullptr");\r
             return;\r
         }\r
-    if (bluetoothModel->GetTagReconnectJump() == true) {\r
+    if (bluetoothModel->GetTagReconnectJump()) {\r
         ChangeView(hideView, BLUETOOTHEOPTIONSVIEW);\r
     } else {\r
         std::list<BluetoothCaseInfo> &bluetoothScanList = BluetoothModel::GetInstance()->GetCase();\r
         bool ret = bluetoothScanList.empty();\r
-        if (ret != true) {\r
+        if (!ret) {\r
             ChangeView(hideView, BLUETOOTHEARLISTVIEW);\r
         } else {\r
             ChangeView(hideView, BLUETOOTHEARPHONEVIEW);\r
@@ -348,13 +342,11 @@ void MainBluetoothView::ChangeSettingView()
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeSettingView");\r
     BluetoothModel::GetInstance()->SetTagConnectView(false);\r
     BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false);\r
-    //NativeAbility::GetInstance().ChangeSlice(VIEW_CLASSIC_BLUETOOTH);\r
-    NativeAbility::GetInstance().Back();\r
+    NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
 }\r
 \r
 void MainBluetoothView::DropEarPhoneView()\r
 {\r
-    BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance();\r
     if (bluetoothEarPhoneView == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr");\r
         return;\r
@@ -362,7 +354,7 @@ void MainBluetoothView::DropEarPhoneView()
     bluetoothEarPhoneView->BtAnimatorStop();\r
     bluetoothEarPhoneView->StopBtDiscovery();\r
     bool ret = BluetoothModel::GetInstance()->IsTagReturnToDeviceListView();\r
-    if (ret == true) {\r
+    if (ret) {\r
         ChangeView(BLUETOOTHEARPHONEVIEW, BLUETOOTHDEVICELISTVIEW);\r
     } else {\r
         ChangeSettingView();\r
@@ -380,7 +372,6 @@ void MainBluetoothView::DropEarListView()
         errcode_t retVal = gap_disconnect_remote_device((const bd_addr_t *)caseInfo->addr);\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropEarListView gap_disconnect_remote_device retVal = %d", retVal);\r
     }\r
-    BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance();\r
     if (bluetoothEarPhoneView == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr");\r
         return;\r
@@ -423,14 +414,12 @@ void MainBluetoothView::DropView(UIView& view)
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHRECONNECTVIEW]");\r
         CorrespondingJump(BLUETOOTHRECONNECTVIEW);\r
         BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
-        BluetoothReconnectView *bluetoothReconnectView = BluetoothReconnectView::GetInstance();\r
         bluetoothReconnectView->BtReconnectStop();\r
     }\r
 }\r
 \r
 void MainBluetoothView::ResetEarListView(int16_t hideView)\r
 {\r
-    BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance();\r
     if (bluetoothEarListView == nullptr) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ResetEarListView bluetoothEarListView == nullptr");\r
         return;\r
@@ -469,14 +458,14 @@ void MainBluetoothView::ChangeView(int16_t hideView, int16_t showView)
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeView %d, %d", hideView, showView);\r
 \r
-    if (CheckViewParam(hideView, showView) == false) {\r
+    if (!CheckViewParam(hideView, showView)) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::CheckViewParam failed.");\r
         return;\r
     }\r
 \r
     PreprosssChangeView tmpPreProcessView = preProcessView[showView];\r
 \r
-    if ((this->*tmpPreProcessView)(hideView, showView) == false) {\r
+    if (!(this->*tmpPreProcessView)(hideView, showView)) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeView %d %dfailed", showView, hideView);\r
         return;\r
     }\r
index ffaf77d..552f968 100644 (file)
@@ -189,7 +189,7 @@ void TipsConnFailMessageView::RefreshNameLabel(const bd_addr_t &bdAddr)
     BluetoothCaseInfo caseInfo;\r
     (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN);\r
     bool ret = BluetoothModel::GetInstance()->FindNameFromList(&caseInfo);\r
-    if (ret == false) {\r
+    if (!ret) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsConnFailMessageView FindNameFromList fail");\r
         return;\r
     }\r
index 3dd80a7..9bab50f 100644 (file)
@@ -149,7 +149,7 @@ void TipsSuccMessageView::RefreshNameLabel(const bd_addr_t &bdAddr)
     BluetoothCaseInfo caseInfo;\r
     (void)memcpy_s(caseInfo.addr, BD_ADDR_LEN, bdAddr.addr, BD_ADDR_LEN);\r
     bool ret = BluetoothModel::GetInstance()->FindNameFromList(&caseInfo);\r
-    if (ret == false) {\r
+    if (!ret) {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsSuccMessageView FindNameFromList fail");\r
         return;\r
     }\r