diff --git a/inspector/connect_inspector.cpp b/inspector/connect_inspector.cpp index 200d2842bc081437fe47a030c1b10cfafd2476be..1530a11f824425f82a539cee7a5ae607c653f9be 100644 --- a/inspector/connect_inspector.cpp +++ b/inspector/connect_inspector.cpp @@ -26,6 +26,8 @@ static constexpr char REQUEST_MESSAGE[] = "tree"; static constexpr char STOPDEBUGGER_MESSAGE[] = "stopDebugger"; static constexpr char OPEN_ARKUI_STATE_PROFILER[] = "ArkUIStateProfilerOpen"; static constexpr char CLOSE_ARKUI_STATE_PROFILER[] = "ArkUIStateProfilerClose"; +static constexpr char START_RECORD_MESSAGE[] = "start"; +static constexpr char STOP_RECORD_MESSAGE[] = "stop"; std::function g_setConnectCallBack; void* HandleDebugManager(void* const server) @@ -115,6 +117,21 @@ void OnMessage(const std::string& message) g_inspector->setDebugMode_(); } } + if (message.find(START_RECORD_MESSAGE, 0) != std::string::npos) { + g_inspector->waitingForDebugger_ = true; + if (g_inspector->setDebugMode_ != nullptr) { + LOGI("record start"); + g_inspector->startRecord_(); + } + } + + if (message.find(STOP_RECORD_MESSAGE, 0) != std::string::npos) { + g_inspector->waitingForDebugger_ = true; + if (g_inspector->setDebugMode_ != nullptr) { + LOGI("record stop"); + g_inspector->stopRecord_(); + } + } } } @@ -269,4 +286,16 @@ void SetProfilerCallback(const std::function &setArkUIStateProfilerS g_inspector->setArkUIStateProfilerStatus_ = setArkUIStateProfilerStatus; } + +void SetRecordCallback(const std::function & startRecordFunc, + const std::function & stopRecordRunc) +{ + std::lock_guard lock(g_connectMutex); + if (g_inspector == nullptr) { + g_inspector = std::make_unique(); + } + g_inspector->startRecord_ = startRecordFunc; + g_inspector->stopRecord_ = stopRecordRunc; +} + } // OHOS::ArkCompiler::Toolchain diff --git a/inspector/connect_inspector.h b/inspector/connect_inspector.h index 4225304f53635762659b4d854707e32914a2072f..3aa466453d547dac651d68b479b8d5df84aeb80c 100644 --- a/inspector/connect_inspector.h +++ b/inspector/connect_inspector.h @@ -59,6 +59,9 @@ void SetSwitchCallBack(const std::function& setSwitchStatus, void SetProfilerCallback(const std::function &setArkUIStateProfilerStatus); +void SetRecordCallback(const std::function & startRecordFunc, + const std::function & stopRecordRunc); + #ifdef __cplusplus #if __cplusplus } @@ -86,6 +89,9 @@ public: std::function createLayoutInfo_; std::function setDebugMode_; int32_t instanceId_ = -1; + std::function startRecord_; + std::function stopRecord_; + }; } // namespace OHOS::ArkCompiler::Toolchain