Commit c43f5c1bdf517c01fb0dd76b7df2c91c9b23021e

Authored by Eunki, Hong
1 parent d9b72be5

Fix dali-demo SIGKILL issue

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
... ... @@ -227,6 +227,19 @@ IF( ENABLE_PKG_CONFIGURE )
227 227  
228 228 SET( ENABLE_SCENE_LOADER "ON" )
229 229 ENDIF()
  230 +
  231 + # if build as tizen platform, use capi-appfw-app-control
  232 + IF( TIZEN )
  233 + pkg_check_modules(CAPI_APPFW_APP_CONTROL capi-appfw-app-control)
  234 + IF( CAPI_APPFW_APP_CONTROL_FOUND)
  235 + FOREACH(flag ${CAPI_APPFW_APP_CONTROL_CFLAGS})
  236 + SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
  237 + ENDFOREACH(flag)
  238 + FOREACH(flag ${CAPI_APPFW_APP_CONTROL_LDFLAGS})
  239 + SET(REQUIRED_PKGS_LDFLAGS "${REQUIRED_PKGS_LDFLAGS} ${flag}")
  240 + ENDFOREACH(flag)
  241 + ENDIF()
  242 + ENDIF()
230 243 ENDIF()
231 244  
232 245 SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
... ... @@ -417,6 +430,18 @@ ADD_SUBDIRECTORY(examples-reel)
417 430 ADD_SUBDIRECTORY(tests-reel)
418 431 ADD_SUBDIRECTORY(builder)
419 432  
  433 +# Setup CURRENT_BUILD_PLATFORM to use at message
  434 +IF(ANDROID)
  435 + SET(CURRENT_BUILD_PLATFORM "Android")
  436 +ELSEIF(WIN32)
  437 + SET(CURRENT_BUILD_PLATFORM "Windows")
  438 +ELSEIF(APPLE)
  439 + SET(CURRENT_BUILD_PLATFORM "MacOS")
  440 +ELSEIF(TIZEN)
  441 + SET(CURRENT_BUILD_PLATFORM "Tizen")
  442 +ELSE()
  443 + SET(CURRENT_BUILD_PLATFORM "Ubuntu")
  444 +ENDIF()
420 445  
421 446 MESSAGE( " Folder DEMO_IMAGE_DIR : [" ${DEMO_IMAGE_DIR} "]" )
422 447 MESSAGE( " Folder DEMO_STYLE_DIR : [" ${DEMO_STYLE_DIR} "]" )
... ... @@ -429,4 +454,5 @@ MESSAGE( &quot; Folder DEMO_SCRIPT_DIR : [&quot; ${DEMO_SCRIPT_DIR} &quot;]&quot; )
429 454 MESSAGE( " Folder DEMO_LOCALE_DIR : [" ${DEMO_LOCALE_DIR} "]" )
430 455 MESSAGE( " Folder DEMO_EXAMPLE_BIN : [" ${DEMO_EXAMPLE_BIN} "]" )
431 456 MESSAGE( " Folder DEMO_LANG : [" ${DEMO_LANG} "]" )
  457 +MESSAGE( " Current Build Platform : [" ${CURRENT_BUILD_PLATFORM} "]" )
432 458 MESSAGE( " Scene Loader Enabled : [" ${ENABLE_SCENE_LOADER} "]" )
... ...
build/tizen/demo/CMakeLists.txt
... ... @@ -19,6 +19,11 @@ ELSEIF(ANDROID)
19 19 ${DEMO_SRCS}
20 20 "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
21 21 )
  22 +ELSEIF(TIZEN)
  23 + SET(DEMO_SRCS
  24 + ${DEMO_SRCS}
  25 + "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
  26 + )
22 27 ELSE()
23 28 SET(DEMO_SRCS
24 29 ${DEMO_SRCS}
... ...
build/tizen/examples-reel/CMakeLists.txt
... ... @@ -19,6 +19,11 @@ ELSEIF(ANDROID)
19 19 ${EXAMPLES_REEL_SRCS}
20 20 "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
21 21 )
  22 +ELSEIF(TIZEN)
  23 + SET(EXAMPLES_REEL_SRCS
  24 + ${EXAMPLES_REEL_SRCS}
  25 + "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
  26 + )
