From 0a40614c946702498cbe0baffd935ea97a8c56ae Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Mon, 8 Nov 2021 13:45:30 +0900 Subject: [PATCH] implement getscreensize feature Change-Id: I83baf89a7003424b800ca68aa5ec51e8e7e97f09 --- org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h | 3 ++ org.tizen.aurum-bootstrap/inc/Commands/Commands.h | 1 + .../inc/Commands/GetScreenSizeCommand.h | 34 ++++++++++++++++++ org.tizen.aurum-bootstrap/meson.build | 1 + org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc | 8 +++++ .../src/Commands/GetScreenSizeCommand.cc | 41 ++++++++++++++++++++++ protocol/aurum.proto | 9 +++++ 7 files changed, 97 insertions(+) create mode 100644 org.tizen.aurum-bootstrap/inc/Commands/GetScreenSizeCommand.h create mode 100644 org.tizen.aurum-bootstrap/src/Commands/GetScreenSizeCommand.cc diff --git a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h index e7d348a..f532b6a 100644 --- a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h +++ b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h @@ -107,6 +107,9 @@ public: ::grpc::Status dumpObjectTree(::grpc::ServerContext *context, const ::aurum::ReqDumpObjectTree *request, ::aurum::RspDumpObjectTree *response) override; + ::grpc::Status getScreenSize(::grpc::ServerContext *context, + const ::aurum::ReqGetScreenSize *request, + ::aurum::RspGetScreenSize *response) override; }; #endif diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h index 1311895..5c9b25f 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h @@ -45,3 +45,4 @@ #include "Commands/TakeScreenshotCommand.h" #include "Commands/DumpObjectTreeCommand.h" +#include "Commands/GetScreenSizeCommand.h" diff --git a/org.tizen.aurum-bootstrap/inc/Commands/GetScreenSizeCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/GetScreenSizeCommand.h new file mode 100644 index 0000000..cbb37ff --- /dev/null +++ b/org.tizen.aurum-bootstrap/inc/Commands/GetScreenSizeCommand.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include "Commands/Command.h" +#include "ObjectMapper.h" +#include +#include "config.h" + +class GetScreenSizeCommand : public Command { +private: + const ::aurum::ReqGetScreenSize *mRequest; + ::aurum::RspGetScreenSize *mResponse; + +public: + GetScreenSizeCommand(const ::aurum::ReqGetScreenSize *request, + ::aurum::RspGetScreenSize *response); + ::grpc::Status execute() override; +}; diff --git a/org.tizen.aurum-bootstrap/meson.build b/org.tizen.aurum-bootstrap/meson.build index e27c68a..ae2f8dd 100644 --- a/org.tizen.aurum-bootstrap/meson.build +++ b/org.tizen.aurum-bootstrap/meson.build @@ -40,6 +40,7 @@ bootstrap_svr_src += [ files('src/Commands/PreCommand.cc'), files('src/Commands/PostCommand.cc'), files('src/Commands/DumpObjectTreeCommand.cc'), + files('src/Commands/GetScreenSizeCommand.cc'), ] bootstrap_svr_dep = [ diff --git a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc index 51b0863..371af97 100644 --- a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc +++ b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc @@ -232,3 +232,11 @@ aurumServiceImpl::~aurumServiceImpl() std::unique_ptr cmd = std::make_unique(request, response); return execute(cmd.get(), true); } + +::grpc::Status aurumServiceImpl::getScreenSize(::grpc::ServerContext *context, + const ::aurum::ReqGetScreenSize *request, + ::aurum::RspGetScreenSize *response) +{ + std::unique_ptr cmd = std::make_unique(request, response); + return execute(cmd.get(), true); +} diff --git a/org.tizen.aurum-bootstrap/src/Commands/GetScreenSizeCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/GetScreenSizeCommand.cc new file mode 100644 index 0000000..29f4cfb --- /dev/null +++ b/org.tizen.aurum-bootstrap/src/Commands/GetScreenSizeCommand.cc @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "bootstrap.h" +#include "GetScreenSizeCommand.h" +#include "UiDevice.h" + +GetScreenSizeCommand::GetScreenSizeCommand(const ::aurum::ReqGetScreenSize *request, + ::aurum::RspGetScreenSize *response) + : mRequest{request}, mResponse{response} +{ +} + +::grpc::Status GetScreenSizeCommand::execute() +{ + LOGI("GetScreenSize --------------- "); + + ::aurum::Rect *rect = mResponse->mutable_size(); + std::shared_ptr mDevice = UiDevice::getInstance(); + + rect->set_x(0); + rect->set_y(0); + rect->set_width(mDevice->getScreenSize().width); + rect->set_height(mDevice->getScreenSize().height); + + return grpc::Status::OK; +} diff --git a/protocol/aurum.proto b/protocol/aurum.proto index d26d272..acb2c8c 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -29,6 +29,7 @@ service Bootstrap { rpc sendKey(ReqKey) returns (RspKey) {} rpc takeScreenshot(ReqTakeScreenshot) returns (stream RspTakeScreenshot) {} rpc dumpObjectTree(ReqDumpObjectTree) returns (RspDumpObjectTree) {} + rpc getScreenSize(ReqGetScreenSize) returns (RspGetScreenSize) {} } // ------------------------------------ // @@ -416,3 +417,11 @@ message RspDumpObjectTree { RspStatus status = 1; repeated Element roots = 2; } + +message ReqGetScreenSize { +} + +message RspGetScreenSize { + RspStatus status = 1; + Rect size = 2; +} -- 2.7.4