From 8170501d4a425477cf6d36e2ddd49df80f91ee58 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Sat, 10 Dec 2016 17:33:54 +0900 Subject: [PATCH] powerkey-popup : devide powerkey popup according to telephony support Change-Id: I88c9c9974abfd3e634dea8d771ef68df02c88d28 Signed-off-by: lokilee73 --- packaging/system-servant.spec | 1 + src/powerkey/CMakeLists.txt | 1 + src/powerkey/powerkey-wearable.c | 64 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/packaging/system-servant.spec b/packaging/system-servant.spec index 90fb9b6..4e65a38 100755 --- a/packaging/system-servant.spec +++ b/packaging/system-servant.spec @@ -99,6 +99,7 @@ BuildRequires: pkgconfig(capi-media-wav-player) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-media-recorder) +BuildRequires: pkgconfig(capi-system-info) BuildRequires: model-build-features %if "%{?model_build_feature_formfactor}" == "circle" diff --git a/src/powerkey/CMakeLists.txt b/src/powerkey/CMakeLists.txt index 8cea45c..2c47e99 100755 --- a/src/powerkey/CMakeLists.txt +++ b/src/powerkey/CMakeLists.txt @@ -39,6 +39,7 @@ SET(PKG_MODULES feedback efl-extension capi-appfw-application + capi-system-info ) IF("${DPMS}" STREQUAL "x") diff --git a/src/powerkey/powerkey-wearable.c b/src/powerkey/powerkey-wearable.c index bcadd7d..0dd614d 100755 --- a/src/powerkey/powerkey-wearable.c +++ b/src/powerkey/powerkey-wearable.c @@ -19,7 +19,7 @@ #include "popup-common.h" #include - +#include "system_info_type.h" #define SYSTEMD_STOP_POWER_OFF 4 @@ -30,8 +30,11 @@ #define POWER_METHOD "reboot" #define POWER_OPERATION_OFF "poweroff" #define TIMEOUT_POWEROFF 5 /* seconds */ +#define TELEPHONY_PATH "tizen.org/feature/network.telephony" extern appdata_s *app_info; +extern int system_info_get_platform_bool(const char *key, bool *value); + static Evas_Object *flight_icon = NULL; enum { @@ -59,6 +62,19 @@ static void set_flight_icon(int value); static __attribute__ ((constructor)) void powerkey_register_popup(void); static const struct popup_ops powerkey_ops; static const struct popup_ops flightmode_ops; +static const struct popup_ops poweroff_ops; + +static int is_supported(const char *path) +{ + bool res; + + if (system_info_get_platform_bool(path, &res) != SYSTEM_INFO_ERROR_NONE) { + _E("Fail to get TELEPHONY INFO"); + return -1; + } + + return res; +} static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) @@ -470,6 +486,24 @@ static void flight_mode_terminate(const struct popup_ops *ops) unregister_handlers(ops); } +static void remove_other_poweroff_popups(const struct popup_ops *ops) +{ + if (ops != &poweroff_ops) + unload_simple_popup(&poweroff_ops); +} + +static int poweroff_launch(bundle *b, const struct popup_ops *ops) +{ + remove_other_poweroff_popups(ops); + register_handlers(ops); + return 0; +} + +static void poweroff_terminate(const struct popup_ops *ops) +{ + unregister_handlers(ops); +} + static const struct popup_ops powerkey_ops = { .name = "powerkey", .show = powerkey_list, @@ -490,8 +524,32 @@ static const struct popup_ops flightmode_ops = { .terminate = flight_mode_terminate, }; +static const struct popup_ops poweroff_ops = { + .name = "powerkey", + .show = load_simple_popup, + .title = "IDS_ST_BODY_POWER_OFF", + .content = "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q", + .left_text = "IDS_COM_SK_CANCEL", + .right_text = "IDS_HS_BUTTON_POWER_OFF_ABB2", + .right = poweroff_clicked, + .pre = poweroff_launch, + .terminate = poweroff_terminate, +}; + static __attribute__ ((constructor)) void powerkey_register_popup(void) { - register_popup(&powerkey_ops); - register_popup(&flightmode_ops); + int telephony_supported = -1; + + telephony_supported = is_supported(TELEPHONY_PATH); + _I("TELEPHONY = %d", telephony_supported); + if (telephony_supported > 1 || telephony_supported < 0) { + _E("Cannot decide powerkey type!"); + telephony_supported = 0; + } + + if (telephony_supported) { + register_popup(&powerkey_ops); + register_popup(&flightmode_ops); + } else + register_popup(&poweroff_ops); } -- 2.7.4