summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjunkyu han <junkyu.han@samsung.com>2017-11-27 16:30:40 +0900
committerjunkyu han <junkyu.han@samsung.com>2017-11-27 19:39:52 +0900
commit13899a9accb4c2cfee3a3d9ca3377520160bebef (patch)
treeebd153f0923aa04944d2896cf8da56d46f2aa21b
parent933d79194ee09755dc9df9a12a85bf97c0a0d13b (diff)
downloadw3-home-13899a9accb4c2cfee3a3d9ca3377520160bebef.tar.gz
w3-home-13899a9accb4c2cfee3a3d9ca3377520160bebef.tar.bz2
w3-home-13899a9accb4c2cfee3a3d9ca3377520160bebef.zip
Change-Id: Iebe84669cbb2f3ed1b5c587bf1f3315ca2a47d14
-rwxr-xr-xdata/org.tizen.w-home.xml.in1
-rwxr-xr-xpackaging/org.tizen.w-home.spec1
-rwxr-xr-xsrc/clock.c13
-rwxr-xr-xsrc/moments/moments_control_flight_mode.c120
-rwxr-xr-xsrc/moments/moments_manager.c34
5 files changed, 157 insertions, 12 deletions
diff --git a/data/org.tizen.w-home.xml.in b/data/org.tizen.w-home.xml.in
index 738a7d9..b928c4b 100755
--- a/data/org.tizen.w-home.xml.in
+++ b/data/org.tizen.w-home.xml.in
@@ -25,6 +25,7 @@
<privilege>http://tizen.org/privilege/packagemanager.info</privilege>
<privilege>http://tizen.org/privilege/notification</privilege>
<privilege>http://tizen.org/privilege/telephony</privilege>
+ <privilege>http://tizen.org/privilege/telephony.admin</privilege>
<privilege>http://tizen.org/privilege/network.get</privilege>
<privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
<privilege>http://tizen.org/privilege/volume.set</privilege>
diff --git a/packaging/org.tizen.w-home.spec b/packaging/org.tizen.w-home.spec
index 351c001..b3756e4 100755
--- a/packaging/org.tizen.w-home.spec
+++ b/packaging/org.tizen.w-home.spec
@@ -42,6 +42,7 @@ BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-ui-efl-util)
BuildRequires: pkgconfig(capi-telephony)
BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(tapi)
%ifarch %{arm}
%define ARCH arm
diff --git a/src/clock.c b/src/clock.c
index cd477b6..a2cf80f 100755
--- a/src/clock.c
+++ b/src/clock.c
@@ -98,6 +98,12 @@ static void _clock_set_dnd_icon(int is_dnd_mode, Evas_Object *layout)
{
Evas_Object *image = NULL;
image = elm_image_add(layout);
+ static int current_dnd_mode = -1;
+
+ if (is_dnd_mode == current_dnd_mode)
+ return;
+
+ current_dnd_mode = is_dnd_mode;
if (is_dnd_mode) {
elm_image_file_set(image, IMG_DND_ICON, NULL);
@@ -135,6 +141,13 @@ static void _clock_set_flight_mode_icon(int is_flight_mode, Evas_Object *layout)
Evas_Object *image = NULL;
image = elm_image_add(layout);
+ static int current_flight_mode = -1;
+
+ if (is_flight_mode == current_flight_mode)
+ return;
+
+ current_flight_mode = is_flight_mode;
+
if (is_flight_mode) {
elm_image_file_set(image, IMG_FLIGHT_MODE, NULL);
if (indicator_data.is_left == 0) {
diff --git a/src/moments/moments_control_flight_mode.c b/src/moments/moments_control_flight_mode.c
index 5c075ea..75591c4 100755
--- a/src/moments/moments_control_flight_mode.c
+++ b/src/moments/moments_control_flight_mode.c
@@ -16,6 +16,11 @@
#include <efl_extension.h>
+#include <tapi_common.h>
+#include <TapiUtility.h>
+#include <ITapiSim.h>
+#include <ITapiModem.h>
+#include <TelPower.h>
#include <vconf.h>
#include "log.h"
@@ -28,13 +33,101 @@
static struct __control_flight_mode_s {
Evas_Object *flight_mode_popup;
Evas_Object *flight_mode_layout;
+ TapiHandle *tel_handle;
} s_info = {
.flight_mode_popup = NULL,
.flight_mode_layout = NULL,
+ .tel_handle = NULL,
};
extern control_info_t control_button_list[MOMENTS_CONTROLS_MAX];
+
+static int __init_tapi_handle(void)
+{
+ TelSimCardStatus_t sim_status = TAPI_SIM_STATUS_UNKNOWN;
+ int card_changed = 0;
+ int ret = 0;
+
+ char **cp_names = tel_get_cp_name_list();
+ if (!cp_names) {
+ _E("Failed to get cp_names");
+ return -1;
+ }
+
+ s_info.tel_handle = tel_init(cp_names[0]);
+ if (!s_info.tel_handle) {
+ _E("Failed to init tapi handle");
+ return -1;
+ }
+
+ ret = tel_get_sim_init_info(s_info.tel_handle, &sim_status, &card_changed);
+ if (ret != TAPI_API_SUCCESS) {
+ _E("Failed to get sim init info[%d]", ret);
+ return -1;
+ }
+
+ _D("SIM NAME: %s, %d", cp_names[0], sim_status);
+
+ free(cp_names);
+ return 0;
+}
+
+static void __fini_tapi_handle(void)
+{
+ if (s_info.tel_handle) {
+ tel_deinit(s_info.tel_handle);
+ s_info.tel_handle = NULL;
+ }
+}
+
+static void __tapi_flightmode_event_cb(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ _D("Set Call State as Flight Mode Result[%d]", result);
+
+ switch (result) {
+ case TAPI_POWER_FLIGHT_MODE_RESP_ON:
+ break;
+ case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
+ __fini_tapi_handle();
+ break;
+ case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
+ _E("Failed to set call state as flight mode");
+ break;
+ case TAPI_POWER_FLIGHT_MODE_RESP_MAX:
+ break;
+ default:
+ break;
+ }
+}
+
+static int __set_call_state_as_flight_mode(bool current_flight_mode)
+{
+ int ret = TAPI_API_SUCCESS;
+ tapi_power_flight_mode_type_t mode;
+
+ if (!s_info.tel_handle) {
+ ret = __init_tapi_handle();
+ if (ret != 0) {
+ _E("Failed to init tapi handle[%d]", ret);
+ return -1;
+ }
+ }
+
+ if (!current_flight_mode)
+ mode = TAPI_POWER_FLIGHT_MODE_ENTER;
+ else
+ mode = TAPI_POWER_FLIGHT_MODE_LEAVE;
+
+ ret = tel_set_flight_mode(s_info.tel_handle, mode, __tapi_flightmode_event_cb, NULL);
+ if (ret != TAPI_API_SUCCESS) {
+ _E("Failed to set tapi flight mode event cb[%d]", ret);
+ return -1;
+ }
+
+ return 0;
+}
+
static void __flight_mode_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
{
if (evas_object_visible_get(s_info.flight_mode_popup) == false)
@@ -48,12 +141,20 @@ static void __flight_mode_popup_cancel_cb(void *data, Evas_Object *obj, void *ev
static void __flight_mode_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
{
+ int ret = 0;
+
if (evas_object_visible_get(s_info.flight_mode_popup) == false)
return;
- int ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
- if (ret < 0)
- _E("Failed to set vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
+ if (!moments_check_is_3g_device()) {
+ ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, true);
+ if (ret < 0)
+ _E("Failed to set vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
+ } else {
+ ret = __set_call_state_as_flight_mode(false);
+ if (ret < 0)
+ _E("Failed to set call state as flight mode");
+ }
elm_popup_dismiss(s_info.flight_mode_popup);
s_info.flight_mode_popup = NULL;
@@ -131,9 +232,16 @@ void moments_control_flight_mode_pressed_cb(void *data, Evas *e, Evas_Object *ob
moments_hide();
__flight_mode_popup_view_create();
} else {
- int ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
- if (ret < 0)
- _E("Failed to set vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
+ int ret = 0;
+ if (moments_check_is_3g_device()) {
+ ret = __set_call_state_as_flight_mode(is_flight_mode);
+ if (ret < 0)
+ _E("Failed to set call state as flight mode");
+ } else {
+ ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, false);
+ if (ret < 0)
+ _E("Failed to set vconfkey(%s) : %d", VCONFKEY_TELEPHONY_FLIGHT_MODE, ret);
+ }
}
}
diff --git a/src/moments/moments_manager.c b/src/moments/moments_manager.c
index 349b778..a0c4a81 100755
--- a/src/moments/moments_manager.c
+++ b/src/moments/moments_manager.c
@@ -461,10 +461,18 @@ static void __callsignal_state_changed_cb(telephony_h handle, telephony_noti_e n
_D("Callsignal Strength or Roaming State is changed");
int callsignal_strength = 0;
bool is_roaming = false;
+ int is_flight = 0;
- __get_callsignal_state(&is_roaming, &callsignal_strength);
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight) < 0) {
+ _E("Failed to get vconfkey for flight");
+ return;
+ }
- moments_status_callsignal_update(callsignal_strength, is_roaming);
+ if (!is_flight) {
+ __get_callsignal_state(&is_roaming, &callsignal_strength);
+
+ moments_status_callsignal_update(callsignal_strength, is_roaming);
+ }
}
static void __callsignal_enable(void)
{
@@ -491,10 +499,18 @@ static void __network_type_changed_cb(keynode_t *node, void *user_data)
_D("Network type or Packet type is changed");
int network_type = 0;
int packet_type = 0;
+ int is_flight = 0;
+
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight) < 0) {
+ _E("Failed to get vconfkey for flight");
+ return;
+ }
- __get_network_strength_and_packet_type(&network_type, &packet_type);
+ if (!is_flight) {
+ __get_network_strength_and_packet_type(&network_type, &packet_type);
- moments_status_network_update(network_type, network_type == 0 ? network_type : packet_type+NETWORK_PACKET_INDEX_START);
+ moments_status_network_update(network_type, network_type == 0 ? network_type : packet_type+NETWORK_PACKET_INDEX_START);
+ }
}
static void __network_enable(void)
{
@@ -536,13 +552,13 @@ static void __network_packet_type_changed_cb(telephony_h handle, telephony_noti_
static void __flight_mode_changed_cb(keynode_t *node, void *user_data)
{
- _D("Flight Mode is changed");
int is_flight = 0;
if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight) < 0) {
_E("Failed to get vconfkey for flight");
return;
}
+ _D("Flight Mode is changed to [%d]", is_flight);
// on
if (is_flight) {
if (moments_check_is_3g_device() && s_info.telephony_initialized) {
@@ -658,13 +674,19 @@ static void __callforwarding_state_changed_cb(keynode_t *node, void *user_data)
{
_D("Callforwarding State is changed");
int state = 0;
+ int is_flight = 0;
+
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight) < 0) {
+ _E("Failed to get vconfkey for flight");
+ return;
+ }
if (vconf_get_int(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, &state) < 0) {
_E("Failed to get vconfkey for callforwarding");
return;
}
- if (state == VCONFKEY_TELEPHONY_CALL_FORWARD_ON)
+ if (state == VCONFKEY_TELEPHONY_CALL_FORWARD_ON && !is_flight)
moments_status_callforwarding_icon_show();
else
moments_status_callforwarding_icon_hide();