Fix dali-demo SIGKILL issue 56/265956/6
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 2 Nov 2021 10:09:32 +0000 (19:09 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 3 Nov 2021 06:03:47 +0000 (15:03 +0900)
Use capi-appfw-appcontrol instead of unix default fork().
If process group is connected, AMD check whole of them as same process.
So even if child process call ecore_shutdown, it's parent process also killed after 5 seconds later.
That's why dali-examples / com.samsung.dali-demo got SIGKILL from amd.

This patch separate execute logic between unix and tizen by -DTIZEN:BOOL=ON option.
TIZEN will be set ON only at packaging/com.samsung.dali-demo.spec

NOTE. app_control_send_launch_request need privilege 'http://tizen.org/privilege/appmanager.launch'.

Change-Id: I1d37a21f0d3091c0dc2fcbb4806900256e464aa5
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
build/tizen/CMakeLists.txt
build/tizen/demo/CMakeLists.txt
build/tizen/examples-reel/CMakeLists.txt
build/tizen/tests-reel/CMakeLists.txt
com.samsung.dali-demo.xml
packaging/com.samsung.dali-demo.spec
shared/execute-process-tizen.cpp [new file with mode: 0644]

index df31de6052a75afe1c835dfd9ec59706202d0cf6..e3bda7d8f611af5cf78c746bcc06195c5c7126c9 100644 (file)
@@ -227,6 +227,19 @@ IF( ENABLE_PKG_CONFIGURE )
 
     SET( ENABLE_SCENE_LOADER "ON" )
   ENDIF()
+
+  # if build as tizen platform, use capi-appfw-app-control
+  IF( TIZEN )
+    pkg_check_modules(CAPI_APPFW_APP_CONTROL capi-appfw-app-control)
+    IF( CAPI_APPFW_APP_CONTROL_FOUND)
+      FOREACH(flag ${CAPI_APPFW_APP_CONTROL_CFLAGS})
+        SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
+      ENDFOREACH(flag)
+      FOREACH(flag ${CAPI_APPFW_APP_CONTROL_LDFLAGS})
+        SET(REQUIRED_PKGS_LDFLAGS "${REQUIRED_PKGS_LDFLAGS} ${flag}")
+      ENDFOREACH(flag)
+    ENDIF()
+  ENDIF()
 ENDIF()
 
 SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
@@ -417,6 +430,18 @@ ADD_SUBDIRECTORY(examples-reel)
 ADD_SUBDIRECTORY(tests-reel)
 ADD_SUBDIRECTORY(builder)
 
+# Setup CURRENT_BUILD_PLATFORM to use at message
+IF(ANDROID)
+  SET(CURRENT_BUILD_PLATFORM "Android")
+ELSEIF(WIN32)
+  SET(CURRENT_BUILD_PLATFORM "Windows")
+ELSEIF(APPLE)
+  SET(CURRENT_BUILD_PLATFORM "MacOS")
+ELSEIF(TIZEN)
+  SET(CURRENT_BUILD_PLATFORM "Tizen")
+ELSE()
+  SET(CURRENT_BUILD_PLATFORM "Ubuntu")
+ENDIF()
 
 MESSAGE( " Folder   DEMO_IMAGE_DIR : [" ${DEMO_IMAGE_DIR} "]" )
 MESSAGE( " Folder   DEMO_STYLE_DIR : [" ${DEMO_STYLE_DIR} "]" )
@@ -429,4 +454,5 @@ MESSAGE( " Folder  DEMO_SCRIPT_DIR : [" ${DEMO_SCRIPT_DIR} "]" )
 MESSAGE( " Folder  DEMO_LOCALE_DIR : [" ${DEMO_LOCALE_DIR} "]" )
 MESSAGE( " Folder DEMO_EXAMPLE_BIN : [" ${DEMO_EXAMPLE_BIN} "]" )
 MESSAGE( " Folder        DEMO_LANG : [" ${DEMO_LANG} "]" )
+MESSAGE( " Current Build Platform  : [" ${CURRENT_BUILD_PLATFORM} "]" )
 MESSAGE( " Scene Loader Enabled    : [" ${ENABLE_SCENE_LOADER} "]" )
index 855b82c4a34b7f754d3a60838e85edd1bef278fe..536849345ec3f49ca46ffca5fe59fa5ea7e787a2 100644 (file)
@@ -19,6 +19,11 @@ ELSEIF(ANDROID)
     ${DEMO_SRCS}
     "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
   )
