Aurum: Introduce GetAngleCommand 97/292297/3
authorHosang Kim <hosang12.kim@samsung.com>
Wed, 3 May 2023 07:39:01 +0000 (16:39 +0900)
committerkim hosang <hosang12.kim@samsung.com>
Tue, 9 May 2023 05:40:02 +0000 (05:40 +0000)
Change-Id: I6cf209fd097521accde1506ae7484e4f9269ceba

18 files changed:
libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Interface/IObject.h
libaurum/inc/UiDevice.h
libaurum/inc/UiObject.h
libaurum/src/Accessibility/AccessibleNode.cc
libaurum/src/Impl/TizenDeviceImpl.cc
libaurum/src/UiDevice.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h
org.tizen.aurum-bootstrap/inc/Commands/Commands.h
org.tizen.aurum-bootstrap/inc/Commands/GetAngleCommand.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/DumpObjectTreeCommand.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc
org.tizen.aurum-bootstrap/src/Commands/GetAngleCommand.cc [new file with mode: 0644]
protocol/aurum.proto

index d54d832..8c3e555 100644 (file)
@@ -172,6 +172,16 @@ public:
     std::string getOcrText() const override;
 
     /**
+     * @copydoc UiObject::getWindowAngle()
+     */
+    int getWindowAngle() const override;
+
+    /**
+     * @copydoc UiObject::getTargetAngle()
+     */
+    int getTargetAngle() const override;
+
+    /**
      * @copydoc UiObject::isFocusable()
      */
     bool isFocusable() const override;
@@ -213,6 +223,24 @@ public:
     void setOcrText(std::string text);
 
     /**
+     * @brief Sets Node's angle of window.
+     *
+     * @param[in] int window angle
+     *
+     * @since_tizen 7.5
+     */
+    void setWindowAngle(int windowAngle);
+
+    /**
+     * @brief Sets Node's angle of target device.
+     *
+     * @param[in] int target angle
+     *
+     * @since_tizen 7.5
+     */
+    void setTargetAngle(int targetAngle);
+
+    /**
      * @copydoc UiObject::getPkg()
      */
     std::string getPkg() const;
@@ -537,6 +565,8 @@ protected:
     int mSupportingIfaces;
     int mFeatureProperty;
     int mPid;
+    int mWindowAngle;
+    int mTargetAngle;
     double mMinValue;
     double mMaxValue;
     double mValue;
index 0e6ee9f..6fcaf42 100644 (file)
@@ -54,6 +54,16 @@ public:
     virtual std::string getOcrText() const = 0;
 
     /**
+     * @copydoc UiObject::getWindowAngle()
+     */
+    virtual int getWindowAngle() const = 0;
+
+    /**
+     * @copydoc UiObject::getTargetAngle()
+     */
+    virtual int getTargetAngle() const = 0;
+
+    /**
      * @copydoc UiObject::isFocusable()
      */
     virtual bool isFocusable() const = 0;
index f1369df..fd30c7a 100644 (file)
@@ -457,6 +457,24 @@ public:
      */
     bool getWithScreenAnalyzer();
 
