bootstrap: turn display on just before executing commands
authorWonki Kim <wonki_.kim@samsung.com>
Fri, 24 Apr 2020 10:52:42 +0000 (19:52 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Sat, 25 Apr 2020 05:58:37 +0000 (14:58 +0900)
commands might be working properly while display isn't in off state.
this patch turns the display on just before executing commands.

Change-Id: I8a6b38fbe13a7d1b04e6ba65e9f1c58492ab7578

org.tizen.aurum-bootstrap/meson.build
org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml
org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc
org.tizen.aurum-bootstrap/src/Commands/PreCommand.cc
packaging/aurum.spec

index aeb2413..4327453 100644 (file)
@@ -49,6 +49,7 @@ bootstrap_svr_dep = [
 if get_option('tizen') == true
 bootstrap_svr_dep += [
    dependency('capi-appfw-app-control'),
+   dependency('capi-system-device'),
    dependency('capi-appfw-app-manager'),
    dependency('capi-appfw-package-manager'),
    dependency('capi-appfw-service-application'),
index f7c6fa1..04f7f0e 100644 (file)
@@ -22,6 +22,7 @@
                <privilege>http://tizen.org/privilege/inputgenerator</privilege>
                <privilege>http://tizen.org/privilege/screenshot</privilege>
                <privilege>http://tizen.org/privilege/location</privilege>
+               <privilege>http://tizen.org/privilege/display</privilege>
        </privileges>
        <feature name="http://tizen.org/feature/network.ethernet">true</feature>
 </manifest>
index 6002a94..86326eb 100644 (file)
@@ -49,6 +49,6 @@ LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp* request,
 ::grpc::Status LaunchAppCommand::executePost()
 {
     LOG_SCOPE_F(INFO, "LaunchAppCommand::executePost");
-    std::this_thread::sleep_for(std::chrono::milliseconds{1500});
+    std::this_thread::sleep_for(std::chrono::milliseconds{2500});
     return grpc::Status::OK;
 }
\ No newline at end of file
index a0f13ff..b978b9c 100644 (file)
@@ -2,6 +2,14 @@
 #include <atspi/atspi.h>
 #include <loguru.hpp>
 
+#include <thread>
+#include <chrono>
+
+#include <Ecore.h>
+#include <device/power.h>
+#include <device/display.h>
+#include <device/callback.h>
+
 PreCommand::PreCommand() : PreCommand(nullptr) {}
 PreCommand::PreCommand(Command *cmd) : mCommand{cmd} {}
 
@@ -9,6 +17,43 @@ PreCommand::PreCommand(Command *cmd) : mCommand{cmd} {}
 {
     {
         LOG_SCOPE_F(INFO, "PreCommand --------------- ");
+
+        bool isDisplayOn = (bool)ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+            display_state_e state;
+            if(device_display_get_state(&state) == DEVICE_ERROR_NONE) {
+                return (void*)(state);
+            }
+            return NULL;
+        }, NULL) != (display_state_e)DISPLAY_STATE_SCREEN_OFF;
+
+        if (!isDisplayOn)
+        {
+            LOG_F(INFO, "display state : SCREEN_OFF, turn display on");
+            ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+                if (device_power_wakeup(false) != DEVICE_ERROR_NONE) {
+                    LOG_F(INFO, "turning display up has failed");
+                    return NULL;
+                }
+                if (device_power_request_lock(POWER_LOCK_DISPLAY, 10*1000) != DEVICE_ERROR_NONE) {
+                    LOG_F(INFO, "request lock device has failed");
+                    return NULL;
+                }
+                return NULL;
+            }, NULL); //FIXME : extract ecore dep from here
+
+            // sleep for display on effect
+            std::this_thread::sleep_for(std::chrono::milliseconds{5*1000});
+        } else {
+            LOG_F(INFO, "display state : SCREEN_ON, lock display on");
+            ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+                if (device_power_request_lock(POWER_LOCK_DISPLAY, 10*1000) != DEVICE_ERROR_NONE) {
+                    LOG_F(INFO, "request lock device has failed");
+                    return NULL;
+                }
+                return NULL;
+            }, NULL); //FIXME : extract ecore dep from here
+        }
+
         AtspiAccessible *n = atspi_get_desktop(0);
         if (n) {
             char *name = atspi_accessible_get_name(n, NULL);
@@ -23,4 +68,4 @@ PreCommand::PreCommand(Command *cmd) : mCommand{cmd} {}
 ::grpc::Status PreCommand::executePost()
 {
     return mCommand->executePost();
-}
\ No newline at end of file
+}
index 60f5072..bfea344 100644 (file)
@@ -24,6 +24,7 @@ BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(capi-appfw-app-control)
 BuildRequires: pkgconfig(capi-appfw-app-manager)
 BuildRequires: pkgconfig(capi-appfw-service-application)
+BuildRequires: pkgconfig(capi-system-device)
 BuildRequires: pkgconfig(libtzplatform-config)
 
 %if "%{?profile}" == "tv"