From 9ecd0b4a5a209717bba5b28cec5792ed35d0b914 Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Tue, 21 Apr 2020 00:45:26 +0900 Subject: [PATCH] aurum: enhance tizen implementations this patch contains * add more privileges into tizen service app manifest * fine tune bootstrap commands * fix bugs in tizen device impl Change-Id: Iee68ce9e4dc6c1d7b28e242cae27a6ef19b305fc --- libaurum/inc/DeviceImpl/TizenImpl.h | 6 +- libaurum/src/AccessibleNode.cc | 4 - libaurum/src/DeviceImpl/TizenImpl.cc | 111 +++++++++++++-------- misc/setup_device.sh | 1 + .../inc/Commands/InstallAppCommand.h | 1 + .../inc/Commands/RemoveAppCommand.h | 1 + .../org.tizen.aurum-bootstrap.xml | 7 ++ .../src/Commands/InstallAppCommand.cc | 9 ++ .../src/Commands/PostCommand.cc | 2 + .../src/Commands/RemoveAppCommand.cc | 9 ++ 10 files changed, 102 insertions(+), 49 deletions(-) diff --git a/libaurum/inc/DeviceImpl/TizenImpl.h b/libaurum/inc/DeviceImpl/TizenImpl.h index 159abb4..8db3236 100644 --- a/libaurum/inc/DeviceImpl/TizenImpl.h +++ b/libaurum/inc/DeviceImpl/TizenImpl.h @@ -32,12 +32,14 @@ public: bool pressKeyCode(std::string keycode) override; bool takeScreenshot(std::string path, float scale, int quality) override; +protected: + bool pressKeyCode(std::string keycode, unsigned int intv); + private: -#ifdef GBS_BUILD efl_util_inputgen_h mFakeTouchHandle; efl_util_inputgen_h mFakeKeyboardHandle; -#endif static const unsigned int INTV_CLICK = 5; + static const unsigned int INTV_KEYPRESS = 10; }; #endif \ No newline at end of file diff --git a/libaurum/src/AccessibleNode.cc b/libaurum/src/AccessibleNode.cc index 88e4550..e9ca33b 100644 --- a/libaurum/src/AccessibleNode.cc +++ b/libaurum/src/AccessibleNode.cc @@ -88,15 +88,11 @@ void AccessibleNode::refresh() const g_free(rolename); } -#ifdef GBS_BUILD gchar *uID = atspi_accessible_get_unique_id(mNode.get(), NULL); if (uID) { mRes = uID; g_free(uID); } -#else - mRes = "Not_Supported"; -#endif GHashTable *attributes = atspi_accessible_get_attributes(mNode.get(), NULL); char *t = (char*)g_hash_table_lookup(attributes, "type"); diff --git a/libaurum/src/DeviceImpl/TizenImpl.cc b/libaurum/src/DeviceImpl/TizenImpl.cc index 29cf7db..d7af264 100644 --- a/libaurum/src/DeviceImpl/TizenImpl.cc +++ b/libaurum/src/DeviceImpl/TizenImpl.cc @@ -11,27 +11,23 @@ TizenImpl::TizenImpl() { LOG_SCOPE_F(INFO, "device implementation init"); -#ifdef GBSBUILD ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ TizenImpl *obj = static_cast(data); obj->mFakeTouchHandle = efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN); obj->mFakeKeyboardHandle = efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_KEYBOARD); + return NULL; }, this); -#endif - } TizenImpl::~TizenImpl() { -#ifdef GBSBUILD ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ TizenImpl *obj = static_cast(data); efl_util_input_deinitialize_generator(obj->mFakeTouchHandle); efl_util_input_deinitialize_generator(obj->mFakeKeyboardHandle); return NULL; }, this); -#endif } bool TizenImpl::click(const int x, const int y) @@ -41,8 +37,7 @@ bool TizenImpl::click(const int x, const int y) bool TizenImpl::click(const int x, const int y, const unsigned int intv) { -LOG_SCOPE_F(INFO, "click at (%d, %d)", x, y); -#ifdef GBSBUILD + LOG_SCOPE_F(INFO, "click at (%d, %d)", x, y); auto args = std::make_tuple(this, x, y, intv); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ TizenImpl *obj; @@ -58,15 +53,11 @@ LOG_SCOPE_F(INFO, "click at (%d, %d)", x, y); return NULL; }, (void*)(&args)); return true; -#else - return false; -#endif } bool TizenImpl::touchDown(const int x, const int y) { -#ifdef GBSBUILD LOG_F(INFO, "%d %d", x, y); auto args = std::make_tuple(this, x, y); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ @@ -78,13 +69,11 @@ bool TizenImpl::touchDown(const int x, const int y) return NULL; }, (void*)(&args)); -#endif return true; } bool TizenImpl::touchMove(const int x, const int y) { -#ifdef GBSBUILD LOG_F(INFO, "%d %d", x, y); auto args = std::make_tuple(this, x, y); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ @@ -97,13 +86,11 @@ bool TizenImpl::touchMove(const int x, const int y) return NULL; }, (void*)(&args)); -#endif return true; } bool TizenImpl::touchUp(const int x, const int y) { -#ifdef GBSBUILD LOG_F(INFO, "touch up %d %d", x, y); auto args = std::make_tuple(this, x, y); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ @@ -117,46 +104,72 @@ bool TizenImpl::touchUp(const int x, const int y) }, (void*)(&args)); return true; -#endif - return false; } bool TizenImpl::drag(const int sx, const int sy, const int ex, const int ey, const int duration) { -#ifdef GBSBUILD - auto args = std::make_tuple(this, sx, sy, ex, ey, duration); - ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ - TizenImpl *obj; - int sx, sy, ex, ey, duration; - std::tie(obj, sx, sy, ex, ey, duration) = *static_cast*>(data); + int i, j, dirX, dirY, stepX, stepY; + int dur; - int i, j; - int dur; - // TODO fixed fps implementation - if (duration < 10) dur = 10; - else dur = duration; + // TODO fixed fps implementation + if (duration < 10) dur = 10; + else dur = duration; + + dirX = sx > ex ? -1 : 1; + dirY = sy > ey ? -1 : 1; - i = sx, j = sy; - LOG_SCOPE_F(INFO, "flicking (%d, %d)", i, j); + stepX = (ex - sx)/20; + stepY = (ey - sy)/20; + LOG_SCOPE_F(INFO, "flicking (%d, %d) -> (%d, %d) for (%d ms)", sx, sy, ex, ey, duration); + + auto args1 = std::make_tuple(this, sx, sy); + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ + TizenImpl *obj; + int i, j; + std::tie(obj, i, j) = *static_cast*>(data); efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_BEGIN, i, j); - for (; i <= ex && j <= ey; i += (ex - sx) / 10, j += (ey - sy) / 10) { + LOG_F(INFO, "flick begin (%d, %d)", i, j); + return NULL; + }, (void*)(&args1)); + + i = sx, j = sy; + do { + std::tuple args; + args = std::make_tuple(this, i, j); + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ + TizenImpl *obj; + int i, j; + std::tie(obj, i, j) = *static_cast*>(data); + LOG_F(INFO, "flick move (%d, %d)", i, j); + efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_UPDATE, i, j); - usleep(dur * 1000); - LOG_SCOPE_F(INFO, "flicking (%d, %d)", i, j); - } - LOG_SCOPE_F(INFO, "flicking (%d, %d)", i, j); + return NULL; + }, (void*)(&args)); + + usleep(dur * 1000); + LOG_F(INFO, "sleep ms %d", dur); + i += stepX; + j += stepY; + } while(i*dirX <= ex && j*dirY <= ey); + + auto args2 = std::make_tuple(this, ex, ey); + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ + TizenImpl *obj; + int i, j; + std::tie(obj, i, j) = *static_cast*>(data); efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_END, i, j); - + LOG_SCOPE_F(INFO, "flick end: (%d, %d)", i, j); return NULL; - }, (void*)(&args)); + }, (void*)(&args2)); + + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{return NULL;}, NULL); + return true; -#endif - return false; } bool TizenImpl::pressBack() @@ -191,19 +204,31 @@ bool TizenImpl::pressPower() bool TizenImpl::pressKeyCode(std::string keycode) { -#ifdef GBSBUILD + return pressKeyCode(keycode, INTV_KEYPRESS); +} + +bool TizenImpl::pressKeyCode(std::string keycode, unsigned int intv) +{ auto args = std::make_tuple(this, keycode); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ TizenImpl *obj; std::string keycode; std::tie(obj, keycode) = *static_cast*>(data); - efl_util_input_generate_key(obj->mFakeKeyboardHandle, keycode.c_str(), 1); - efl_util_input_generate_key(obj->mFakeKeyboardHandle, keycode.c_str(), 0); + return NULL; + }, (void*)(&args)); + + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{return NULL;}, NULL); + usleep(intv * 1000); + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ + TizenImpl *obj; + std::string keycode; + std::tie(obj, keycode) = *static_cast*>(data); + efl_util_input_generate_key(obj->mFakeKeyboardHandle, keycode.c_str(), 0); return NULL; }, (void*)(&args)); -#endif + return true; } diff --git a/misc/setup_device.sh b/misc/setup_device.sh index 4f665da..37942f3 100755 --- a/misc/setup_device.sh +++ b/misc/setup_device.sh @@ -1,4 +1,5 @@ #!/bin/bash sdb forward --remove-all sdb forward tcp:50051 tcp:50051 +sdb shell app_launcher -k org.tizen.aurum-bootstrap sdb shell app_launcher -s org.tizen.aurum-bootstrap diff --git a/org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h index 4ddc3e2..91c4d82 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h @@ -17,6 +17,7 @@ public: InstallAppCommand(::grpc::ServerReader< ::aurum::ReqInstallApp>* request, ::aurum::RspInstallApp* response); ::grpc::Status execute() override; + ::grpc::Status executePost() override; }; #endif \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h index 9ab28ba..5d6a0c4 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h @@ -18,6 +18,7 @@ public: ::aurum::RspRemoveApp* response); ; ::grpc::Status execute() override; + ::grpc::Status executePost() override; }; #endif \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml b/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml index 84cd8ab..f7c6fa1 100644 --- a/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml +++ b/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml @@ -14,7 +14,14 @@ http://tizen.org/privilege/application.info http://tizen.org/privilege/application.launch http://tizen.org/privilege/packagemanager.info + http://tizen.org/privilege/packagemanager.kill + http://tizen.org/privilege/packagemanager.admin + http://tizen.org/privilege/packagemanager.install + http://tizen.org/privilege/appmanager.kill + http://tizen.org/privilege/appmanager.launch http://tizen.org/privilege/inputgenerator + http://tizen.org/privilege/screenshot + http://tizen.org/privilege/location true diff --git a/org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc index 454bda5..58c369f 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc @@ -1,5 +1,7 @@ #include "InstallAppCommand.h" #include +#include +#include #include #ifdef GBSBUILD #include @@ -34,4 +36,11 @@ InstallAppCommand::InstallAppCommand( package_manager_request_install(pkgRequest, "/tmp/app.tpk", &id); #endif return grpc::Status::OK; +} + +::grpc::Status InstallAppCommand::executePost() +{ + LOG_SCOPE_F(INFO, "InstallAppCommand::executePost"); + std::this_thread::sleep_for(std::chrono::milliseconds{5000}); + return grpc::Status::OK; } \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc index 71f4692..32f7d11 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc @@ -1,6 +1,7 @@ #include "PostCommand.h" #include #include +#include PostCommand::PostCommand() : PostCommand(nullptr) {} PostCommand::PostCommand(Command *cmd) : mCommand{cmd} {} @@ -10,6 +11,7 @@ PostCommand::PostCommand(Command *cmd) : mCommand{cmd} {} ::grpc::Status rst = mCommand->execute(); LOG_SCOPE_F(INFO, "PostCommand --------------- "); mCommand->executePost(); + ecore_main_loop_thread_safe_call_sync([](void *data)->void*{return NULL;}, NULL); //FIXME : extract ecore dep from here // do post-command return rst; } diff --git a/org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc index 0fa6816..c5de333 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc @@ -1,5 +1,7 @@ #include "RemoveAppCommand.h" #include +#include +#include #ifdef GBSBUILD #include #endif @@ -24,4 +26,11 @@ RemoveAppCommand::RemoveAppCommand(const ::aurum::ReqRemoveApp* request, #endif return grpc::Status::OK; +} + +::grpc::Status RemoveAppCommand::executePost() +{ + LOG_SCOPE_F(INFO, "RemoveAppCommand::executePost"); + std::this_thread::sleep_for(std::chrono::milliseconds{5000}); + return grpc::Status::OK; } \ No newline at end of file -- 2.7.4