mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
!3749 LayoutInspector支持Stage模型
Merge pull request !3749 from 张荣杰/dev1107
This commit is contained in:
@@ -42,6 +42,8 @@ using StartServer = void (*)(const std::string&);
|
||||
using SendMessage = void (*)(const std::string&);
|
||||
using StopServer = void (*)(const std::string&);
|
||||
using StoreMessage = void (*)(int32_t, const std::string&);
|
||||
using StoreInspectorInfo = void (*)(const std::string&, const std::string&);
|
||||
using SetSwitchCallBack = void (*)(const std::function<void(bool)>& setSwitchStatus);
|
||||
using RemoveMessage = void (*)(int32_t);
|
||||
using WaitForDebugger = bool (*)();
|
||||
|
||||
@@ -113,6 +115,14 @@ bool ConnectServerManager::AddInstance(int32_t instanceId, const std::string& in
|
||||
}
|
||||
}
|
||||
|
||||
auto setSwitchCallBack = reinterpret_cast<SetSwitchCallBack>(
|
||||
dlsym(handlerConnectServerSo_, "SetSwitchCallBack"));
|
||||
if (setSwitchCallBack == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'setSwitchCallBack'");
|
||||
return false;
|
||||
}
|
||||
setSwitchCallBack(std::bind(&ConnectServerManager::SetLayoutInspectorStatus, this, std::placeholders::_1));
|
||||
|
||||
// Get the message including information of new instance, which will be send to IDE.
|
||||
std::string message = GetInstanceMapMessage("addInstance", instanceId, instanceName);
|
||||
|
||||
@@ -186,4 +196,24 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
}
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void ConnectServerManager::SendInspector(const std::string& jsonTreeStr, const std::string& jsonSnapshotStr)
|
||||
{
|
||||
auto sendMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendMessage"));
|
||||
if (sendMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'SendMessage'");
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessage(jsonTreeStr);
|
||||
sendMessage(jsonSnapshotStr);
|
||||
auto storeInspectorInfo = reinterpret_cast<StoreInspectorInfo>(
|
||||
dlsym(handlerConnectServerSo_, "StoreInspectorInfo"));
|
||||
if (storeInspectorInfo == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'StoreInspectorInfo'");
|
||||
return;
|
||||
}
|
||||
storeInspectorInfo(jsonTreeStr, jsonSnapshotStr);
|
||||
}
|
||||
|
||||
} // namespace OHOS::AbilityRuntime
|
||||
@@ -26,9 +26,17 @@ public:
|
||||
|
||||
void StartConnectServer(const std::string& bundleName);
|
||||
void StopConnectServer();
|
||||
|
||||
void SetLayoutInspectorStatus(bool status)
|
||||
{
|
||||
layoutInspectorStatus_ = status;
|
||||
}
|
||||
bool GetlayoutInspectorStatus() const
|
||||
{
|
||||
return layoutInspectorStatus_;
|
||||
}
|
||||
bool AddInstance(int32_t instanceId, const std::string& instanceName = "PandaDebugger");
|
||||
void RemoveInstance(int32_t instanceId);
|
||||
void SendInspector(const std::string& jsonTreeStr, const std::string& jsonSnapshotStr);
|
||||
|
||||
private:
|
||||
ConnectServerManager() = default;
|
||||
@@ -39,7 +47,7 @@ private:
|
||||
|
||||
std::mutex mutex_;
|
||||
std::unordered_map<int32_t, std::string> instanceMap_;
|
||||
|
||||
bool layoutInspectorStatus_ = false;
|
||||
ConnectServerManager(const ConnectServerManager&) = delete;
|
||||
ConnectServerManager(ConnectServerManager&&) = delete;
|
||||
ConnectServerManager& operator=(const ConnectServerManager&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user