implement getscreensize feature 17/266117/5
authorHosang Kim <hosang12.kim@samsung.com>
Mon, 8 Nov 2021 04:45:30 +0000 (13:45 +0900)
committerwoochan lee <wc0917.lee@samsung.com>
Mon, 8 Nov 2021 06:47:12 +0000 (06:47 +0000)
Change-Id: I83baf89a7003424b800ca68aa5ec51e8e7e97f09

org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h
org.tizen.aurum-bootstrap/inc/Commands/Commands.h
org.tizen.aurum-bootstrap/inc/Commands/GetScreenSizeCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/meson.build
org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc
org.tizen.aurum-bootstrap/src/Commands/GetScreenSizeCommand.cc [new file with mode: 0644]
protocol/aurum.proto

index e7d348a..f532b6a 100644 (file)
@@ -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
index 1311895..5c9b25f 100644 (file)
@@ -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 (file)
index 0000000..cbb37ff
--- /dev/null
@@ -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 <gio/gio.h>
+#include <grpcpp/grpcpp.h>
+#include "Commands/Command.h"
+#include "ObjectMapper.h"
+#include <aurum.grpc.pb.h>
+#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;
+};
index e27c68a..ae2f8dd 100644 (file)
@@ -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 = [
index 51b0863..371af97 100644 (file)
@@ -232,3 +232,11 @@ aurumServiceImpl::~aurumServiceImpl()
     std::unique_ptr<DumpObjectTreeCommand> cmd = std::make_unique<DumpObjectTreeCommand>(request, response);
     return execute(cmd.get(), true);
 }
+
+::grpc::Status aurumServiceImpl::getScreenSize(::grpc::ServerContext *context,
+                                         const ::aurum::ReqGetScreenSize *request,
+                                         ::aurum::RspGetScreenSize *response)
+{
+    std::unique_ptr<GetScreenSizeCommand> cmd = std::make_unique<GetScreenSizeCommand>(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 (file)
index 0000000..29f4cfb
--- /dev/null
@@ -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<UiDevice> 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;
+}
index d26d272..acb2c8c 100644 (file)
@@ -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;
+}