From 282413319be99f27a48f6512378c39182dc2e5cb Mon Sep 17 00:00:00 2001 From: "changjoo.lee" Date: Tue, 7 Jun 2016 17:39:41 +0900 Subject: [PATCH] Fix always active issue of sysapp-launcher after boot-up. And removed tts function in source code. Change-Id: Ibbc17dd6fde7262258e779f59b000c569164a6a3 Signed-off-by: changjoo.lee --- CMakeLists.txt | 1 + packaging/system-servant.spec | 10 ++ src/launcher/launcher.h | 5 +- system-cooperator/CMakeLists.txt | 38 +++++ system-cooperator/system-cooperator.c | 271 ++++++++++++++++++++++++++++++++++ 5 files changed, 321 insertions(+), 4 deletions(-) create mode 100755 system-cooperator/CMakeLists.txt create mode 100755 system-cooperator/system-cooperator.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fa07ec..e14becd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,4 +60,5 @@ ADD_SUBDIRECTORY(src/crash) ADD_SUBDIRECTORY(src/launcher) ADD_SUBDIRECTORY(src/po) ADD_SUBDIRECTORY(signal-sender) +ADD_SUBDIRECTORY(system-cooperator) ADD_SUBDIRECTORY(src/overheat) \ No newline at end of file diff --git a/packaging/system-servant.spec b/packaging/system-servant.spec index 3de8cb7..8484596 100755 --- a/packaging/system-servant.spec +++ b/packaging/system-servant.spec @@ -18,6 +18,7 @@ %define watchdog_popup off %define overheat_popup off %define storage_popup off +%define system_cooperator off %if "%{?profile}" == "mobile" %define PROFILE mobile @@ -27,6 +28,7 @@ %define system_popup on %define notification_service on %define signal_sender on +%define system_cooperator on #sub-popups of system-popup %define battery_popup on %define mmc_popup on @@ -49,6 +51,7 @@ %define powerkey_popup on %define crash_popup on %define system_popup on +%define system_cooperator on #sub-popups of system-popup %define storage_popup on %define watchdog_popup on @@ -94,6 +97,8 @@ BuildRequires: pkgconfig(feedback) BuildRequires: pkgconfig(efl-extension) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: edje-bin +BuildRequires: pkgconfig(capi-media-sound-manager) +BuildRequires: pkgconfig(capi-media-wav-player) %if %{with x} BuildRequires: pkgconfig(ecore-x) @@ -204,6 +209,7 @@ cp %{SOURCE2003} . -DBATTERY_POPUP=%{battery_popup} \ -DSYSTEM_POPUP=%{system_popup} \ -DSIGNAL_SENDER=%{signal_sender} \ + -DSYSTEM_COOPERATOR=%{system_cooperator} \ -DMMC_POPUP=%{mmc_popup} \ -DSTORAGE_POPUP=%{storage_popup} \ -DUSB_POPUP=%{usb_popup} \ @@ -293,6 +299,10 @@ rm -rf %{buildroot} %{TZ_SYS_RO_SHARE}/system-apps/res/icons/led_torch.png %endif +%if %{system_cooperator} == on +%{_bindir}/system-cooperator +%endif + %if %{crash_popup} == on %files -n org.tizen.crash-syspopup %manifest org.tizen.crash-syspopup.manifest diff --git a/src/launcher/launcher.h b/src/launcher/launcher.h index 6e3d847..67ec930 100755 --- a/src/launcher/launcher.h +++ b/src/launcher/launcher.h @@ -59,7 +59,7 @@ /* App launching */ #define CRADLE_APP_NAME "org.tizen.desk-dock" #define PWLOCK_APP_NAME "org.tizen.pwlock" -#define SERVANT_APP_NAME "/usr/bin/system-servant" +#define SERVANT_APP_NAME "/usr/bin/system-cooperator" enum noti_type { NOTI_NONE = 0, @@ -81,9 +81,6 @@ enum noti_type { }; enum service_type { - TTS_SCREENOFF, - TTS_ENABLED, - TTS_DISABLED, CHARGER_CONNECTION, SERVICE_MAX, }; diff --git a/system-cooperator/CMakeLists.txt b/system-cooperator/CMakeLists.txt new file mode 100755 index 0000000..b348258 --- /dev/null +++ b/system-cooperator/CMakeLists.txt @@ -0,0 +1,38 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(system-cooperator C) + +IF(SYSTEM_COOPERATOR STREQUAL off) + RETURN() +ENDIF(SYSTEM_COOPERATOR STREQUAL off) + +SET(SRCS ${CMAKE_SOURCE_DIR}/system-cooperator/system-cooperator.c) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) + +SET(PKG_MODULES + appcore-efl + glib-2.0 + vconf + dlog + feedback + capi-media-sound-manager + capi-media-wav-player +) +INCLUDE(FindPkgConfig) +pkg_check_modules(system-cooperator_pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${system-cooperator_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -g") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ") +SET(CMAKE_C_FLAGS_RELEASE "-O2") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + +ADD_DEFINITIONS("-DAPPNAME=\"${PROJECT}\"") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${system-cooperator_pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin) diff --git a/system-cooperator/system-cooperator.c b/system-cooperator/system-cooperator.c new file mode 100755 index 0000000..6ef683b --- /dev/null +++ b/system-cooperator/system-cooperator.c @@ -0,0 +1,271 @@ +/* + * system-cooperator + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef LOG_TAG +#define LOG_TAG "SYSTEM_APPS" +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) +#define _I(fmt, args...) SLOGI(fmt, ##args) + +#define CHARGER_TIMEOUT 2000 /* Milliseconds */ + +#define CHARGER_CONNECTION_PATH "/usr/share/feedback/sound/operation/operation.wav" + +enum service_type { + CHARGER_CONNECTION, + SERVICE_MAX, +}; + +enum loop_type { + LOOP_ERROR, + LOOP_G_MAIN_LOOP, +}; + +enum sound_status { + SOUND, + VIBRATION, + MUTE, +}; + +static GMainLoop *loop = NULL; +static int loop_type = LOOP_ERROR; + +static void quit_main_loop(ltype) +{ + switch (ltype) { + case LOOP_G_MAIN_LOOP: + g_main_loop_quit(loop); + break; + default: + break; + } +} + +static int get_sound_state(void) +{ + int state; + + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &state) == 0 + && state == 1) + return SOUND; + + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &state) == 0 + && state == 1) + return VIBRATION; + + return MUTE; +} + +static bool get_call_state(void) +{ + int state; + if (vconf_get_int(VCONFKEY_CALL_STATE, &state) == 0 + && state != VCONFKEY_CALL_OFF) + return true; + return false; +} + +static bool get_voice_recording_state(void) +{ + int state; + if (vconf_get_int(VCONFKEY_RECORDER_STATE, &state) == 0 + && (state == VCONFKEY_RECORDER_STATE_RECORDING)) + return true; + return false; +} + +static void play_completed(int id, void *data) +{ + quit_main_loop(loop_type); +} + +static gboolean time_expired(gpointer data) +{ + quit_main_loop(loop_type); + return FALSE; +} + +static void play_notification_sound(void) +{ + int ret; + static bool session = false; + + if (access(CHARGER_CONNECTION_PATH, F_OK) != 0) { + _E("The sound file does not exist (%d)", CHARGER_CONNECTION_PATH); + return; + } + + if (!session) { + ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_NOTIFICATION); + if (ret != SOUND_MANAGER_ERROR_NONE) { + _E("Failed to set session to play sound(%d)", ret); + return; + } + } + + ret = wav_player_start(CHARGER_CONNECTION_PATH, SOUND_TYPE_NOTIFICATION, play_completed, NULL, NULL); + if (ret != WAV_PLAYER_ERROR_NONE) + _E("Failed to play sound file (%d, %s)", ret, CHARGER_CONNECTION_PATH); +} + +static void play_feedback(int pattern) +{ + feedback_initialize(); + feedback_play_type(FEEDBACK_TYPE_VIBRATION, pattern); + feedback_deinitialize(); +} + +static int play_battery_sound(void) +{ + int sound; + + sound = get_sound_state(); + switch (sound) { + case SOUND: + if (!get_call_state() && !get_voice_recording_state()) { + play_notification_sound(); + break; + } + case VIBRATION: + play_feedback(FEEDBACK_PATTERN_CHARGERCONN); + break; + case MUTE: + default: + break; + } + g_timeout_add(CHARGER_TIMEOUT, time_expired, NULL); + return 0; +} + +static int app_create(int type) +{ + switch (type) { + case CHARGER_CONNECTION: + return play_battery_sound(); + default: + _E("Unknown type(%d)", type); + return -EINVAL; + } +} + +static int app_terminate(int type) +{ + switch (type) { + case CHARGER_CONNECTION: + return 0; + default: + _E("Unknown type(%d)", type); + return -EINVAL; + } +} + +static int get_main_loop_type(int type) +{ + switch (type) { + case CHARGER_CONNECTION: + return LOOP_G_MAIN_LOOP; + default: + return LOOP_ERROR; + } +} + +static int init_main_loop(int ltype) +{ + switch (ltype) { + case LOOP_G_MAIN_LOOP: + loop = g_main_loop_new(NULL, TRUE); + if (!loop) + return -ENOMEM; + return 0; + default: + return -EINVAL; + } +} + +static void start_main_loop(int ltype) +{ + switch (ltype) { + case LOOP_G_MAIN_LOOP: + g_main_loop_run(loop); + break; + default: + break; + } +} + +static void finalize_main_loop(int ltype) +{ + switch (ltype) { + case LOOP_G_MAIN_LOOP: + g_main_loop_unref(loop); + break; + default: + break; + } +} + +int main(int argc, char *argv[]) +{ + int ret, type; + + ret = appcore_set_i18n(LANG_DOMAIN, LOCALE_DIR); + if (ret != 0) + _E("FAIL: appcore_set_i18n()"); + + if (argc <= 1) + return 0; + + type = atoi(argv[1]); + loop_type = get_main_loop_type(type); + + ret = init_main_loop(loop_type); + if (ret < 0) { + _E("Failed to init main loop (%d)", ret); + return ret; + } + + ret = app_create(type); + if (ret < 0) { + _E("Failed to register handlers"); + goto out; + } + + start_main_loop(loop_type); + +out: + ret = app_terminate(type); + if (ret < 0) + _E("Failed to release handlers(%d)", ret); + + finalize_main_loop(loop_type); + + return 0; +} -- 2.7.4