From d598b584422167463f5f95bc29b0a16fe216091d Mon Sep 17 00:00:00 2001 From: "gs86.lee" Date: Fri, 10 Jun 2016 13:16:42 +0900 Subject: [PATCH] [mobile] Fix JIRA issue(TSAM-4595) : Lockscreen launches on calling device_display_change_state Change-Id: I55825a3ab299538fc516a6071f7c200668e0e4c0 --- CMakeLists.txt | 2 + packaging/starter.spec | 2 + src/mobile/hw_key.c | 12 +---- src/mobile/lock_mgr.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 132 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 357e058..68ef92c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,8 @@ pkg_check_modules(pkgs REQUIRED capi-appfw-app-manager capi-network-bluetooth capi-system-system-settings + capi-system-info + capi-telephony feedback alarm-service pkgmgr-info diff --git a/packaging/starter.spec b/packaging/starter.spec index ce21cc8..ed06e90 100644 --- a/packaging/starter.spec +++ b/packaging/starter.spec @@ -35,6 +35,8 @@ BuildRequires: pkgconfig(efl-extension) BuildRequires: tts BuildRequires: tts-devel BuildRequires: pkgconfig(capi-message-port) +BuildRequires: pkgconfig(capi-telephony) +BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(efl-extension) %else if "%{profile}" == "ivi" BuildRequires: tts diff --git a/src/mobile/hw_key.c b/src/mobile/hw_key.c index d9942db..27e814c 100644 --- a/src/mobile/hw_key.c +++ b/src/mobile/hw_key.c @@ -229,11 +229,7 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) /* Priority 3 : Check the lock status */ if ((status_passive_get()->idle_lock_state == VCONFKEY_IDLE_LOCK) && (status_active_get()->setappl_screen_lock_type_int > SETTING_SCREEN_LOCK_TYPE_NONE)) { - if (!strcmp(ev->keyname, KEY_BACK)) { - _D("Back key is released"); - } else { - _D("phone lock state, ignore home key."); - } + _D("phone lock state, ignore home key."); return ECORE_CALLBACK_RENEW; } @@ -304,7 +300,7 @@ static Eina_Bool _key_press_cb(void *data, int type, void *event) _D("_key_press_cb : %s Pressed", ev->keyname); /* Priority 1 : Cancel */ - /* every reserved events have to be canceld when cancel key is pressed */ + /* every reserved events have to be canceld when cancel key is pressed */ if (!strcmp(ev->keyname, KEY_CANCEL)) { _D("Cancel button is pressed"); key_info.cancel = EINA_TRUE; @@ -741,11 +737,7 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) /* Priority 3 : Check the lock status */ if ((status_passive_get()->idle_lock_state == VCONFKEY_IDLE_LOCK) && (status_active_get()->setappl_screen_lock_type_int > SETTING_SCREEN_LOCK_TYPE_NONE)) { - if (!strcmp(ev->keyname, key_name[KEY_BACK])) { - _D("Back key is released"); - } else { _D("phone lock state, ignore home key."); - } return ECORE_CALLBACK_RENEW; } diff --git a/src/mobile/lock_mgr.c b/src/mobile/lock_mgr.c index e328aa8..dec24dd 100644 --- a/src/mobile/lock_mgr.c +++ b/src/mobile/lock_mgr.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include "lock_mgr.h" #include "package_mgr.h" @@ -38,6 +40,8 @@ #include "util.h" #include "status.h" +#define SYSTEM_INFO_KEY_NETWORK_TELEPHONY "http://tizen.org/feature/network.telephony" + static struct { @@ -45,13 +49,17 @@ static struct { int old_lock_type; int lock_pid; int lcd_state; + Eina_Bool is_support_telephony; } s_lock_mgr = { .checkfd = 0, .old_lock_type = 0, .lock_pid = -1, .lcd_state = -1, + .is_support_telephony = EINA_FALSE, }; +static telephony_handle_list_s tel_handle_list; + int lock_mgr_lcd_state_get(void) @@ -68,6 +76,88 @@ int lock_mgr_get_lock_pid(void) +static bool _check_support_telephony(void) +{ + int ret = 0; + bool is_support= EINA_FALSE; + + ret = system_info_get_platform_bool(SYSTEM_INFO_KEY_NETWORK_TELEPHONY, &is_support); + if (ret != SYSTEM_INFO_ERROR_NONE) { + _E("Failed to get system information : %s", SYSTEM_INFO_KEY_NETWORK_TELEPHONY); + return false; + } + + return is_support; +} + + + +static void _init_telephony(void) +{ + int ret = 0; + + ret = telephony_init(&tel_handle_list); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to initialize telephony"); + } +} + + + +static void _deinit_telephony(void) +{ + int ret = 0; + + ret = telephony_deinit(&tel_handle_list); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to deinitialize telephony"); + } +} + + + +static Eina_Bool _check_call_idle_status(void) +{ + telephony_call_h *call_list = NULL; + unsigned int call_count = 0; + int ret = 0; + int i = 0, j = 0; + + for (i = 0; i < tel_handle_list.count; i++) { + ret = telephony_call_get_call_list(tel_handle_list.handle[i], &call_count, &call_list); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to get telephony call list"); + continue; + } + + if (call_count == 0) { + _E("[%d] No calls available", i); + } else { + for (j = 0; j < call_count; j++) { + telephony_call_status_e status; + + ret = telephony_call_get_status(call_list[i], &status); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to get call status(%d)", ret); + continue; + } + + if (status != TELEPHONY_CALL_STATUS_IDLE) { + _D("[%d] call status : %d", i, status); + telephony_call_release_call_list(call_count, &call_list); + return EINA_FALSE; + } + } + } + + telephony_call_release_call_list(call_count, &call_list); + } + + return EINA_TRUE; +} + + + void lock_mgr_sound_play(lock_sound_type_e type) { int val = status_passive_get()->setappl_sound_lock_bool; @@ -179,12 +269,37 @@ static void _on_lcd_changed_receive(void *data, DBusMessage *msg) s_lock_mgr.lcd_state = LCD_STATE_ON; } else if (lcd_off) { int idle_lock_state = 0; + Eina_Bool is_call_idle = EINA_TRUE; Eina_Bool ret = EINA_FALSE; s_lock_mgr.lcd_state = LCD_STATE_OFF; - idle_lock_state = status_passive_get()->idle_lock_state; _D("idle_lock_state(%d)", idle_lock_state); + is_call_idle = _check_call_idle_status(); + if (is_call_idle == EINA_FALSE) { + char *lcd_off_source = NULL; + + /* + * lcd off source + * string : 'powerkey' or 'timeout' or 'event' or 'unknown' + */ + lcd_off_source = dbus_util_msg_arg_get_str(msg); + _I("lcd off source : %s", lcd_off_source); + + if (lcd_off_source) { + /* If LCD turn off by means other than 'powerkey' when call is running, + * do not launch lockscreen. + */ + if (strncmp(lcd_off_source, "powerkey", strlen(lcd_off_source))) { + _E("Do not launch lockscreen"); + free(lcd_off_source); + return; + } + + free(lcd_off_source); + } + } + if (idle_lock_state == VCONFKEY_IDLE_UNLOCK) { ret = lock_mgr_lockscreen_launch(); if (ret != EINA_TRUE) { @@ -268,6 +383,7 @@ static int _lock_type_changed_cb(status_active_key_e key, void *data) } + int lock_mgr_daemon_start(void) { int lock_type = 0; @@ -280,6 +396,11 @@ int lock_mgr_daemon_start(void) status_active_register_cb(STATUS_ACTIVE_KEY_SETAPPL_SCREEN_LOCK_TYPE_INT, _lock_type_changed_cb, NULL); + s_lock_mgr.is_support_telephony = _check_support_telephony(); + if (s_lock_mgr.is_support_telephony == true) { + _init_telephony(); + } + ret = lock_mgr_lockscreen_launch(); if (ret != EINA_TRUE) { _E("Failed to launch lockscreen"); @@ -298,5 +419,9 @@ void lock_mgr_daemon_end(void) { status_active_unregister_cb(STATUS_ACTIVE_KEY_SETAPPL_SCREEN_LOCK_TYPE_INT, _lock_type_changed_cb); + if (s_lock_mgr.is_support_telephony == EINA_TRUE) { + _deinit_telephony(); + } + feedback_deinitialize(); } -- 2.7.4