#include "../notify/debug_output_notification/debug_output_notification_adapter.h"
#include "../notify/debug_output_notification/debug_output_notification_itemview.h"
#include <custom_runtime.h>
+#include <custom_utils.h>
+#include "bluetooth/include/BluetoothModel.h"
namespace OHOS
{
DebugOutputAdapter *debugOutputAdapter{nullptr};
UILabel *debugOutputLabel{nullptr};
UILabelButton *debugOutputLabelButton{nullptr};
+ UILabelButton *debugOutputbleServiceLabelButton{nullptr};
+ static constexpr const char *DEBUGOUTPUTLABELBUTTON = "debugOutputLabelButton";
+ static constexpr const char *DEBUGOUTPUTBLESERVICELABELBUTTON = "debugOutputbleServiceLabelButton";
/* -------------------------------------------------------------------------- */
void DebugOutputViewEventListener::InitDebugOutputItem()
{
int index = 0;
- debugOutputItemInfo[index++] = {0, "debugOutpt"}; // 标题:设置()
+ debugOutputItemInfo[index++] = {0, "exit"}; // 标题:设置()
debugOutputItemInfo[index++] = {1, "bt_ble_connectstat"};
debugOutputItemInfo[index++] = {2, "cat1_runtime_status_t"};
debugOutputItemInfo[index++] = {3, "runtime_status_t"};
static DebugOutputViewEventListener instance;
return instance;
}
+ static std::string getCurrentWatchMacAddress()
+ {
+ uint32_t len = 32;
+ char *buf_btaddr = (char *)malloc(32);
+ if (buf_btaddr == NULL)
+ return "";
+ uint8_t ret = uapi_get_btaddr((uint8_t *)buf_btaddr, &len);
+ std::string str = std::string(buf_btaddr);
+ printf("%s | %s \n", buf_btaddr, str.c_str());
+ free(buf_btaddr);
+ return (str);
+ }
std::string DebugOutputViewEventListener::get_bt_runtime_status_t(void)
{
result += "ad2p_service_handler: ";
result += "spp_service_handler: ";
result += "hfp_service_handler: ";
+ result += "localAddress:" + (getCurrentWatchMacAddress()) + " ";
+ result += "ble广播状态:" + std::to_string(BluetoothModel::GetInstance()->GetAdvStartState());
+
+ // 蓝牙ble广播开关,基础信息如,地址,广播状态
return result;
}
bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
+ std::string viewId = view.GetViewId();
int viewIndex;
- if (&view == debugOutputLabelButton)
+ std::string str;
+ if (viewId == DEBUGOUTPUTBLESERVICELABELBUTTON) // 开启ble广播
+ {
+ if (BluetoothModel::GetInstance()->GetAdvStartState() == false) // 如果广播是关的就去开启广播
+ BleAdvStart();
+ return true;
+ }
+ else if (viewId == DEBUGOUTPUTLABELBUTTON) // 点击的是刷新按钮
{
viewIndex = GetCurViewIndex();
}
- else
+ else // 如果点击的是列表中的itemview
{
DebugOutputItemView *debugOutputItemView = static_cast<DebugOutputItemView *>(&view);
viewIndex = debugOutputItemView->GetViewIndex();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewIndex:%d", viewIndex);
if (viewIndex == 0)
{
+ NotificationManager::GetInstance()->StopNotify();
return true;
}
ChangeView(0, 1);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputLabel is nullptr");
return false;
}
- std::string str;
switch (viewIndex)
{
case 1:
{
if (hideView == 1)
{
- DebugGroupView->Remove(DebugScrollView[hideView]);
- if (DebugScrollView[hideView] != nullptr)
+ DebugGroupView->Remove(DebugScrollView[1]);
+ if (DebugScrollView[1] != nullptr)
{
- DebugScrollView[hideView]->RemoveAll();
+ DebugScrollView[1]->RemoveAll();
delete debugOutputLabel;
debugOutputLabel = nullptr;
}
debugOutputLabelButton->SetPosition(43, debugOutputLabel->GetY() + debugOutputLabel->GetHeight() + 20);
debugOutputLabelButton->Resize(380, 100);
+ debugOutputLabelButton->SetViewId(DEBUGOUTPUTLABELBUTTON);
debugOutputLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
debugOutputLabelButton->SetText("刷新");
debugOutputLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
DebugScrollView[0]->SetHorizontalScrollState(false);
DebugScrollView[0]->SetTouchable(true);
DebugScrollView[0]->SetThrowDrag(true);
+ DebugScrollView[0]->SetScrollBlankSize(70);
+ DebugScrollView[0]->SetReboundSize(30);
DebugGroupView->Add(DebugScrollView[0]);
/* -------------------------------------------------------------------------- */
if (debugOutputAdapter == nullptr)
return nullptr;
}
}
- debugOutputList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ debugOutputList->SetPosition(0, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
debugOutputList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
debugOutputList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐
debugOutputList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。
debugOutputList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/
debugOutputList->SetAdapter(debugOutputAdapter);
debugOutputList->RefreshList();
- debugOutputList->SetReboundSize(30);
+ // debugOutputList->SetReboundSize(30);
// debugOutputList->SetScrollBlankSize(30);
debugOutputList->SetRotateFactor(1.0);
DebugScrollView[0]->Add(debugOutputList);
/* -------------------------------------------------------------------------- */
+ if (debugOutputbleServiceLabelButton == nullptr)
+ {
+ debugOutputbleServiceLabelButton = new UILabelButton();
+ if (debugOutputbleServiceLabelButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "debugOutputbleServiceLabelButton is new fail!!");
+ return nullptr;
+ }
+ }
+ debugOutputbleServiceLabelButton->SetPosition(43, debugOutputList->GetY() + debugOutputList->GetHeight());
+ debugOutputbleServiceLabelButton->SetViewId(DEBUGOUTPUTBLESERVICELABELBUTTON);
+ debugOutputbleServiceLabelButton->Resize(380, 100);
+ debugOutputbleServiceLabelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ debugOutputbleServiceLabelButton->SetText("开启ble广播");
+ debugOutputbleServiceLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
+ debugOutputbleServiceLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ debugOutputbleServiceLabelButton->SetOnClickListener(clickListener);
+ DebugScrollView[0]->Add(debugOutputbleServiceLabelButton);
+ /* -------------------------------------------------------------------------- */
NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeDebugOutputMainView);
/* -------------------------------------------------------------------------- */
+ enable_drag(0, 1);
+ enable_drag(1, 1);
}
return DebugGroupView;
}
delete debugOutputAdapter;
debugOutputAdapter = nullptr;
+ delete debugOutputbleServiceLabelButton;
+ debugOutputbleServiceLabelButton = nullptr;
+
delete DebugScrollView[0];
DebugScrollView[0] = nullptr;
}
DebugGroupView = nullptr;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeDebugOutputMainView success!!");
}
+ if (uapi_dev_runtime_get_saveele_status() == 1) // 如果省电模式开启,该调试窗口关闭时候恢复原状态
+ {
+ enable_drag(0, 0);
+ enable_drag(1, 0);
+ }
return;
}
}