+ELSEIF(TIZEN)
+  SET(DEMO_SRCS
+    ${DEMO_SRCS}
+    "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
+  )
 ELSE()
   SET(DEMO_SRCS
     ${DEMO_SRCS}
index 8b392e7190c7ca4775ed4ad51133eefbe2579a86..853e1c6d2490b8e9863b81a45ce895a89ce64fcc 100644 (file)
@@ -19,6 +19,11 @@ ELSEIF(ANDROID)
     ${EXAMPLES_REEL_SRCS}
     "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
   )
+ELSEIF(TIZEN)
+  SET(EXAMPLES_REEL_SRCS
+    ${EXAMPLES_REEL_SRCS}
+    "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
+  )
 ELSE()
   SET(EXAMPLES_REEL_SRCS
     ${EXAMPLES_REEL_SRCS}
index a4d0af889e218bdff7a51090ab7163fe7e4fd632..a4a04d958d45b7b7d20c4a8432aa81a8280a727b 100644 (file)
@@ -19,6 +19,11 @@ ELSEIF(ANDROID)
     ${TESTS_REEL_SRCS}
     "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
   )
+ELSEIF(TIZEN)
+  SET(TESTS_REEL_SRCS
+    ${TESTS_REEL_SRCS}
+    "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
+  )
 ELSE()
   SET(TESTS_REEL_SRCS
     ${TESTS_REEL_SRCS}
index 2c46609af1a9115586d4f1ece4bf19b78cd7af9b..2876eef1f0640282479fd5ff46d44a891a523706 100644 (file)
        <!-- END OF ALPHABETICAL ORDER SORT. -->
 
        <privileges>
+               <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
                <privilege>http://tizen.org/privilege/mediastorage</privilege>
                <privilege>http://tizen.org/privilege/externalstorage</privilege>
                <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege>
index 6235223a0864342cc38aeed8f0bf63c5749870bb..9de395746334c0b4623f960990aa4c43c41ca646 100755 (executable)
@@ -15,6 +15,7 @@ Requires(postun): /sbin/ldconfig
 BuildRequires:  cmake
 BuildRequires:  pkgconfig
 BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(capi-media-player)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  gettext-tools
@@ -66,6 +67,7 @@ cmake -DDALI_APP_DIR=%{dali_app_ro_dir}/bin \
 %endif
       -DLOCAL_STYLE_DIR=%{local_style_dir} \
       -DINTERNATIONALIZATION:BOOL=OFF \
+      -DTIZEN:BOOL=ON \
       .
 
 make %{?jobs:-j%jobs}
diff --git a/shared/execute-process-tizen.cpp b/shared/execute-process-tizen.cpp
new file mode 100644 (file)
index 0000000..aa1c4b7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+// FILE HEADER
+#include "execute-process.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/integration-api/debug.h>
+#include <app_control.h>
+
+namespace {
+
+#define MATCH_THEN_RETURN_ERROR_NAME(ret, error_type) \
+do                                                    \
+{                                                     \
+  if(ret == error_type)                               \
+  {                                                   \
+   return #error_type;                                \
+  }                                                   \
+} while(0)
+
+const char* GetAppControlErrorName(int ret)
+{
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_NONE);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_INVALID_PARAMETER);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_OUT_OF_MEMORY);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_APP_NOT_FOUND);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_KEY_NOT_FOUND);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_KEY_REJECTED);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_INVALID_DATA_TYPE);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_LAUNCH_REJECTED);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_PERMISSION_DENIED);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_LAUNCH_FAILED);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_TIMED_OUT);
+  MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_IO_ERROR);
+  return "Unknown error!";
+}
+
+} // unnamed namespace
+
+void ExecuteProcess(const std::string& processName, Dali::Application& application)
+{
+  app_control_h handle;
+  app_control_create(&handle);
+  app_control_set_app_id(handle, processName.c_str());
+
+  DALI_LOG_RELEASE_INFO("Try to launch app[%s]\n", processName.c_str());
+  int ret = app_control_send_launch_request(handle, NULL, NULL);
+  if(ret == APP_CONTROL_ERROR_NONE)
+  {
+    DALI_LOG_RELEASE_INFO("Succeeded to launch app[%s]\n", processName.c_str());
+  }
+  else
+  {
+    DALI_LOG_ERROR("Fail to launch app[%s] ret=%d(%s)\n",processName.c_str(), ret, GetAppControlErrorName(ret));
+    DALI_ASSERT_ALWAYS(false && "Send launch request failed!");
+  }
+  app_control_destroy(handle);
+}