aurum: enhance tizen implementations
authorWonki Kim <wonki_.kim@samsung.com>
Mon, 20 Apr 2020 15:45:26 +0000 (00:45 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Thu, 23 Apr 2020 21:26:49 +0000 (06:26 +0900)
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
libaurum/src/AccessibleNode.cc
libaurum/src/DeviceImpl/TizenImpl.cc
misc/setup_device.sh
org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h
org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h
org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml
org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc
org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc

index 159abb4..8db3236 100644 (file)
@@ -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
index 88e4550..e9ca33b 100644 (file)
@@ -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");
index 29cf7db..d7af264 100644 (file)
 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<TizenImpl*>(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<TizenImpl*>(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<std::tuple<TizenImpl*, int, int, int, int, int>*>(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<std::tuple<TizenImpl*, int, int>*>(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<TizenImpl*, int, int> 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<std::tuple<TizenImpl*, int, int>*>(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<std::tuple<TizenImpl*, int, int>*>(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<std::tuple<TizenImpl*, std::string>*>(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<std::tuple<TizenImpl*, std::string>*>(data);
+        efl_util_input_generate_key(obj->mFakeKeyboardHandle, keycode.c_str(), 0);
         return NULL;
     }, (void*)(&args));
-#endif
+
     return true;
 }
 
index 4f665da..37942f3 100755 (executable)
@@ -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
index 4ddc3e2..91c4d82 100644 (file)
@@ -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
index 9ab28ba..5d6a0c4 100644 (file)
@@ -18,6 +18,7 @@ public:
                      ::aurum::RspRemoveApp*       response);
     ;
     ::grpc::Status execute() override;
+    ::grpc::Status executePost() override;
 };
 
 #endif
\ No newline at end of file
index 84cd8ab..f7c6fa1 100644 (file)
                <privilege>http://tizen.org/privilege/application.info</privilege>
                <privilege>http://tizen.org/privilege/application.launch</privilege>
                <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
+               <privilege>http://tizen.org/privilege/packagemanager.kill</privilege>
+               <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+               <privilege>http://tizen.org/privilege/packagemanager.install</privilege>
+               <privilege>http://tizen.org/privilege/appmanager.kill</privilege>
+               <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
                <privilege>http://tizen.org/privilege/inputgenerator</privilege>
+               <privilege>http://tizen.org/privilege/screenshot</privilege>
+               <privilege>http://tizen.org/privilege/location</privilege>
        </privileges>
        <feature name="http://tizen.org/feature/network.ethernet">true</feature>
 </manifest>
index 454bda5..58c369f 100644 (file)
@@ -1,5 +1,7 @@
 #include "InstallAppCommand.h"
 #include <fstream>
+#include <chrono>
+#include <thread>
 #include <loguru.hpp>
 #ifdef GBSBUILD
 #include <package_manager.h>
@@ -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
index 71f4692..32f7d11 100644 (file)
@@ -1,6 +1,7 @@
 #include "PostCommand.h"
 #include <atspi/atspi.h>
 #include <loguru.hpp>
+#include <Ecore.h>
 
 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;
 }
index 0fa6816..c5de333 100644 (file)
@@ -1,5 +1,7 @@
 #include "RemoveAppCommand.h"
 #include <loguru.hpp>
+#include <chrono>
+#include <thread>
 #ifdef GBSBUILD
 #include <package_manager.h>
 #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