summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjunkyu han <junkyu.han@samsung.com>2017-07-19 17:28:06 +0900
committerjunkyu han <junkyu.han@samsung.com>2017-07-19 18:58:11 +0900
commit9c33a190865c2f8eff43f2f918804844571ce7a3 (patch)
treede4a11407354ff391080c9efa26d4b1705773f65
parent3df908c8e8adb0e3842b9c723ec019aa7eda9bb0 (diff)
downloadw3-home-9c33a190865c2f8eff43f2f918804844571ce7a3.tar.gz
w3-home-9c33a190865c2f8eff43f2f918804844571ce7a3.tar.bz2
w3-home-9c33a190865c2f8eff43f2f918804844571ce7a3.zip
Change-Id: Ie1a2e9ee79736be8083fdb51e1bbfb1d3271fd28
-rwxr-xr-xsrc/moments/moments_manager.c149
1 files changed, 91 insertions, 58 deletions
diff --git a/src/moments/moments_manager.c b/src/moments/moments_manager.c
index 34c187a..4dc91d9 100755
--- a/src/moments/moments_manager.c
+++ b/src/moments/moments_manager.c
@@ -40,12 +40,14 @@ static struct __manager_s {
Evas_Object *layout;
bool visible;
bool on_initialization;
+ bool telephony_initialized;
} s_info = {
.win = NULL,
.bg_scroller = NULL,
.layout = NULL,
.visible = false,
.on_initialization = false,
+ .telephony_initialized = false,
};
static telephony_handle_list_s handle_list;
@@ -130,7 +132,6 @@ bool moments_check_is_with_phone_via_bluetooth(void)
bool moments_check_is_call_fwd_enable(void)
{
- return true;
int status = 0;
if (vconf_get_int(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, &status) < 0) {
_E("Failed to get vconfkey : %s", VCONFKEY_TELEPHONY_CALL_FORWARD_STATE);
@@ -141,7 +142,6 @@ bool moments_check_is_call_fwd_enable(void)
bool moments_check_is_music_enable(void)
{
- return true;
package_info_h package_info = NULL;
if (package_info_create(MUSIC_PKG_NAME, &package_info) != PACKAGE_MANAGER_ERROR_NONE) {
@@ -242,12 +242,14 @@ static void __initialize_status_view(void)
__battery_state_changed_cb(-1, NULL, NULL);
if (moments_check_is_3g_device()) {
_D("This device is 3G DEVICE");
- moments_status_callsignal_icon_show();
- moments_status_network_icon_show();
- __callsignal_state_changed_cb(NULL, 0, NULL, NULL);
- __network_type_changed_cb(NULL, NULL);
- __location_service_state_changed_cb(0, NULL);
- __callforwarding_state_changed_cb(NULL, NULL);
+ if (s_info.telephony_initialized) {
+ moments_status_callsignal_icon_show();
+ moments_status_network_icon_show();
+ __callsignal_state_changed_cb(NULL, 0, NULL, NULL);
+ __network_type_changed_cb(NULL, NULL);
+ __location_service_state_changed_cb(0, NULL);
+ __callforwarding_state_changed_cb(NULL, NULL);
+ }
}
__wifi_state_changed_cb(NULL, NULL);
__bluetooth_state_changed_cb(NULL, NULL);
@@ -257,6 +259,73 @@ static void __initialize_status_view(void)
s_info.on_initialization = false;
}
+static void __initialize_telephony_service(void)
+{
+ int ret = TELEPHONY_ERROR_NONE;
+
+ ret = telephony_init(&handle_list);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to initialize telephony");
+ return;
+ }
+
+ /* Sim State */
+ ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS, __simcard_state_changed_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to set telephony notify sim state callback");
+ return;
+ }
+
+ __simcard_state_changed_cb(handle_list.handle[0], 0, NULL, NULL);
+
+ /* Telephony service state */
+ ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE, __telephony_service_state_changed_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to set telephony notify service state callback");
+ return;
+ }
+
+ /* CallSignal */
+ ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, __callsignal_state_changed_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to set telephony notify signal strength callback");
+ return;
+ }
+ ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_ROAMING_STATUS, __callsignal_state_changed_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to set telephony notify roaming status callback");
+ return;
+ }
+
+ /* Network */
+ vconf_notify_key_changed(VCONFKEY_DNET_STATE, __network_type_changed_cb, NULL);
+ ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_PS_TYPE, __network_packet_type_changed_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ _E("Falied to set telephony notify ps type callback");
+ return;
+ }
+
+ /* Location */
+ ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_GPS_STATUS, __location_service_state_changed_cb, NULL);
+ if (ret != RUNTIME_INFO_ERROR_NONE) {
+ _E("Failed to set location changed cb");
+ return;
+ }
+
+ /* Callforwarding */
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, __callforwarding_state_changed_cb, NULL);
+
+ s_info.telephony_initialized = true;
+}
+
+static void __telephony_state_changed_cb(telephony_state_e state, void *user_data)
+{
+ if (state == TELEPHONY_STATE_READY && !s_info.telephony_initialized) {
+ __initialize_telephony_service();
+ __initialize_status_view();
+ }
+}
+
static void __register_status_callback(void)
{
/* battery */
@@ -264,58 +333,20 @@ static void __register_status_callback(void)
device_add_callback(DEVICE_CALLBACK_BATTERY_CHARGING, __battery_state_changed_cb, NULL);
if (moments_check_is_3g_device()) {
+ telephony_state_e state;
int ret = TELEPHONY_ERROR_NONE;
- ret = telephony_init(&handle_list);
- if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to initialize telephony");
- return;
- }
-
- /* Sim State */
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_SIM_STATUS, __simcard_state_changed_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to set telephony notify sim state callback");
- return;
- }
-
- __simcard_state_changed_cb(handle_list.handle[0], 0, NULL, NULL);
-
- /* Telephony service state */
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE, __telephony_service_state_changed_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to set telephony notify service state callback");
- return;
- }
-
- /* CallSignal */
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL, __callsignal_state_changed_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to set telephony notify signal strength callback");
- return;
- }
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_ROAMING_STATUS, __callsignal_state_changed_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to set telephony notify roaming status callback");
- return;
- }
- /* Network */
- vconf_notify_key_changed(VCONFKEY_DNET_STATE, __network_type_changed_cb, NULL);
- ret = telephony_set_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_PS_TYPE, __network_packet_type_changed_cb, NULL);
+ ret = telephony_get_state(&state);
if (ret != TELEPHONY_ERROR_NONE) {
- _E("Falied to set telephony notify ps type callback");
+ _E("Falied to get telephony state");
return;
}
- /* Location */
- ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_GPS_STATUS, __location_service_state_changed_cb, NULL);
- if (ret != RUNTIME_INFO_ERROR_NONE) {
- _E("Failed to set location changed cb");
- return;
+ if (state == TELEPHONY_STATE_READY) {
+ __initialize_telephony_service();
+ } else {
+ ret = telephony_set_state_changed_cb(__telephony_state_changed_cb, NULL);
}
-
- /* Callforwarding */
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, __callforwarding_state_changed_cb, NULL);
}
/* FLIGHT MODE */
vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __flight_mode_changed_cb, NULL);
@@ -378,6 +409,8 @@ static void __unregister_status_callback(void)
vconf_ignore_key_changed(VCONFKEY_DNET_STATE, __network_type_changed_cb);
vconf_ignore_key_changed(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, __callforwarding_state_changed_cb);
+
+ s_info.telephony_initialized = false;
}
vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __flight_mode_changed_cb);
@@ -510,7 +543,7 @@ static void __flight_mode_changed_cb(keynode_t *node, void *user_data)
}
// on
if (is_flight) {
- if (moments_check_is_3g_device()) {
+ if (moments_check_is_3g_device() && s_info.telephony_initialized) {
__callsignal_disable();
__network_disable();
moments_status_callforwarding_icon_hide();
@@ -521,7 +554,7 @@ static void __flight_mode_changed_cb(keynode_t *node, void *user_data)
moments_status_headset_icon_hide();
} else {
// off
- if (moments_check_is_3g_device()) {
+ if (moments_check_is_3g_device() && s_info.telephony_initialized) {
__callsignal_enable();
__callforwarding_state_changed_cb(NULL, NULL);
}
@@ -552,11 +585,11 @@ static void __wifi_state_changed_cb(keynode_t *node, void *user_data)
__get_wifi_strength_and_packet_type(&network_type, &packet_type);
moments_status_network_update(network_type + MOMENT_STATUS_SIGNAL_WIFI_INDEX, packet_type+15);
} else {
- if (moments_check_is_3g_device()) {
- _D("WIFI DISCONNECTED, 3G");
+ if (moments_check_is_3g_device() && s_info.telephony_initialized) {
+ _D("WIFI DISCONNECTED, 3G");
__network_enable();
} else {
- _D("WIFI DISCONNECTED, NOT 3G");
+ _D("WIFI DISCONNECTED, NOT 3G");
moments_status_network_icon_hide();
}
}