mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-01 20:44:05 -04:00
!81 预览调试模式显示的路由路径不是有时ability的LoadContent中配置的路径
Merge pull request !81 from fupengfei/master
This commit is contained in:
@@ -648,6 +648,20 @@ void CurrentRouterCommand::RunGet()
|
||||
ILOG("Get CurrentRouter run finished.");
|
||||
}
|
||||
|
||||
LoadContentCommand::LoadContentCommand(CommandType commandType, const Json::Value& arg, const LocalSocket& socket)
|
||||
: CommandLine(commandType, arg, socket)
|
||||
{
|
||||
}
|
||||
|
||||
void LoadContentCommand::RunGet()
|
||||
{
|
||||
Json::Value resultContent;
|
||||
std::string currentRouter = VirtualScreenImpl::GetInstance().GetAbilityCurrentRouter();
|
||||
resultContent["AbilityCurrentRouter"] = currentRouter;
|
||||
SetResultToManager("args", resultContent, "AbilityCurrentJsRouter");
|
||||
ILOG("Get AbilityCurrentRouter run finished.");
|
||||
}
|
||||
|
||||
LanguageCommand::LanguageCommand(CommandType commandType, const Json::Value& arg, const LocalSocket& socket)
|
||||
: CommandLine(commandType, arg, socket)
|
||||
{
|
||||
|
||||
@@ -269,6 +269,15 @@ protected:
|
||||
void RunGet() override;
|
||||
};
|
||||
|
||||
class LoadContentCommand : public CommandLine {
|
||||
public:
|
||||
LoadContentCommand(CommandType commandType, const Json::Value& arg, const LocalSocket& socket);
|
||||
~LoadContentCommand() override {}
|
||||
|
||||
protected:
|
||||
void RunGet() override;
|
||||
};
|
||||
|
||||
class SupportedLanguagesCommand : public CommandLine {
|
||||
public:
|
||||
SupportedLanguagesCommand(CommandType commandType, const Json::Value& arg, const LocalSocket& socket);
|
||||
|
||||
@@ -46,6 +46,7 @@ void CommandLineFactory::InitCommandMap()
|
||||
typeMap["FastPreviewMsg"] = &CommandLineFactory::CreateObject<FastPreviewMsgCommand>;
|
||||
typeMap["DropFrame"] = &CommandLineFactory::CreateObject<DropFrameCommand>;
|
||||
typeMap["KeyPress"] = &CommandLineFactory::CreateObject<KeyPressCommand>;
|
||||
typeMap["LoadContent"] = &CommandLineFactory::CreateObject<LoadContentCommand>;
|
||||
} else {
|
||||
typeMap["Power"] = &CommandLineFactory::CreateObject<PowerCommand>;
|
||||
typeMap["Volume"] = &CommandLineFactory::CreateObject<VolumeCommand>;
|
||||
|
||||
@@ -75,7 +75,7 @@ void JsAppImpl::Start()
|
||||
|
||||
void JsAppImpl::Restart()
|
||||
{
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
if (simulator) {
|
||||
simulator->TerminateAbility(debugAbilityId);
|
||||
@@ -154,7 +154,7 @@ void JsAppImpl::ColorModeChanged(const std::string commandColorMode)
|
||||
void JsAppImpl::Interrupt()
|
||||
{
|
||||
isStop = true;
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
if (simulator) {
|
||||
simulator->TerminateAbility(debugAbilityId);
|
||||
@@ -205,7 +205,7 @@ void JsAppImpl::RunJsApp()
|
||||
VirtualScreenImpl::GetInstance().GetCompressionHeight());
|
||||
SetJsAppArgs(aceRunArgs);
|
||||
InitGlfwEnv();
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
RunDebugAbility(); // for debug preview
|
||||
} else {
|
||||
RunNormalAbility(); // for normal preview
|
||||
@@ -226,6 +226,7 @@ void JsAppImpl::RunNormalAbility()
|
||||
OHOS::Rosen::WMError errCode;
|
||||
OHOS::sptr<OHOS::Rosen::WindowOption> sp = nullptr;
|
||||
auto window = OHOS::Rosen::Window::Create("previewer", sp, nullptr, errCode);
|
||||
window->SetContentInfoCallback(std::move(VirtualScreenImpl::LoadContentCallBack));
|
||||
window->CreateSurfaceNode("preview_surface", aceRunArgs.onRender);
|
||||
ability->SetWindow(window);
|
||||
ability->InitEnv();
|
||||
@@ -257,6 +258,7 @@ void JsAppImpl::RunDebugAbility()
|
||||
ELOG("JsApp::Run get window failed.");
|
||||
return;
|
||||
}
|
||||
window->SetContentInfoCallback(std::move(VirtualScreenImpl::LoadContentCallBack));
|
||||
window->CreateSurfaceNode(options.moduleName, std::move(VirtualScreenImpl::CallBack));
|
||||
}
|
||||
|
||||
@@ -539,7 +541,7 @@ void JsAppImpl::ResolutionChanged(int32_t changedOriginWidth,
|
||||
|
||||
ILOG("ResolutionChanged: %s %d %d %f", orientation.c_str(), aceRunArgs.deviceWidth,
|
||||
aceRunArgs.deviceHeight, aceRunArgs.deviceConfig.density);
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
SetWindowParams();
|
||||
OHOS::Ace::ViewportConfig config;
|
||||
@@ -726,7 +728,7 @@ void JsAppImpl::DispatchBackPressedEvent() const
|
||||
}
|
||||
void JsAppImpl::DispatchKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) const
|
||||
{
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
OHOS::Rosen::Window* window = OHOS::Previewer::PreviewerWindow::GetInstance().GetWindowObject();
|
||||
if (!window) {
|
||||
@@ -741,7 +743,7 @@ void JsAppImpl::DispatchKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& key
|
||||
}
|
||||
void JsAppImpl::DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) const
|
||||
{
|
||||
if (isDebug && debugServerPort) {
|
||||
if (isDebug && debugServerPort >= 0) {
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
OHOS::Rosen::Window* window = OHOS::Previewer::PreviewerWindow::GetInstance().GetWindowObject();
|
||||
if (!window) {
|
||||
|
||||
@@ -71,6 +71,16 @@ void VirtualScreen::SetCurrentRouter(const std::string currentRouterValue)
|
||||
currentRouter = currentRouterValue;
|
||||
}
|
||||
|
||||
std::string VirtualScreen::GetAbilityCurrentRouter() const
|
||||
{
|
||||
return abilityCurrentRouter;
|
||||
}
|
||||
|
||||
void VirtualScreen::SetAbilityCurrentRouter(const std::string currentRouterValue)
|
||||
{
|
||||
abilityCurrentRouter = currentRouterValue;
|
||||
}
|
||||
|
||||
int32_t VirtualScreen::GetOrignalWidth() const
|
||||
{
|
||||
return orignalResolutionWidth;
|
||||
|
||||
@@ -36,6 +36,9 @@ public:
|
||||
std::string GetCurrentRouter() const;
|
||||
void SetCurrentRouter(const std::string currentRouterValue);
|
||||
|
||||
std::string GetAbilityCurrentRouter() const;
|
||||
void SetAbilityCurrentRouter(const std::string currentRouterValue);
|
||||
|
||||
int32_t GetOrignalHeight() const;
|
||||
void SetOrignalHeight(const int32_t& value);
|
||||
|
||||
@@ -108,6 +111,7 @@ protected:
|
||||
uint16_t protocolVersion = static_cast<uint16_t>(VirtualScreen::ProtocolVersion::LOADNORMAL);
|
||||
bool isWebSocketConfiged;
|
||||
std::string currentRouter;
|
||||
std::string abilityCurrentRouter;
|
||||
std::string fastPreviewMsg;
|
||||
uint8_t* jpgScreenBuffer;
|
||||
unsigned long jpgBufferSize;
|
||||
|
||||
@@ -133,13 +133,22 @@ bool VirtualScreenImpl::CallBack(const void* data, const size_t length,
|
||||
bool VirtualScreenImpl::PageCallBack(const std::string currentRouterPath)
|
||||
{
|
||||
std::string currentRouter = currentRouterPath.substr(0, currentRouterPath.size() - 3);
|
||||
ILOG("PageCallBack currentPage is : %s", currentRouter.c_str());
|
||||
ILOG("PageCallback currentPage is : %s", currentRouter.c_str());
|
||||
GetInstance().SetCurrentRouter(currentRouter);
|
||||
Json::Value val;
|
||||
CommandLineInterface::GetInstance().CreatCommandToSendData("CurrentRouter", val, "get");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualScreenImpl::LoadContentCallBack(const std::string currentRouterPath)
|
||||
{
|
||||
ILOG("LoadContentCallback currentPage is : %s", currentRouterPath.c_str());
|
||||
GetInstance().SetAbilityCurrentRouter(currentRouterPath);
|
||||
Json::Value val;
|
||||
CommandLineInterface::GetInstance().CreatCommandToSendData("LoadContent", val, "get");
|
||||
return true;
|
||||
}
|
||||
|
||||
void VirtualScreenImpl::FastPreviewCallBack(const std::string& jsonStr)
|
||||
{
|
||||
GetInstance().SetFastPreviewMsg(jsonStr);
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
const int32_t width, const int32_t height);
|
||||
static bool CallBack(const void* data, const size_t length, const int32_t width, const int32_t height);
|
||||
static bool PageCallBack(const std::string currentRouterPath);
|
||||
static bool LoadContentCallBack(const std::string currentRouterPath);
|
||||
static void FastPreviewCallBack(const std::string& jsonStr);
|
||||
void InitAll(std::string pipeName, std::string pipePort);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user