powerkey-popup : devide powerkey popup according to telephony support 05/103905/4
authorlokilee73 <changjoo.lee@samsung.com>
Sat, 10 Dec 2016 08:33:54 +0000 (17:33 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 12 Dec 2016 01:48:12 +0000 (10:48 +0900)
Change-Id: I88c9c9974abfd3e634dea8d771ef68df02c88d28
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
packaging/system-servant.spec
src/powerkey/CMakeLists.txt
src/powerkey/powerkey-wearable.c

index 90fb9b6..4e65a38 100755 (executable)
@@ -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"
index 8cea45c..2c47e99 100755 (executable)
@@ -39,6 +39,7 @@ SET(PKG_MODULES
                feedback
                efl-extension
                capi-appfw-application
+               capi-system-info
 )
 
 IF("${DPMS}" STREQUAL "x")
index bcadd7d..0dd614d 100755 (executable)
@@ -19,7 +19,7 @@
 
 #include "popup-common.h"
 #include <app.h>
-
+#include "system_info_type.h"
 
 #define SYSTEMD_STOP_POWER_OFF 4
 
 #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);
 }