22 27 ELSE()
23 28 SET(EXAMPLES_REEL_SRCS
24 29 ${EXAMPLES_REEL_SRCS}
... ...
build/tizen/tests-reel/CMakeLists.txt
... ... @@ -19,6 +19,11 @@ ELSEIF(ANDROID)
19 19 ${TESTS_REEL_SRCS}
20 20 "${ROOT_SRC_DIR}/shared/execute-process-android.cpp"
21 21 )
  22 +ELSEIF(TIZEN)
  23 + SET(TESTS_REEL_SRCS
  24 + ${TESTS_REEL_SRCS}
  25 + "${ROOT_SRC_DIR}/shared/execute-process-tizen.cpp"
  26 + )
22 27 ELSE()
23 28 SET(TESTS_REEL_SRCS
24 29 ${TESTS_REEL_SRCS}
... ...
com.samsung.dali-demo.xml
... ... @@ -344,6 +344,7 @@
344 344 <!-- END OF ALPHABETICAL ORDER SORT. -->
345 345  
346 346 <privileges>
  347 + <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
347 348 <privilege>http://tizen.org/privilege/mediastorage</privilege>
348 349 <privilege>http://tizen.org/privilege/externalstorage</privilege>
349 350 <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege>
... ...
packaging/com.samsung.dali-demo.spec
... ... @@ -15,6 +15,7 @@ Requires(postun): /sbin/ldconfig
15 15 BuildRequires: cmake
16 16 BuildRequires: pkgconfig
17 17 BuildRequires: pkgconfig(capi-appfw-application)
  18 +BuildRequires: pkgconfig(capi-appfw-app-control)
18 19 BuildRequires: pkgconfig(capi-media-player)
19 20 BuildRequires: pkgconfig(dlog)
20 21 BuildRequires: gettext-tools
... ... @@ -66,6 +67,7 @@ cmake -DDALI_APP_DIR=%{dali_app_ro_dir}/bin \
66 67 %endif
67 68 -DLOCAL_STYLE_DIR=%{local_style_dir} \
68 69 -DINTERNATIONALIZATION:BOOL=OFF \
  70 + -DTIZEN:BOOL=ON \
69 71 .
70 72  
71 73 make %{?jobs:-j%jobs}
... ...
shared/execute-process-tizen.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +// FILE HEADER
  19 +#include "execute-process.h"
  20 +
  21 +// EXTERNAL INCLUDES
  22 +#include <dali/public-api/common/dali-common.h>
  23 +#include <dali/integration-api/debug.h>
  24 +#include <app_control.h>
  25 +
  26 +namespace {
  27 +
  28 +#define MATCH_THEN_RETURN_ERROR_NAME(ret, error_type) \
  29 +do \
  30 +{ \
  31 + if(ret == error_type) \
  32 + { \
  33 + return #error_type; \
  34 + } \
  35 +} while(0)
  36 +
  37 +const char* GetAppControlErrorName(int ret)
  38 +{
  39 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_NONE);
  40 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_INVALID_PARAMETER);
  41 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_OUT_OF_MEMORY);
  42 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_APP_NOT_FOUND);
  43 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_KEY_NOT_FOUND);
  44 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_KEY_REJECTED);
  45 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_INVALID_DATA_TYPE);
  46 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_LAUNCH_REJECTED);
  47 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_PERMISSION_DENIED);
  48 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_LAUNCH_FAILED);
  49 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_TIMED_OUT);
  50 + MATCH_THEN_RETURN_ERROR_NAME(ret, APP_CONTROL_ERROR_IO_ERROR);
  51 + return "Unknown error!";
  52 +}
  53 +
  54 +} // unnamed namespace
  55 +
  56 +void ExecuteProcess(const std::string& processName, Dali::Application& application)
  57 +{
  58 + app_control_h handle;
  59 + app_control_create(&handle);
  60 + app_control_set_app_id(handle, processName.c_str());
  61 +
  62 + DALI_LOG_RELEASE_INFO("Try to launch app[%s]\n", processName.c_str());
  63 + int ret = app_control_send_launch_request(handle, NULL, NULL);
  64 + if(ret == APP_CONTROL_ERROR_NONE)
  65 + {
  66 + DALI_LOG_RELEASE_INFO("Succeeded to launch app[%s]\n", processName.c_str());
  67 + }
  68 + else
  69 + {
  70 + DALI_LOG_ERROR("Fail to launch app[%s] ret=%d(%s)\n",processName.c_str(), ret, GetAppControlErrorName(ret));
  71 + DALI_ASSERT_ALWAYS(false && "Send launch request failed!");
  72 + }
  73 + app_control_destroy(handle);
  74 +}
... ...