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