+    /**
+     * @brief Gets angle of root window.
+     *
+     * @return window angle int
+     *
+     * @since_tizen 7.5
+     */
+    int getWindowAngle();
+
+        /**
+     * @brief Gets angle of target device.
+     *
+     * @return target angle int
+     *
+     * @since_tizen 7.5
+     */
+    int getTargetAngle();
+
 private:
     /**
      * @brief Waits process idle.
index 0c963d4..52d4a9c 100644 (file)
@@ -194,6 +194,24 @@ public:
     std::string getOcrText() const override;
 
     /**
+     * @brief Gets object's angle of window.
+     *
+     * @return int
+     *
+     * @since_tizen 7.5
+     */
+    int getWindowAngle() const override;
+
+    /**
+     * @brief Gets object's angle of target device.
+     *
+     * @return int
+     *
+     * @since_tizen 7.5
+     */
+    int getTargetAngle() const override;
+
+    /**
      * @brief Gets object's focusable property.
      *
      * @return true if focusable else false
index 7bd33c7..8f6212b 100644 (file)
@@ -32,7 +32,7 @@ AccessibleNode::~AccessibleNode()
 
 AccessibleNode::AccessibleNode()
 : mText{""}, mOcrText{""}, mPkg{""}, mRole{""}, mId{""}, mAutomationId{""}, mType{""}, mStyle{""}, mXPath{""}, mToolkitName{""},
-  mScreenBoundingBox{0,0,0,0}, mWindowBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0), mPid(0), mMinValue{0.0}, mMaxValue{0.0}, mValue{0.0}, mIncrement{0.0}, mValid{true}, mLock{}
+  mScreenBoundingBox{0,0,0,0}, mWindowBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0), mPid(0), mWindowAngle(0), mTargetAngle(0), mMinValue{0.0}, mMaxValue{0.0}, mValue{0.0}, mIncrement{0.0}, mValid{true}, mLock{}
 {
 }
 
@@ -126,11 +126,31 @@ std::string AccessibleNode::getOcrText() const
     return mOcrText;
 }
 
+int AccessibleNode::getWindowAngle() const
+{
+    return mWindowAngle;
+}
+
+int AccessibleNode::getTargetAngle() const
+{
+    return mTargetAngle;
+}
+
 void AccessibleNode::setOcrText(std::string text)
 {
     mOcrText = text;
 }
 
+void AccessibleNode::setWindowAngle(int windowAngle)
+{
+    mWindowAngle = windowAngle;
+}
+
+void AccessibleNode::setTargetAngle(int targetAngle)
+{
+    mTargetAngle = targetAngle;
+}
+
 std::string AccessibleNode::getPkg() const
 {
     return mPkg;
index 83fc1b7..16e59da 100644 (file)
@@ -459,6 +459,8 @@ std::vector<std::shared_ptr<AccessibleNode>> TizenDeviceImpl::getWindowRoot() co
         std::transform(wins.begin(), wins.end(), std::back_inserter(ret),
              [&](std::shared_ptr<AccessibleWindow> window) {
                  window->getAccessibleNode()->updateApplication();
+                 window->getAccessibleNode()->setWindowAngle(tWin->getWindowAngle());
+                 window->getAccessibleNode()->setTargetAngle(tWin->getTargetAngle());
                  LOGI("Target window add pkg: (%s), name (%s)", window->getAccessibleNode()->getPkg().c_str(), window->getTitle().c_str());
                  return window->getAccessibleNode();
              }
index 9f162a0..e4164bd 100644 (file)
@@ -332,3 +332,21 @@ bool UiDevice::registerCallback(const A11yEvent type, EventHandler cb, void *dat
 {
     return AccessibleWatcher::getInstance()->registerCallback(type, cb, data);
 }
+
+int UiDevice::getWindowAngle()
+{
+    auto wins = getWindowRoot();
+
+    if (wins.size() > 0) return wins[0]->getWindowAngle();
+
+    return 0;
+}
+
+int UiDevice::getTargetAngle()
+{
+    auto wins = getWindowRoot();
+
+    if (wins.size() > 0) return wins[0]->getTargetAngle();
+
+    return 0;
+}
\ No newline at end of file
index 3bbecc0..411cd4d 100644 (file)
@@ -247,6 +247,16 @@ std::string UiObject::getOcrText() const
     return getAccessibleNode()->getOcrText();
 }
 
+int UiObject::getWindowAngle() const
+{
+    return getAccessibleNode()->getWindowAngle();
+}
+
+int UiObject::getTargetAngle() const
+{
+    return getAccessibleNode()->getTargetAngle();
+}
+
 std::string UiObject::getToolkitName() const
 {
     getAccessibleNode()->updateToolkitName();
index 939adcb..22be632 100644 (file)
@@ -135,6 +135,9 @@ public:
     ::grpc::Status setXMLSync(::grpc::ServerContext *context,
                             const ::aurum::ReqSetXMLSync *request,
                             ::aurum::RspSetXMLSync *response) override;
+    ::grpc::Status getAngle(::grpc::ServerContext *context,
+                            const ::aurum::ReqGetAngle *request,
+                            ::aurum::RspGetAngle *response) override;
 public:
     int WAIT_TIMEOUT_MS;
 };
index 2d80fcc..992295d 100644 (file)
@@ -53,4 +53,5 @@
 #include "Commands/EnableScreenAnalyzerCommand.h"
 
 #include "Commands/GetTextMinBoundingRectCommand.h"
-#include "Commands/SetXMLSyncCommand.h"
\ No newline at end of file
+#include "Commands/SetXMLSyncCommand.h"
+#include "Commands/GetAngleCommand.h"
\ No newline at end of file
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/GetAngleCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/GetAngleCommand.h
new file mode 100644 (file)
index 0000000..d378b16
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2023 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 GetAngleCommand : public Command {
+private:
+    const ::aurum::ReqGetAngle *mRequest;
+    ::aurum::RspGetAngle *mResponse;
+
+public:
+    GetAngleCommand(const ::aurum::ReqGetAngle *request,
+                          ::aurum::RspGetAngle *response);
+    ::grpc::Status execute() override;
+};
\ No newline at end of file
index a6295b3..5eed3ed 100644 (file)
@@ -49,6 +49,7 @@ bootstrap_svr_src += [
    files('src/Commands/EnableScreenAnalyzerCommand.cc'),
    files('src/Commands/GetTextMinBoundingRectCommand.cc'),
    files('src/Commands/SetXMLSyncCommand.cc'),
+   files('src/Commands/GetAngleCommand.cc'),
 ]
 
 bootstrap_svr_dep = [
index ef684d1..16f8842 100644 (file)
@@ -307,4 +307,12 @@ aurumServiceImpl::~aurumServiceImpl()
 {
     std::unique_ptr<SetXMLSyncCommand> cmd = std::make_unique<SetXMLSyncCommand>(request, response);
     return execute(cmd.get(), true);
+}
+
+::grpc::Status aurumServiceImpl::getAngle(::grpc::ServerContext *context,
+                                          const ::aurum::ReqGetAngle *request,
+                                          ::aurum::RspGetAngle *response)
+{
+    std::unique_ptr<GetAngleCommand> cmd = std::make_unique<GetAngleCommand>(request, response);
+    return execute(cmd.get(), true);
 }
\ No newline at end of file
index b899715..80fbca3 100644 (file)
@@ -83,6 +83,9 @@ void DumpObjectTreeCommand::traverse(::aurum::Element *root, std::shared_ptr<Nod
     root->set_value(obj->getValue());
     root->set_increment(obj->getIncrement());
 
+    root->set_windowangle(obj->getWindowAngle());
+    root->set_targetangle(obj->getTargetAngle());
+
     for( auto && childNode : node->mChildren) {
         ::aurum::Element *child = root->add_child();
         traverse(child, childNode, depth+1);
index f212722..b894822 100644 (file)
@@ -191,6 +191,9 @@ std::shared_ptr<UiSelector> FindElementCommand::getSelector(void)
             elm->set_value(obj->getValue());
             elm->set_increment(obj->getIncrement());
 
+            elm->set_windowangle(obj->getWindowAngle());
+            elm->set_targetangle(obj->getTargetAngle());
+
             mResponse->set_status(::aurum::RspStatus::OK);
         } else {
             mResponse->set_status(::aurum::RspStatus::ERROR);
index 626d6a9..796839d 100644 (file)
@@ -202,6 +202,9 @@ std::vector<std::shared_ptr<UiSelector>> FindElementsCommand::getSelectors(void)
                 elm->set_maxvalue(obj->getMaxValue());
                 elm->set_value(obj->getValue());
                 elm->set_increment(obj->getIncrement());
+
+                elm->set_windowangle(obj->getWindowAngle());
+                elm->set_targetangle(obj->getTargetAngle());
             }
             mResponse->set_status(::aurum::RspStatus::OK);
         } else {
diff --git a/org.tizen.aurum-bootstrap/src/Commands/GetAngleCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/GetAngleCommand.cc
new file mode 100644 (file)
index 0000000..01a9420
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2023 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 "GetAngleCommand.h"
+
+#include "UiDevice.h"
+
+GetAngleCommand::GetAngleCommand(const ::aurum::ReqGetAngle* request,
+                                   ::aurum::RspGetAngle*       response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status GetAngleCommand::execute()
+{
+    LOGI("GetAngle --------------- ");
+
+    std::shared_ptr<UiDevice> mDevice = UiDevice::getInstance();
+
+    mResponse->set_windowangle(mDevice->getWindowAngle());
+    mResponse->set_targetangle(mDevice->getTargetAngle());
+
+    mResponse->set_status(::aurum::RspStatus::OK);
+    return grpc::Status::OK;
+}
index eac2b9b..d929d4d 100644 (file)
@@ -38,6 +38,7 @@ service Bootstrap {
    rpc getTextMinBoundingRect(ReqGetTextMinBoundingRect) returns (RspGetTextMinBoundingRect) {}
    rpc setTimeout(ReqSetTimeout) returns (RspSetTimeout) {}
    rpc setXMLSync(ReqSetXMLSync) returns (RspSetXMLSync) {}
+   rpc getAngle(ReqGetAngle) returns (RspGetAngle) {}
 }
 
 // ------------------------------------ //
@@ -91,6 +92,9 @@ message Element {
    double maxValue = 28;
    double value = 29;
    double increment = 30;
+
+   int32 windowAngle = 31;
+   int32 targetAngle = 32;
 }
 
 message Point {
@@ -660,3 +664,12 @@ message ReqSetXMLSync {
 message RspSetXMLSync {
    RspStatus status = 1;
 }
+
+message ReqGetAngle {
+}
+
+message RspGetAngle {
+   RspStatus status = 1;
+   int32 windowAngle = 2;
+   int32 targetAngle = 3;
+}