From b81fb847b562222a5f76f87cf656050bb57cc613 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 16 Mar 2026 11:47:08 +0800 Subject: [PATCH] =?utf8?q?n9=20=E5=88=A0=E9=99=A4=E8=93=9D=E7=89=99?= =?utf8?q?=E8=80=B3=E6=9C=BA=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/bluetooth/src/BluetoothModel.cpp | 9 +- .../bluetooth/src/BluetoothPresenter.cpp | 2 +- .../include/ClassicBlueToothView.h | 2 - .../src/ClassicBlueToothPresenter.cpp | 2 +- .../src/ClassicBlueToothView.cpp | 54 +++------- .../main/include/ConnectedStatusView.h | 3 - .../nativeui/main/include/PullUpDownView.h | 3 - .../nativeui/main/src/ConnectedStatusView.cpp | 54 ++-------- .../nativeui/main/src/PullUpDownView.cpp | 100 +----------------- .../makephone/src/MainCallingPresenter.cpp | 2 +- .../player/src/MusicPlayerSourceView.cpp | 8 +- .../nativeui/player/src/PlayersView.cpp | 8 +- .../nativeui/settings/src/SettingModel.cpp | 3 + 13 files changed, 41 insertions(+), 209 deletions(-) diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index 1e4178807..af22c1a94 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -1307,10 +1307,9 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionSuss, *bdAddr)); #ifdef SUPPORT_CAT1_HFP_AG_SERV - SendMsgToUIService(EARPHONE_CONNECTED_TO_UI, 0, nullptr, 0); - uapi_dev_runtime_set_earphone_connect_stat(1); - uapi_save_runtime_log(RUNTIME_LOG_BR_CONNECT_A2DP_HEADSET); + uapi_dev_runtime_set_earphone_connect_stat(1); + uapi_save_runtime_log(RUNTIME_LOG_BR_CONNECT_A2DP_HEADSET); if(headset_Is_connect() == false) do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CONNECT_AG, nullptr, 0); @@ -1322,10 +1321,6 @@ static void A2dpSrcConnectstateChanged(bd_addr_t *bdAddr, int connState) PhoneAudioManagerSetDeviceConnState(OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_DISCONNECTED); GraphicService::GetInstance()->PostGraphicEvent(std::bind(ACLConnectionFail, *bdAddr)); - #ifdef SUPPORT_BLE_SERVICE - // SendMsgToUIService(EARPHONE_DISCONNECTED_TO_UI, 0, nullptr, 0); - #endif - uapi_save_runtime_log(RUNTIME_LOG_BR_DISCONNECT_A2DP_HEADSET); /* 实验室测试耳机回连场景,用户根据需要调整策略 */ bool ret = gap_br_set_bt_scan_mode(GAP_SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 60); // start scan diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp index 8e568908a..005261f0d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/bluetooth/src/BluetoothPresenter.cpp @@ -19,7 +19,7 @@ namespace OHOS { - REGIST_SLICE(VIEW_BLUETOOTH_EARPHONE, MainBluetoothView, BluetoothPresenter); + // REGIST_SLICE(VIEW_BLUETOOTH_EARPHONE, MainBluetoothView, BluetoothPresenter); static BluetoothPresenter *g_pBluetoothPresenter = nullptr; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h index 2d878fda8..03154255d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/include/ClassicBlueToothView.h @@ -57,10 +57,8 @@ namespace OHOS bool SetUpBlueToothToggleButton(void); UIScrollView *BlueToothScrollView = nullptr; UILabelExt *Title = nullptr; - UILabelButtonExt *BlueToothEarPhoneButton = nullptr; // 蓝牙耳机按钮 UILabelButtonExt *TradionalBlueToothButton = nullptr; // 传统蓝牙按钮 UILabelButtonExt *BluetoothServiceOptionsButton = nullptr; // 蓝牙服务选项按钮 - UILabelExt *BlueToothEarPhoneLabel = nullptr; // 蓝牙耳机 UILabelExt *TradionalBlueToothLabel = nullptr; // 传统蓝牙 UILabelExt *BluetoothServiceOptionsLabel = nullptr; // 蓝牙服务选项 UILabelExt *AttentionLabel = nullptr; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp index 60a882383..1b6b3ab75 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp @@ -72,7 +72,7 @@ namespace OHOS if (strcmp(view.GetViewId(), BLUETOOTHEARPHONEBUTTON) == 0) { - NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); + // NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); } else if (strcmp(view.GetViewId(), BLUETOOTHSERVICEOPTIONSBUTTON) == 0) { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp index 0ecb24876..05bbe8982 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp @@ -38,11 +38,6 @@ namespace OHOS delete Title; Title = nullptr; } - if (BlueToothEarPhoneButton != nullptr) - { - delete BlueToothEarPhoneButton; - BlueToothEarPhoneButton = nullptr; - } if (TradionalBlueToothButton != nullptr) { delete TradionalBlueToothButton; @@ -53,11 +48,6 @@ namespace OHOS delete BluetoothServiceOptionsButton; BluetoothServiceOptionsButton = nullptr; } - if (BlueToothEarPhoneLabel != nullptr) - { - delete BlueToothEarPhoneLabel; - BlueToothEarPhoneLabel = nullptr; - } if (TradionalBlueToothLabel != nullptr) { delete TradionalBlueToothLabel; @@ -155,18 +145,10 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - .textId = STR_BLUETOOTH_HEADPHONES, /*蓝牙耳机*/ + // .textId = STR_BLUETOOTH_HEADPHONES, /*蓝牙耳机*/ + .textId = STR_TRADITIONAL_BLUETOOTH, /*传统蓝牙*/ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; - BlueToothEarPhoneLabel = SetClassicBlueToothViewLabel(labelconfig); - if (nullptr == BlueToothEarPhoneLabel) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::BlueToothEarPhoneLabel is nullptr!"); - return false; - } - /* -------------------------------------------------------------------------- */ - labelconfig.top = 273; - labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; /*传统蓝牙*/ TradionalBlueToothLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == TradionalBlueToothLabel) { @@ -174,7 +156,7 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - labelconfig.top = 393; + labelconfig.top = 273; labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; /*蓝牙服务选项*/ BluetoothServiceOptionsLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BluetoothServiceOptionsLabel) @@ -189,7 +171,12 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::AttentionLabel is nullptr!"); return false; } - AttentionLabel->SetPosition(53, 499, 360, 180); // 位置大小 + int y = 0; + if (BluetoothServiceOptionsButton) + { + y = BluetoothServiceOptionsButton->GetY() + BluetoothServiceOptionsButton->GetHeight() + 39; + } + AttentionLabel->SetPosition(53, y, 360, 180); // 位置大小 AttentionLabel->SetStyle(STYLE_TEXT_FONT, 20); // 字体大小 AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用(该功能主要用于电话拨打/通知、音乐控制/传输等)", @@ -208,18 +195,6 @@ namespace OHOS // 按钮初始化 bool ClassicBlueToothView::SetUpBlueToothButton(void) { - BlueToothEarPhoneButton = new UILabelButtonExt(); - if (BlueToothEarPhoneButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BlueToothEarPhoneButton new fail!"); - return false; - } - BlueToothEarPhoneButton->SetPosition(43, 120, 380, 100); - BlueToothEarPhoneButton->SetViewId(BLUETOOTHEARPHONEBUTTON); - BlueToothEarPhoneButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - BlueToothEarPhoneButton->SetImagePosition(326, 37); - BlueToothEarPhoneButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); - BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ TradionalBlueToothButton = new UILabelButtonExt(); if (TradionalBlueToothButton == nullptr) @@ -227,7 +202,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::TradionalBlueToothButton new fail!"); return false; } - TradionalBlueToothButton->SetPosition(43, 240, 380, 100); + TradionalBlueToothButton->SetPosition(43, 120, 380, 100); TradionalBlueToothButton->SetViewId(TRADIONALBLUETOOTHBUTTON); TradionalBlueToothButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); TradionalBlueToothButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16); @@ -239,14 +214,13 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BluetoothServiceOptionsButton new fail!"); return false; } - BluetoothServiceOptionsButton->SetPosition(43, 360, 380, 100); + BluetoothServiceOptionsButton->SetPosition(43, 240, 380, 100); BluetoothServiceOptionsButton->SetViewId(BLUETOOTHSERVICEOPTIONSBUTTON); BluetoothServiceOptionsButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); BluetoothServiceOptionsButton->SetImagePosition(326, 37); BluetoothServiceOptionsButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ - BlueToothEarPhoneButton->SetOnClickListener(presenter_); BluetoothServiceOptionsButton->SetOnClickListener(presenter_); return true; @@ -258,10 +232,10 @@ namespace OHOS TradionalBlueToothToggleButton = new UIToggleButton(); if (nullptr == TradionalBlueToothToggleButton) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::BlueToothEarPhoneButton new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::TradionalBlueToothToggleButton new fail!"); return false; } - TradionalBlueToothToggleButton->SetPosition(298, 265, 100, 50); + TradionalBlueToothToggleButton->SetPosition(298, 145, 100, 50); TradionalBlueToothToggleButton->SetState(ConfigModel::GetInstance()->GetClassicBlueToothState()); TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); @@ -299,10 +273,8 @@ namespace OHOS return; } BlueToothScrollView->Add(Title); - BlueToothScrollView->Add(BlueToothEarPhoneButton); BlueToothScrollView->Add(TradionalBlueToothButton); BlueToothScrollView->Add(BluetoothServiceOptionsButton); - BlueToothScrollView->Add(BlueToothEarPhoneLabel); BlueToothScrollView->Add(TradionalBlueToothLabel); BlueToothScrollView->Add(BluetoothServiceOptionsLabel); BlueToothScrollView->Add(AttentionLabel); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/ConnectedStatusView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/ConnectedStatusView.h index cb0b68c6a..4fd9233b8 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/ConnectedStatusView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/ConnectedStatusView.h @@ -18,7 +18,6 @@ namespace OHOS typedef enum : uint8_t { PHONECONNECTEDSTATUS_ID = 0, - EARPHONECONNECTESTATUS_ID, BLUETOOTHCONNECTEDSTATUS, MAX_CONNECTEDSTATUS_ID, } CONNECTEDSTATUS_ID; @@ -33,7 +32,6 @@ namespace OHOS UIViewGroup *ConnectedStatusViewInit(void); UIButton *GetCloseButton(); void UpdatePhoneConnectedStatus(int status); - void UpdateEarPhoneConnectedStatus(int status); void UpdateBlueToothConnectedStatus(int status); struct LabelConfig @@ -87,7 +85,6 @@ namespace OHOS UIImageView *background[MAX_CONNECTEDSTATUS_ID]{nullptr}; UIImageView *PhoneConnectedStatusImage{nullptr}; // 显示手机连接状态 - UIImageView *EarPhoneConnectedStatusImage{nullptr}; // 显示耳机连接状态 UIImageView *BluetoothConnectedStatusImage{nullptr}; // 显示蓝牙连接状态 UILabelExt *ConnectedStatusLabel[MAX_CONNECTEDSTATUS_ID]{nullptr}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/PullUpDownView.h index a956666ad..6cb268d7a 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/include/PullUpDownView.h @@ -69,12 +69,9 @@ namespace OHOS /* ---------------------------------- 1.连接状态 ---------------------------------- */ public: bool GetPhoneConnectedStatus(void); - bool GetEarPhoneConnectedStatus(void); bool GetBlueToothConnectedStatus(void); void UpdatePhoneStatus(int status); - void UpdateEarPhoneStatus(int status); void UpdateBlueToothStatus(int status); - void SetPhoneConnectedIsVisible(bool state); private: UIImageView *DropDownConnectedStatusImageViweInit(int16_t x, int16_t y, int16_t w, int16_t h); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/ConnectedStatusView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/ConnectedStatusView.cpp index 9bc59a5cb..bdb765c89 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/ConnectedStatusView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/ConnectedStatusView.cpp @@ -11,7 +11,6 @@ namespace OHOS { static OHOS::ColorType connectedColor[MAX_CONNECTEDSTATUS_ID] = { Color::GetColorFromRGBA(0xff, 0x8f, 0x00, 0xff), - Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff), Color::GetColorFromRGBA(0x01, 0x76, 0xff, 0xff), }; static OHOS::ColorType disconnectedColor = Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff); @@ -60,9 +59,6 @@ namespace OHOS delete PhoneConnectedStatusImage; PhoneConnectedStatusImage = nullptr; - delete EarPhoneConnectedStatusImage; - EarPhoneConnectedStatusImage = nullptr; - delete BluetoothConnectedStatusImage; BluetoothConnectedStatusImage = nullptr; @@ -175,7 +171,7 @@ namespace OHOS bool ConnectedStatusView::initBackground(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectedStatusView::initBackground"); - int background_position_x = 33; + int background_position_x = 97; for (int i = 0; i < MAX_CONNECTEDSTATUS_ID; i++) { background[i] = new UIImageView(); @@ -184,7 +180,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "background[%d] new fail!!", i); return false; } - background[i]->SetPosition(background_position_x + i * 140, 113, 120, 200); + background[i]->SetPosition(background_position_x + i * 152, 113, 120, 200); background[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); background[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); background[i]->SetStyle(STYLE_BORDER_RADIUS, 40); @@ -205,7 +201,7 @@ namespace OHOS } StatusImageParams params = { - .x = 63, + .x = 127, .y = 135, .width = 60, .height = 60, @@ -217,19 +213,7 @@ namespace OHOS group->Add(PhoneConnectedStatusImage); params = { - .x = 203, - .y = 135, - .width = 60, - .height = 60, - .connectedImage = DROPDOWN_EARPHONESCONNECTED, - .disconnectedImage = DROPDOWN_EARPHONESDISCONNECTED, - .isConnected = pullUpDownView->GetEarPhoneConnectedStatus(), - }; - EarPhoneConnectedStatusImage = InitStatusImage(params); - group->Add(EarPhoneConnectedStatusImage); - - params = { - .x = 343, + .x = 279, .y = 135, .width = 60, .height = 60, @@ -242,16 +226,15 @@ namespace OHOS uint16_t deviceName[MAX_CONNECTEDSTATUS_ID] = { STR_PHONE, // 手机 - STR_HEADSET, // 耳机 STR_BLUETOOTH, // 蓝牙 }; // 初始化设备名称数组 - int PhoneAndEarAndBluetooth_position_x = 53; - int ConnectedStatusLabel_position_x = 59; + int PhoneAndEarAndBluetooth_position_x = 117; + int ConnectedStatusLabel_position_x = 123; for (int i = 0; i < MAX_CONNECTEDSTATUS_ID; i++) { - LabelConfig titleConfig = {PhoneAndEarAndBluetooth_position_x + i * 140, 220, 80, 35, 30, 35, deviceName[i]}; + LabelConfig titleConfig = {PhoneAndEarAndBluetooth_position_x + i * 152, 220, 80, 35, 30, 35, deviceName[i]}; PhoneAndEarAndBluetooth[i] = InitLabel(titleConfig); group->Add(PhoneAndEarAndBluetooth[i]); @@ -261,7 +244,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectedStatusLabel[%d] new fail!!", i); return false; } - ConnectedStatusLabel[i]->SetPosition(ConnectedStatusLabel_position_x + i * 140, 258, 70, 27); + ConnectedStatusLabel[i]->SetPosition(ConnectedStatusLabel_position_x + i * 152, 258, 70, 27); ConnectedStatusLabel[i]->SetStyle(STYLE_TEXT_FONT, 23); ConnectedStatusLabel[i]->SetStyle(STYLE_LINE_HEIGHT, 27); ConnectedStatusLabel[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); @@ -270,7 +253,6 @@ namespace OHOS group->Add(ConnectedStatusLabel[i]); } UpdatePhoneConnectedStatus(pullUpDownView->GetPhoneConnectedStatus()); - UpdateEarPhoneConnectedStatus(pullUpDownView->GetEarPhoneConnectedStatus()); UpdateBlueToothConnectedStatus(pullUpDownView->GetBlueToothConnectedStatus()); return true; @@ -345,26 +327,6 @@ namespace OHOS updateConnectionStatus(params); } - // 更新蓝牙耳机连接状态 - void ConnectedStatusView::UpdateEarPhoneConnectedStatus(int status) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectedStatusView::UpdateEarPhoneConnectedStatus"); - - ConnectionStatusParams params = { - .statusImage = EarPhoneConnectedStatusImage, - .statusLabel = ConnectedStatusLabel[EARPHONECONNECTESTATUS_ID], - .status = status, - .connectedImage = DROPDOWN_EARPHONESCONNECTED, - .disconnectedImage = DROPDOWN_EARPHONESDISCONNECTED, - .connectedText = STR_CONNECTED, - .disconnectedText = STR_DISCONNECTED, - .connectedColor = connectedColor[EARPHONECONNECTESTATUS_ID], - .disconnectedColor = disconnectedColor, - }; - - updateConnectionStatus(params); - } - // 更新蓝牙连接状态 void ConnectedStatusView::UpdateBlueToothConnectedStatus(int status) { diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/PullUpDownView.cpp index 9a39bcc9f..613594e70 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/main/src/PullUpDownView.cpp @@ -37,9 +37,6 @@ namespace OHOS // 手机连接状态 static constexpr const char *DROPDOWN_PHONECONNECTED_IMAGE = "/user/res/dropdown/phone_connect.bin"; static constexpr const char *DROPDOWN_PHONEDISCONNECTED_IMAGE = "/user/res/dropdown/phone_disconnect.bin"; - // 耳机连接状态 - static constexpr const char *DROPDOWN_EARPHONESCONNECTED_IMAGE = "/user/res/dropdown/earphones_connect.bin"; - static constexpr const char *DROPDOWN_EARPHONESDISCONNECTED_IMAGE = "/user/res/dropdown/earphones_disconnect.bin"; // 蓝牙连接状态 static constexpr const char *DROPDOWN_BLUETOOTHCONNECTED_IMAGE = "/user/res/dropdown/bluetooth_connect.bin"; static constexpr const char *DROPDOWN_BLUETOOTHDISCONNECTED_IMAGE = "/user/res/dropdown/bluetooth_disconnect.bin"; @@ -122,72 +119,17 @@ namespace OHOS bool PullUpDownView::GetPhoneConnectedStatus(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetPhoneConnectedStatus"); - // uint8_t ret = uapi_dev_runtime_get_ble_connect_stat(); - // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret); - // if (ret == 1) - // return true; - // else - // return false; return SettingModel::GetInstance().GetPhoneConnectStatus(); } - // 获取蓝牙耳机连接状态 - bool PullUpDownView::GetEarPhoneConnectedStatus(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetEarPhoneConnectedStatus"); - // uint8_t ret = uapi_dev_runtime_get_earphone_connect_stat(); - // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "earphone connect stat = %d", ret); - // if (ret == 1) - // return true; - // else - // return false; - - return SettingModel::GetInstance().GetEarPhoneConnectStatus(); - } // 获取蓝牙连接状态 bool PullUpDownView::GetBlueToothConnectedStatus(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetBlueToothConnectedStatus"); - // uint8_t ret = uapi_dev_runtime_get_br_connect_stat(); - // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "br connect stat = %d [0 no connect, 1 a2dp, 2 hfp, 3 both]", ret); - // if (ret != 0) - // return true; - // else - // return false; return SettingModel::GetInstance().GetBlueToothConnectStatus(); } - // 设置蓝牙连接状态是否显示 - void PullUpDownView::SetPhoneConnectedIsVisible(bool state) - { - if (connectedStatusBackgroundButton && showPhoneConnectedStatus && showEarPhoneConnectedStatus && showBluetoothConnectedStatus) - { - if (!state) - { - connectedStatusBackgroundButton->SetPosition(153, 10, 160, 50); - int x = connectedStatusBackgroundButton->GetX(); - int y = connectedStatusBackgroundButton->GetY(); - showPhoneConnectedStatus->SetVisible(true); - showEarPhoneConnectedStatus->SetPosition(x + 68, y + 13); - showBluetoothConnectedStatus->SetPosition(x + 110, y + 13); - } - else - { - connectedStatusBackgroundButton->SetPosition(178, 10, 110, 50); - int x = connectedStatusBackgroundButton->GetX(); - int y = connectedStatusBackgroundButton->GetY(); - showPhoneConnectedStatus->SetVisible(false); - showEarPhoneConnectedStatus->SetPosition(x + 22, y + 13); - showBluetoothConnectedStatus->SetPosition(showEarPhoneConnectedStatus->GetX() + showEarPhoneConnectedStatus->GetWidth() + 18, y + 13); - } - connectedStatusBackgroundButton->Invalidate(); - showPhoneConnectedStatus->Invalidate(); - showEarPhoneConnectedStatus->Invalidate(); - showBluetoothConnectedStatus->Invalidate(); - } - } - // 更新手机连接状态 void PullUpDownView::UpdatePhoneStatus(int status) { @@ -197,38 +139,17 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showPhoneConnectedStatus nullptr"); return; } - // showPhoneConnectedStatus->SetSrc(status ? DROPDOWN_PHONECONNECTED_IMAGE : DROPDOWN_PHONEDISCONNECTED_IMAGE); - // showPhoneConnectedStatus->Invalidate(); if (status) showPhoneConnectedStatus->SetSrc(DROPDOWN_PHONECONNECTED_IMAGE); else showPhoneConnectedStatus->SetSrc(DROPDOWN_PHONEDISCONNECTED_IMAGE); - SetPhoneConnectedIsVisible(status); - if (GetConnectedStatusView() != nullptr) GetConnectedStatusView()->UpdatePhoneConnectedStatus(status); return; } - // 更新蓝牙耳机连接状态 - void PullUpDownView::UpdateEarPhoneStatus(int status) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateEarPhoneStatus"); - if (showEarPhoneConnectedStatus == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus nullptr"); - return; - } - showEarPhoneConnectedStatus->SetSrc(status ? DROPDOWN_EARPHONESCONNECTED_IMAGE : DROPDOWN_EARPHONESDISCONNECTED_IMAGE); - showEarPhoneConnectedStatus->Invalidate(); - - if (GetConnectedStatusView() != nullptr) - GetConnectedStatusView()->UpdateEarPhoneConnectedStatus(status); - - return; - } // 更新蓝牙连接状态 void PullUpDownView::UpdateBlueToothStatus(int status) { @@ -273,7 +194,7 @@ namespace OHOS return; } } - connectedStatusBackgroundButton->SetPosition(153, 10, 160, 50); + connectedStatusBackgroundButton->SetPosition(178, 10, 110, 50); connectedStatusBackgroundButton->SetViewId(CONNECTEDSTATUSBACKGROUNDBUTTON); connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); @@ -297,20 +218,10 @@ namespace OHOS return; } } - /* -------------------------------- 显示耳机连接状态 -------------------------------- */ - if (showEarPhoneConnectedStatus == nullptr) - { - showEarPhoneConnectedStatus = DropDownConnectedStatusImageViweInit(x + 68, y + 13, 24, 24); - if (showEarPhoneConnectedStatus == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus new fail"); - return; - } - } /* -------------------------------- 显示蓝牙连接状态 -------------------------------- */ if (showBluetoothConnectedStatus == nullptr) { - showBluetoothConnectedStatus = DropDownConnectedStatusImageViweInit(x + 110, y + 13, 24, 24); + showBluetoothConnectedStatus = DropDownConnectedStatusImageViweInit(x + 68, y + 13, 24, 24); if (showBluetoothConnectedStatus == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showBluetoothConnectedStatus new fail"); @@ -319,12 +230,10 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ UpdatePhoneStatus(GetPhoneConnectedStatus()); - UpdateEarPhoneStatus(GetEarPhoneConnectedStatus()); UpdateBlueToothStatus(GetBlueToothConnectedStatus()); /* -------------------------------------------------------------------------- */ group[DROPDOWNVIEW]->Add(connectedStatusBackgroundButton); group[DROPDOWNVIEW]->Add(showPhoneConnectedStatus); - group[DROPDOWNVIEW]->Add(showEarPhoneConnectedStatus); group[DROPDOWNVIEW]->Add(showBluetoothConnectedStatus); } @@ -340,11 +249,6 @@ namespace OHOS delete showPhoneConnectedStatus; showPhoneConnectedStatus = nullptr; } - if (showEarPhoneConnectedStatus != nullptr) - { - delete showEarPhoneConnectedStatus; - showEarPhoneConnectedStatus = nullptr; - } if (showBluetoothConnectedStatus != nullptr) { delete showBluetoothConnectedStatus; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp index e0b0082d1..2189e8e1d 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/makephone/src/MainCallingPresenter.cpp @@ -431,7 +431,7 @@ bool MainCallingPresenter::OnClick(UIView& view, const ClickEvent& event) } else if (strcmp(view.GetViewId(), "callingheadset") == 0) { - NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); + // NativeAbility::GetInstance().EnterSlice(VIEW_BLUETOOTH_EARPHONE); } // #endif diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp index 65f47c18c..f02943741 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/MusicPlayerSourceView.cpp @@ -287,6 +287,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothHeadsetLableButton new fail!!"); return false; } + bluetoothHeadsetLableButton->SetVisible(false); return true; } @@ -346,6 +347,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothHeadsetLabel new fail!!"); return false; } + bluetoothHeadsetLabel->SetVisible(false); /* ---------------------- bluetoothHeadsetConnectState ---------------------- */ labelConfig.top = 413; labelConfig.fontSize = 23; @@ -357,6 +359,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothHeadsetConnectState new fail!!"); return false; } + bluetoothHeadsetConnectState->SetVisible(false); return true; } @@ -409,6 +412,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail"); return false; } + bluetoothHeadsetImage->SetVisible(false); return true; } @@ -467,8 +471,8 @@ namespace OHOS return nullptr; } - UpdateBluetoothHeadsetConnectLabel(); - UpdateBluetoothHeadSetViewIsVisible(); + // UpdateBluetoothHeadsetConnectLabel(); + // UpdateBluetoothHeadSetViewIsVisible(); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(titleLabel); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/PlayersView.cpp index 842da114a..f1f0893a8 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/player/src/PlayersView.cpp @@ -1023,10 +1023,10 @@ namespace OHOS MusicSourceLabelSetText(STR_WATCH_MUSIC); /*手表音乐*/ SetMusicPlayerButtonIsTouchable(false); } - if (musicPlayerSourceView) - { - musicPlayerSourceView->UpdateBluetoothHeadSetViewIsVisible(); - } + // if (musicPlayerSourceView) + // { + // musicPlayerSourceView->UpdateBluetoothHeadSetViewIsVisible(); + // } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdatePlayerView over!!"); } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/settings/src/SettingModel.cpp index ecf67875e..86cee90c9 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -137,6 +137,8 @@ namespace OHOS // 更新耳机连接状态 void SettingModel::UpdateEarPhoneConnectStatus(bool status) { + /*屏蔽蓝牙耳机*/ + #if 0 earphoneConnectStatus = status; if (PullUpDownView::GetInstance() != nullptr) { @@ -150,6 +152,7 @@ namespace OHOS { MusicPlayerSourceView::GetInstance()->UpdateBluetoothHeadsetConnectLabel(); } + #endif } // 更新蓝牙连接状态 -- 2.17.1