mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
divide data
Signed-off-by: lzr <liuzengrui1@huawei.com>
This commit is contained in:
parent
b737372db2
commit
fbbdc5e5dd
@ -21,7 +21,7 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
int32_t UIContentServiceProxy::GetInspectorTree(const EventCallback& eventCallback)
|
||||
int32_t UIContentServiceProxy::GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -30,6 +30,10 @@ int32_t UIContentServiceProxy::GetInspectorTree(const EventCallback& eventCallba
|
||||
LOGW("GetInspectorTree write interface token failed");
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->RegisterGetInspectorTreeCallback(eventCallback);
|
||||
if (Remote()->SendRequest(UI_CONTENT_SERVICE_GET_TREE, data, reply, option) != ERR_NONE) {
|
||||
LOGW("GetInspectorTree send request failed");
|
||||
@ -78,7 +82,8 @@ int32_t UIContentServiceProxy::RegisterClickEventCallback(const EventCallback& e
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->RegisterClickEventCallback(eventCallback);
|
||||
if (Remote()->SendRequest(REGISTER_CLICK_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -98,7 +103,8 @@ int32_t UIContentServiceProxy::RegisterSearchEventCallback(const EventCallback&
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->RegisterSearchEventCallback(eventCallback);
|
||||
if (Remote()->SendRequest(REGISTER_SEARCH_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -118,7 +124,8 @@ int32_t UIContentServiceProxy::RegisterRouterChangeEventCallback(const EventCall
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->RegisterRouterChangeEventCallback(eventCallback);
|
||||
if (Remote()->SendRequest(REGISTER_ROUTER_CHANGE_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -138,7 +145,8 @@ int32_t UIContentServiceProxy::RegisterComponentChangeEventCallback(const EventC
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->RegisterComponentChangeEventCallback(eventCallback);
|
||||
if (Remote()->SendRequest(REGISTER_COMPONENT_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -158,7 +166,8 @@ int32_t UIContentServiceProxy::UnregisterClickEventCallback()
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->UnregisterClickEventCallback();
|
||||
if (Remote()->SendRequest(UNREGISTER_CLICK_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -178,7 +187,8 @@ int32_t UIContentServiceProxy::UnregisterSearchEventCallback()
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->UnregisterSearchEventCallback();
|
||||
if (Remote()->SendRequest(UNREGISTER_SEARCH_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -198,7 +208,8 @@ int32_t UIContentServiceProxy::UnregisterRouterChangeEventCallback()
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->UnregisterRouterChangeEventCallback();
|
||||
if (Remote()->SendRequest(UNREGISTER_ROUTER_CHANGE_EVENT, data, reply, option) != ERR_NONE) {
|
||||
@ -218,7 +229,8 @@ int32_t UIContentServiceProxy::UnregisterComponentChangeEventCallback()
|
||||
return FAILED;
|
||||
}
|
||||
if (report_ == nullptr) {
|
||||
LOGW("reportStub is nullptr,connect is not execute");
|
||||
LOGW("reportStub is nullptr");
|
||||
return FAILED;
|
||||
}
|
||||
report_->UnregisterComponentChangeEventCallback();
|
||||
if (Remote()->SendRequest(UNREGISTER_COMPONENT_EVENT, data, reply, option) != ERR_NONE) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
|
||||
namespace OHOS::Ace {
|
||||
|
||||
int32_t UIContentServiceStubImpl::GetInspectorTree(const EventCallback& eventCallback)
|
||||
int32_t UIContentServiceStubImpl::GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback)
|
||||
{
|
||||
UiSessionManager::GetInstance().GetInspectorTree();
|
||||
return NO_ERROR;
|
||||
|
@ -93,7 +93,7 @@ void UiReportProxy::ReportSearchEvent(const std::string& data)
|
||||
}
|
||||
}
|
||||
|
||||
void UiReportProxy::ReportInspectorTreeValue(const std::string& data)
|
||||
void UiReportProxy::ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart)
|
||||
{
|
||||
MessageParcel messageData;
|
||||
MessageParcel reply;
|
||||
@ -106,6 +106,14 @@ void UiReportProxy::ReportInspectorTreeValue(const std::string& data)
|
||||
LOGW("ReportInspectorTreeValue write data failed");
|
||||
return;
|
||||
}
|
||||
if (!messageData.WriteInt32(partNum)) {
|
||||
LOGW("ReportInspectorTreeValue write data failed");
|
||||
return;
|
||||
}
|
||||
if (!messageData.WriteBool(isLastPart)) {
|
||||
LOGW("ReportInspectorTreeValue write data failed");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(REPORT_INSPECTOR_VALUE, messageData, reply, option) != ERR_NONE) {
|
||||
LOGW("ReportInspectorTreeValue send request failed");
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ int32_t UiReportStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag
|
||||
break;
|
||||
}
|
||||
case REPORT_INSPECTOR_VALUE: {
|
||||
ReportInspectorTreeValue(result);
|
||||
int32_t partNum = data.ReadInt32();
|
||||
bool isLastPart = data.ReadBool();
|
||||
ReportInspectorTreeValue(result, partNum, isLastPart);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -82,10 +84,10 @@ void UiReportStub::ReportSearchEvent(const std::string& data)
|
||||
}
|
||||
}
|
||||
|
||||
void UiReportStub::ReportInspectorTreeValue(const std::string& data)
|
||||
void UiReportStub::ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart)
|
||||
{
|
||||
if (inspectorTreeCallback_ != nullptr) {
|
||||
inspectorTreeCallback_(data);
|
||||
inspectorTreeCallback_(data, partNum, isLastPart);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +96,8 @@ void UiReportStub::RegisterClickEventCallback(const EventCallback& eventCallback
|
||||
clickEventCallback_ = std::move(eventCallback);
|
||||
}
|
||||
|
||||
void UiReportStub::RegisterGetInspectorTreeCallback(const EventCallback& eventCallback)
|
||||
void UiReportStub::RegisterGetInspectorTreeCallback(
|
||||
const std::function<void(std::string, int32_t, bool)>& eventCallback)
|
||||
{
|
||||
inspectorTreeCallback_ = std::move(eventCallback);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
|
||||
namespace OHOS::Ace {
|
||||
std::mutex UiSessionManager::mutex_;
|
||||
|
||||
constexpr int32_t ONCE_IPC_SEND_DATA_MAX_SIZE = 4096;
|
||||
UiSessionManager& UiSessionManager::GetInstance()
|
||||
{
|
||||
static UiSessionManager instance_;
|
||||
@ -175,7 +175,15 @@ void UiSessionManager::ReportInspectorTreeValue(const std::string& data)
|
||||
for (auto pair : reportObjectMap_) {
|
||||
auto reportService = iface_cast<ReportService>(pair.second);
|
||||
if (reportService != nullptr) {
|
||||
reportService->ReportInspectorTreeValue(data);
|
||||
int partSize = data.size() / ONCE_IPC_SEND_DATA_MAX_SIZE;
|
||||
for (int i = 0; i <= partSize; i++) {
|
||||
if (i != partSize) {
|
||||
reportService->ReportInspectorTreeValue(
|
||||
data.substr(i * ONCE_IPC_SEND_DATA_MAX_SIZE, ONCE_IPC_SEND_DATA_MAX_SIZE), i + 1, false);
|
||||
} else {
|
||||
reportService->ReportInspectorTreeValue(data.substr(i * ONCE_IPC_SEND_DATA_MAX_SIZE), i + 1, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGW("report component event failed,process id:%{public}d", pair.first);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace OHOS::Ace {
|
||||
class ACE_FORCE_EXPORT UIContentServiceProxy : public IRemoteProxy<IUiContentService> {
|
||||
public:
|
||||
explicit UIContentServiceProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IUiContentService>(impl) {};
|
||||
virtual int32_t GetInspectorTree(const EventCallback& eventCallback) override;
|
||||
virtual int32_t GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback) override;
|
||||
virtual int32_t Connect() override;
|
||||
virtual int32_t RegisterClickEventCallback(const EventCallback& eventCallback) override;
|
||||
virtual int32_t RegisterRouterChangeEventCallback(const EventCallback& eventCallback) override;
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
* @description: define get the current page inspector tree info interface
|
||||
* @return: result number
|
||||
*/
|
||||
virtual int32_t GetInspectorTree(const EventCallback& eventCallback) = 0;
|
||||
virtual int32_t GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback) = 0;
|
||||
|
||||
/**
|
||||
* @description: define SA process and current process connect interface
|
||||
@ -137,7 +137,8 @@ public:
|
||||
/**
|
||||
* @description: define reports inspector value to the proxy interface
|
||||
*/
|
||||
virtual void ReportInspectorTreeValue(const std::string& data) = 0;
|
||||
virtual void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) = 0;
|
||||
virtual void ReportWebUnfocusEvent(int64_t accessibilityId, const std::string& data) = 0;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int32_t GetInspectorTree(const EventCallback& eventCallback) override;
|
||||
int32_t GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback) override;
|
||||
int32_t RegisterClickEventCallback(const EventCallback& eventCallback) override;
|
||||
int32_t RegisterRouterChangeEventCallback(const EventCallback& eventCallback) override;
|
||||
int32_t RegisterSearchEventCallback(const EventCallback& eventCallback) override;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
/**
|
||||
* @description: notify stub side to report inspector value
|
||||
*/
|
||||
void ReportInspectorTreeValue(const std::string& data) override;
|
||||
void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) override;
|
||||
|
||||
void OnComponentChange(const std::string& key, const std::string& value);
|
||||
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
* @description: register a callback when get inspector tree
|
||||
* @param eventCallback callback to be performed
|
||||
*/
|
||||
void RegisterGetInspectorTreeCallback(const EventCallback& eventCallback);
|
||||
void RegisterGetInspectorTreeCallback(const std::function<void(std::string, int32_t, bool)>& eventCallback);
|
||||
|
||||
/**
|
||||
* @description: unregister the click callback last register
|
||||
@ -102,14 +102,14 @@ public:
|
||||
/**
|
||||
* @description: report whole inspectorTree for SA
|
||||
*/
|
||||
void ReportInspectorTreeValue(const std::string& data) override;
|
||||
void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) override;
|
||||
|
||||
private:
|
||||
EventCallback clickEventCallback_;
|
||||
EventCallback searchEventCallback_;
|
||||
EventCallback RouterChangeEventCallback_;
|
||||
EventCallback ComponentChangeEventCallback_;
|
||||
EventCallback inspectorTreeCallback_;
|
||||
std::function<void(std::string, int32_t, bool)> inspectorTreeCallback_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H
|
||||
|
Loading…
Reference in New Issue
Block a user