Merge #1304 into sdk602patch0911 from refs/changes/1304/head 1305/target/1
author罗正 <1732036298@qq.com>
Thu, 31 Oct 2024 09:08:58 +0000 (09:08 +0000)
committer袁清梦 <3449750381@qq.com>
Thu, 31 Oct 2024 09:08:58 +0000 (09:08 +0000)
Code review from 罗正

* refs/changes/1304/head: (2 commits squashed)

  - 解决耳机配对后重启蓝牙耳机连接点击无反应bug

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

Signed-off-by: 罗正 <1732036298@qq.com>
Reviewed-by: Caisking <3449750381@qq.com>
Reviewed-by: 罗正 <1732036298@qq.com>
Reviewed-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Reviewed-by: aliyun6865282430 <1624952103@qq.com>
Merged-by: Caisking <3449750381@qq.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1304
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp

index 5be4c75..c6346f7 100644 (file)
@@ -76,17 +76,24 @@ public:
             if(view.GetViewType() == UIViewType::UI_BUTTON)
             {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_BUTTON,%s",reinterpret_cast<const char *>(bluetoothInfo_.deviceName));
-                // 判断是否正在连接
                 bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr();
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lastAddr:%02X %02X %02X * * *",
+                lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]);
+
                 bool ret = bt_is_acl_connected(lastAddr);
-                if (ret) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt_is_acl_connected:%d lastAddr:%02X %02X %02X * * *",
+                ret, lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]);
+
+                //地址不是全0并且ret为真
+                if (!( lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0 && 
+                       lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0 ) && ret) {
                     BluetoothModel::GetInstance()->SetTagConnectNew(false);
                     errcode_t retVal = gap_disconnect_remote_device(lastAddr);
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  %d", retVal);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[gap_disconnect_remote_device] retVal =  %d", retVal);
                 } else {
                     mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW);
                     errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr);
-                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret =  %d", retVal);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[ConnectRemoteDevice] retVal =  %d", retVal);
                 }
             }
             else if(view.GetViewType() == UIViewType::UI_IMAGE_VIEW) /*点击的是图片*/
index fe94d99..ee89bf6 100644 (file)
@@ -516,16 +516,19 @@ namespace OHOS
         {\r
             bool state = SettingModel::GetInstance().GetEarPhoneConnectStatus();\r
             List<BluetoothCaseInfo> &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase();\r
-            if (bluetoothCaseList.IsEmpty()) // 如果已连接设备列表为空,则显示未配对\r
+            bool ConnedDevicesListIsEmpty = bluetoothCaseList.IsEmpty();\r
+            if (ConnedDevicesListIsEmpty) // 如果已连接设备列表为空,则显示未配对\r
             {\r
                 bluetoothHeadsetConnectState->SetTextId(STR_NOT_PAIRED);\r
+                bluetoothHeadsetConnectState->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
+                bluetoothHeadsetConnectState->Invalidate();\r
             }\r
             else // 否则则显示连接状态\r
             {\r
                 bluetoothHeadsetConnectState->SetTextId(state ? STR_CONNECTED : STR_DISCONNECTED);\r
+                bluetoothHeadsetConnectState->SetTextColor(state ? Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff) : Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
+                bluetoothHeadsetConnectState->Invalidate();\r
             }\r
-            bluetoothHeadsetConnectState->SetTextColor(state ? Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff) : Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
-            bluetoothHeadsetConnectState->Invalidate();\r
         }\r
     }\r
 }\r