From: lokilee73 Date: Sat, 10 Dec 2016 08:33:54 +0000 (+0900) Subject: powerkey-popup : devide powerkey popup according to telephony support X-Git-Tag: submit/tizen_3.0/20161212.050116~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F103905%2F4;p=platform%2Fcore%2Fsystem%2Fsystem-popup.git powerkey-popup : devide powerkey popup according to telephony support Change-Id: I88c9c9974abfd3e634dea8d771ef68df02c88d28 Signed-off-by: lokilee73 --- 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); }