~AiVoiceConnectingView();
static AiVoiceConnectingView *GetInstance(void);
UIScrollView *CreateAiVoiceConnectingView(void);
-
+ UIScrollView *CreateAiVoiceConnectingView(uint8_t);
private:
const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
void FreeImagePathsArray(const char **imagePaths, const int numImages);
bool CreateAiVoiceConnectingViewButton(void);
bool CreateAivoiceConnectingImageAnimator(void);
bool CreateAiVoiceConnectingScrollView(void);
+ bool CreateAiVoiceConnectingScrollView(uint8_t);
void ClearAll(void);
UIScrollView *scrollView{nullptr};
UILabelExt *title{nullptr};
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_Y = 153;
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_W = 100;
static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_H = 120;
- static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 200; // 图片更新间隔
+ static constexpr int16_t AIVOICE_CONNECTING_IMAGE_ANIMATOR_DELAY = 50; // 图片更新间隔
static constexpr const char *AIVoiceListeningImagePaths = "/user/res/connect/";
static AiVoiceConnectingView *g_pAiVoiceConnecting{nullptr};
return true;
}
+ bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(uint8_t type)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!");
+ return false;
+ }
+ scrollView->SetPosition(0, 0, 466, 466);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+
+ return true;
+ }
+
+
UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
return scrollView;
}
+ UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(uint8_t type)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
+ if (!CreateAiVoiceConnectingScrollView(type) || !CreateAivoiceConnectingImageAnimator()|| !CreateAiVoiceConnectingViewLabel() )
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!");
+ return nullptr;
+ }
+ scrollView->Add(connectingAnimatorView);
+ return scrollView;
+ }
+
}
\ No newline at end of file
#endif\r
#include "Bluetooyhpabpserver.h"\r
#include "bletest.h"\r
+#include "ConfigModelC.h"\r
namespace OHOS {\r
\r
#define BT_SPP_TASK_STACK_SIZE 2048\r
memcpy(&BtGapPair_bdAddr,bdAddr,sizeof(bd_addr_t));\r
// if(status == GAP_PAIR_PAIRED)\r
// { \r
+ \r
+ \r
+ //}\r
+ //uapi_a2dp_snk_connect();\r
+ //a2dp_snk_connect(bdAddr);\r
if(cm_custom_ble_service_on_flag() && !get_ble_pair())\r
{\r
+ if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
uapi_a2dp_snk_connect();\r
+ //uapi_reconnect();\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect");\r
}\r
- \r
- //}\r
- //uapi_a2dp_snk_connect();\r
- //a2dp_snk_connect(bdAddr);\r
- \r
if (status == GAP_PAIR_PAIRED) {\r
if (ConnectPhonePresenter::GetInstance() != nullptr) {\r
NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
}\r
+ \r
}\r
}\r
\r
#include "components/ui_button.h"
#include "components/ui_image_view.h"
#include "components/ui_toggle_button.h"
+#include "aivoice/include/AiVoiceConnectingView.h"
namespace OHOS
{
// 返回setting视图界面
uint16_t textId;
uint8_t lineBreakMode; // 断行模式。
};
+
+ typedef enum
+ {
+ CONNECT_HFP = 0,
+ DISCONNECT_HFP,
+ CONNECT_A2DP,
+ DISCONNECT_A2DP,
+ } BluetoothServiceOptionsView_state;
+
BluetoothServiceOptionsView();
virtual ~BluetoothServiceOptionsView();
static BluetoothServiceOptionsView *GetInstance(void);
void ClearAll(void);
UIToggleButton *GetHFP_ToggleButton(void);
UIToggleButton *GetA2DP_ToggleButton(void);
-
+ void show_connecting_view(bool data);
+ void Button_UPdata(void);
+ bool init_connect_timer(uint8_t type);
+ bool get_connectview_Visible(void);
public:
virtual void OnStart() override;
virtual void OnSetUpView() override;
UIImageView *A2DP_Image{nullptr};
UIToggleButton *HFP_ToggleButton{nullptr}; // HFP
UIToggleButton *A2DP_ToggleButton{nullptr}; // A2DP
+ UIScrollView * connectingScrollView{nullptr};
+ AiVoiceConnectingView* p_AiVoiceConnectingView{nullptr};
+
bool initViewStatus{false};
};
}
UIToggleButton *toggleButton = dynamic_cast<UIToggleButton *>(&view);
if (toggleButton != nullptr)
{
+ classicBlueToothView->show_connecting_view(true);
if (toggleButton->GetState() == true)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
+ //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
if (it->second == "HFP")
{
ConfigModel::GetInstance()->SetHFPState(true);
//enable_hfp_service(true);
uapi_hfp_connect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP);
+
}
else if (it->second == "A2DP")
{
ConfigModel::GetInstance()->SetA2DPState(true);
uapi_a2dp_snk_connect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_A2DP);
//enable_a2dp_service(true);
}
}
else
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
if (it->second == "HFP")
{
ConfigModel::GetInstance()->SetHFPState(false);
//enable_hfp_service(false);
uapi_hfp_disconnect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
// errcode_t ret = gap_ble_set_ctkd_enable(false);
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
}
ConfigModel::GetInstance()->SetA2DPState(false);
uapi_a2dp_snk_disconnect();
+ classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::DISCONNECT_HFP);
// uapi_hfp_disconnect();
- // uapi_disconnect_remote_device();
+ //uapi_disconnect_remote_device();
// errcode_t ret = gap_ble_set_ctkd_enable(false);
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gap_ble_set_ctkd_enable ret = %u", ret);
//bluetooth_set_auto_reconnect(1);
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::OnDragEnd");
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
{
+ if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
NativeAbility::GetInstance().Back();
}
// 如果是power键,且是亮屏状态,按键释放就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
{
+ if(! BluetoothServiceOptionsView::GetInstance()->get_connectview_Visible())
NativeAbility::GetInstance().Back();
}
return true;
#include "phoneservice/include/PhoneService.h"
#include "BluetoothModel.h"
#include "ui_resource_string.h"
+#include "cmsis_os2.h"
+
namespace OHOS
{
static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr};
delete A2DP_ToggleButton;
A2DP_ToggleButton = nullptr;
}
+ if(p_AiVoiceConnectingView)
+ {
+ delete p_AiVoiceConnectingView;
+ p_AiVoiceConnectingView=nullptr;
+ }
+ if(connectingScrollView)
+ {
+ delete connectingScrollView;
+ connectingScrollView = nullptr;
+ }
delete BlueToothScrollView;
BlueToothScrollView = nullptr;
}
}
}
+ static osTimerId_t MG_TEST_timer=NULL;
+ static uint8_t button_state=0;
+ static uint8_t count_num=0;
+
+ bool BluetoothServiceOptionsView::get_connectview_Visible(void)
+ {
+ return connectingScrollView->IsVisible();
+ }
+
+ void connectTimerCallBack(int data)
+ {
+ bool connect_state=false;
+ count_num++;
+ switch (button_state)
+ {
+ case BluetoothServiceOptionsView::CONNECT_HFP:
+ if(uapi_hfp_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_HFP:
+ if(!uapi_hfp_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::CONNECT_A2DP:
+ if(uapi_a2dp_snk_get_device_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+ if(!uapi_a2dp_snk_get_device_connect_state())
+ {
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ connect_state=true;
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ if(count_num==3 || connect_state)
+ {
+ if( BluetoothServiceOptionsView::GetInstance())
+ BluetoothServiceOptionsView::GetInstance()->show_connecting_view(false);
+ osTimerStop(MG_TEST_timer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+ }
+ else if(count_num==2)
+ {
+ //仅尝试重连一次
+ switch (button_state)
+ {
+ case BluetoothServiceOptionsView::CONNECT_HFP:
+ //uapi_hfp_connect();
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_HFP:
+ //uapi_hfp_disconnect();
+ break;
+ case BluetoothServiceOptionsView::CONNECT_A2DP:
+ // uapi_a2dp_snk_connect();
+ break;
+ case BluetoothServiceOptionsView::DISCONNECT_A2DP:
+ //uapi_a2dp_snk_disconnect();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ bool BluetoothServiceOptionsView::init_connect_timer(uint8_t type)
+ {
+ uint32_t tick;
+ osStatus_t retTimer;
+ count_num=0;
+ button_state=type;
+
+ if(MG_TEST_timer)
+ {
+ osTimerStop(MG_TEST_timer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+
+ }
+ MG_TEST_timer = osTimerNew((osTimerFunc_t)connectTimerCallBack, osTimerPeriodic, NULL, NULL);
+ tick =1500;
+ retTimer = osTimerStart(MG_TEST_timer, tick);
+ if (retTimer != osOK && MG_TEST_timer != NULL) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+ osTimerDelete(MG_TEST_timer);
+ MG_TEST_timer = NULL;
+ return false;
+ }
+ return true;
+ }
+
+
bool BluetoothServiceOptionsView::SetUpBlueToothScrollView(void)
{
BlueToothScrollView = new UIScrollView();
{
BluetoothServiceOptionsViewInit();
initViewStatus = true;
+
}
// 增加按键监听
RootView::GetInstance()->SetOnKeyActListener(keyactListener);
}
+ void BluetoothServiceOptionsView::show_connecting_view(bool data)
+ {
+
+ connectingScrollView->SetVisible(data);
+ if(data==false)
+ {
+ A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+ HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+ }
+ }
+
+ void BluetoothServiceOptionsView::Button_UPdata(void)
+ {
+
+ A2DP_ToggleButton->SetState(uapi_a2dp_snk_get_device_connect_state());
+ HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState());
+
+ }
+
void BluetoothServiceOptionsView::OnSetUpView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnSetUpView");
BlueToothScrollView->Add(A2DP_Label);
BlueToothScrollView->Add(HFP_ToggleButton);
BlueToothScrollView->Add(A2DP_ToggleButton);
+ p_AiVoiceConnectingView = new AiVoiceConnectingView();
+
+ connectingScrollView= p_AiVoiceConnectingView->CreateAiVoiceConnectingView(1);
+ connectingScrollView->SetVisible(false);
+ connectingScrollView->SetDraggable(false);
+ BlueToothScrollView->Add(connectingScrollView);
+
RootView::GetInstance()->Add(BlueToothScrollView);
Draw();
}
#include "settings/include/SettingModel.h"
#include "main/include/PullUpDownView.h"
#include "ui_resource_string.h"
+#include "classicbluetooth/include/BluetoothServiceOptionsView.h"
namespace OHOS
{
SettingModel::SettingModel() {}
{
PullUpDownView::GetInstance()->UpdateEarPhoneStatus(status);
}
+ if(BluetoothServiceOptionsView::GetInstance())
+ {
+ BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+ }
}
// 更新蓝牙连接状态
{
PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);
}
+ if(BluetoothServiceOptionsView::GetInstance())
+ {
+ BluetoothServiceOptionsView::GetInstance()->Button_UPdata();
+ }
}
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! \r\n");\r
// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_DISCONNECTED!!! svr_alipay_get_adv_start_state %d alipay_get_binding_status:%d\r\n",svr_alipay_get_adv_start_state(),alipay_get_binding_status());\r
// if(AdverFlag == true){\r
- free_ble_data(); \r
- svr_ble_adv_start(); \r
+ free_ble_data(); \r
+ if(cm_custom_ble_service_on_flag()) \r
+ svr_ble_adv_start();\r
+\r
ble_disconnect_ok(); \r
// } \r
} else {\r
\r
\r
}else{\r
+ \r
bd_addr_t bdaddr={0};\r
uapi_get_br_address(&bdaddr);\r
if(false==(bt_is_acl_connected(&bdaddr)))\r
}\r
else\r
{\r
+ if(cm_get_A2DP_switch() || cm_get_HFP_switch())\r
uapi_a2dp_snk_connect();\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_a2dp_snk_connect!!! \r\n");\r
}\r