From 03632659db1fcc596559c176f44d3206a3016808 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Wed, 3 May 2023 16:39:01 +0900 Subject: [PATCH] Aurum: Introduce GetAngleCommand Change-Id: I6cf209fd097521accde1506ae7484e4f9269ceba --- libaurum/inc/Accessibility/AccessibleNode.h | 30 ++++++++++++++ libaurum/inc/Interface/IObject.h | 10 +++++ libaurum/inc/UiDevice.h | 18 +++++++++ libaurum/inc/UiObject.h | 18 +++++++++ libaurum/src/Accessibility/AccessibleNode.cc | 22 +++++++++- libaurum/src/Impl/TizenDeviceImpl.cc | 2 + libaurum/src/UiDevice.cc | 18 +++++++++ libaurum/src/UiObject.cc | 10 +++++ .../inc/AurumServiceImpl.h | 3 ++ .../inc/Commands/Commands.h | 3 +- .../inc/Commands/GetAngleCommand.h | 34 ++++++++++++++++ org.tizen.aurum-bootstrap/meson.build | 1 + .../src/AurumServiceImpl.cc | 8 ++++ .../src/Commands/DumpObjectTreeCommand.cc | 3 ++ .../src/Commands/FindElementCommand.cc | 3 ++ .../src/Commands/FindElementsCommand.cc | 3 ++ .../src/Commands/GetAngleCommand.cc | 40 +++++++++++++++++++ protocol/aurum.proto | 13 ++++++ 18 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 org.tizen.aurum-bootstrap/inc/Commands/GetAngleCommand.h create mode 100644 org.tizen.aurum-bootstrap/src/Commands/GetAngleCommand.cc diff --git a/libaurum/inc/Accessibility/AccessibleNode.h b/libaurum/inc/Accessibility/AccessibleNode.h index d54d832..8c3e555 100644 --- a/libaurum/inc/Accessibility/AccessibleNode.h +++ b/libaurum/inc/Accessibility/AccessibleNode.h @@ -171,6 +171,16 @@ public: */ std::string getOcrText() const override; + /** + * @copydoc UiObject::getWindowAngle() + */ + int getWindowAngle() const override; + + /** + * @copydoc UiObject::getTargetAngle() + */ + int getTargetAngle() const override; + /** * @copydoc UiObject::isFocusable() */ @@ -212,6 +222,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() */ @@ -537,6 +565,8 @@ protected: int mSupportingIfaces; int mFeatureProperty; int mPid; + int mWindowAngle; + int mTargetAngle; double mMinValue; double mMaxValue; double mValue; diff --git a/libaurum/inc/Interface/IObject.h b/libaurum/inc/Interface/IObject.h index 0e6ee9f..6fcaf42 100644 --- a/libaurum/inc/Interface/IObject.h +++ b/libaurum/inc/Interface/IObject.h @@ -53,6 +53,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() */ diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index f1369df..fd30c7a 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -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. diff --git a/libaurum/inc/UiObject.h b/libaurum/inc/UiObject.h index 0c963d4..52d4a9c 100644 --- a/libaurum/inc/UiObject.h +++ b/libaurum/inc/UiObject.h @@ -193,6 +193,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. * diff --git a/libaurum/src/Accessibility/AccessibleNode.cc b/libaurum/src/Accessibility/AccessibleNode.cc index 7bd33c7..8f6212b 100644 --- a/libaurum/src/Accessibility/AccessibleNode.cc +++ b/libaurum/src/Accessibility/AccessibleNode.cc @@ -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; diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index 83fc1b7..16e59da 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -459,6 +459,8 @@ std::vector> TizenDeviceImpl::getWindowRoot() co std::transform(wins.begin(), wins.end(), std::back_inserter(ret), [&](std::shared_ptr 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(); } diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index 9f162a0..e4164bd 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -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 diff --git a/libaurum/src/UiObject.cc b/libaurum/src/UiObject.cc index 3bbecc0..411cd4d 100644 --- a/libaurum/src/UiObject.cc +++ b/libaurum/src/UiObject.cc @@ -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(); diff --git a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h index 939adcb..22be632 100644 --- a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h +++ b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h @@ -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; }; diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h index 2d80fcc..992295d 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h @@ -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 index 0000000..d378b16 --- /dev/null +++ b/org.tizen.aurum-bootstrap/inc/Commands/GetAngleCommand.h @@ -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 +#include +#include "Commands/Command.h" +#include "ObjectMapper.h" +#include +#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 diff --git a/org.tizen.aurum-bootstrap/meson.build b/org.tizen.aurum-bootstrap/meson.build index a6295b3..5eed3ed 100644 --- a/org.tizen.aurum-bootstrap/meson.build +++ b/org.tizen.aurum-bootstrap/meson.build @@ -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 = [ diff --git a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc index ef684d1..16f8842 100644 --- a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc +++ b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc @@ -307,4 +307,12 @@ aurumServiceImpl::~aurumServiceImpl() { std::unique_ptr cmd = std::make_unique(request, response); return execute(cmd.get(), true); +} + +::grpc::Status aurumServiceImpl::getAngle(::grpc::ServerContext *context, + const ::aurum::ReqGetAngle *request, + ::aurum::RspGetAngle *response) +{ + std::unique_ptr cmd = std::make_unique(request, response); + return execute(cmd.get(), true); } \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc index b899715..80fbca3 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc @@ -83,6 +83,9 @@ void DumpObjectTreeCommand::traverse(::aurum::Element *root, std::shared_ptrset_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); diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index f212722..b894822 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -191,6 +191,9 @@ std::shared_ptr 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); diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc index 626d6a9..796839d 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc @@ -202,6 +202,9 @@ std::vector> 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 index 0000000..01a9420 --- /dev/null +++ b/org.tizen.aurum-bootstrap/src/Commands/GetAngleCommand.cc @@ -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 mDevice = UiDevice::getInstance(); + + mResponse->set_windowangle(mDevice->getWindowAngle()); + mResponse->set_targetangle(mDevice->getTargetAngle()); + + mResponse->set_status(::aurum::RspStatus::OK); + return grpc::Status::OK; +} diff --git a/protocol/aurum.proto b/protocol/aurum.proto index eac2b9b..d929d4d 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -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; +} -- 2.34.1