Add new features and fixes 26/100626/6 accepted/tizen/common/20161214.160738 accepted/tizen/ivi/20161214.085609 accepted/tizen/mobile/20161214.085327 accepted/tizen/tv/20161214.085422 accepted/tizen/wearable/20161214.085531 submit/tizen/20161214.021341
authorSuresh Kumar N <suresh.n@samsung.com>
Mon, 28 Nov 2016 16:28:11 +0000 (21:58 +0530)
committerNarasimhaiah Suresh Kumar <suresh.n@samsung.com>
Tue, 13 Dec 2016 14:53:58 +0000 (06:53 -0800)
 - IMS related changes

Change-Id: I3da2e00b06b85944c6b0c85fab9655558c749aeb
Signed-off-by: Suresh Kumar N <suresh.n@samsung.com>
CMakeLists.txt
include/ps_common.h
include/ps_log.h
introspection/master.xml
src/ps_context.c
src/ps_log.c
src/ps_main.c
src/ps_master.c
src/ps_modem.c
src/ps_service.c
src/ps_tcore-interface.c

index 36b9e21..57b29e6 100644 (file)
@@ -27,7 +27,6 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-
 ### Purge unused code ###
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
 
-# model definitions #
 IF (CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
   ADD_DEFINITIONS("-DCONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER")
 ENDIF (CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
@@ -36,22 +35,23 @@ IF (TIZEN_PROFILE_IVI)
   SET(RES_DIR ${CMAKE_SOURCE_DIR}/resources/ivi)
 ELSE ()
   IF (SUPPORT_VOLTE)
+    ADD_DEFINITIONS("-DTIZEN_SUPPORT_VOLTE")
     SET(RES_DIR ${CMAKE_SOURCE_DIR}/resources/lte)
   ELSE ()
     SET(RES_DIR ${CMAKE_SOURCE_DIR}/resources/3g)
   ENDIF ()
 ENDIF ()
 
+# default definitions #
 ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG")
 ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"PS\"")
 ADD_DEFINITIONS("-DPLUGIN_VERSION=${VERSION}")
 ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
-#ADD_DEFINITIONS("-DTIZEN_UPS_ENABLED")
+ADD_DEFINITIONS("-DTIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL")
 IF(PREPAID_SIM_APN_SUPPORT)
        ADD_DEFINITIONS("-DPREPAID_SIM_APN_SUPPORT")
 ENDIF(PREPAID_SIM_APN_SUPPORT)
 
-#ADD_DEFINITIONS("-DPOWER_SAVING_FEATURE_WEARABLE")
 MESSAGE(${CMAKE_C_FLAGS})
 MESSAGE(${pkgs_LDFLAGS})
 
index aeb2c65..5b977b5 100644 (file)
@@ -75,6 +75,7 @@
 
 
 /*Storage Key value*/
+#define KEY_TELEPHONY_READY            STORAGE_KEY_TELEPHONY_READY
 #define KEY_3G_ENABLE                          STORAGE_KEY_3G_ENABLE
 #define KEY_DATA_ROAMING_SETTING       STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL
 #define KEY_POWER_SAVING_MODE          STORAGE_KEY_POWER_SAVING_MODE
@@ -86,6 +87,7 @@
 #define KEY_SAP_CONNECTION_TYPE                STORAGE_KEY_SAP_CONNECTION_TYPE
 #define KEY_WIFI_STATE STORAGE_KEY_WIFI_STATE_INT
 
+#define PS_ERR_PERM_DENIED "Permission Denied"
 #define PS_ERR_INTERNAL "Internal Error"
 #define PS_ERR_NO_SERVICE "NO service"
 #define PS_ERR_TRASPORT "No Transport"
 #define POWER_SAVING_MODE_POWERFUL 0x01
 #define POWER_SAVING_MODE_EMERGENCY 0x02
 #define POWER_SAVING_MODE_WEARABLE 0x03
-#define POWER_SAVING_MODE_FMM 0x10
+#define POWER_SAVING_MODE_DATA_ALLOWED 0x10
 
 /*Tizen CDMA dummy Profile Index*/
 #define PS_CDMA_DUMMY_PROFILE_IDX 0
 #define PS_CDMA_DUMMY_PROFILE_PLMN "00000"
 
-/*
- * PS plugin Private information
- */
-typedef struct {
-       GDBusConnection *conn; /* DBUS connection */
-       guint bus_id; /* Packet service BUS ID */
-
-       /* Parent plug-in */
-       TcorePlugin *p;
-
-       /* List of masters */
-       GSList *master;
-} PsPrivInfo;
-
 typedef enum {
        PS_SUBS_PRIMARY,
        PS_SUBS_SECONDARY,
@@ -177,6 +165,8 @@ typedef struct packet_service_master {
        GDBusConnection *conn;
        PacketServiceMaster *if_obj;
        GHashTable *modems;
+
+       gboolean initial_pdp_conn; // If FALSE, PDP never been connected for any of slots.
 } ps_master_t;
 
 typedef struct packet_service_modem {
@@ -197,17 +187,20 @@ typedef struct packet_service_modem {
        gboolean sim_init;
        gboolean reset_profile;
        gboolean flight_mode;
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        gboolean flight_mode_ups; /*CP state right before UPS*/
-
+#endif
        gboolean roaming_allowed;
        gboolean roaming;
        gboolean roaming_apn_support;
 
        gboolean data_allowed;
        gint ps_mode;
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        unsigned char hook_flag;
        gboolean mode_pref_changed;
        GQueue *work_queue;
+#endif
        gchar *cp_name;
        GHashTable *services;
        GSList *contexts;
@@ -227,17 +220,25 @@ typedef struct packet_service_service {
        gboolean ps_attached;
        gboolean roaming;
        gboolean restricted;
-       gboolean initial_pdp_conn; // If FALSE, PDP never been connected.
        gboolean wifi_connected_checked; // If TRUE, We already checked wifi-connected state.
        gboolean attach_apn_complete; // set TRUE, initial define is complete for attach APN.
        enum telephony_network_access_technology act;
-       /*PDP retry timer*/
-       alarm_id_t timer_src;
-       guint connection_timeout;
 
        GSList *contexts;
+
+       /* Track user requested activation; for re-try logic */
+       gboolean ims_activation_requested;
+
+       /* Track user requested activation; for re-try logic */
+       gboolean is_epdg_available;
 } ps_service_t;
 
+typedef struct {
+       PacketServiceContext *obj_context;
+       void *invocation;
+       void *user_data;
+} ps_remove_profile_data;
+
 typedef struct packet_service_context {
        gchar* path;
        gchar* mccmnc;
@@ -265,6 +266,12 @@ typedef struct packet_service_context {
        gpointer async_context;
        gpointer user_data;
        gboolean deact_required;
+       gboolean remove_profile_required;
+       ps_remove_profile_data *remove_profile_cb_data;
+
+       /* PDP retry timer */
+       alarm_id_t timer_src;
+       guint connection_timeout;
 } ps_context_t;
 
 
@@ -277,13 +284,13 @@ gboolean    _ps_master_get_storage_value_bool(gpointer master, enum tcore_storag
 gboolean    _ps_master_get_storage_value_int(gpointer master, enum tcore_storage_key key);
 gboolean    _ps_master_set_storage_value_bool(gpointer master, enum tcore_storage_key key, gboolean value);
 gboolean    _ps_master_set_storage_value_int(gpointer master, enum tcore_storage_key key, gint value);
+gboolean       _ps_master_set_always_on_control(gpointer master, gboolean enable);
 
 /*MODEM*/
 void           __remove_modem_handler(gpointer modem);
 gpointer    _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer master,
                                gchar* modem_name, gpointer co_modem, gchar *cp_name);
 void        _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object);
-gboolean       _ps_modem_send_filght_mode_request(gpointer value, void *data);
 gboolean    _ps_modem_processing_flight_mode(gpointer object, gboolean enable);
 gboolean    _ps_modem_processing_power_enable(gpointer modem, int enable);
 gboolean    _ps_modem_processing_sim_complete(gpointer modem, gboolean complete, gchar *operator);
@@ -293,6 +300,7 @@ GSource * _ps_modem_get_profile_reset_gsource(gpointer object);
 gboolean _ps_modem_set_profile_reset_gsource(gpointer object, GSource * source);
 gboolean  _ps_modem_remove_profile_reset_gsource(gpointer object);
 gboolean    _ps_modem_set_sim_enabled(gpointer object, gboolean value);
+gboolean       _ps_modem_connect_default_context(gpointer object);
 gboolean    _ps_modem_set_data_allowed(gpointer modem, gboolean value);
 gboolean    _ps_modem_get_data_allowed(gpointer modem);
 gboolean    _ps_modem_set_data_roaming_allowed(gpointer modem, gboolean value);
@@ -303,21 +311,24 @@ gboolean    _ps_modem_set_psmode(gpointer modem, gint value);
 gint           _ps_modem_get_psmode(gpointer modem);
 gint           _ps_modem_get_roaming_apn_support(gpointer object);
 void           _ps_modem_set_roaming_apn_support(gpointer object, gboolean value);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 guchar         _ps_modem_get_hook_flag(gpointer modem);
+#endif
 gboolean    _ps_modem_get_flght_mode(gpointer object);
-void           _ps_modem_set_flght_mode_ups(gpointer object, gboolean value);
-gboolean    _ps_modem_get_flght_mode_ups(gpointer object);
 gboolean    _ps_modem_get_sim_init(gpointer object);
 int    _ps_modem_get_power(gpointer object);
 gchar*      _ps_modem_ref_operator(gpointer object);
 gboolean       _ps_modem_get_properties_handler(gpointer object, GVariantBuilder * properties);
 GVariant*      _ps_modem_get_properties(gpointer object, GVariantBuilder *properties);
+gpointer       _ps_modem_ref_master(gpointer modem);
 GHashTable* _ps_modem_ref_services(gpointer modem);
 gchar*      _ps_modem_ref_path(gpointer modem);
 gpointer    _ps_modem_ref_plugin(gpointer modem);
 gpointer    _ps_modem_ref_dbusconn(gpointer modem);
 gpointer    _ps_modem_ref_co_modem(gpointer modem);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 gpointer       _ps_modem_ref_work_queue(gpointer modem);
+#endif
 gchar*         _ps_modem_ref_cp_name(gpointer modem);
 gpointer       _ps_modem_ref_contexts(gpointer modem);
 ps_subs_type _ps_modem_get_subs_type(gpointer modem);
@@ -342,7 +353,7 @@ gboolean    _ps_service_set_context_bearerinfo(gpointer object, struct tnoti_ps_de
 int            _ps_service_define_context(gpointer object, gpointer context);
 int         _ps_service_activate_context(gpointer service, gpointer context);
 gboolean    _ps_service_deactivate_context(gpointer service, gpointer context);
-void        _ps_service_set_retry_timeout_value(gpointer service, int value);
+void        _ps_service_set_retry_timeout_value(gpointer service, guint value);
 void        _ps_service_connection_timer(gpointer service, gpointer context);
 void        _ps_service_reset_connection_timer(gpointer context);
 int         _ps_service_connect_default_context(gpointer service);
@@ -354,17 +365,21 @@ gpointer    _ps_service_return_context_by_cid(gpointer object, int context_id);
 #endif
 void        _ps_service_remove_contexts(gpointer object);
 void        _ps_service_disconnect_contexts(gpointer service);
-void   _ps_service_disconnect_internet_mms_contexts(gpointer object);
+void   _ps_service_disconnect_internet_mms_tethering_contexts(gpointer object);
 gboolean    _ps_service_processing_network_event(gpointer service, gboolean ps_attached, gboolean roaming);
 gpointer    _ps_service_return_default_context(gpointer object, int svc_cat_id);
 gboolean    _ps_service_set_connected(gpointer service, gpointer cstatus, gboolean enabled);
-void           _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid);
+void           _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid);
 gboolean    _ps_service_set_ps_attached(gpointer service, gboolean value);
 gboolean    _ps_service_set_number_of_pdn_cnt(gpointer object, gchar *operator);
 gboolean    _ps_service_set_roaming(gpointer service, gboolean value);
 gboolean    _ps_service_get_roaming(gpointer object);
 gboolean    _ps_service_set_restricted(gpointer object, gboolean value);
 gboolean    _ps_service_get_restricted(gpointer object);
+gboolean _ps_service_set_ims_activation_requested(gpointer object, gboolean enabled);
+gboolean _ps_service_get_ims_activation_requested(gpointer object);
+gboolean _ps_service_set_epdg_status(gpointer object, gboolean available);
+gboolean _ps_service_get_epdg_status(gpointer object);
 gboolean    _ps_service_set_access_technology(gpointer service,
                                enum telephony_network_access_technology value);
 enum telephony_ps_state
@@ -411,7 +426,9 @@ gboolean    _ps_context_set_bearer_info(gpointer object, struct tnoti_ps_dedicated
 gboolean       _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name);
 
 /*PLUGIN INTERFACE*/
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 void        _ps_get_network_mode(gpointer data);
+#endif
 gboolean    _ps_hook_co_modem_event(gpointer modem);
 gboolean    _ps_free_co_modem_event(gpointer modem);
 gboolean    _ps_get_co_modem_values(gpointer modem);
@@ -425,20 +442,24 @@ gboolean _ps_free_co_modem_event(gpointer modem);
 gboolean    _ps_update_cellular_state_key(gpointer service);
 
 /* Utilities */
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command, unsigned int data_len, const void *data, void *user_data);
 void __ps_modem_cp_reset_send_pending_request_response(gpointer data);
+#endif
 enum tcore_hook_return ps_handle_dds(Server *s, UserRequest *ur, void *user_data);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_data);
 void __ps_send_pending_user_request(gpointer data);
+#endif
 #ifdef POWER_SAVING_FEATURE_WEARABLE
 typedef enum {
        ON_REQUEST,
        ON_NON_CALL_NOTI_HOOK,
        ON_CALL_NOTI_HOOK,
 }__ps_call_flow_type;
-
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type,enum tcore_notification_command command);
-
+#endif
 #endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
 
 enum tcore_hook_return __on_hook_modem_added(Server *s, CoreObject *source, enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data);
index 8397593..2b032d2 100644 (file)
 
 #pragma once
 
-extern gchar *ps_log_get_tag(CoreObject *co);
+#define PS_LOG_TAG_BUFFER 32
+
+extern const gchar *ps_log_get_cp_name(CoreObject *co);
 
 #define ps_err_ex_co(c,...) do {       \
-               gchar *tag = ps_log_get_tag(c); \
-               err_ex(tag, "[ERROR] "__VA_ARGS__);     \
-               g_free(tag);    \
+               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
+               int subs_type = tcore_object_ref_subscription_type(c);  \
+               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
+               err_ex(tag_buffer, "[ERROR] "__VA_ARGS__);      \
        } while (0)
 
 #define ps_warn_ex_co(c,...) do {      \
-               gchar *tag = ps_log_get_tag(c); \
-               warn_ex(tag, "[WARN] "__VA_ARGS__);     \
-               g_free(tag);    \
+               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
+               int subs_type = tcore_object_ref_subscription_type(c);  \
+               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
+               warn_ex(tag_buffer, "[WARN] "__VA_ARGS__);      \
        } while (0)
 
 #define ps_msg_ex_co(c,...) do {       \
-               gchar *tag = ps_log_get_tag(c); \
-               msg_ex(tag, __VA_ARGS__);       \
-               g_free(tag);    \
+               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
+               int subs_type = tcore_object_ref_subscription_type(c);  \
+               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
+               msg_ex(tag_buffer, __VA_ARGS__);        \
        } while (0)
 
 #define ps_dbg_ex_co(c,...) do {       \
-               gchar *tag = ps_log_get_tag(c); \
-               dbg_ex(tag, __VA_ARGS__);       \
-               g_free(tag);    \
+               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
+               int subs_type = tcore_object_ref_subscription_type(c);  \
+               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
+               dbg_ex(tag_buffer, __VA_ARGS__);        \
+       } while (0)
+
+#define ps_info_ex_co(c,...) do {      \
+               gchar tag_buffer[PS_LOG_TAG_BUFFER];  \
+               int subs_type = tcore_object_ref_subscription_type(c);  \
+               g_snprintf(tag_buffer, PS_LOG_TAG_BUFFER, "%s/SUBS-%d", MODULE_TAG, subs_type);  \
+               info_ex(tag_buffer, __VA_ARGS__);       \
        } while (0)
+
index 901b966..b8f6d89 100644 (file)
@@ -3,6 +3,10 @@
                <method name="GetModems">
                        <arg  type="a{sa{ss}}" name="modem_hash" direction="out" />
                </method>
+               <method name="SetAlwayson">
+                       <arg  type="b" name="enable" direction="in" />
+                       <arg  type="b" name="result" direction="out" />
+               </method>
                <signal name="ModemAdded">
                        <arg  type="a{ss}" name="modem" direction="out" />
                </signal>
index e447c08..bf859a5 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
+#define MODULE_TAG "PS-CONTEXT"
+
 #define PROP_DEFAULT           FALSE
 #define PROP_DEFAULT_STR       NULL
 #define DATABASE_PATH_0                tzplatform_mkpath(TZ_SYS_DB, ".dnet.db")
 #define DATABASE_PATH_1                tzplatform_mkpath(TZ_SYS_DB, ".dnet2.db")
 #define DELAY_TO_SIGNAL_EMIT 1
 
+#define TIMEOUT_DEFAULT                5
+#define TIMEOUT_MAX                    1800
+
 typedef struct {
        const char *mccmnc;
        const char *apn;
@@ -70,6 +75,7 @@ OperatorTable attach_apn_preference[] = {
        {"45005", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "220.103.220.10", "2001:2d8:00e0:0220::10"},
        {"45006", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
        {"45008", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
+       {"45028", "", CONTEXT_TYPE_IPV4V6, CONTEXT_ROLE_IMS, "", ""},
 };
 
 static void __ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context);
@@ -78,7 +84,7 @@ static void _ps_context_setup_interface(PacketServiceContext *context, ps_contex
 
 static gboolean __ps_context_create_storage_handle(gpointer plugin);
 static gchar *__ps_context_create_path(char *profile_name, int profile_id, int svc_ctg_id, gchar *cp_name);
-static gboolean __ps_context_profile_is_attach_apn(CoreObject *co_context, const gchar *mccmnc);
+static gboolean __ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc);
 static gboolean __ps_context_create_co_context(gpointer context, GHashTable *property, gchar *cp_name);
 static gboolean __ps_context_update_profile(ps_context_t *context, GHashTable *property);
 static gboolean __ps_context_update_database(ps_context_t *context);
@@ -99,17 +105,15 @@ void __remove_context_handler(gpointer data)
 {
        ps_context_t *context = data;
 
-       dbg("Entered");
-
        if (!context) {
-               dbg("Context is Null");
+               err("Context is Null");
                return;
        }
 
        /*Need to UNexport and Unref the master Object */
        g_object_unref(context->if_obj);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context removed for the path [%s]", context->path);
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context removed for the path [%s]", context->path);
 
        g_free(context->path);
        g_free(context->mccmnc);
@@ -192,7 +196,7 @@ static void __ps_context_emit_dedicated_bearer_info_signal(ps_context_t *context
        ps_warn_ex_co(co_network, "context (%p) emit the dedicated bearer infomation signal", context);
 }
 
-static void __ps_context_emit_property_changed_signal(ps_context_t *context)
+void __ps_context_emit_property_changed_signal(ps_context_t *context)
 {
        GVariant *gv = NULL;
        GVariantBuilder property;
@@ -216,11 +220,9 @@ gboolean _ps_context_remove_context(gpointer context)
        ps_service_t *service = _ps_context_ref_service(pscontext);
 
        g_return_val_if_fail(pscontext != NULL, FALSE);
-       g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(pscontext->path != NULL, FALSE);
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(service),
-               "remove context (%s)", pscontext->path);
+       dbg("remove context (%s)", pscontext->path);
 
        /*Removing the context from the static list */
        _ps_service_reset_connection_timer(context);
@@ -230,8 +232,10 @@ gboolean _ps_context_remove_context(gpointer context)
        g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(pscontext->if_obj));
 
        /* remove context from the list (modem, service) */
-       tcore_ps_remove_context(service->co_ps,
-               (CoreObject *)_ps_context_ref_co_context(context));
+       if (service) {
+               tcore_ps_remove_context(service->co_ps,
+                       (CoreObject *)_ps_context_ref_co_context(context));
+       }
        tcore_context_free(pscontext->co_context);
 
        /* free allocated resources for context. */
@@ -239,7 +243,7 @@ gboolean _ps_context_remove_context(gpointer context)
        g_free(pscontext->path);
        g_free(pscontext);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return TRUE;
 }
 
@@ -259,7 +263,7 @@ static gchar *__ps_context_create_path(char *profile_name, int profile_id, int s
        int str_len = 0, context_index = 0;
 
        if (!profile_name) {
-               dbg("profile_name is null");
+               err("[%s] profile_name is null", cp_name);
                return NULL;
        }
 
@@ -281,52 +285,63 @@ static gchar *__ps_context_create_path(char *profile_name, int profile_id, int s
        dbg("converted name(%s) path(%s)", profile_name, in_path);
 
        path = g_strdup_printf("%s_%d_%d", in_path, profile_id, svc_ctg_id);
-       dbg("path (%s)", path);
+       info("path (%s)", path);
 
        g_free(in_path);
        return path;
 }
 
-static gboolean __ps_context_profile_is_attach_apn(CoreObject *co_context, const gchar *mccmnc)
+static gboolean __ps_context_update_attach_apn(GSList *contexts, const gchar *mccmnc)
 {
-       gboolean attach_apn = FALSE, default_conn = FALSE;
-       int role = 0;
+       gboolean ret = FALSE;
+       unsigned int pos = 0;
+       enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
+       CoreObject *default_internet = NULL;
 
-       if (co_context == NULL)
-               goto EXIT;
+#ifndef TIZEN_SUPPORT_VOLTE
+       warn("VoLTE is NOT supported, use default setting.");
+       role = CONTEXT_ROLE_INTERNET;
+       goto UPDATE;
+#endif
 
-       default_conn = tcore_context_get_default_profile(co_context);
-       role = tcore_context_get_role(co_context);
+       if (contexts == NULL || mccmnc == NULL)
+               return ret;
 
-       /*
-        * TODO: Read CSC Configuration routine.
-        * By default, default Ineternet profile will be used for PS attach.
-        * CSC will define APN for PS attach according to operator requirement.
-        */
-        if (default_conn) {
-               int i, count;
-               gboolean matched = FALSE;
-
-               count = sizeof(attach_apn_preference) / sizeof(attach_apn_preference[0]);
-               for (i = 0; i < count ; i++) {
-                       if (g_strcmp0(attach_apn_preference[i].mccmnc, mccmnc) == 0) {
-                               if (attach_apn_preference[i].role == role) {
-                                       dbg("index[%d], attach_apn_preference[%d].role: %d, role: %d, apn: %s",
-                                               i, i, attach_apn_preference[i].role, role, attach_apn_preference[i].apn);
-                                       attach_apn = TRUE;
-                               }
-                               matched = TRUE;
-                               break;
+       info("Internet profile by default.");
+       role = CONTEXT_ROLE_INTERNET;
+
+UPDATE:
+        for (pos = 0; pos < g_slist_length(contexts); pos++) {
+               ps_context_t *context = g_slist_nth_data(contexts, pos);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               int p_role = tcore_context_get_role(co_context);
+               gboolean default_profile = tcore_context_get_default_profile(co_context);
+
+               if (default_profile) {
+                       char *apn = tcore_context_get_apn(co_context);
+
+                       if (p_role == CONTEXT_ROLE_INTERNET)
+                               default_internet = co_context;
+
+                       if (role == p_role) {
+                               info("Attach APN: role[%d], apn[%s]", p_role, apn);
+                               tcore_context_set_attach_apn(co_context, TRUE);
+                               ret = TRUE;
+                       } else {
+                               /* otherwise, reset to FALSE. */
+                               info("Reset APN: role[%d], apn[%s]", p_role, apn);
+                               tcore_context_set_attach_apn(co_context, FALSE);
                        }
+                       g_free(apn);
                }
-               if (!matched) {
-                       if (role == CONTEXT_ROLE_INTERNET)
-                               attach_apn = TRUE;
-                }
         }
-EXIT:
-       dbg("role(%d), attach_apn (%d)", role, attach_apn);
-       return attach_apn;
+
+       if (ret != TRUE && default_internet) {
+               warn("Attach APN preference: role[%d] but there is no matched profile.", role);
+               tcore_context_set_attach_apn(default_internet, TRUE);
+               ret = TRUE;
+       }
+       return ret;
 }
 
 static gboolean __ps_context_create_co_context(gpointer object, GHashTable *property, gchar *cp_name)
@@ -342,36 +357,38 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        gchar *apn = NULL;
        gchar *auth_id = NULL, *auth_pwd = NULL, *home_url = NULL, *proxy_addr = NULL;
        int auth_type = 0, svc_ctg_id = 0, pdp_type = 0, roam_pdp_type = 0;
-       gboolean hidden = FALSE, editable = FALSE, default_conn = FALSE, user_defined = FALSE, is_roaming_apn = FALSE, profile_enable = TRUE;
+       gboolean hidden = FALSE, editable = FALSE, default_conn = FALSE, user_defined = FALSE;
+       gboolean is_roaming_apn = FALSE, profile_enable = TRUE, attach_apn = FALSE;
+       gboolean default_pdn = FALSE;
 
        g_hash_table_iter_init(&iter, (GHashTable *) property);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                if (g_str_equal(key, "3") == TRUE) { /*Profile ID*/
                        if (value) {
                                profile_id = atoi((const char *) value);
-                               dbg("profile id (%d)", profile_id);
+                               info("profile id (%d)", profile_id);
                        }
                } else if (g_str_equal(key, "4") == TRUE) {
                        g_free(profile_name);
                        profile_name = g_strdup((const char *) value);
-                       dbg("profile name (%s)", profile_name);
+                       info("profile name (%s)", profile_name);
                } else if (g_str_equal(key, "5") == TRUE) {
                        g_free(apn);
                        apn = g_strdup((const char *) value);
-                       dbg("APN (%s)", apn);
+                       info("APN (%s)", apn);
                } else if (g_str_equal(key, "6") == TRUE) {
                        if (value) {
                                auth_type = atoi((const char *) value);
-                               dbg("auth type (%d)", auth_type);
+                               info("auth type (%d)", auth_type);
                        }
                } else if (g_str_equal(key, "7") == TRUE) {
                        g_free(auth_id);
                        auth_id = g_strdup((const char *) value);
-                       dbg("auth id (%s)", auth_id);
+                       info("auth id (%s)", auth_id);
                } else if (g_str_equal(key, "8") == TRUE) {
                        g_free(auth_pwd);
                        auth_pwd = g_strdup((const char *) value);
-                       dbg("auth pwd (%s)", auth_pwd);
+                       info("auth pwd (%s)", auth_pwd);
                } else if (g_str_equal(key, "9") == TRUE) {
                        if (!value || g_strcmp0((const gchar *) value, "") == 0) {
                                g_free(proxy_addr);
@@ -402,51 +419,50 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
                                        proxy_addr = g_strdup((const char *) value);
                                } /* not in regular experssion */
                        }
-
-                       dbg("proxy addr (%s)", proxy_addr);
+                       info("proxy addr (%s)", proxy_addr);
                } else if (g_str_equal(key, "10") == TRUE) {
                        g_free(home_url);
                        home_url = g_strdup((const char *) value);
-                       dbg("home url (%s)", home_url);
+                       info("home url (%s)", home_url);
                } else if (g_str_equal(key, "11") == TRUE) {
                        if (value) {
                                pdp_type = atoi((const char *) value);
-                               dbg("pdp type (%d)", pdp_type);
+                               info("pdp type (%d)", pdp_type);
                        }
                } else if (g_str_equal(key, "19") == TRUE) {
                        if (value) {
                                svc_ctg_id = atoi((const char *) value);
-                               dbg("context category type (%d)", svc_ctg_id);
+                               info("context category type (%d)", svc_ctg_id);
                        }
                } else if (g_str_equal(key, "20") == TRUE) {
                        if (value) {
                                hidden = atoi((const char *) value);
-                               dbg("hidden profile (%d)", hidden);
+                               info("hidden profile (%d)", hidden);
                        }
                } else if (g_str_equal(key, "21") == TRUE) {
                        if (value) {
                                editable = atoi((const char *) value);
-                               dbg("editable profile (%d)", editable);
+                               info("editable profile (%d)", editable);
                        }
                } else if (g_str_equal(key, "22") == TRUE) {
                        if (value) {
                                default_conn = atoi((const char*) value);
-                               dbg("default connection profile (%d)", default_conn);
+                               info("default connection profile (%d)", default_conn);
                        }
                } else if (g_str_equal(key, "23") == TRUE) {
                        if (value) {
                                user_defined = atoi((const char*) value);
-                               dbg("user defined profile (%d)", user_defined);
+                               info("user defined profile (%d)", user_defined);
                        }
                } else if (g_str_equal(key, "24") == TRUE) {
                        if (value) {
                                is_roaming_apn = atoi((const char*) value);
-                               dbg("roaming APN profile (%d)", is_roaming_apn);
+                               info("roaming APN profile (%d)", is_roaming_apn);
                        }
                } else if (g_str_equal(key, "25") == TRUE) {
                        if (value) {
                                profile_enable = atoi((const char*) value);
-                               dbg("profile enable (%d)", profile_enable);
+                               info("profile enable (%d)", profile_enable);
                        }
                } else if (g_str_equal(key, "26") == TRUE) {
                        if (value) {
@@ -472,16 +488,42 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
        tcore_context_set_mmsurl(co_context, home_url);
        tcore_context_set_profile_name(co_context, profile_name);
        tcore_context_set_default_profile(co_context, default_conn);
-       tcore_context_set_attach_apn(co_context, __ps_context_profile_is_attach_apn(co_context, context->mccmnc));
        tcore_context_set_roaming_apn(co_context, is_roaming_apn);
 
        context->profile_id = profile_id;
-       context->hidden = hidden;
        context->editable = editable;
        context->is_default = default_conn;
        _ps_context_set_profile_enable(context, profile_enable);
        context->path = path;
        context->co_context = co_context;
+       switch(svc_ctg_id) {
+       case CONTEXT_ROLE_INTERNET:
+               if (default_conn)
+                       attach_apn = TRUE; /* ME's default setting */
+               context->hidden = hidden;
+       break;
+
+       case CONTEXT_ROLE_MMS:
+       case CONTEXT_ROLE_PREPAID_INTERNET:
+       case CONTEXT_ROLE_PREPAID_MMS:
+               context->hidden = hidden;
+       break;
+
+       case CONTEXT_ROLE_IMS:
+               context->hidden = TRUE;
+       break;
+
+       case CONTEXT_ROLE_IMS_UT:
+               context->hidden = TRUE;
+       break;
+
+       default:
+               context->hidden = TRUE;
+       break;
+       }
+       tcore_context_set_attach_apn(co_context, attach_apn);
+       info("Attach APN (%d), role (%d) default_pdn (%d)", attach_apn, svc_ctg_id, default_pdn);
+       tcore_context_set_default_pdn(co_context, default_pdn);
 
        g_free(profile_name);
        g_free(apn);
@@ -501,35 +543,32 @@ static gpointer __ps_context_create_context(GDBusConnection *conn, TcorePlugin *
        ps_context_t *new_context;
        gchar *path = NULL;
 
-       dbg("Entered");
-
        /*Initializing the master list for internal referencing*/
        new_context = g_try_malloc0(sizeof(ps_context_t));
        if (NULL == new_context) {
-               err("Unable to allocate memory for context");
+               err("[%s] Unable to allocate memory for context", cp_name);
                goto FAILURE;
        }
-       dbg("creating the skeleton object");
+       dbg("[%s] creating the skeleton object", cp_name);
        context = packet_service_context_skeleton_new();
        if (NULL == context) {
                g_free(new_context);
                goto FAILURE;
        }
 
-       dbg("Assigning the memory location for the internal data");
+       dbg("[%s] Assigning the memory location for the internal data", cp_name);
        new_context->conn = conn;
        new_context->plg = p;
        new_context->if_obj = context;
        new_context->mccmnc = g_strdup(mccmnc);
+       new_context->connection_timeout = TIMEOUT_DEFAULT;
 
        __ps_context_create_co_context(new_context, property , cp_name);
        _ps_context_set_alwayson_enable(new_context, TRUE);
        path = _ps_context_ref_path(new_context);
        _ps_context_setup_interface(context, new_context);
 
-       dbg("registering the interface object");
-
-       dbg("exporting the interface object to the dbus connection");
+       dbg("[%s] exporting the interface object to the dbus connection", cp_name);
        /*exporting the interface object to the path mention for master*/
        g_dbus_interface_skeleton_export((G_DBUS_INTERFACE_SKELETON(context)),
                        conn,
@@ -538,12 +577,12 @@ static gpointer __ps_context_create_context(GDBusConnection *conn, TcorePlugin *
 
        g_assert_no_error(error);
 
-       dbg("Successfully new object created for the interface for path [%s]", path);
+       info("Successfully new object created for the interface for path [%s]", path);
        return new_context;
 
 FAILURE:
        /*To do : handle failure */
-       dbg("Unable to allocate memory for the new object");
+       err("[%s] Unable to allocate memory for the new object", cp_name);
        return NULL;
 }
 
@@ -638,7 +677,7 @@ static gboolean __ps_context_update_default_internet_to_db(ps_context_t *context
                 where profile_id = ?");
 
        rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
-       ps_dbg_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -704,7 +743,7 @@ static gboolean __ps_context_update_database(ps_context_t *context)
                 pdp_protocol = ?, roam_pdp_protocol = ?, profile_enable = ? where profile_id = ?");
 
        rv = tcore_storage_update_query_database(strg_db, handle, szQuery, in_param);
-       ps_dbg_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_co(co_network, "Update Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -747,7 +786,7 @@ static gboolean __ps_context_remove_database(ps_context_t *context)
                " delete from pdp_profile where profile_id = ? ");
 
        rv = tcore_storage_remove_query_database(strg_db, handle, szQuery, in_param);
-       ps_dbg_ex_co(co_network, "Remove from Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       ps_info_ex_co(co_network, "Remove from Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* Free resources */
        g_hash_table_destroy(in_param);
@@ -775,7 +814,7 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
 
@@ -784,16 +823,14 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
         * if NONE exists, then 'Network ID' would be equal to 1
         * else if there exists a valid maximum entry; 'Network ID' would be incremented value.
         */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                               (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
                "select max(network_info_id) as network_id from network_info");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
@@ -803,7 +840,7 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
                if (value) {
                        g_hash_table_iter_init(&iter2, (GHashTable *)value);
                        while (g_hash_table_iter_next(&iter2, &key2, &value2) == TRUE) {
-                               dbg("key2(%s) value2(%s)", key2, value2);
+                               dbg("[%s] key2(%s) value2(%s)", cp_name, key2, value2);
                                if (g_str_equal(key2, "0") == TRUE) {
                                        if (!value2 || g_strcmp0((const char *)value2, "") == 0)
                                                network_id = 0;
@@ -836,7 +873,7 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
 
        rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
        if (rv == FALSE) {
-               err("Failed to insert query to Storage");
+               err("[%s] Failed to insert query to Storage", cp_name);
                network_id = 0;
        }
 
@@ -861,7 +898,7 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
 
        int profile_id = 0;
        gchar *profile_name = NULL, *apn = NULL, *auth_type = NULL;
-       gchar *auth_id = NULL, *auth_pwd = NULL, *proxy_addr = NULL;
+       gchar *auth_id = NULL, *auth_pwd = NULL, *proxy_addr = NULL, *is_roaming_apn = NULL;
        gchar *home_url = NULL, *svc_id = NULL, *pdp_protocol = NULL, *roam_pdp_protocol = NULL;
 
        /* Initialize Storage */
@@ -870,13 +907,13 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return 0;
        }
 
        profile_id = __ps_context_load_profile_id_from_database(cp_name);
        if (profile_id < 0) {
-               dbg("Failed to get last Profile ID");
+               err("[%s] Failed to get last Profile ID", cp_name);
                profile_id = 0;
 
                goto EXIT;
@@ -914,6 +951,8 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
                        FREE_AND_ASSIGN(pdp_protocol, value);
                } else if (g_str_equal(key, "roam_pdp_protocol") == TRUE) {     /* Roam PDP protocol */
                        FREE_AND_ASSIGN(roam_pdp_protocol, value);
+               } else if (g_str_equal(key, "is_roaming_apn") == TRUE) {        /* Roam APN */
+                       FREE_AND_ASSIGN(is_roaming_apn, value);
                }
        }
 
@@ -929,25 +968,34 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
                roam_pdp_protocol = g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6);
        }
 
+       /* Set default Roam PDP protocol */
+       if (is_roaming_apn == NULL) {
+               dbg("[%s] default is_roaming_apn = 0", cp_name);
+               is_roaming_apn = g_strdup_printf("%d", 0);
+       }
+
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
-       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id));  /* Profile ID */
-       g_hash_table_insert(in_param, "2", g_strdup(profile_name));     /* Profile Name */
-       g_hash_table_insert(in_param, "3", g_strdup(apn));                      /* APN */
-       g_hash_table_insert(in_param, "4", g_strdup(auth_type));        /* Auth Type */
-       g_hash_table_insert(in_param, "5", g_strdup(auth_id));          /* Auth ID */
-       g_hash_table_insert(in_param, "6", g_strdup(auth_pwd));         /* Auth Password */
-       g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));     /* PDP Protocol */
-       g_hash_table_insert(in_param, "8", g_strdup(roam_pdp_protocol));        /* Roam PDP Protocol */
-       g_hash_table_insert(in_param, "9", g_strdup(proxy_addr));               /* Proxy Address */
-       g_hash_table_insert(in_param, "10", g_strdup(home_url));                /* Home URL */
-       g_hash_table_insert(in_param, "11", g_strdup_printf("%d", network_id));         /* Network ID */
-       g_hash_table_insert(in_param, "12", g_strdup(svc_id));          /* Service ID */
+       g_hash_table_insert(in_param, "1",
+                       g_strdup_printf("%d", profile_id));                     /* Profile ID */
+       g_hash_table_insert(in_param, "2", profile_name);       /* Profile Name */
+       g_hash_table_insert(in_param, "3", apn);                        /* APN */
+       g_hash_table_insert(in_param, "4", auth_type);          /* Auth Type */
+       g_hash_table_insert(in_param, "5", auth_id);            /* Auth ID */
+       g_hash_table_insert(in_param, "6", auth_pwd);           /* Auth Password */
+       g_hash_table_insert(in_param, "7", pdp_protocol);               /* PDP Protocol */
+       g_hash_table_insert(in_param, "8", roam_pdp_protocol);          /* Roam PDP Protocol */
+       g_hash_table_insert(in_param, "9", proxy_addr);         /* Proxy Address */
+       g_hash_table_insert(in_param, "10", home_url);          /* Home URL */
+       g_hash_table_insert(in_param, "11",
+                       g_strdup_printf("%d", network_id));                     /* Network ID */
+       g_hash_table_insert(in_param, "12", svc_id);            /* Service ID */
+       g_hash_table_insert(in_param, "13", is_roaming_apn);    /* Roaming APN */
 
        info("[%s] Profile ID: [%d] Profile name: [%s] APN :[%s] Auth Type [%s] Auth ID: [%s] "
-               "Auth Password: [%s] PDP Protocol: [%s] Roam PDP Protocol: [%s] Proxy Address: [%s] Home URL: [%s] Service ID: [%s]",
-               cp_name, profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol, roam_pdp_protocol, proxy_addr, home_url, svc_id);
+               "Auth Password: [%s] PDP Protocol: [%s] Roam PDP Protocol: [%s] Proxy Address: [%s] Home URL: [%s] Service ID: [%s] Roaming apn: [%s]",
+               cp_name, profile_id, profile_name, apn, auth_type, auth_id, auth_pwd, pdp_protocol, roam_pdp_protocol, proxy_addr, home_url, svc_id, is_roaming_apn);
 
        /* SQL Query */
        memset(szQuery, 0x0, sizeof(szQuery));
@@ -959,26 +1007,17 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
                 default_internet_con, user_defined, is_roaming_apn, profile_enable) values(\
                 ?, ?, ?, ?, ?, ?, \
                 ?, ?, ?, ?, 300, \
-                ?, ?, 0, 1, 0, 1, 0, 1)");
+                ?, ?, 0, 1, 0, 1, ?, 1)");
 
        rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
        if (rv == FALSE) {
-               err("Failed to insert to Storage");
+               err("[%s] Failed to insert to Storage", cp_name);
                profile_id = 0;
        }
 
        /* Free resources */
-       g_free(profile_name);
-       g_free(apn);
-       g_free(auth_type);
-       g_free(auth_id);
-       g_free(auth_pwd);
-       g_free(proxy_addr);
-       g_free(home_url);
-       g_free(svc_id);
-       g_free(pdp_protocol);
-       g_free(roam_pdp_protocol);
        g_hash_table_destroy(in_param);
+
 EXIT:
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
@@ -1004,7 +1043,7 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return network_id;
        }
 
@@ -1012,16 +1051,13 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                       (GDestroyNotify) g_hash_table_destroy);
-
        /* SQL Query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
                "select network_info_id from network_info where mccmnc = ? ");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
@@ -1072,7 +1108,7 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return NULL;
        }
 
@@ -1080,16 +1116,13 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                                               (GDestroyNotify)g_hash_table_destroy);
-
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
                "select network_name from network_info where network_info_id = ? ");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
@@ -1138,21 +1171,17 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return profile_id;
        }
 
-       /* Initialize parameters */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                       (GDestroyNotify) g_hash_table_destroy);
-
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
                "select max(profile_id) as last_profile from pdp_profile");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, NULL, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
@@ -1202,7 +1231,7 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return 0;
        }
 
@@ -1210,17 +1239,14 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                       (GDestroyNotify) g_hash_table_destroy);
-
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
                "select a.max_pdp_3g from max_pdp a, network_info b \
                where a.network_info_id = b.network_info_id and b.mccmnc = ? ");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        g_hash_table_iter_init(&iter, out_param);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
@@ -1233,10 +1259,10 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
                                if (g_str_equal(key2, "0") == TRUE) {
                                        if (!value2 || (g_strcmp0((const char *)value2, "") == 0)) {
                                                num_of_pdn = 3;
-                                               dbg("There is NO value... Using 'default'");
+                                               dbg("[%s] There is NO value... Using 'default'", cp_name);
                                        } else {
                                                num_of_pdn = atoi((const char *) value2);
-                                               dbg("value (%d)", num_of_pdn);
+                                               dbg("[%s] value (%d)", cp_name, num_of_pdn);
                                        }
 
                                        /* TODO - Check this logic */
@@ -1247,10 +1273,10 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
        }
 
        if (num_of_pdn <= 0) {
-               dbg("Loaded value is wrong... restoring to 'default'");
+               info("[%s] Loaded value is wrong... restoring to 'default'", cp_name);
                num_of_pdn = PS_MAX_CID;
        } else if (num_of_pdn > PS_MAX_CID) {
-               dbg("Loaded value is gretaer than 3... restoring to 'default'");
+               info("[%s] Loaded value is gretaer than 3... restoring to 'default'", cp_name);
                num_of_pdn = PS_MAX_CID;
        }
 
@@ -1279,7 +1305,7 @@ static gboolean __ps_context_remove_profile_tuple(dictionary *dic, int profile_i
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
 
@@ -1297,7 +1323,7 @@ static gboolean __ps_context_remove_profile_tuple(dictionary *dic, int profile_i
                " delete from pdp_profile where network_info_id = ?");
 
        rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
-       dbg("delete from pdp_profile where network_info_id = %s, result(%d)", network_info_id, rv);
+       info("[%s] delete from pdp_profile where network_info_id = %s, result(%d)", cp_name, network_info_id, rv);
        /* Free resources */
        g_hash_table_destroy(in_param);
 
@@ -1319,7 +1345,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
 
@@ -1329,14 +1355,26 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
        {/* profile id */
                gchar *profile_id;
                gchar *item_key = NULL;
+               int max_profile_id = -1;
                item_key = g_strdup_printf("connection:profile_id_%d", profile_index);
                profile_id = iniparser_getstring(dic, item_key, NULL);
+               g_free(item_key);
+               /* In case of upgrade of Tizen OS, validation of profile_id is required. */
+               max_profile_id = __ps_context_load_profile_id_from_database(cp_name);
                if (profile_id == NULL) {
-                       g_free(item_key);
-                       goto EXIT;
+                       if (max_profile_id == -1) {
+                               err("[%s] profile_id is mandatory but not provided.", cp_name);
+                               goto EXIT;
+                       }
+                       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", max_profile_id));
+               } else {
+                       int tmp_id = atoi(profile_id);
+                       if (max_profile_id != -1 && max_profile_id >= tmp_id) {
+                               warn("[%s] profile_id:[%d] is less than max_profile_id:[%d]", cp_name, tmp_id, max_profile_id);
+                               tmp_id = max_profile_id+1;
+                       }
+                       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", tmp_id));
                }
-               g_hash_table_insert(in_param, "1", g_strdup(profile_id));
-               g_free(item_key);
        }
 
        {/* profile name */
@@ -1344,11 +1382,10 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:profile_name_%d", profile_index);
                profile_name = iniparser_getstring(dic, item_key, NULL);
-               if (profile_name == NULL) {
-                       g_free(item_key);
-                       goto EXIT;
-               }
-               g_hash_table_insert(in_param, "2", g_strdup(profile_name));
+               if (profile_name == NULL)
+                       g_hash_table_insert(in_param, "2", g_strdup("TEMP"));
+               else
+                       g_hash_table_insert(in_param, "2", g_strdup(profile_name));
                g_free(item_key);
        }
 
@@ -1357,12 +1394,12 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                gchar *item_key = NULL;
                item_key = g_strdup_printf("connection:apn_%d", profile_index);
                apn = iniparser_getstring(dic, item_key, NULL);
+               g_free(item_key);
                if (apn == NULL) {
-                       g_free(item_key);
+                       err("[%s] apn is mandatory but not provided.", cp_name);
                        goto EXIT;
                }
                g_hash_table_insert(in_param, "3", g_strdup(apn));
-               g_free(item_key);
        }
 
        {/* auth type */
@@ -1401,9 +1438,9 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                item_key = g_strdup_printf("connection:pdp_protocol_%d", profile_index);
                pdp_protocol = iniparser_getstring(dic, item_key, NULL);
                if (pdp_protocol == NULL)
-                       g_hash_table_insert(in_param, "7", g_strdup_printf("%d", CONTEXT_TYPE_IP));
+                       g_hash_table_insert(in_param, "7", g_strdup_printf("%d", CONTEXT_TYPE_IPV4V6));
                else
-               g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));
+                       g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));
                g_free(item_key);
        }
 
@@ -1587,7 +1624,7 @@ static gboolean __ps_context_insert_profile_tuple(dictionary *dic, int profile_i
                         ?, ?, ?, ?, ?, 0, ?, 1)");
 
                rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
-               dbg("Insert to Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+               info("[%s] Insert to Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
        }
 
 EXIT:
@@ -1605,7 +1642,7 @@ static int __ps_context_get_network_id(gchar *mccmnc, gchar *cp_name)
        int network_id;
 
        network_id = __ps_context_load_network_id_from_database(mccmnc, cp_name);
-       dbg("network id(%d)", network_id);
+       dbg("[%s] network id(%d)", cp_name, network_id);
        if (network_id > 0)
                return network_id;
 
@@ -1688,7 +1725,7 @@ GVariant *__ps_context_get_profile_properties(gpointer object, GVariantBuilder *
        g_free(home_url);
        g_free(profile_name);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
 
        return g_variant_builder_end(properties);
 }
@@ -1734,9 +1771,6 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                       (GDestroyNotify) g_hash_table_destroy);
-
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
@@ -1751,10 +1785,10 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
                 from network_info a, pdp_profile b \
                 where b.profile_id = ? and a.network_info_id = b.network_info_id ");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 27);
-       ps_dbg_ex_co(co_modem, "Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 27);
+       ps_info_ex_co(co_modem, "Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
 
-       ps_dbg_ex_co(co_modem, "Create profile by Profile ID: [%d]", profile_id);
+       ps_info_ex_co(co_modem, "Create profile by Profile ID: [%d]", profile_id);
        conn = _ps_modem_ref_dbusconn(modem);
        p = _ps_modem_ref_plugin(modem);
 
@@ -1794,32 +1828,29 @@ gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return ret;
        }
 
        network_info_id = __ps_context_load_network_id_from_database(mccmnc, cp_name);
        if (network_info_id == -1)
-               err("Failed to load network_info_id from mccmnc (%s)", mccmnc);
+               err("[%s] Failed to load network_info_id from mccmnc (%s)", cp_name, mccmnc);
 
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_info_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-                       (GDestroyNotify) g_hash_table_destroy);
-
        /* SQL query */
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s", "select profile_id from pdp_profile \
                where network_info_id = ? and is_roaming_apn = 1 ");
 
-       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, out_param, 1);
-       dbg("Read Database: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       rv = tcore_storage_read_query_database(strg_db, handle, szQuery, in_param, &out_param, 1);
+       info("[%s] Read Database: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        profile_cnt = g_hash_table_size(out_param);
        if (profile_cnt > 0) {
-               dbg("roaming profiles for (mccmnc: %s [%d]) exists: count[%d]", mccmnc, network_info_id,  profile_cnt);
+               info("[%s] roaming profiles for (mccmnc: %s [%d]) exists: count[%d]", cp_name, mccmnc, network_info_id,  profile_cnt);
                ret = TRUE;
        }
        /* Free resources */
@@ -1853,7 +1884,7 @@ gboolean _ps_context_reset_profile_table(gchar *cp_name)
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return rv;
        }
 
@@ -1862,7 +1893,7 @@ gboolean _ps_context_reset_profile_table(gchar *cp_name)
        snprintf(szQuery, sizeof(szQuery), "%s", " delete from pdp_profile");
 
        rv = tcore_storage_remove_query_database(strg_db, handle, szQuery, NULL);
-       dbg("Reset profile table: [%s]", (rv == TRUE ? "SUCCESS" : "FAIL"));
+       info("[%s] Reset profile table: [%s]", cp_name, (rv == TRUE ? "SUCCESS" : "FAIL"));
 
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
@@ -1883,18 +1914,20 @@ gboolean _ps_context_fill_profile_table_from_ini_file(gchar *cp_name)
                dic = iniparser_load("/opt/system/csc-default/data/csc-default-data-connection.ini");
 
        if (dic == NULL) {
-               dbg("fail to load the csc default file");
+               err("[%s] fail to load the csc default file", cp_name);
                return FALSE;
        }
 
+       info("[%s] Update profiles from init file", cp_name);
+
        /* delete first */
        do {
                section_key = g_strdup_printf("connection:profile_id_%d", profile_index);
-               dbg("section key (%s)", section_key);
+               dbg("[%s] section key (%s)", cp_name, section_key);
                data_exist = iniparser_find_entry(dic, section_key);
                if (!data_exist) {
                        g_free(section_key);
-                       dbg("no more data in ini");
+                       dbg("[%s] no more data in ini", cp_name);
                        break;
                }
                __ps_context_remove_profile_tuple(dic, profile_index, cp_name);
@@ -1906,12 +1939,12 @@ gboolean _ps_context_fill_profile_table_from_ini_file(gchar *cp_name)
        profile_index = 1;
        do {
                section_key = g_strdup_printf("connection:profile_id_%d", profile_index);
-               dbg("section key (%s)", section_key);
+               dbg("[%s] section key (%s)", cp_name, section_key);
                data_exist = iniparser_find_entry(dic, section_key);
                if (!data_exist) {
                        g_free(section_key);
                        iniparser_freedict(dic);
-                       dbg("no more data in ini");
+                       dbg("[%s] No more data in ini", cp_name);
                        break;
                }
                __ps_context_insert_profile_tuple(dic, profile_index, cp_name);
@@ -1957,7 +1990,7 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
                        roaming ? "TRUE" : "FALSE", roaming_apn ? "TRUE" : "FALSE");
                roaming = roaming_apn;
        }
-       ps_dbg_ex_co(co_modem, "create profile by mccmnc (%s)", mdm->operator);
+       ps_info_ex_co(co_modem, "create profile by mccmnc (%s)", mdm->operator);
 
        memset(szQuery, 0x0, sizeof(szQuery));
        snprintf(szQuery, sizeof(szQuery), "%s",
@@ -1981,7 +2014,7 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
                if (rv != FALSE)
                        break;
        }
-       ps_dbg_ex_co(co_modem, "Read Database: [%s], Retry[%d]", (rv == TRUE ? "SUCCESS" : "FAIL"), retry);
+       ps_info_ex_co(co_modem, "Read Database: [%s], Retry[%d]", (rv == TRUE ? "SUCCESS" : "FAIL"), retry);
 
        for (index = 0; index < g_slist_length(out_param); index++) {
                gchar *path = NULL;
@@ -1998,14 +2031,17 @@ GSList* _ps_context_create_hashtable(gpointer modem, gboolean roaming)
                mdm->contexts = g_slist_append(mdm->contexts, object);
                ps_dbg_ex_co(co_modem, "context (%p, %s) insert to linked-list", object, path);
        }
-
+#ifdef TIZEN_SUPPORT_VOLTE
+       /* Update Attach APN here. */
+       __ps_context_update_attach_apn(mdm->contexts, mdm->operator);
+#endif
        g_hash_table_destroy(in_param);
        g_slist_free_full(out_param, (GDestroyNotify)g_hash_table_destroy);
 
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(co_modem, "Exiting");
        return mdm->contexts;
 }
 
@@ -2022,13 +2058,13 @@ gboolean _ps_context_add_context(gpointer modem, gchar *operator, GHashTable *pr
 
        network_id = __ps_context_get_network_id(operator, mdm->cp_name);
        if (network_id <= 0) {
-               dbg("fail to add network info");
+               ps_err_ex_co(_ps_modem_ref_co_modem(mdm), "fail to add network info");
                return FALSE;
        }
 
        profile_id = __ps_context_insert_profile_to_database(property, network_id, mdm->cp_name);
        if (profile_id <= 0) {
-               dbg("fail to insert profile info to database");
+               ps_err_ex_co(_ps_modem_ref_co_modem(mdm), "fail to insert profile info to database");
                return FALSE;
        }
 
@@ -2057,11 +2093,10 @@ gboolean _ps_context_get_properties_handler(gpointer object, GVariantBuilder *pr
        char *ipv4_address, *ipv4_gateway, *ipv4_dns1, *ipv4_dns2;
        char *ipv6_address, *ipv6_gateway, *ipv6_dns1, *ipv6_dns2;
 
-
-       dbg("get context properties");
        g_return_val_if_fail(context != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "get context properties");
        context_state =    tcore_context_get_state(context->co_context);
        if (context_state == CONTEXT_STATE_ACTIVATED)
                active = TRUE;
@@ -2130,7 +2165,7 @@ gboolean _ps_context_get_properties_handler(gpointer object, GVariantBuilder *pr
        g_free(proxy);
        g_free(dev_name);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
        return TRUE;
 }
 
@@ -2146,11 +2181,13 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
        char *ipv6_address, *ipv6_gateway, *ipv6_dns1, *ipv6_dns2;
        pcscf_addr *pcscf_ipv4, *pcscf_ipv6;
        unsigned int i;
+       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "get context properties");
        g_return_val_if_fail(context != NULL, NULL);
        g_return_val_if_fail(properties != NULL, NULL);
 
+       ps_info_ex_co(co_network, "get context properties");
+
        context_state =    tcore_context_get_state(context->co_context);
        if (context_state == CONTEXT_STATE_ACTIVATED)
                active = TRUE;
@@ -2176,8 +2213,17 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
        proxy = tcore_context_get_proxy(context->co_context);
        dev_name = tcore_context_get_ipv4_devname(context->co_context);
 
+       ps_info_ex_co(co_network, "ipv4_address[%s] ipv4_gateway[%s] ipv4_dns1[%s] ipv4_dns2[%s]",
+               ipv4_address, ipv4_gateway, ipv4_dns1, ipv4_dns2);
+
+       ps_info_ex_co(co_network, "ipv6_address[%s] ipv6_gateway[%s] ipv6_dns1[%s] ipv6_dns2[%s]",
+               ipv6_address, ipv6_gateway, ipv6_dns1, ipv6_dns2);
+
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
 
+       ps_info_ex_co(co_network, "path[%s]",
+               context->path);
+
        g_variant_builder_add(properties, "{ss}", "path", (context->path));
        g_variant_builder_add(properties, "{ss}", "active", (BOOL2STRING(active)));
        g_variant_builder_add(properties, "{ss}", "routing_only", (BOOL2STRING(context->b_routing_only)));
@@ -2225,8 +2271,10 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
                g_variant_builder_add(properties, "{ss}", "pcscf_ipv4_count", buf);
                g_free(buf);
 
+               ps_info_ex_co(co_network, "pcscf_ipv4_count[%d]", pcscf_ipv4->count);
                for (i = 0; i < pcscf_ipv4->count; i++) {
                        buf = g_strdup_printf("%s_%d", "pcscf_ipv4_addr", i);
+                       ps_info_ex_co(co_network, "pcscf_ipv4_addr[%d] - %s", i, pcscf_ipv4->addr[i]);
                        g_variant_builder_add(properties, "{ss}", buf, pcscf_ipv4->addr[i]);
                        g_free(buf);
                }
@@ -2241,9 +2289,10 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
                buf = g_strdup_printf("%d", pcscf_ipv6->count);
                g_variant_builder_add(properties, "{ss}", "pcscf_ipv6_count", buf);
                g_free(buf);
-
+               ps_info_ex_co(co_network, "pcscf_ipv6_count[%d]", pcscf_ipv6->count);
                for (i = 0; i < pcscf_ipv6->count; i++) {
                        buf = g_strdup_printf("%s_%d", "pcscf_ipv6_addr", i);
+                       ps_info_ex_co(co_network, "pcscf_ipv6_addr[%d] - %s", i, pcscf_ipv6->addr[i]);
                        g_variant_builder_add(properties, "{ss}", buf, pcscf_ipv6->addr[i]);
                        g_free(buf);
                }
@@ -2276,7 +2325,7 @@ GVariant *_ps_context_get_properties(gpointer object, GVariantBuilder *propertie
        g_free(proxy);
        g_free(dev_name);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "Exiting");
        return g_variant_builder_end(properties);
 }
 
@@ -2288,14 +2337,14 @@ gboolean _ps_context_set_alwayson_enable(gpointer object, gboolean enabled)
 
        role = tcore_context_get_role(context->co_context);
 
-       if ((role == CONTEXT_ROLE_INTERNET) && context->is_default)
+       if (((role == CONTEXT_ROLE_INTERNET) && context->is_default) || role == CONTEXT_ROLE_INTERNET)
                context->alwayson = enabled;
 
 #ifdef PREPAID_SIM_APN_SUPPORT
        if ((role == CONTEXT_ROLE_PREPAID_INTERNET) && context->is_default)
                context->prepaid_alwayson = enabled;
 #endif
-       dbg("context (%p) alwayson (%d)", context, context->alwayson);
+       info("context (%p) alwayson (%d)", context, context->alwayson);
        return TRUE;
 }
 
@@ -2341,7 +2390,7 @@ gboolean _ps_context_get_alwayson_enable(gpointer object)
 {
        ps_context_t *context = object;
        g_return_val_if_fail(context != NULL, FALSE);
-       dbg("context (%p) alwayson (%d)", context, context->alwayson);
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context (%p) alwayson (%d)", context, context->alwayson);
        return context->alwayson;
 }
 
@@ -2378,7 +2427,8 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
        gchar *ipv6 = NULL;
        ps_context_t *context = object;
        Storage *strg_vconf = NULL;
-       gpointer p_modem = NULL;
+       ps_modem_t *p_modem = NULL;
+       CoreObject *co_network = NULL;
 
        gboolean b_roaming_checker = TRUE;
        gboolean data_allowed = FALSE;
@@ -2386,12 +2436,12 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
        gboolean b_ims_checker = TRUE;
 
        enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
 
        dbg("Entry [enabled :%d]", enabled);
 
        g_return_val_if_fail(context != NULL, FALSE);
 
+       co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
        strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(context->plg), "vconf");
        data_allowed = tcore_storage_get_bool(strg_vconf, STORAGE_KEY_3G_ENABLE);
        ipv4 = tcore_context_get_ipv4_addr(context->co_context);
@@ -2402,7 +2452,7 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
        if (role == CONTEXT_ROLE_MMS || role == CONTEXT_ROLE_PREPAID_MMS)
                b_mms_checker = TRUE;
 
-       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY)
+       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT)
                b_ims_checker = TRUE;
 
 #if !defined(TIZEN_SUPPORT_MMS_CONNECT_FORCE)
@@ -2411,8 +2461,8 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
 #endif
 
        context->b_active = enabled;
-       if ((_ps_modem_get_roaming(p_modem)) && !(_ps_modem_get_data_roaming_allowed(p_modem))) {
-               dbg("roaming network is not allowed");
+       if (!b_ims_checker && (_ps_modem_get_roaming(p_modem)) && !(_ps_modem_get_data_roaming_allowed(p_modem))) {
+               ps_info_ex_co(co_network, "roaming network is not allowed");
                b_roaming_checker = FALSE;
        }
 
@@ -2422,7 +2472,7 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
                tcore_context_set_state(context->co_context, CONTEXT_STATE_ACTIVATED);
 
                if (context->deact_required == TRUE) {
-                       warn("Deactivation is required for context(%p)", context);
+                       ps_info_ex_co(co_network, "Deactivation is required for context(%p)", context);
                        _ps_service_deactivate_context(context->p_service, context);
                        context->deact_required = FALSE;
                        goto EXIT;
@@ -2430,7 +2480,7 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
 
                if (ipv4) {
                        if ((g_str_equal(ipv4, "0.0.0.0") == TRUE) && (ipv6 == NULL)) {
-                               dbg("ip address is NULL");
+                               ps_warn_ex_co(co_network, "ip address is NULL");
                                _ps_service_deactivate_context(context->p_service, context);
                                goto EXIT;
                        }
@@ -2441,15 +2491,15 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
                 * default internet PDP could be activated if LCD was on at trigger time.
                 */
                ps_mode = _ps_modem_get_psmode(p_modem);
-               warn("ps_mode: %d", ps_mode);
                if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
                        gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
+                       ps_info_ex_co(co_network, "ps_mode: %d", ps_mode);
                        if (pm_state == 3 && _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET)) {
                                char *devname = tcore_context_get_ipv4_devname(context->co_context);
                                if (TCORE_RETURN_SUCCESS != tcore_util_netif_down(devname))
-                                       err("Failed to bring up interface");
+                                       ps_err_ex_co(co_network, "Failed to bring up interface");
 
-                               warn("[EXCEPTION] do not emit signal for PDP activation.");
+                               ps_warn_ex_co(co_network, "[EXCEPTION] do not emit signal for PDP activation.");
                                context->b_notify = TRUE;
                                goto EXIT;
                        }
@@ -2457,15 +2507,37 @@ gboolean _ps_context_set_connected(gpointer object, gboolean enabled)
 
                if (b_roaming_checker && (data_allowed || b_mms_checker || b_ims_checker))
                        __ps_context_emit_property_changed_signal(context);
-
        } else {
                if (context->deact_required == TRUE) {
-                       ps_dbg_ex_co(co_network, "set deact_required flag of context(%p) to FALSE", context);
+                       ps_info_ex_co(co_network, "set deact_required flag of context(%p) to FALSE", context);
                        context->deact_required = FALSE;
                }
                tcore_context_set_state(context->co_context, CONTEXT_STATE_DEACTIVATED);
                tcore_context_reset_devinfo(context->co_context);
                __ps_context_emit_property_changed_signal(context);
+               if (context->remove_profile_required == TRUE) {
+                       ps_service_t *service = _ps_context_ref_service(context);
+                       CoreObject *co_context = _ps_context_ref_co_context(context);
+                       gboolean attach_apn = tcore_context_get_attach_apn(co_context);
+
+                       ps_info_ex_co(co_network, "set remove_profile_required flag of context(%p) to FALSE", context);
+                       context->remove_profile_required = FALSE;
+                       __ps_context_remove_database(context);
+
+                       /* Send remove profile response */
+                       packet_service_context_complete_remove_profile(context->remove_profile_cb_data->obj_context, context->remove_profile_cb_data->invocation, TRUE);
+                       g_free(context->remove_profile_cb_data);
+                       context->remove_profile_cb_data = NULL;
+
+                       /* Remove context */
+                       _ps_service_unref_context(service, context);
+                       service->contexts = g_slist_remove(service->contexts, context);
+                       _ps_context_remove_context(context);
+
+                       /* Update Attach APN required. */
+                       if (attach_apn)
+                               __ps_context_update_attach_apn(service->contexts, p_modem->operator);
+               }
        }
 EXIT:
        if (ipv4)
@@ -2479,14 +2551,15 @@ EXIT:
 gboolean _ps_context_set_profile_enable(gpointer object, gboolean value)
 {
        ps_context_t *context = object;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
 
        dbg("Entry [value :%d]", value);
 
        g_return_val_if_fail(context != NULL, FALSE);
 
-       context->profile_enable = value;
-       ps_dbg_ex_co(co_network, "context(%p) profile_enable(%d)", context, context->profile_enable);
+       if (context->profile_enable != value) {
+               context->profile_enable = value;
+               info("context(%p) profile_enable(%d)", context, context->profile_enable);
+       }
        return TRUE;
 }
 
@@ -2494,7 +2567,7 @@ gboolean _ps_context_get_profile_enable(gpointer object)
 {
        ps_context_t *context = object;
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), profile_enable(%d)", context, context->profile_enable);
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), profile_enable(%d)", context, context->profile_enable);
 
        return context->profile_enable;
 }
@@ -2502,14 +2575,15 @@ gboolean _ps_context_get_profile_enable(gpointer object)
 gboolean _ps_context_set_ps_defined(gpointer object, gboolean value)
 {
        ps_context_t *context = (ps_context_t *)object;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
 
        dbg("Entry [value :%d]", value);
 
        g_return_val_if_fail(context != NULL, FALSE);
 
-       context->ps_defined = value;
-       ps_dbg_ex_co(co_network, "context(%p) ps_defined(%d)", context, context->ps_defined);
+       if (context->ps_defined != value) {
+               context->ps_defined = value;
+               ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p) ps_defined(%d)", context, context->ps_defined);
+       }
        return TRUE;
 }
 
@@ -2517,7 +2591,7 @@ gboolean _ps_context_get_ps_defined(gpointer object)
 {
        ps_context_t *context = (ps_context_t *)object;
 
-       ps_dbg_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), ps_defined(%d)", context, context->ps_defined);
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "context(%p), ps_defined(%d)", context, context->ps_defined);
 
        return context->ps_defined;
 }
@@ -2543,7 +2617,7 @@ gboolean _ps_context_set_bearer_info(gpointer object, struct tnoti_ps_dedicated_
        co_context = _ps_context_ref_co_context(object);
 
        if (bearer_info->dedicated_bearer.num_dedicated_bearer > 0) {
-               warn("num_dedicated_bearer: %d", bearer_info->dedicated_bearer.num_dedicated_bearer);
+               ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(context)), "num_dedicated_bearer: %d", bearer_info->dedicated_bearer.num_dedicated_bearer);
                /* reset previous bearer info. */
                tcore_context_reset_bearer_info(co_context);
                tcore_context_set_bearer_info(co_context, bearer_info);
@@ -2563,12 +2637,12 @@ TReturn _ps_connection_hdlr(gpointer object)
 {
        int rv = TCORE_RETURN_FAILURE;
        ps_context_t *pscontext = object;
-       CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
+       ps_service_t *service = _ps_context_ref_service(pscontext);
+       CoreObject *co_network = _ps_service_ref_co_network(service);
 
-       _ps_context_set_alwayson_enable(pscontext, TRUE);
        rv = _ps_service_activate_context(pscontext->p_service, pscontext);
        if (rv != TCORE_RETURN_SUCCESS) {
-               ps_dbg_ex_co(co_network, "fail to activate context connection");
+               ps_err_ex_co(co_network, "fail to activate context connection");
                return rv;
        }
 
@@ -2589,7 +2663,7 @@ gboolean _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name)
        else
                handle = tcore_storage_create_handle(strg_db, DATABASE_PATH_0);
        if (handle == NULL) {
-               err("Failed to get Storage handle");
+               err("[%s] Failed to get Storage handle", cp_name);
                return FALSE;
        }
 
@@ -2605,7 +2679,7 @@ gboolean _ps_context_create_cdma_profile(gchar *mccmnc, gchar *cp_name)
        g_hash_table_insert(in_param, "1", g_strdup("http://mms.vtext.com/servlets/mms")); /* home_url */
 
        rv = tcore_storage_insert_query_database(strg_db, handle, szQuery, in_param);
-       dbg("insert into pdp_profile result(%d)", rv);
+       info("[%s] insert into pdp_profile result(%d)", cp_name, rv);
        g_hash_table_destroy(in_param);
 
        /* De-initialize Storage */
@@ -2643,10 +2717,14 @@ void _ps_default_connection_hdlr(gpointer object)
                        _ps_context_set_ps_defined((gpointer)pscontext, FALSE);
                        tcore_ps_set_cid_active(p_service->co_ps, cid, FALSE);
                        tcore_ps_clear_context_id(p_service->co_ps, pscontext->co_context);
+               } else if (rv == TCORE_RETURN_PS_ACTIVATION_ON_HOLD) {
+                       /*
+                        * We need to clear the context for Activation 'ON HOLD'
+                        */
+                       ps_info_ex_co(co_network, "Activation is ON HOLD");
                }
        }
-       ps_dbg_ex_co(co_network, "complete to change the default connection");
-       return;
+       ps_info_ex_co(co_network, "complete to change the default connection");
 }
 
 gint _ps_context_get_number_of_pdn(gchar *operator, gchar *cp_name)
@@ -2654,7 +2732,7 @@ gint _ps_context_get_number_of_pdn(gchar *operator, gchar *cp_name)
        gint num_of_pdn = 0;
 
        num_of_pdn = __ps_context_load_num_of_pdn_from_database(operator, cp_name);
-       dbg("loaded num_of_pdn (%d)", num_of_pdn);
+       info("[%s] loaded num_of_pdn (%d) for %s", cp_name, num_of_pdn);
 
        return num_of_pdn;
 }
@@ -2666,7 +2744,7 @@ gboolean _ps_context_handle_ifaceup(gpointer user_data)
        int context_state = 0;
 
        context_state =  tcore_context_get_state(pscontext->co_context);
-       ps_warn_ex_co(co_network, "context_state: %d", context_state);
+       ps_info_ex_co(co_network, "context_state: %d", context_state);
        if (context_state == CONTEXT_STATE_ACTIVATED) {
                char *devname = tcore_context_get_ipv4_devname(pscontext->co_context);
                gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(pscontext->p_service));
@@ -2714,7 +2792,7 @@ gboolean _ps_context_handle_ifacedown(gpointer user_data)
        int context_state = 0;
 
        context_state =  tcore_context_get_state(pscontext->co_context);
-       ps_warn_ex_co(co_network, "context_state: %d", context_state);
+       ps_info_ex_co(co_network, "context_state: %d", context_state);
        if (context_state == CONTEXT_STATE_ACTIVATED) {
                char *devname = tcore_context_get_ipv4_devname(pscontext->co_context);
                gint ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(pscontext->p_service));
@@ -2747,7 +2825,7 @@ static gboolean on_context_get_properties(PacketServiceContext *obj_context,
        GVariant *gv = NULL;
        GVariantBuilder property;
 
-       dbg("Entered");
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(user_data)), "Entered");
        gv = _ps_context_get_properties(user_data, &property);
        packet_service_context_complete_get_properties(obj_context, invocation, gv);
        return TRUE;
@@ -2760,7 +2838,7 @@ static gboolean on_context_get_profile(PacketServiceContext *obj_context,
        GVariant *gv = NULL;
        GVariantBuilder profile;
 
-       dbg("Entered");
+       ps_info_ex_co(_ps_service_ref_co_network(_ps_context_ref_service(user_data)), "Entered");
        gv = __ps_context_get_profile_properties(user_data, &profile);
        packet_service_context_complete_get_profile(obj_context, invocation, gv);
 
@@ -2784,17 +2862,16 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
 
        ps_context_t *pscontext = user_data;
 
-       dbg("Entered");
        if (pscontext == NULL) {
                err("activation request object is NULL");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
        p_service = pscontext->p_service;
        if (!p_service) {
                err("service object is null");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
@@ -2802,37 +2879,37 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
        co_ps = _ps_service_ref_co_ps(p_service);
        if (!co_ps) {
                ps_err_ex_co(co_network, "core object is null");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
-       ps_dbg_ex_co(co_network, "activate context(%s)", _ps_context_ref_path(pscontext));
+       ps_info_ex_co(co_network, "activate context(%s)", _ps_context_ref_path(pscontext));
 
        apn = (gchar *)tcore_context_get_apn(pscontext->co_context);
 
        context_state = tcore_context_get_state(pscontext->co_context);
        if (context_state != CONTEXT_STATE_DEACTIVATED) {
                ps_warn_ex_co(co_network, "operation is in progress");
-               FAIL_RESPONSE(invocation,  PS_ERR_INTERNAL);
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                return TRUE;
        }
 
-       ps_dbg_ex_co(co_network, "requested context(%p) co_context(%p) apn (%s)", pscontext, pscontext->co_context, apn);
+       ps_info_ex_co(co_network, "requested context(%p) co_context(%p) apn (%s)", pscontext, pscontext->co_context, apn);
        /* check apn is activated or not */
        rv = tcore_ps_is_active_apn(co_ps, (const char *)apn);
        if (rv) {
-               ps_dbg_ex_co(co_network, "requested apn is already activated");
+               ps_info_ex_co(co_network, "requested apn is already activated");
 
                result = _ps_connection_hdlr(pscontext);
                if (result != TCORE_RETURN_SUCCESS) {
-                       FAIL_RESPONSE(invocation,  PS_ERR_INTERNAL);
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                        return TRUE;
                }
 
                packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
                context_state = tcore_context_get_state(pscontext->co_context);
                if (context_state == CONTEXT_STATE_ACTIVATED) {
-                       ps_dbg_ex_co(co_network, "context is already connected");
+                       ps_info_ex_co(co_network, "context is already connected");
                        _ps_context_set_connected(pscontext, TRUE);
                }
 
@@ -2843,12 +2920,17 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
        active_cids = tcore_ps_get_active_cids(co_ps);
        num_of_active_cids = g_slist_length(active_cids);
        max_pdn = tcore_ps_get_num_of_pdn(co_ps);
-       ps_dbg_ex_co(co_network, "activate cids(%d), max pdn(%d)", num_of_active_cids, max_pdn);
+       ps_info_ex_co(co_network, "activate cids(%d), max pdn(%d)", num_of_active_cids, max_pdn);
        if (num_of_active_cids < max_pdn) {
                ps_dbg_ex_co(co_network, "enough to active another pdn");
+
+               /* Set context activation requested */
+               if (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(pscontext)))
+                       _ps_service_set_ims_activation_requested(p_service, TRUE);
+
                result = _ps_connection_hdlr(pscontext);
                if (result != TCORE_RETURN_SUCCESS) {
-                       FAIL_RESPONSE(invocation,  PS_ERR_INTERNAL);
+                       FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                        return TRUE;
                }
 
@@ -2860,14 +2942,14 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
        /* find the current default connection */
        c_def_context = _ps_service_return_default_context(p_service, CONTEXT_ROLE_INTERNET);
        if (c_def_context == NULL) {
-               err("default context is NULL");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               ps_err_ex_co(co_network, "default context is NULL");
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
        cid_def = tcore_context_get_id(((ps_context_t *)c_def_context)->co_context);
        if (cid_def == 0) {
                ps_err_ex_co(co_network, "it is not avaiable to open connection");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
@@ -2883,7 +2965,7 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
                        packet_service_context_complete_activate(obj_context, invocation, pscontext->path);
                        return TRUE;
                }
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
@@ -2892,7 +2974,7 @@ static gboolean on_context_handle_activate(PacketServiceContext *obj_context,
        result = tcore_ps_deactivate_cid(co_ps, cid_def);
        if (result != TCORE_RETURN_SUCCESS) {
                ps_err_ex_co(co_network, "fail to deactivate exist network connection");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
@@ -2909,32 +2991,36 @@ static gboolean on_context_handle_deactiavte(PacketServiceContext *obj_context,
        CoreObject *co_network;
        int context_state = 0;
        ps_context_t *pscontext = user_data;
+       ps_service_t *service = _ps_context_ref_service(pscontext);
 
-       dbg("Entered");
        if (pscontext == NULL) {
                err("deactivation request object is NULL");
-               FAIL_RESPONSE(invocation,  PS_ERR_NO_PROFILE);
+               FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
 
        co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
+
+       /* Set context activation requested */
+       if (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(pscontext)))
+               _ps_service_set_ims_activation_requested(service, FALSE);
+
        context_state = tcore_context_get_state(pscontext->co_context);
-       ps_dbg_ex_co(co_network, "requested context(%p) co_context(%p), context_state %d", pscontext, pscontext->co_context, context_state);
+       ps_info_ex_co(co_network, "requested context(%p) co_context(%p), context_state %d", pscontext, pscontext->co_context, context_state);
        if (context_state != CONTEXT_STATE_ACTIVATED) {
                ps_err_ex_co(co_network, "operation is in progress");
-               FAIL_RESPONSE(invocation,  PS_ERR_INTERNAL);
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                return TRUE;
        }
 
-       ps_dbg_ex_co(co_network, "deactivate context(%s)", _ps_context_ref_path(pscontext));
+       ps_info_ex_co(co_network, "deactivate context(%s)", _ps_context_ref_path(pscontext));
 
        _ps_service_reset_connection_timer(pscontext);
        _ps_context_set_alwayson_enable(pscontext, FALSE);
-
-       rv = _ps_service_deactivate_context(pscontext->p_service, pscontext);
+       rv = _ps_service_deactivate_context(service, pscontext);
        if (rv != TCORE_RETURN_SUCCESS) {
                ps_err_ex_co(co_network, "fail to deactivate context connection");
-               FAIL_RESPONSE(invocation,  PS_ERR_TRASPORT);
+               FAIL_RESPONSE(invocation, PS_ERR_TRASPORT);
                return TRUE;
        }
 
@@ -2943,7 +3029,7 @@ static gboolean on_context_handle_deactiavte(PacketServiceContext *obj_context,
 
        context_state =  tcore_context_get_state(pscontext->co_context);
        if (context_state == CONTEXT_STATE_DEACTIVATED) {
-               ps_dbg_ex_co(co_network, "context is already disconnected");
+               ps_info_ex_co(co_network, "context is already disconnected");
                pscontext->ps_defined = FALSE;
                _ps_context_set_connected(pscontext, FALSE);
        }
@@ -2960,12 +3046,11 @@ static gboolean on_context_set_default_connection(PacketServiceContext *obj_cont
        gboolean is_default = FALSE;
 
        gpointer co_ps = NULL;
-       gpointer service = NULL;
        gpointer cur_default_ctx = NULL;
+       ps_service_t *service = NULL;
        ps_context_t *pscontext = user_data;
-       CoreObject *co_network;
+       CoreObject *co_network = NULL;
 
-       dbg("enter set default connection ps_context_t(%p)", pscontext);
        if (pscontext == NULL) {
                err("activation request object is NULL");
                FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
@@ -2973,18 +3058,19 @@ static gboolean on_context_set_default_connection(PacketServiceContext *obj_cont
        }
 
        co_network = _ps_service_ref_co_network(_ps_context_ref_service(pscontext));
-       ps_dbg_ex_co(co_network, "start default connection");
+       ps_info_ex_co(co_network, "start default connection");
        role = tcore_context_get_role(pscontext->co_context);
        is_default = tcore_context_get_default_profile(pscontext->co_context);
 
+       service = pscontext->p_service;
+
        if (is_default) {
                ps_err_ex_co(co_network, "already default profile for role (%d).", role);
                goto OUT;
        }
 
-       service = pscontext->p_service;
        cur_default_ctx = _ps_service_return_default_context(service, role);
-       ps_dbg_ex_co(co_network, "current default connection (%p)", cur_default_ctx);
+       ps_info_ex_co(co_network, "current default connection (%p)", cur_default_ctx);
 
        if (!cur_default_ctx) {
                ps_err_ex_co(co_network, "No current default connection.");
@@ -2994,7 +3080,7 @@ static gboolean on_context_set_default_connection(PacketServiceContext *obj_cont
        /* First, send deactivation request first. */
        rv = _ps_service_deactivate_context(((ps_context_t *)cur_default_ctx)->p_service, cur_default_ctx);
        if (rv == TCORE_RETURN_PS_ACTIVATING) {
-               ps_dbg_ex_co(co_network, "fail to deactivate default connection, rv(%d)", rv);
+               ps_err_ex_co(co_network, "fail to deactivate default connection, rv(%d)", rv);
                FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                return TRUE;
        }
@@ -3026,9 +3112,11 @@ static gboolean on_context_set_default_connection(PacketServiceContext *obj_cont
        /* Allow Connman to update profile information. */
        __ps_context_emit_property_changed_signal(cur_default_ctx);
 
-       ps_dbg_ex_co(co_network, "activation requeset in new ps (%p)", pscontext);
+       ps_info_ex_co(co_network, "activation requeset in new ps (%p)", pscontext);
 OUT:
        _ps_default_connection_hdlr(pscontext);
+       /* Update Attach APN required. */
+       __ps_context_update_attach_apn(service->contexts, pscontext->mccmnc);
        packet_service_context_complete_set_default_connection(obj_context, invocation, TRUE);
        return TRUE;
 
@@ -3049,7 +3137,7 @@ static gboolean on_context_modify_profile(PacketServiceContext *obj_context,
        CoreObject *co_network = _ps_service_ref_co_network(_ps_context_ref_service(context));
        GHashTable *profile_property = NULL;
 
-       ps_dbg_ex_co(co_network, "modify context's profile properties");
+       ps_info_ex_co(co_network, "modify context's profile properties");
 
        /*Creating the profile property hash for for internal handling*/
        /*Create a hash table for the profile property as all fucntion already use ghash table */
@@ -3065,16 +3153,16 @@ static gboolean on_context_modify_profile(PacketServiceContext *obj_context,
 
        rv = __ps_context_update_profile(context, profile_property);
        if (rv != TRUE) {
-               FAIL_RESPONSE(invocation,  PS_ERR_INTERNAL);
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                g_hash_table_destroy(profile_property);
                return TRUE;
        }
 
        context_state = tcore_context_get_state(context->co_context);
        if (context_state == CONTEXT_STATE_ACTIVATING) {
-               ps_dbg_ex_co(co_network, "Modify profile in activating state, set deactivate flag.");
+               ps_info_ex_co(co_network, "Modify profile in activating state, set deactivate flag.");
                context->deact_required = TRUE;
-               return TRUE;
+               goto EXIT;
        }
 
        _ps_service_deactivate_context(context->p_service, context);
@@ -3082,7 +3170,7 @@ static gboolean on_context_modify_profile(PacketServiceContext *obj_context,
                ps_dbg_ex_co(co_network, "context is already disconnected");
                _ps_context_set_connected(context, FALSE);
        }
-
+EXIT:
        packet_service_context_complete_modify_profile(obj_context, invocation, TRUE);
        g_hash_table_destroy(profile_property);
        return TRUE;
@@ -3093,26 +3181,56 @@ static gboolean on_context_remove_profile(PacketServiceContext *obj_context,
 {
        ps_context_t *context = user_data;
        ps_service_t *service = _ps_context_ref_service(context);
+       ps_modem_t* modem = _ps_service_ref_modem(service);
        CoreObject *co_network = _ps_service_ref_co_network(service);
+       CoreObject *co_context = _ps_context_ref_co_context(context);
+       gboolean attach_apn = tcore_context_get_attach_apn(co_context);
+       int context_state = 0;
 
-       g_return_val_if_fail(service != NULL, FALSE);
+       if (service == NULL || modem == NULL) {
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+               return TRUE;
+       }
+       ps_info_ex_co(co_network, "Remove context.");
 
-       ps_dbg_ex_co(co_network, "Remove context.");
+       context_state = tcore_context_get_state(context->co_context);
+       ps_info_ex_co(co_network, "context_state: %d", context_state);
 
-       __ps_context_remove_database(context);
-       _ps_service_unref_context(service, context);
-       service->contexts = g_slist_remove(service->contexts, context);
-       _ps_context_remove_context(context);
+       if (context_state == CONTEXT_STATE_DEACTIVATED) {
+               ps_dbg_ex_co(co_network, "context is already disconnected");
+               __ps_context_remove_database(context);
+               _ps_service_unref_context(service, context);
+               service->contexts = g_slist_remove(service->contexts, context);
+               _ps_context_remove_context(context);
 
-       packet_service_context_complete_remove_profile(obj_context, invocation, TRUE);
+               /* Update Attach APN required. */
+               if (attach_apn)
+                       __ps_context_update_attach_apn(service->contexts, modem->operator);
 
+               packet_service_context_complete_remove_profile(obj_context, invocation, TRUE);
+               goto EXIT;
+       } else if (context_state == CONTEXT_STATE_ACTIVATING) {
+               ps_info_ex_co(co_network, "Remove profile in activating state, set remove_profile_required flag.");
+               context->deact_required = TRUE;
+       } else {
+               _ps_service_deactivate_context(context->p_service, context);
+               ps_info_ex_co(co_network, "Remove profile in deactivating/activated state, set remove_profile_required flag.");
+       }
+       context->remove_profile_required = TRUE;
+       context->remove_profile_cb_data = g_malloc0(sizeof(ps_remove_profile_data));
+       context->remove_profile_cb_data->obj_context = obj_context;
+       context->remove_profile_cb_data->invocation = invocation;
+       context->remove_profile_cb_data->user_data = user_data;
+
+EXIT:
        ps_dbg_ex_co(co_network, "Exit");
        return TRUE;
 }
 
 static void _ps_context_setup_interface(PacketServiceContext *context, ps_context_t *context_data)
 {
-       dbg("Entered");
+       info("Entered");
+
        g_signal_connect(context,
                        "handle-get-properties",
                        G_CALLBACK(on_context_get_properties),
index 3e9c1f0..5e8bfd8 100644 (file)
 
 #include <glib.h>
 
-gchar *ps_log_get_tag(CoreObject *co);
+const gchar *ps_log_get_cp_name(CoreObject *co);
 
-gchar *ps_log_get_tag(CoreObject *co)
+const gchar *ps_log_get_cp_name(CoreObject *co)
 {
        const char *cp_name;
        cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co));
 
-       return g_strdup_printf("PS/%s", cp_name);
+       return cp_name;
 }
index 0593c21..a163864 100644 (file)
 #include "ps_main.h"
 #include <ps_common.h>
 
+/*
+ * PS plugin Private information
+ */
+typedef struct {
+       GDBusConnection *conn; /* DBUS connection */
+       guint bus_id; /* Packet service BUS ID */
+
+       /* Parent plug-in */
+       TcorePlugin *p;
+
+       /* List of masters */
+       GSList *master;
+} PsPrivInfo;
+
 static void __packet_service_cleanup(PsPrivInfo *priv_info)
 {
        /* Sanity Check */
@@ -62,7 +76,7 @@ static void on_bus_acquired(GDBusConnection *conn,
        TcorePlugin *p = user_data;
        PsPrivInfo *priv_info = tcore_plugin_ref_user_data(p);
 
-       dbg("Bus is acquired: [%s]", name);
+       info("Bus is acquired: [%s]", name);
 
        if (!priv_info) {
                err("Failed to get 'plugin->user_data' Object for Packet Service");
@@ -85,11 +99,11 @@ static void on_bus_acquired(GDBusConnection *conn,
         */
        rv = _ps_master_create_modems(master, NULL);
        if (!rv) {
-               dbg("Failure : Modem creation Failed ");
+               err("Failure : Modem creation Failed ");
                goto FAILURE;
        }
 
-       dbg("Packet Service plugin initialization: [Successful]");
+       info("Packet Service plugin initialization: [Successful]");
 
        return;
 
@@ -97,6 +111,9 @@ FAILURE:
        ps_main_exit(p);
 }
 
+/*
+ * Packet service initializer
+ */
 gboolean ps_main_init(TcorePlugin *p)
 {
        PsPrivInfo *priv_info = NULL;
@@ -137,9 +154,10 @@ gboolean ps_main_init(TcorePlugin *p)
                NULL,
                NULL,
                &error);
+       g_free(address);
        g_assert_no_error(error);
        if (!conn)
-               dbg("Failure: G-dBus Connection failed"); /* TODO - Clean-up */
+               err("Failure: G-dBus Connection failed"); /* TODO - Clean-up */
 
        /*
         * Storing the G-dBus connection in Private information of PS Plugin
@@ -154,10 +172,9 @@ gboolean ps_main_init(TcorePlugin *p)
                p,
                NULL);
 
-       dbg("PacketService - dBus address: [%s] dBus connection ID: [%d]",
+       info("PacketService - dBus address: [%s] dBus connection ID: [%d]",
                address, id);
 
-       g_free(address);
        /*
         * Initializing custom data for Packet Service
         */
index 21f41dc..478f4ae 100644 (file)
@@ -57,7 +57,7 @@ static void __ps_master_handle_ups_mode(gpointer object, gchar *request)
        if (modem == NULL)
                return;
 
-       dbg("send dbus %s requeset", request);
+       info("send dbus %s requeset", request);
        contexts = modem->contexts;
        if (contexts == NULL) {
                err("no profiles");
@@ -98,7 +98,7 @@ void __remove_master(gpointer data, gpointer user_data)
 {
        ps_master_t *master = data;
 
-       dbg("Entered");
+       info("Entered");
 
        /*Deinit alarm*/
        alarmmgr_fini();
@@ -177,6 +177,7 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
        case KEY_3G_ENABLE:
        case KEY_DATA_ROAMING_SETTING:
        case KEY_NETWORK_RESTRICT_MODE:
+       case KEY_TELEPHONY_READY:
                type_check = g_variant_is_of_type(tmp, G_VARIANT_TYPE_BOOLEAN);
                if (!type_check) {
                        err("wrong variant data type");
@@ -192,7 +193,7 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
 #endif
                type_check = g_variant_is_of_type(tmp, G_VARIANT_TYPE_INT32);
                if (!type_check) {
-                       dbg("wrong variant data type");
+                       err("wrong variant data type");
                        g_variant_unref(tmp);
                        return;
                }
@@ -214,7 +215,7 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                                        int sap_conn_type = SAP_CONN_TYPE_ALL;
                                        sap_conn_type = _ps_master_get_storage_value_int(master, KEY_SAP_CONNECTION_TYPE);
                                        if (sap_conn_type == SAP_CONN_TYPE_BT) {
-                                               dbg("[Companion mode] ignore data_allowed.");
+                                               warn("[Companion mode] ignore data_allowed.");
                                                return;
                                        }
                                }
@@ -226,40 +227,22 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                        msg("[PSINFO] roaming_allowed [%d] changed.", roaming_allowed);
                        _ps_modem_set_data_roaming_allowed(h_value, roaming_allowed);
                } else if (key == KEY_POWER_SAVING_MODE) {
-                       gint ps_mode = g_variant_get_int32(tmp);
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-                       gboolean f_mode = _ps_modem_get_flght_mode(h_value);
-                       gboolean f_mode_ups = _ps_modem_get_flght_mode_ups(h_value);
-                       struct treq_modem_set_flightmode data = {0};
-                       dbg("f_mode: %d, f_mode_ups: %d", f_mode, f_mode_ups);
-
-                       if (ps_mode == POWER_SAVING_MODE_NORMAL) {
-                               if (f_mode_ups != f_mode) {
-                                       dbg("set flight mode off");
-                                       data.enable = f_mode_ups;
-                               }
-                       } else if (ps_mode == POWER_SAVING_MODE_WEARABLE) {
-                               if (!f_mode) {
-                                       dbg("set flight mode on");
-                                       /* save flight mode state when UPS off. */
-                                       _ps_modem_set_flght_mode_ups(h_value, _ps_modem_get_flght_mode(h_value));
-                                       data.enable = TRUE;
-                               }
-                       } else {
-                               err("Not supported");
-                               return;
-                       }
-                       _ps_modem_send_filght_mode_request(h_value, &data);
-#endif
-                       if (ps_mode == POWER_SAVING_MODE_NORMAL && ps_mode != _ps_modem_get_psmode(h_value))
-                               warn("[PSINFO] UPS mode change: On -> Off ");
+                       gint new_ps_mode = g_variant_get_int32(tmp);
+                       gint curr_ps_mode = _ps_modem_get_psmode(h_value);
+
+                       if (curr_ps_mode & POWER_SAVING_MODE_DATA_ALLOWED)
+                               new_ps_mode |= POWER_SAVING_MODE_DATA_ALLOWED;
 
-                       _ps_modem_set_psmode(h_value, ps_mode);
+                       info("curr_ps_mode [0X%x] new_ps_mode[0X%x]", curr_ps_mode, new_ps_mode);
+                       _ps_modem_set_psmode(h_value, new_ps_mode);
                } else if (key == KEY_PM_STATE) {
                        gint pm_state = g_variant_get_int32(tmp);
                        gint ps_mode = _ps_modem_get_psmode(h_value);
-                       dbg("current power saving mode: %d, pm_state: %d", ps_mode, pm_state);
-                       if (ps_mode & POWER_SAVING_MODE_FMM) {
+
+                       if (ps_mode != POWER_SAVING_MODE_NORMAL)
+                               dbg("current power saving mode: %d, pm_state: %d", ps_mode, pm_state);
+
+                       if (ps_mode & POWER_SAVING_MODE_DATA_ALLOWED) {
                                warn("UPS by FMM: Do not change data network state.");
                                return;
                        }
@@ -304,6 +287,10 @@ static void __ps_master_storage_key_callback(enum tcore_storage_key key, void *v
                                _ps_modem_set_data_allowed(h_value, key_3g_enable);
                        }
 #endif
+               } else if (key == KEY_TELEPHONY_READY) {
+                       gboolean b_telephony_ready = _ps_master_get_storage_value_bool(master, KEY_TELEPHONY_READY);
+                       if (b_telephony_ready)
+                               __ps_master_emit_modem_added_signal(master, h_value);
                }
        }
 
@@ -355,6 +342,7 @@ gpointer _ps_master_create_master(GDBusConnection *conn, TcorePlugin *p)
        g_assert_no_error(error);
 
        /*Registering the key callbacks for values in storage settings */
+       __ps_master_register_key_callback(new_master, KEY_TELEPHONY_READY);
        __ps_master_register_key_callback(new_master, KEY_3G_ENABLE);
        __ps_master_register_key_callback(new_master, KEY_DATA_ROAMING_SETTING);
 #if defined(TIZEN_UPS_ENABLED)
@@ -374,7 +362,7 @@ gpointer _ps_master_create_master(GDBusConnection *conn, TcorePlugin *p)
        tcore_server_add_notification_hook(tcore_plugin_ref_server(p),
                TNOTI_SERVER_REMOVED_MODEM_PLUGIN, __on_hook_modem_removed, new_master);
 
-       dbg("Successfully created the master");
+       info("Successfully created the master");
        return new_master;
 
 FAILURE:
@@ -391,11 +379,13 @@ gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
        CoreObject *co_modem = NULL;
        gchar *modem_name = NULL;
        gchar *cp_name = NULL;
+       gboolean key_telephony_ready;
 
-       dbg("create modem objects");
        g_return_val_if_fail(object != NULL, FALSE);
+       dbg("create modem objects");
 
        master = (ps_master_t *)object;
+       key_telephony_ready = _ps_master_get_storage_value_bool(master, KEY_TELEPHONY_READY);
        if (modem_plg) {
                cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(modem_plg);
                modem_name = g_strdup_printf("/%s", cp_name);
@@ -411,15 +401,19 @@ gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
                modem = _ps_modem_create_modem(master->conn, master->plg,
                        master, modem_name, co_modem, cp_name);
                if (modem == NULL) {
-                       dbg("fail to create modem");
+                       err("fail to create modem");
                        g_free(modem_name);
                        return FALSE;
                }
 
                g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
-               dbg("modem (%p) created at path %s", modem , modem_name);
+               info("modem (%p) created at path %s", modem , modem_name);
 
-               __ps_master_emit_modem_added_signal(master, modem);
+               if (key_telephony_ready) {
+                       __ps_master_emit_modem_added_signal(master, modem);
+               } else {
+                       warn("Wait for telephony ready");
+               }
 
                g_free(modem_name);
        } else {
@@ -436,7 +430,7 @@ gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
                plist_head = tcore_server_get_modem_plugin_list(s);
 
                if (!plist_head) {
-                       dbg("Modem plugin is not present");
+                       warn("Modem plugin is not present");
                        return TRUE;
                }
 
@@ -446,7 +440,7 @@ gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
                        p = plist->data;
                        modemlist_head = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_MODEM);
                        if (!modemlist_head) {
-                               dbg("Found no modem core-objects");
+                               warn("Found no modem core-objects");
                                plist = plist->next;
                                continue;
                        }
@@ -465,17 +459,19 @@ gboolean _ps_master_create_modems(gpointer object, TcorePlugin *modem_plg)
 
                                modem = _ps_modem_create_modem(master->conn, master->plg, master, modem_name, co_modem, cp_name);
                                if (!modem) {
-                                       dbg("Fail to create modem ");
+                                       err("Fail to create modem ");
                                        modemlist = modemlist->next;
                                        g_free(modem_name);
                                        continue;
                                }
 
                                g_hash_table_insert(master->modems, g_strdup(modem_name), modem);
-                               dbg("modem (%p) created at path %s", modem , modem_name);
-
-                               __ps_master_emit_modem_added_signal(master, modem);
-
+                               info("modem (%p) created at path %s", modem , modem_name);
+                               if (key_telephony_ready) {
+                                       __ps_master_emit_modem_added_signal(master, modem);
+                               } else {
+                                       warn("Wait for telephony ready");
+                               }
                                g_free(modem_name);
                                modemlist = modemlist->next;
                        }
@@ -504,17 +500,17 @@ gboolean _ps_master_destroy_modem(gpointer object, TcorePlugin *plugin)
 
        modem = g_hash_table_lookup(master->modems, modem_name);
        if (modem == NULL) {
-               dbg("modem '%s' doesn't exists", modem_name);
+               warn("modem '%s' doesn't exists", modem_name);
                g_free(modem_name);
                return FALSE;
        }
 
        /*  Destroy Modem */
-       dbg("Destroying modem object for '%s' modem[%p]", modem_name, modem);
+       info("Destroying modem object for '%s' modem[%p]", modem_name, modem);
        _ps_modem_destroy_modem(master->conn, modem);
 
        if (g_hash_table_remove(master->modems, modem_name) == TRUE)
-               dbg("Removed modem '%s'", modem_name);
+               info("Removed modem '%s'", modem_name);
 
        g_free(modem_name);
 
@@ -573,6 +569,39 @@ gboolean _ps_master_set_storage_value_int(gpointer object, enum tcore_storage_ke
        return tcore_storage_set_int(strg, key, value);
 }
 
+gboolean _ps_master_set_always_on_control(gpointer user_data, gboolean enable)
+{
+       ps_master_t *master = user_data;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_return_val_if_fail(master != NULL, FALSE);
+       g_return_val_if_fail(master->modems != NULL, FALSE);
+
+       dbg("Entered");
+
+       g_hash_table_iter_init(&iter, master->modems);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               unsigned int i;
+               ps_modem_t *modem = value;
+
+               if (modem == NULL)
+                       continue;
+               if (modem->contexts == NULL)
+                       continue;
+
+               for (i = 0; i < g_slist_length(modem->contexts); i++) {
+                       ps_context_t *context = (ps_context_t*)g_slist_nth_data(modem->contexts, i);
+                       gchar *path = _ps_context_ref_path(context);
+                       if (path) {
+                               dbg("context(%s)", path);
+                               _ps_context_set_alwayson_enable(context, enable);
+                       }
+               }
+       }
+       return TRUE;
+}
+
 static gboolean on_master_get_modems(PacketServiceMaster *obj_master,
                GDBusMethodInvocation *invocation,
                gpointer user_data)
@@ -584,7 +613,7 @@ static gboolean on_master_get_modems(PacketServiceMaster *obj_master,
        gpointer key, value;
        ps_master_t *master = user_data;
 
-       dbg("Entered");
+       info("Entered");
 
        if (master->modems == NULL) {
                err("No modem Present");
@@ -616,6 +645,22 @@ static gboolean on_master_get_modems(PacketServiceMaster *obj_master,
        return TRUE;
 }
 
+static gboolean on_master_set_alwayson(PacketServiceMaster *obj_master,
+               GDBusMethodInvocation *invocation,
+               gboolean enable,
+               gpointer user_data)
+{
+       gboolean result = FALSE;
+
+       info("Entered");
+       result = _ps_master_set_always_on_control(user_data, enable);
+       if (result)
+               packet_service_master_complete_set_alwayson(obj_master, invocation, result);
+       else
+               FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
+       return TRUE;
+}
+
 static void _ps_master_setup_interface(PacketServiceMaster *master, ps_master_t *master_data)
 {
        dbg("Entered");
@@ -624,6 +669,11 @@ static void _ps_master_setup_interface(PacketServiceMaster *master, ps_master_t
                        "handle-get-modems",
                        G_CALLBACK(on_master_get_modems),
                        master_data);
+
+       g_signal_connect(master,
+                       "handle-set-alwayson",
+                       G_CALLBACK(on_master_set_alwayson),
+                       master_data);
        return;
 
 }
index 4e60b0b..714482b 100644 (file)
@@ -31,6 +31,8 @@
 #include <co_context.h>
 #include <co_ps.h>
 
+#define MODULE_TAG "PS-MODEM"
+
 #define PROP_DEFAULT   FALSE
 #define PROP_DEFAULT_STR   NULL
 #define DATABASE_PATH_0        tzplatform_mkpath(TZ_SYS_DB, ".dnet.db")
@@ -69,14 +71,14 @@ static gboolean __ps_modem_thread_finish_cb(gpointer data)
 
        modem = thread_data->modem;
 
-       dbg("Thread %p return is complete", thread_data->selfi);
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Thread %p return is complete", thread_data->selfi);
 
        _ps_get_co_modem_values(thread_data->modem);
        _ps_modem_set_reset_profile(thread_data->modem, FALSE);
        packet_service_modem_complete_reset_profile(thread_data->modem->if_obj, thread_data->modem->invocation, TRUE);
 
        g_thread_join(thread_data->selfi);
-       dbg("Clean up of thread %p is complete", thread_data->selfi);
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Clean up of thread %p is complete", thread_data->selfi);
        thread_data->modem->invocation = NULL;
        _ps_modem_remove_profile_reset_gsource(thread_data->modem);
        thread_data->modem = NULL;
@@ -100,7 +102,7 @@ static gpointer __ps_modem_regenerate_database(gpointer data)
 
        thread_data = g_try_malloc0(sizeof(*thread_data));
        if (!thread_data) {
-               err("mamory alloc is fail !!!");
+               ps_err_ex_co(_ps_modem_ref_co_modem(modem), "memory alloc is fail !!!");
                return NULL;
        }
        thread_data->modem = modem;
@@ -117,7 +119,7 @@ static gpointer __ps_modem_regenerate_database(gpointer data)
        rv = _ps_context_fill_profile_table_from_ini_file(modem->cp_name);
 
        if (TRUE == ps_util_thread_dispatch(g_main_context_default(), G_PRIORITY_LOW, (GSourceFunc)__ps_modem_thread_finish_cb, thread_data))
-               dbg("Thread %p processing is complete", thread_data->selfi);
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Thread %p processing is complete", thread_data->selfi);
 
        g_free(command);
 
@@ -128,14 +130,16 @@ void __remove_modem_handler(gpointer data)
 {
        ps_modem_t *modem = data;
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Entered");
        if (!modem) {
-               dbg("Modem is NULL");
+               warn("Modem is NULL");
                return;
        }
 
-       __ps_modem_cp_reset_send_pending_request_response(modem);
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Entered");
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+       __ps_modem_cp_reset_send_pending_request_response(modem);
+#endif
        /*Need to remove the compelete hash table*/
        g_hash_table_remove_all(modem->services);
 
@@ -145,7 +149,9 @@ void __remove_modem_handler(gpointer data)
        g_object_unref(modem->if_obj);
 
        /*Need to free memory allocated for the internal structure*/
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        g_queue_free(modem->work_queue);
+#endif
        g_free(modem->path);
        g_free(modem->operator);
        g_free(modem->cp_name);
@@ -213,7 +219,7 @@ static void __ps_modem_create_service(GDBusConnection *conn, TcorePlugin *p,
                g_free(t_path);
                return;
        }
-       ps_dbg_ex_co(co_modem, "service path (%s)", t_path);
+       ps_info_ex_co(co_modem, "service path (%s)", t_path);
        object = _ps_service_create_service(conn, p, modem, co_network, co_ps, t_path);
        if (object == NULL) {
                ps_err_ex_co(co_modem, "Failed to create service ");
@@ -244,7 +250,7 @@ static void __ps_modem_remove_service(ps_modem_t *modem, gpointer service)
 
        g_hash_table_remove(modem->services, _ps_service_ref_path(service));
 
-       dbg("Successfully removed the service from the modem");
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Successfully removed the service from the modem");
        return;
 }
 
@@ -252,9 +258,11 @@ static gboolean __ps_modem_set_powered(ps_modem_t *modem, gboolean value)
 {
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->powered = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) powered(%d)", modem, modem->powered);
-       __ps_modem_emit_property_changed_signal(modem);
+       if (modem->powered != value) {
+               modem->powered = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) powered(%d)", modem, modem->powered);
+               __ps_modem_emit_property_changed_signal(modem);
+       }
        return TRUE;
 }
 
@@ -262,13 +270,15 @@ static gboolean __ps_modem_set_sim_complete(ps_modem_t *modem, gboolean value, g
 {
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       /* Update SIM init status */
-       modem->sim_init = value;
-       if (value && operator != NULL && !modem->operator)
-               modem->operator = g_strdup(operator);
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem [%p] SIM-Init [%s]", modem, (modem->sim_init ? "INITIALIZED" : "UNINITIALIZED"));
+       if (modem->sim_init != value) {
+               /* Update SIM init status */
+               modem->sim_init = value;
+               if (value && operator != NULL && !modem->operator)
+                       modem->operator = g_strdup(operator);
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem [%p] SIM-Init [%s]", modem, (modem->sim_init ? "INITIALIZED" : "UNINITIALIZED"));
 
-       __ps_modem_emit_property_changed_signal(modem);
+               __ps_modem_emit_property_changed_signal(modem);
+       }
 
        return TRUE;
 }
@@ -277,10 +287,12 @@ static gboolean __ps_modem_set_flght_mode(ps_modem_t *modem, gboolean value)
 {
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->flight_mode = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) flight_mode(%d)", modem, modem->flight_mode);
-       __ps_modem_emit_property_changed_signal(modem);
-       __ps_modem_processing_modem_event(modem);
+       if (modem->flight_mode != value) {
+               modem->flight_mode = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) flight_mode(%d)", modem, modem->flight_mode);
+               __ps_modem_emit_property_changed_signal(modem);
+               __ps_modem_processing_modem_event(modem);
+       }
 
        return TRUE;
 }
@@ -292,9 +304,6 @@ static void __ps_modem_get_ps_setting_from_storage(ps_modem_t *object)
        gint key_ps_mode = 0;
        ps_modem_t *modem = NULL;
        CoreObject *co_modem;
-#if defined(TIZEN_UPS_ENABLED)
-       struct treq_modem_set_flightmode data = {0};
-#endif
 
        modem = (ps_modem_t *) object;
        co_modem = _ps_modem_ref_co_modem(modem);
@@ -308,18 +317,6 @@ static void __ps_modem_get_ps_setting_from_storage(ps_modem_t *object)
 
 #if defined(TIZEN_UPS_ENABLED)
        _ps_modem_set_psmode(modem, key_ps_mode);
-       if (key_ps_mode == POWER_SAVING_MODE_NORMAL) {
-               dbg("set flight mode off");
-               data.enable = FALSE;
-       } else if (key_ps_mode == POWER_SAVING_MODE_WEARABLE) {
-               dbg("set flight mode on");
-               data.enable = TRUE;
-       } else {
-               err("Not supported");
-               goto OUT;
-       }
-       _ps_modem_send_filght_mode_request(modem, &data);
-OUT:
 #endif
        ps_dbg_ex_co(co_modem, "data allowed(%d) roaming allowed(%d) power saving mode(%d), network restrict mode (%d)",
                key_3g_enable, key_roaming_allowed, key_ps_mode, key_nw_restrict_mode);
@@ -355,11 +352,11 @@ static void __ps_modem_processing_modem_event(gpointer object)
                        continue;
                }
 
-               if (modem->flight_mode || (s_roaming && !modem->roaming_allowed)) {
+               if (modem->flight_mode) {
                        _ps_service_disconnect_contexts(value);
                        continue;
-               } else if (!modem->data_allowed) {
-                       _ps_service_disconnect_internet_mms_contexts(value);
+               } else if (!modem->data_allowed || (s_roaming && !modem->roaming_allowed)) {
+                       _ps_service_disconnect_internet_mms_tethering_contexts(value);
                        continue;
                }
 
@@ -397,6 +394,7 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
                return NULL;
        }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        /*Add work queue to keep user request in case of handling active PDP context*/
        new_modem->hook_flag = 0x00;
        new_modem->work_queue = g_queue_new();
@@ -405,7 +403,7 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
                g_free(new_modem);
                return NULL;
        }
-
+#endif
        new_modem->conn = conn;
        new_modem->p_master = master;
        new_modem->plg = p;
@@ -430,6 +428,7 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
 
        g_assert_no_error(error);
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        /* Adding hooks for special Network Requests */
        tcore_server_add_request_hook(tcore_plugin_ref_server(p),
                        TREQ_NETWORK_SEARCH,
@@ -461,8 +460,9 @@ gpointer _ps_modem_create_modem(GDBusConnection *conn, TcorePlugin *p, gpointer
        tcore_server_add_request_hook(tcore_plugin_ref_server(p),
                        TREQ_MODEM_POWER_ON,
                        ps_handle_hook, new_modem);
+#endif
 
-       ps_err_ex_co(co_modem, "Successfully created the modem");
+       ps_info_ex_co(co_modem, "Successfully created the modem");
        return new_modem;
 }
 
@@ -479,7 +479,7 @@ void _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object)
        if (modem->services == NULL)
                return;
 
-       dbg("Clearing all services");
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Clearing all services");
        g_hash_table_iter_init(&iter, modem->services);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                /* Update Cellular state */
@@ -508,33 +508,6 @@ void _ps_modem_destroy_modem(GDBusConnection *conn, gpointer object)
        _ps_free_co_modem_event(modem);
 }
 
-gboolean _ps_modem_send_filght_mode_request(gpointer value, void *data)
-{
-       CoreObject *co_modem = NULL, *co_ps = NULL;
-       UserRequest *ur = NULL;
-       ps_modem_t *modem = value;
-       TReturn rv;
-
-       co_modem = _ps_modem_ref_co_modem(modem);
-       co_ps = tcore_plugin_ref_core_object(tcore_object_ref_plugin(co_modem), CORE_OBJECT_TYPE_PS);
-       /* deactivate contexts first. */
-       rv = tcore_ps_deactivate_contexts(co_ps);
-       if (rv != TCORE_RETURN_SUCCESS)
-               ps_dbg_ex_co(co_ps, "fail to deactivation");
-
-       tcore_ps_set_online(co_ps, FALSE);
-
-       ur = tcore_user_request_new(NULL, NULL);
-       tcore_user_request_set_data(ur, sizeof(struct treq_modem_set_flightmode), data);
-       tcore_user_request_set_command(ur, TREQ_MODEM_SET_FLIGHTMODE);
-       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_modem, ur)) {
-               err("fail to send user request");
-               tcore_user_request_unref(ur);
-               return FALSE;
-       }
-       return TRUE;
-}
-
 gboolean _ps_modem_processing_flight_mode(gpointer object, gboolean enable)
 {
        ps_modem_t *modem = object;
@@ -554,7 +527,7 @@ gboolean _ps_modem_processing_power_enable(gpointer object, int modem_state)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       dbg("modem->powered [%d], Modem->sim_init [%d], modem_state [%d]",
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem->powered [%d], Modem->sim_init [%d], modem_state [%d]",
                modem->powered, modem->sim_init, modem_state);
 
        if (modem->powered == modem_state)
@@ -570,7 +543,7 @@ gboolean _ps_modem_processing_power_enable(gpointer object, int modem_state)
                        if (contexts != NULL) {
                                GHashTableIter iter;
                                gpointer key, value;
-                               warn("[WARN] contexts exist, SIM init complete before Modem Power On event.");
+                               ps_warn_ex_co(_ps_modem_ref_co_modem(modem), "contexts exist, SIM init complete before Modem Power On event.");
                                g_hash_table_iter_init(&iter, modem->services);
                                while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                                        _ps_service_set_number_of_pdn_cnt(value, modem->operator);
@@ -604,7 +577,7 @@ gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, g
                gboolean different_sim = FALSE;
 
                if (operator && (g_strcmp0(modem->operator, operator) != 0)) {
-                       ps_dbg_ex_co(co_modem, "Previous operator: [%s] Present operator: [%s]", modem->operator, operator);
+                       ps_info_ex_co(co_modem, "Previous operator: [%s] Present operator: [%s]", modem->operator, operator);
                        g_free(modem->operator);
 
                        modem->operator = g_strdup(operator);
@@ -651,7 +624,7 @@ gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, g
                                                _ps_service_set_attach_apn(value);
                                        }
                                } else {
-                                       ps_dbg_ex_co(co_modem, "Failed to create HASH table");
+                                       ps_err_ex_co(co_modem, "Failed to create HASH table");
                                        return FALSE;
                                }
                        }
@@ -664,13 +637,13 @@ gboolean _ps_modem_processing_sim_complete(gpointer object, gboolean complete, g
 
                        g_hash_table_iter_init(&iter, modem->services);
                        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                               ps_dbg_ex_co(co_modem, "Remove contexts on service(%p)", value);
+                               ps_info_ex_co(co_modem, "Remove contexts on service(%p)", value);
                                _ps_service_remove_contexts(value);
                        }
                }
        }
 EXIT:
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
        return TRUE;
 }
 
@@ -680,8 +653,11 @@ gboolean _ps_modem_set_reset_profile(gpointer object, gboolean value)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->reset_profile = value;
-       dbg("modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       if (modem->reset_profile != value) {
+               modem->reset_profile = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       }
+
        return TRUE;
 }
 
@@ -691,7 +667,7 @@ gboolean _ps_modem_get_reset_profile(gpointer object)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       dbg("modem(%p) reset_profile(%d)", modem, modem->reset_profile);
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) reset_profile(%d)", modem, modem->reset_profile);
 
        return modem->reset_profile;
 }
@@ -736,8 +712,25 @@ gboolean _ps_modem_set_sim_enabled(gpointer object, gboolean value)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->sim_init = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) sim_enabled(%d)", modem, modem->sim_init);
+       if (modem->sim_init != value) {
+               modem->sim_init = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) sim_enabled(%d)", modem, modem->sim_init);
+       }
+       return TRUE;
+}
+
+gboolean _ps_modem_connect_default_context(gpointer object)
+{
+       ps_modem_t *modem = object;
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_return_val_if_fail(modem != NULL, FALSE);
+
+       g_hash_table_iter_init(&iter, modem->services);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE)
+               _ps_service_connect_default_context(value);
+
        return TRUE;
 }
 
@@ -747,10 +740,12 @@ gboolean _ps_modem_set_data_allowed(gpointer object, gboolean value)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->data_allowed = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) data allowed(%d)", modem, modem->data_allowed);
-       __ps_modem_emit_property_changed_signal(modem);
-       __ps_modem_processing_modem_event(modem);
+       if (modem->data_allowed != value)  {
+               modem->data_allowed = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) data allowed(%d)", modem, modem->data_allowed);
+               __ps_modem_emit_property_changed_signal(modem);
+               __ps_modem_processing_modem_event(modem);
+       }
 
        return TRUE;
 }
@@ -769,15 +764,17 @@ gboolean _ps_modem_set_data_roaming_allowed(gpointer object, gboolean roaming_al
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->roaming_allowed = roaming_allowed;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming allowed(%d)", modem, modem->roaming_allowed);
-       __ps_modem_emit_property_changed_signal(modem);
+       if (modem->roaming_allowed != roaming_allowed) {
+               modem->roaming_allowed = roaming_allowed;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming allowed(%d)", modem, modem->roaming_allowed);
+               __ps_modem_emit_property_changed_signal(modem);
 
-       if (!modem->services)
-               return TRUE;
+               if (!modem->services)
+                       return TRUE;
 
-       if (modem->roaming)
-               __ps_modem_processing_modem_event(modem);
+               if (modem->roaming)
+                       __ps_modem_processing_modem_event(modem);
+       }
 
        return TRUE;
 }
@@ -788,8 +785,10 @@ gboolean _ps_modem_set_psmode(gpointer object, gint value)
 
        g_return_val_if_fail(modem != NULL, FALSE);
 
-       modem->ps_mode = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) power saving mode(%d)", modem, modem->ps_mode);
+       if (modem->ps_mode != value) {
+               modem->ps_mode = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) power saving mode(%d)", modem, modem->ps_mode);
+       }
 
        return TRUE;
 }
@@ -807,10 +806,10 @@ void _ps_modem_set_roaming(gpointer object, gboolean value)
        ps_modem_t *modem = object;
        g_return_if_fail(modem != NULL);
 
-       modem->roaming = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming(%d)", modem, modem->roaming);
-
-       return;
+       if (modem->roaming != value) {
+               modem->roaming = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming(%d)", modem, modem->roaming);
+       }
 }
 
 gint _ps_modem_get_roaming_apn_support(gpointer object)
@@ -827,8 +826,10 @@ void _ps_modem_set_roaming_apn_support(gpointer object, gboolean value)
        ps_modem_t *modem = object;
        g_return_if_fail(modem != NULL);
 
-       modem->roaming_apn_support = value;
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming_apn_support(%d)", modem, modem->roaming);
+       if (modem->roaming_apn_support != value) {
+               modem->roaming_apn_support = value;
+               ps_info_ex_co(_ps_modem_ref_co_modem(modem), "modem(%p) roaming_apn_support(%d)", modem, modem->roaming);
+       }
 }
 
 gint _ps_modem_get_psmode(gpointer object)
@@ -840,6 +841,7 @@ gint _ps_modem_get_psmode(gpointer object)
        return modem->ps_mode;
 }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 guchar _ps_modem_get_hook_flag(gpointer object)
 {
        ps_modem_t *modem = object;
@@ -848,6 +850,7 @@ guchar _ps_modem_get_hook_flag(gpointer object)
 
        return modem->hook_flag;
 }
+#endif
 
 gboolean _ps_modem_get_data_roaming_allowed(gpointer object)
 {
@@ -865,25 +868,6 @@ gboolean _ps_modem_get_flght_mode(gpointer object)
        return modem->flight_mode;
 }
 
-void _ps_modem_set_flght_mode_ups(gpointer object, gboolean value)
-{
-       ps_modem_t *modem = object;
-       g_return_if_fail(modem != NULL);
-
-       modem->flight_mode_ups = value;
-       dbg("modem(%p) flight_mode_ups(%d)", modem, modem->flight_mode_ups);
-
-       return;
-}
-
-gboolean _ps_modem_get_flght_mode_ups(gpointer object)
-{
-       ps_modem_t *modem = object;
-       g_return_val_if_fail(modem != NULL, FALSE);
-
-       return modem->flight_mode_ups;
-}
-
 gboolean _ps_modem_get_sim_init(gpointer object)
 {
        ps_modem_t *modem = object;
@@ -930,10 +914,11 @@ gboolean _ps_modem_get_properties_handler(gpointer object, GVariantBuilder *prop
 {
        ps_modem_t *modem = object;
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
+
        g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
        g_variant_builder_add(properties, "{ss}", "path", modem->path);
 
@@ -946,7 +931,7 @@ gboolean _ps_modem_get_properties_handler(gpointer object, GVariantBuilder *prop
        g_variant_builder_add(properties, "{ss}", "data_allowed", BOOL2STRING(modem->data_allowed));
        g_variant_builder_close(properties);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
        return TRUE;
 }
 
@@ -954,10 +939,11 @@ GVariant *_ps_modem_get_properties(gpointer object, GVariantBuilder *properties)
 {
        ps_modem_t *modem = object;
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "get modem properties");
+
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
 
        g_variant_builder_add(properties, "{ss}", "path", modem->path);
@@ -970,10 +956,18 @@ GVariant *_ps_modem_get_properties(gpointer object, GVariantBuilder *properties)
        g_variant_builder_add(properties, "{ss}", "roaming_allowed", BOOL2STRING(modem->roaming_allowed));
        g_variant_builder_add(properties, "{ss}", "data_allowed", BOOL2STRING(modem->data_allowed));
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "Exiting");
        return g_variant_builder_end(properties);
 }
 
+gpointer _ps_modem_ref_master(gpointer object)
+{
+       ps_modem_t *modem = object;
+       g_return_val_if_fail(modem != NULL, NULL);
+
+       return modem->p_master;
+}
+
 GHashTable *_ps_modem_ref_services(gpointer object)
 {
        ps_modem_t *modem = object;
@@ -1014,6 +1008,7 @@ gpointer _ps_modem_ref_co_modem(gpointer object)
        return modem->co_modem;
 }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 gpointer _ps_modem_ref_work_queue(gpointer object)
 {
        ps_modem_t *modem = object;
@@ -1021,6 +1016,7 @@ gpointer _ps_modem_ref_work_queue(gpointer object)
 
        return modem->work_queue;
 }
+#endif
 
 gchar *_ps_modem_ref_cp_name(gpointer object)
 {
@@ -1043,8 +1039,10 @@ static gboolean on_modem_get_properties(PacketServiceModem *obj_modem,
 {
        GVariant *gv = NULL;
        GVariantBuilder properties;
+       ps_modem_t *modem = user_data;
+       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
 
-       dbg("get modem properties");
+       ps_info_ex_co(co_modem, "get modem properties");
 
        gv = _ps_modem_get_properties(user_data, &properties);
        packet_service_modem_complete_get_properties(obj_modem, invocation, gv);
@@ -1063,7 +1061,7 @@ static gboolean on_modem_get_services(PacketServiceModem *obj_modem,
        ps_modem_t *modem = user_data;
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
 
-       ps_dbg_ex_co(co_modem, "modem get service interface");
+       ps_info_ex_co(co_modem, "modem get service interface");
 
        if (modem->services == NULL) {
                FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
@@ -1078,7 +1076,7 @@ static gboolean on_modem_get_services(PacketServiceModem *obj_modem,
                g_variant_builder_open(&b_service, G_VARIANT_TYPE("{sa{ss}}"));
                path = _ps_service_ref_path(value);
                ps_dbg_ex_co(co_modem, "path added [%s]", path);
-               g_variant_builder_add(&b_service, "s", path);
+               g_variant_builder_add(&b_service, "s", g_strdup(path));
                if (FALSE == _ps_service_get_properties_handler(value, &b_service)) {
                        g_variant_builder_close(&b_service);
                        FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
@@ -1101,8 +1099,9 @@ static gboolean on_modem_go_dormant_all(PacketServiceModem *obj_modem,
        GHashTableIter iter;
        gpointer key, value;
        ps_modem_t *modem = user_data;
+       CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
 
-       dbg("modem go dormant all interface");
+       ps_info_ex_co(co_modem, "modem go dormant all interface");
 
        if (modem->services == NULL) {
                FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
@@ -1112,7 +1111,7 @@ static gboolean on_modem_go_dormant_all(PacketServiceModem *obj_modem,
        g_hash_table_iter_init(&iter, modem->services);
        while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
                ps_service_t *service = value;
-               dbg("service (%p), send dormant request, ", service);
+               ps_dbg_ex_co(co_modem, "service (%p), send dormant request, ", service);
                result = tcore_ps_send_dormant_request(service->co_ps, NULL);
        }
 
@@ -1131,7 +1130,7 @@ static gboolean on_modem_get_profile_list(PacketServiceModem *obj_modem,
        ps_modem_t *modem = user_data;
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
 
-       ps_dbg_ex_co(co_modem, "master get the profile list");
+       ps_info_ex_co(co_modem, "master get the profile list");
 
        if (modem->contexts == NULL) {
                ps_err_ex_co(co_modem, "no profiles");
@@ -1150,7 +1149,7 @@ static gboolean on_modem_get_profile_list(PacketServiceModem *obj_modem,
        }
 
        if (profiles == NULL) {
-               ps_dbg_ex_co(co_modem, "no profiles");
+               ps_warn_ex_co(co_modem, "no profiles");
                FAIL_RESPONSE(invocation, PS_ERR_NO_PROFILE);
                return TRUE;
        }
@@ -1174,7 +1173,7 @@ static gboolean on_modem_get_profile_list(PacketServiceModem *obj_modem,
 
        g_strfreev(strv);
        g_slist_free_full(profiles, g_free);
-       dbg("Exiting");
+       ps_dbg_ex_co(co_modem, "Exiting");
        return TRUE;
 }
 
@@ -1193,22 +1192,22 @@ static gboolean on_modem_add_profile(PacketServiceModem *obj_modem,
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
        GHashTable *profile_property = NULL;
 
-       ps_dbg_ex_co(co_modem, "add profile request");
+       ps_info_ex_co(co_modem, "add profile request");
 
        operator = _ps_modem_ref_operator(modem);
 
        if (!operator) {
-               ps_dbg_ex_co(co_modem, "there is no active modem");
+               ps_warn_ex_co(co_modem, "there is no active modem");
                FAIL_RESPONSE(invocation, PS_ERR_INTERNAL);
                return TRUE;
        }
 
-       /*Create a hash table for the profile property as all fucntion already use ghash table */
+       /*Create a hash table for the profile property as all function already use ghash table */
        profile_property = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
        g_variant_iter_init(&g_iter, property);
        while (g_variant_iter_next(&g_iter, "{ss}", &g_key, &g_value)) {
 
-               ps_dbg_ex_co(co_modem, " '%s' value '%s'", g_key, g_value);
+               ps_info_ex_co(co_modem, " '%s' value '%s'", g_key, g_value);
                g_hash_table_insert(profile_property, g_strdup(g_key), g_strdup(g_value));
                /* must free data for ourselves */
                g_free(g_value);
@@ -1226,7 +1225,7 @@ static gboolean on_modem_add_profile(PacketServiceModem *obj_modem,
        packet_service_modem_complete_add_profile(obj_modem, invocation, TRUE);
 
        g_hash_table_destroy(profile_property);
-       dbg("Exiting");
+       ps_dbg_ex_co(co_modem, "Exiting");
        return TRUE;
 }
 
@@ -1242,11 +1241,35 @@ gboolean _ps_modem_initiate_reset_profile(gpointer value)
        co_modem = _ps_modem_ref_co_modem(modem);
 
        ps_dbg_ex_co(co_modem, "Reseting the hash table");
-       /* Remove contexts through only service. */
-       g_hash_table_iter_init(&iter, modem->services);
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               ps_dbg_ex_co(co_modem, "Remove contexts on service(%p)", value);
-               _ps_service_remove_contexts(value);
+       if (modem->powered != PS_MODEM_STATE_ONLINE) {
+               gint index, count;
+               ps_context_t *pscontext;
+
+               count = g_slist_length(modem->contexts);
+               /* Remove contexts directly as there is no service */
+               for (index = 0; index < count; index++) {
+                       pscontext = g_slist_nth_data(modem->contexts, index);
+                       ps_warn_ex_co(co_modem, "Remove context(%p)", pscontext);
+                       _ps_context_remove_context(pscontext);
+               }
+               g_slist_free(modem->contexts);
+               modem->contexts = NULL;
+
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                       ps_service_t *service;
+                       service = (ps_service_t *)value;
+                       ps_warn_ex_co(co_modem, "Remove contexts on service(%p)", value);
+                       g_slist_free(service->contexts);
+                       service->contexts = NULL;
+               }
+       } else {
+               /* Remove contexts through only service. */
+               g_hash_table_iter_init(&iter, modem->services);
+               while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+                       ps_warn_ex_co(co_modem, "Remove contexts on service(%p)", value);
+                       _ps_service_remove_contexts(value);
+               }
        }
 
        if (modem->type == 0) {
@@ -1256,11 +1279,11 @@ gboolean _ps_modem_initiate_reset_profile(gpointer value)
                thread = g_thread_new(name, __ps_modem_regenerate_database, modem);
                g_free(name);
                if (thread == NULL) {
-                       dbg("Thread is not created");
+                       ps_err_ex_co(co_modem, "Thread is not created");
                        FAIL_RESPONSE(modem->invocation , PS_ERR_INTERNAL);
                        _ps_modem_remove_profile_reset_gsource(modem);
                } else {
-                       dbg("Thread(%p) is created", thread);
+                       ps_dbg_ex_co(co_modem, "Thread(%p) is created", thread);
                }
 
                return FALSE;
@@ -1296,7 +1319,7 @@ static gboolean on_modem_reset_profile(PacketServiceModem *obj_modem,
        CoreObject *co_ps;
        int state;
 
-       ps_dbg_ex_co(co_modem, "reset profile request type(%d)", type);
+       ps_info_ex_co(co_modem, "reset profile request type(%d)", type);
 
        if (_ps_modem_get_reset_profile(modem) == TRUE) {
                ps_err_ex_co(co_modem, "Reset Profile is already in Progress");
@@ -1316,18 +1339,17 @@ static gboolean on_modem_reset_profile(PacketServiceModem *obj_modem,
        contexts_active = tcore_ps_any_context_activating_activated(co_ps, &state);
 
        if (contexts_active == TRUE) {
-               ps_dbg_ex_co(co_modem, "Contexts are in [%d] state", state);
+               ps_info_ex_co(co_modem, "Contexts are in [%d] state", state);
                if (state == CONTEXT_STATE_ACTIVATED) {
                        ps_dbg_ex_co(co_modem, "Contexts are in Actived state. Sending Diconnect Notification to all connected contexts");
                        rv = tcore_ps_deactivate_contexts(co_ps);
                        if (rv != TCORE_RETURN_SUCCESS)
-                               ps_dbg_ex_co(co_modem, "fail to deactivation");
+                               ps_err_ex_co(co_modem, "fail to deactivation");
                } else if (state == CONTEXT_STATE_ACTIVATING) {
                        ps_dbg_ex_co(co_modem, "Contexts are in Activating state. Wait for them to connect");
                }
        } else {
-               ps_dbg_ex_co(co_modem, "No contexts are in activating or activated state");
-               ps_dbg_ex_co(co_modem, "Profiles reset is being initiated");
+               ps_info_ex_co(co_modem, "No contexts are in activating or activated state. Profiles reset is being initiated");
                _ps_modem_initiate_reset_profile(modem);
        }
 
index 053dc53..c9f4eb7 100644 (file)
 #include <core_object.h>
 #include <co_ps.h>
 #include <co_context.h>
+#include <co_network.h>
 #include <storage.h>
 
+#define MODULE_TAG "PS-SERVICE"
+
 #define PROP_DEFAULT   FALSE
 #define PROP_DEFAULT_STR   NULL
 
@@ -48,12 +51,12 @@ void __remove_service_handler(gpointer data)
 {
        ps_service_t *service = data;
 
-       dbg("Entered");
        if (!service) {
-               dbg("Service is Null");
+               err("Service is Null");
                return;
        }
 
+       ps_info_ex_co(_ps_service_ref_co_network(service), "Entered");
        /*Need to remove the compelete hash table*/
        g_slist_free(service->contexts);
 
@@ -82,7 +85,7 @@ static void __ps_service_emit_property_changed_signal(ps_service_t *service)
        gv = _ps_service_get_properties(service, &property);
        packet_service_service_emit_property_changed(service->if_obj, gv);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return;
 }
 
@@ -96,7 +99,7 @@ static void __ps_service_emit_context_added_signal(ps_service_t *service, gpoint
        gv = _ps_context_get_properties(context, &property);
        packet_service_service_emit_context_added(service->if_obj, gv);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return;
 }
 
@@ -104,10 +107,10 @@ static void __ps_service_emit_context_removed_signal(ps_service_t *service, gpoi
 {
        ps_context_t *pscontext = context;
 
-       dbg("Entered");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered");
        packet_service_service_emit_context_removed(service->if_obj, pscontext->path);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return;
 }
 
@@ -145,15 +148,19 @@ static char *__ps_service_act2string(enum telephony_network_access_technology ac
 static gboolean __ps_service_check_connection_option(gpointer object, gpointer context)
 {
        gboolean b_connect = TRUE;
-       gboolean power = FALSE, sim = FALSE, data = FALSE, flight = FALSE, nw_ops = FALSE;
+       gboolean power = FALSE, sim = FALSE, data = FALSE, flight = FALSE;
        gboolean profile_reset = FALSE;
 
        enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
        gint ps_mode;
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        guchar hook_flag;
+       gboolean nw_ops = FALSE;
+#endif
 
        ps_service_t *service = object;
        ps_modem_t *modem = _ps_service_ref_modem(service);
+       ps_master_t *master = _ps_modem_ref_master(modem);
        ps_context_t *ps_context = context;
        CoreObject *co_context = (CoreObject *)_ps_context_ref_co_context(context);
        CoreObject *co_network = _ps_service_ref_co_network(service);
@@ -163,26 +170,32 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
                return FALSE;
        }
 
-       role = tcore_context_get_role(co_context);
-       if (service->roaming)
-               b_connect &= _ps_modem_get_data_roaming_allowed(modem);
-
        sim = _ps_modem_get_sim_init(modem);
        data = _ps_modem_get_data_allowed(modem);
        flight = _ps_modem_get_flght_mode(modem);
-       hook_flag = _ps_modem_get_hook_flag(modem);
        profile_reset = _ps_modem_get_reset_profile(modem);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+       hook_flag = _ps_modem_get_hook_flag(modem);
        if (hook_flag != PS_NO_PENDING_REQUEST)
                nw_ops = TRUE;
+#endif
        if (PS_MODEM_STATE_ONLINE == _ps_modem_get_power(modem))
                power = TRUE;
 
        b_connect &= power;
        b_connect &= sim;
 
-       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY) {
-               dbg("Do not check data allowed value in case of IMS type");
+       role = tcore_context_get_role(co_context);
+       if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT) {
+               ps_info_ex_co(co_network, "Do not check data and data roaming allowed value in case of IMS type");
        } else {
+               if (service->roaming) {
+                       gboolean roaming_allowed = FALSE;
+                       roaming_allowed = _ps_modem_get_data_roaming_allowed(modem);
+                       ps_warn_ex_co(co_network, "roaming_allowed:[%d]", roaming_allowed);
+                       b_connect &= roaming_allowed;
+               }
+
 #if defined(TIZEN_SUPPORT_MMS_CONNECT_FORCE)
                ps_dbg_ex_co(co_network, "csc runtime feature enabled");
                if (role != CONTEXT_ROLE_MMS && role != CONTEXT_ROLE_PREPAID_MMS) {
@@ -190,7 +203,7 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
                } else {
                        char *tmp_apn = NULL;
                        tmp_apn = tcore_context_get_apn(co_context);
-                       dbg("csc runtime feature is enabled: apn[%s]", tmp_apn);
+                       ps_info_ex_co(co_network, "csc runtime feature is enabled: apn[%s]", tmp_apn);
                        if (ps_feature_get_bool(PS_FEATURE_OPERATOR_SKT)) {
                                if (data)
                                        tcore_context_set_apn(co_context, "web.sktelecom.com");
@@ -205,7 +218,9 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
        }
 
        b_connect &= !flight;
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        b_connect &= !nw_ops;
+#endif
        b_connect &= !service->restricted;
        b_connect &= !profile_reset;
 #ifndef TIZEN_PS_FORCE_ATTACH_DETACH
@@ -223,7 +238,7 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
         * taken care of by telephony.
         * Solution: Do not PDP retry until initial PDP connection when Wifi connected.
         */
-       if (service->initial_pdp_conn == FALSE) {
+       if (master && master->initial_pdp_conn == FALSE) {
                int wifi_state = PS_WIFI_STATE_OFF;
                Server *s = NULL;
                Storage *strg = NULL;
@@ -233,25 +248,34 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
                wifi_state = tcore_storage_get_int(strg, KEY_WIFI_STATE);
                if (wifi_state == PS_WIFI_STATE_CONNECTED) {
                        if (service->wifi_connected_checked == FALSE) {
-                               ps_dbg_ex_co(co_network, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
+                               ps_info_ex_co(co_network, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
                                b_connect &= FALSE;
                                service->wifi_connected_checked = TRUE;
                        } else {
-                               ps_dbg_ex_co(co_network, "Wifi connected state was already checked.");
+                               ps_info_ex_co(co_network, "Wifi connected state was already checked.");
                        }
                }
        }
-       ps_dbg_ex_co(co_network, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), fook_flag(%d)",
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+       ps_info_ex_co(co_network, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), fook_flag(%d)",
                b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode, hook_flag);
-
+#else
+       ps_info_ex_co(co_network, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d)",
+               b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode);
+#endif
        /* In case of ME in LCD off & UPS mode.
         * Do not allow PDP activation.
         */
        if (b_connect) {
-               if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
+               int ups_mode, emc_data_allowed;
+               ups_mode = ps_mode & ~POWER_SAVING_MODE_DATA_ALLOWED;
+               emc_data_allowed = ps_mode & POWER_SAVING_MODE_DATA_ALLOWED;
+               if (emc_data_allowed == FALSE &&
+                       (ups_mode > POWER_SAVING_MODE_NORMAL && ups_mode < POWER_SAVING_MODE_WEARABLE)) {
                        Storage *strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(service->plg), "vconf");
                        gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
-                       if (pm_state == 3) {
+                       if (pm_state == 3 &&
+                                       (role != CONTEXT_ROLE_IMS &&  role != CONTEXT_ROLE_IMS_EMERGENCY &&  role != CONTEXT_ROLE_IMS_UT)) {
                                ps_warn_ex_co(co_network, "PDP activation is not allowed in LCD off & UPS mode.");
                                b_connect = FALSE;
                        }
@@ -263,39 +287,97 @@ static gboolean __ps_service_check_connection_option(gpointer object, gpointer c
 static int __ps_service_connetion_timeout_handler(alarm_id_t alarm_id, void *context)
 {
        int rv = 0;
-       ps_service_t *service = _ps_context_ref_service(context);
+       ps_context_t *ps_context = context;
+       ps_service_t *service = _ps_context_ref_service(ps_context);
        if (service == NULL) {
                err("service is NULL!!!");
                return rv;
        }
 
-       if (service->timer_src > 0) {
-               dbg("remove connection retry timer (%d)", service->timer_src);
-               alarmmgr_remove_alarm(service->timer_src);
-               service->timer_src = 0;
+       if (ps_context->timer_src > 0) {
+               ps_info_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
+               alarmmgr_remove_alarm(ps_context->timer_src);
+               ps_context->timer_src = 0;
        }
-       rv = _ps_service_activate_context(service, context);
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "Re-try for %d type", tcore_context_get_role(_ps_context_ref_co_context(ps_context)));
+       rv = _ps_service_activate_context(service, ps_context);
+       ps_info_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
+       return rv;
+}
+
+static gboolean __ps_service_check_is_network_in_serivce(gpointer object)
+{
+       ps_service_t *service = object;
+       CoreObject *co_network = NULL;
+       enum telephony_network_service_type service_type = NETWORK_SERVICE_TYPE_UNKNOWN;
+       gboolean rv = FALSE;
+
+       co_network = _ps_service_ref_co_network(service);
+       tcore_network_get_service_type(co_network, &service_type);
+       ps_warn_ex_co(co_network, "service_type[%d]", service_type);
+       switch (service_type) {
+               case NETWORK_SERVICE_TYPE_UNKNOWN:
+               case NETWORK_SERVICE_TYPE_NO_SERVICE:
+               case NETWORK_SERVICE_TYPE_EMERGENCY:
+               case NETWORK_SERVICE_TYPE_SEARCH:
+                       break;
+               default:
+                       rv = TRUE;
+                       break;
+       }
+       return rv;
+}
+
+static TReturn __ps_service_set_attach_apn(ps_service_t *service, CoreObject *co_context, int set_cid)
+{
+       TReturn rv;
+       char *apn = tcore_context_get_apn(co_context);
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "'Attach APN(%d)' [%s]", tcore_context_get_role(co_context), apn);
+
+       if (set_cid)
+               tcore_context_set_id(co_context, set_cid); // internet
+
+       rv = tcore_ps_define_context(service->co_ps, co_context, NULL);
+       if (rv != TCORE_RETURN_SUCCESS)
+               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to define context");
+
+       g_free(apn);
        return rv;
 }
 
 void _ps_service_set_attach_apn(ps_service_t *service)
 {
        unsigned int index;
+       int default_data_subs;
+       ps_subs_type subscription_type;
+       Server *s = NULL;
+       Storage *strg;
+       ps_modem_t *modem = NULL;
+
+       if (service->attach_apn_complete == TRUE) {
+               ps_info_ex_co(_ps_service_ref_co_network(service), "Attach APN already completed");
+               return;
+       }
+
+       modem = _ps_service_ref_modem(service);
+
+       /* Check for default data subscription value if matchs for modem then only attach */
+       subscription_type = _ps_modem_get_subs_type(modem);
+       s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
+       strg = tcore_server_find_storage(s, "vconf");
+       default_data_subs = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
+       if (default_data_subs != (int)subscription_type) {
+               ps_warn_ex_co(_ps_service_ref_co_network(service), "Ignore Attach APN for non-dds sim [DDS - SIM%d]", default_data_subs + 1);
+               return;
+       }
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
                gpointer ps_context = g_slist_nth_data(service->contexts, index);
                CoreObject *co_context = _ps_context_ref_co_context(ps_context);
                gboolean attach_apn = tcore_context_get_attach_apn(co_context);
                if (attach_apn) {
-                       TReturn rv;
-                       char *apn = tcore_context_get_apn(co_context);
-                       dbg("'Attach APN' [%s]", apn);
-                       rv = tcore_ps_define_context(service->co_ps, co_context, NULL);
-                       if (rv != TCORE_RETURN_SUCCESS)
-                               err("fail to define context");
-
-                       g_free(apn);
+                       __ps_service_set_attach_apn(service, co_context, 0);
                        /* Attach APN is only one. */
                        break;
                }
@@ -344,8 +426,8 @@ gpointer _ps_service_create_service(GDBusConnection *conn, TcorePlugin *p, gpoin
        /*Setting up the interface for the service */
        _ps_service_setup_interface(service, new_service);
 
-       new_service->connection_timeout = TIMEOUT_DEFAULT;
-       ps_dbg_ex_co(co_network, "Successfully Created the service");
+//     new_service->connection_timeout = TIMEOUT_DEFAULT;
+       ps_info_ex_co(co_network, "Successfully Created the service");
        return new_service;
 
 FAILURE:
@@ -361,10 +443,10 @@ gboolean _ps_service_ref_context(gpointer object, gpointer context)
        ps_service_t *service = object;
        CoreObject *co_network = NULL;
 
-       dbg("service refer to context");
        g_return_val_if_fail(service != NULL, FALSE);
 
        co_network = _ps_service_ref_co_network(service);
+       ps_dbg_ex_co(co_network, "service refer to context");
        tmp = g_slist_find(service->contexts, context);
        if (tmp != NULL) {
                ps_dbg_ex_co(co_network, "context(%p) already existed", tmp);
@@ -375,7 +457,7 @@ gboolean _ps_service_ref_context(gpointer object, gpointer context)
        tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
        service->contexts = g_slist_append(service->contexts, context);
 
-       ps_dbg_ex_co(co_network, "context(%p) insert to linked-list", context);
+       ps_info_ex_co(co_network, "context(%p) insert to linked-list", context);
        __ps_service_emit_context_added_signal(service, context);
 
        return TRUE;
@@ -390,8 +472,9 @@ gboolean _ps_service_ref_contexts(gpointer object, GSList *contexts, gchar *oper
        CoreObject *co_network = NULL;
        g_return_val_if_fail(service != NULL, FALSE);
        count = g_slist_length(contexts);
-       ps_dbg_ex_co(co_network, "service refer to contexts: count(%d)", count);
        co_network = _ps_service_ref_co_network(service);
+       ps_dbg_ex_co(co_network, "service refer to contexts: count(%d)", count);
+
        for (index = 0; index < count; index++) {
                gpointer tmp = NULL, value = NULL;
 
@@ -406,7 +489,7 @@ gboolean _ps_service_ref_contexts(gpointer object, GSList *contexts, gchar *oper
                tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(value));
                service->contexts = g_slist_append(service->contexts, value);
 
-               ps_dbg_ex_co(co_network, "context(%p) path(%s) insert to linked-list", value, _ps_context_ref_path(value));
+               ps_info_ex_co(co_network, "context(%p) path(%s) insert to linked-list", value, _ps_context_ref_path(value));
                __ps_service_emit_context_added_signal(service, value);
 
 #ifdef PREPAID_SIM_APN_SUPPORT
@@ -420,9 +503,18 @@ gboolean _ps_service_ref_contexts(gpointer object, GSList *contexts, gchar *oper
 
                if (service->ps_attached) {
                        gboolean f_awo = _ps_context_get_alwayson_enable(value);
+                       gboolean ims_activation_requested = FALSE;
+
                        if (f_awo) {
                                rv = _ps_service_define_context(service, value);
-                               ps_dbg_ex_co(co_network, "Always-on started, return rv(%d)", rv);
+                               ps_info_ex_co(co_network, "Always-on started, return rv(%d)", rv);
+                       }
+
+                       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+                       if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(value)))) {
+                               rv = _ps_service_define_context(service, value);
+                               ps_info_ex_co(co_network, "IMS PDN rv(%d)", rv);
+                               ims_activation_requested = FALSE;
                        }
                }
        }
@@ -435,10 +527,11 @@ gboolean _ps_service_get_properties_handler(gpointer object, GVariantBuilder *pr
 {
        ps_service_t *service = object;
 
-       dbg("get service properties");
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
+       ps_info_ex_co(_ps_service_ref_co_network(service), "get service properties");
+
        g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
        g_variant_builder_add(properties, "{ss}", "path", service->path);
        g_variant_builder_add(properties, "{ss}", "ps_attached", BOOL2STRING(service->ps_attached));
@@ -446,7 +539,7 @@ gboolean _ps_service_get_properties_handler(gpointer object, GVariantBuilder *pr
        g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
        g_variant_builder_close(properties);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return TRUE;
 }
 
@@ -454,10 +547,11 @@ GVariant *_ps_service_get_properties(gpointer object, GVariantBuilder *propertie
 {
        ps_service_t *service = object;
 
-       dbg("get service properties ");
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(properties != NULL, FALSE);
 
+       ps_info_ex_co(_ps_service_ref_co_network(service), "get service properties");
+
        g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
 
        g_variant_builder_add(properties, "{ss}", "path", service->path);
@@ -465,7 +559,7 @@ GVariant *_ps_service_get_properties(gpointer object, GVariantBuilder *propertie
        g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
        g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "Exiting");
        return g_variant_builder_end(properties);
 }
 
@@ -515,19 +609,17 @@ gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ip
        ps_service_t *service = object;
        CoreObject *co_context = NULL;
 
-       dbg("set context info");
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(devinfo != NULL, FALSE);
 
+       ps_info_ex_co(_ps_service_ref_co_network(service), "set context device info for cid %d", devinfo->context_id);
+
        contexts = tcore_ps_ref_context_by_id(service->co_ps, devinfo->context_id);
        if (!contexts) {
-               ps_dbg_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
+               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
                return FALSE;
        }
 
-
-
-
        while (contexts) {
                ps_modem_t *modem = NULL;
                int role = CONTEXT_ROLE_UNKNOWN;
@@ -542,7 +634,7 @@ gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ip
                role = tcore_context_get_role(co_context);
                modem = _ps_service_ref_modem(service);
                if (g_strcmp0(modem->operator, "45005") == 0 && role == CONTEXT_ROLE_IMS) {
-                       ps_dbg_ex_co(_ps_service_ref_co_network(service), "SKT INS PDN");
+                       ps_dbg_ex_co(_ps_service_ref_co_network(service), "SKT IMS PDN");
                        /*IPv4*/
                        if (devinfo->pcscf_ipv4_count == 0) {
                                char ipv4[16];
@@ -550,19 +642,21 @@ gboolean _ps_service_set_context_devinfo(gpointer object, struct tnoti_ps_pdp_ip
                                        devinfo->ip_address[0], devinfo->ip_address[1],
                                        devinfo->ip_address[2], devinfo->ip_address[3]);
                                if (!g_str_equal(ipv4, "0.0.0.0")) {
+                                       devinfo->pcscf_ipv4 = g_try_malloc0(sizeof(char *));
+                                       if (devinfo->pcscf_ipv4 == NULL)
+                                               continue;
+                                       devinfo->pcscf_ipv4[0] = g_strdup("220.103.220.10");
                                        devinfo->pcscf_ipv4_count = 1;
-                                       devinfo->pcscf_ipv4 = g_try_malloc0(sizeof(char *) * devinfo->pcscf_ipv4_count);
-                                       if (devinfo->pcscf_ipv4 != NULL)
-                                               devinfo->pcscf_ipv4[0] = g_strdup("220.103.220.10");
                                }
                        }
                        /*IPv6*/
                        if (devinfo->pcscf_ipv6_count == 0) {
                                if (devinfo->ipv6_address != NULL) {
+                                       devinfo->pcscf_ipv6 = g_try_malloc0(sizeof(char *));
+                                       if (devinfo->pcscf_ipv6 == NULL)
+                                               continue;
+                                       devinfo->pcscf_ipv6[0] = g_strdup("2001:2d8:00e0:0220::10");
                                        devinfo->pcscf_ipv6_count = 1;
-                                       devinfo->pcscf_ipv6 = g_try_malloc0(sizeof(char *) * devinfo->pcscf_ipv6_count);
-                                       if (devinfo->pcscf_ipv6 != NULL)
-                                               devinfo->pcscf_ipv6[0] = g_strdup("2001:2d8:00e0:0220::10");
                                }
                        }
                }
@@ -581,13 +675,14 @@ gboolean _ps_service_set_context_bearerinfo(gpointer object, struct tnoti_ps_ded
        ps_service_t *service = object;
        CoreObject *co_context = NULL;
 
-       dbg("set context info");
        g_return_val_if_fail(service != NULL, FALSE);
        g_return_val_if_fail(bearer_info != NULL, FALSE);
 
+       ps_info_ex_co(_ps_service_ref_co_network(service), "set context bearer info");
+
        contexts = tcore_ps_ref_context_by_id(service->co_ps, bearer_info->primary_context_id);
        if (!contexts) {
-               ps_dbg_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
+               ps_err_ex_co(_ps_service_ref_co_network(service), "fail to ref context by cid.");
                return FALSE;
        }
 
@@ -620,7 +715,7 @@ int _ps_service_define_context(gpointer object, gpointer context)
        CoreObject *co_context = NULL;
        gboolean b_connect = TRUE;
 
-       dbg("define context(%p)", context);
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "define context(%p)", context);
        g_return_val_if_fail(service != NULL, FALSE);
 
        b_connect = __ps_service_check_connection_option(service, context);
@@ -639,31 +734,31 @@ int _ps_service_activate_context(gpointer object, gpointer context)
        gboolean ps_defined;
        int ret = TCORE_RETURN_SUCCESS;
        int default_data_subs = 1;
-       ps_subs_type subs_type = 1;
+       ps_subs_type subscription_type = 1;
        Server *s = NULL;
-       static Storage *strg;
-       CoreObject *co_network = NULL;
+       Storage *strg;
+       CoreObject *co_network = _ps_service_ref_co_network(service);
 
-       dbg("activate context(%p)", context);
        g_return_val_if_fail(service != NULL, FALSE);
 
+       ps_dbg_ex_co(co_network, "activate context(%p)", context);
        s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
        strg = tcore_server_find_storage(s, "vconf");
 
-       co_network = _ps_service_ref_co_network(service);
        modem = _ps_service_ref_modem(service);
        ps_defined = _ps_context_get_ps_defined(context);
        co_context = (CoreObject *)_ps_context_ref_co_context(context);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        if (modem->hook_flag != PS_NO_PENDING_REQUEST) {
-               ps_dbg_ex_co(co_network, "Pending request present in queue with flag %x", modem->hook_flag);
+               ps_info_ex_co(co_network, "Pending request present in queue with flag %x", modem->hook_flag);
                ret = TCORE_RETURN_FAILURE;
                goto EXIT;
        }
-
+#endif
        /* Check for default data subscription value if matchs for modem then only activate */
-       subs_type = _ps_modem_get_subs_type(modem);
+       subscription_type = _ps_modem_get_subs_type(modem);
        default_data_subs = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
-       if ((default_data_subs != -1) && (default_data_subs != (int)subs_type)) {
+       if ((default_data_subs != -1) && (default_data_subs != (int)subscription_type)) {
                ps_warn_ex_co(co_network, "activation  for only [SIM%d] selected by Setting", default_data_subs + 1);
                ret = TCORE_RETURN_FAILURE;
                goto EXIT;
@@ -676,10 +771,10 @@ int _ps_service_activate_context(gpointer object, gpointer context)
        }
 
        if (!ps_defined) {
-               ps_dbg_ex_co(co_network, "pdp profile is not defined yet, define first. ");
+               ps_info_ex_co(co_network, "pdp profile is not defined yet, define first. ");
                ret = tcore_ps_define_context(service->co_ps, co_context, NULL);
        } else {
-               ps_dbg_ex_co(co_network, "pdp profile is defined, activate context. ");
+               ps_info_ex_co(co_network, "pdp profile is defined, activate context. ");
                ret = tcore_ps_activate_context(service->co_ps, co_context, NULL);
        }
 EXIT:
@@ -706,86 +801,100 @@ gboolean _ps_service_deactivate_context(gpointer object, gpointer context)
 {
        ps_service_t *service = object;
        CoreObject *co_context = NULL;
+       TReturn ret;
 
        g_return_val_if_fail(service != NULL, FALSE);
-       dbg("deactivate context(%p)", context);
+       ps_info_ex_co(_ps_service_ref_co_network(service), "deactivate context(%p)", context);
        co_context = (CoreObject *)_ps_context_ref_co_context(context);
 
-       return tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
+       ret = tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
+       if (ret == TCORE_RETURN_PS_DEACTIVATED) {
+               ps_info_ex_co(_ps_service_ref_co_network(service), "context is deactivated");
+               return TCORE_RETURN_SUCCESS;
+       }
+       return ret;
 }
 
-void _ps_service_set_retry_timeout_value(gpointer object, int value)
+void _ps_service_set_retry_timeout_value(gpointer object, guint value)
 {
-       ps_service_t *service = object;
-       g_return_if_fail(service != NULL);
+       ps_context_t *ps_context = object;
+       ps_service_t *service = _ps_context_ref_service(ps_context);;
+       g_return_if_fail(ps_context != NULL);
 
-       service->connection_timeout = value;
-       dbg("current timeout (%d)", service->connection_timeout);
-       return;
+       if (ps_context->connection_timeout != value) {
+               ps_context->connection_timeout = value;
+               ps_dbg_ex_co(_ps_service_ref_co_network(service), "current timeout (%d)", ps_context->connection_timeout);
+       }
 }
 
 void _ps_service_connection_timer(gpointer object, gpointer context)
 {
        int result = 0;
        gboolean f_awo = FALSE;
+       gboolean ims_activation_requested = FALSE;
        ps_service_t *service = object;
+       ps_context_t *ps_context = context;
 
        g_return_if_fail(service != NULL);
 
-       f_awo = _ps_context_get_alwayson_enable(context);
-       if (!f_awo)
+       f_awo = _ps_context_get_alwayson_enable(ps_context);
+       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(ps_context)))))
                return;
 
-       if (service->timer_src > 0) {
-               warn("remove connection retry timer (%d)", service->timer_src);
-               alarmmgr_remove_alarm(service->timer_src);
-               service->timer_src = 0;
+       if (ps_context->timer_src > 0) {
+               ps_info_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
+               alarmmgr_remove_alarm(ps_context->timer_src);
+               ps_context->timer_src = 0;
        }
-       result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(service->connection_timeout),
-                       0, __ps_service_connetion_timeout_handler, context, &(service->timer_src));
+       result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(ps_context->connection_timeout),
+                       0, __ps_service_connetion_timeout_handler, ps_context, &(ps_context->timer_src));
        if (result != ALARMMGR_RESULT_SUCCESS) {
-               err("Failed to add alarm(%d)", result);
+               ps_err_ex_co(_ps_service_ref_co_network(service), "Failed to add alarm(%d)", result);
                return;
        }
 
-       dbg("cellular service timer started timer src(%d), timeout(%d)", service->timer_src, service->connection_timeout);
-       service->connection_timeout = (service->connection_timeout)*2;
-       if (service->connection_timeout >= TIMEOUT_MAX)
-               service->connection_timeout = TIMEOUT_MAX;
-
-       return;
+       ps_info_ex_co(_ps_service_ref_co_network(service), "cellular service timer started timer src(%d), timeout(%d)",
+               ps_context->timer_src, ps_context->connection_timeout);
+       ps_context->connection_timeout = (ps_context->connection_timeout)*2;
+       if (ps_context->connection_timeout >= TIMEOUT_MAX)
+               ps_context->connection_timeout = TIMEOUT_MAX;
 }
 
 void _ps_service_reset_connection_timer(gpointer context)
 {
        gboolean f_awo = FALSE;
+       gboolean ims_activation_requested = FALSE;
        ps_service_t *service = NULL;
+       ps_context_t *ps_context = context;
+
+       f_awo = _ps_context_get_alwayson_enable(ps_context);
+       service = _ps_context_ref_service(ps_context);
+       service = _ps_context_ref_service(context);
+       if (service == NULL) {
+               err("service is NULL!!!");
+               return;
+       }
+
 #ifdef PREPAID_SIM_APN_SUPPORT
        gboolean p_awo = FALSE;
 
        p_awo = _ps_context_get_prepaid_alwayson_enable(context);
-       f_awo = _ps_context_get_alwayson_enable(context);
        if (!f_awo && !p_awo)
                return;
-#else
-       f_awo = _ps_context_get_alwayson_enable(context);
-       if (!f_awo)
-               return;
 #endif
 
-       service = _ps_context_ref_service(context);
-       if (service == NULL) {
-               err("service is NULL!!!");
+       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+       if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(ps_context)))))
                return;
-       }
-       service->connection_timeout = TIMEOUT_DEFAULT;
 
-       if (service->timer_src > 0) {
-               warn("remove connection retry timer (%d)", service->timer_src);
-               alarmmgr_remove_alarm(service->timer_src);
-               service->timer_src = 0;
+       ps_context->connection_timeout = TIMEOUT_DEFAULT;
+
+       if (ps_context->timer_src > 0) {
+               ps_warn_ex_co(_ps_service_ref_co_network(service), "remove connection retry timer (%d)", ps_context->timer_src);
+               alarmmgr_remove_alarm(ps_context->timer_src);
+               ps_context->timer_src = 0;
        }
-       return;
 }
 
 gboolean _ps_service_unref_context(gpointer object, gpointer context)
@@ -798,7 +907,7 @@ gboolean _ps_service_unref_context(gpointer object, gpointer context)
        g_return_val_if_fail(modem != NULL, FALSE);
        g_return_val_if_fail(context != NULL, FALSE);
        g_return_val_if_fail(pscontext->path != NULL, FALSE);
-       dbg("service unref context (%s)", pscontext->path);
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "service unref context (%s)", pscontext->path);
 
        _ps_service_deactivate_context(service, context);
        /* remove context from the list (modem, service) */
@@ -815,7 +924,7 @@ void _ps_service_remove_contexts(gpointer object)
 
        g_return_if_fail(service != NULL);
        count = g_slist_length(service->contexts);
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service remove all contexts: count(%d)", count);
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service remove all contexts: count(%d)", count);
 
        for (index = 0; index < count; index++) {
                gpointer value = NULL;
@@ -834,7 +943,7 @@ void _ps_service_disconnect_contexts(gpointer object)
        unsigned int index;
        ps_service_t *service = object;
 
-       dbg("service disconnect all contexts");
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service disconnect all contexts");
        g_return_if_fail(service != NULL);
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
@@ -846,14 +955,14 @@ void _ps_service_disconnect_contexts(gpointer object)
        return;
 }
 
-void _ps_service_disconnect_internet_mms_contexts(gpointer object)
+void _ps_service_disconnect_internet_mms_tethering_contexts(gpointer object)
 {
        unsigned int index;
        ps_service_t *service = object;
        CoreObject *co_context = NULL;
        enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
 
-       dbg("Service disconnect Internet/MMS contexts");
+       ps_info_ex_co(_ps_service_ref_co_network(service), "Service disconnect Internet/MMS/Tethering contexts");
        g_return_if_fail(service != NULL);
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
@@ -867,18 +976,20 @@ void _ps_service_disconnect_internet_mms_contexts(gpointer object)
                 *      - INTERNET_PREPAID
                 *      - MMS
                 *      - MMS_PREPAID
+                *      - TETHERING
                 */
                switch (role) {
                case CONTEXT_ROLE_INTERNET:
                case CONTEXT_ROLE_MMS:
                case CONTEXT_ROLE_PREPAID_INTERNET:
                case CONTEXT_ROLE_PREPAID_MMS:
+               case CONTEXT_ROLE_TETHERING:
                        _ps_service_reset_connection_timer(value);
                        _ps_service_deactivate_context(service, value);
                break;
 
                default: {
-                       dbg("Need not deactivate for %d PDN type", role);
+                       ps_warn_ex_co(_ps_service_ref_co_network(service), "Need not deactivate for %d PDN type", role);
                        continue;
                }
                }
@@ -987,21 +1098,38 @@ int _ps_service_connect_default_context(gpointer object)
        int rv = 0;
        unsigned int index;
        ps_service_t *service = object;
+       gboolean ims_activation_requested = FALSE;
 
-       dbg("service connect default context");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service connect default context");
        g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
 
+       ims_activation_requested = _ps_service_get_ims_activation_requested(service);
+
        for (index = 0; index < g_slist_length(service->contexts); index++) {
                gpointer value = g_slist_nth_data(service->contexts, index);
                gboolean f_awo = FALSE;
-               f_awo = _ps_context_get_alwayson_enable(value);
 
+               f_awo = _ps_context_get_alwayson_enable(value);
                if (f_awo) {
+                       enum co_context_state context_state;
+                       CoreObject *co_network = _ps_service_ref_co_network(service);
+
                        /*  FIX: Kiran PLM P141111-07502 */
                        /* _ps_service_reset_connection_timer(value); */
                        rv = _ps_service_activate_context(service, value);
-                       ps_dbg_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
-                       break;
+                       context_state = tcore_context_get_state(((ps_context_t *)value)->co_context);
+                       if (context_state == CONTEXT_STATE_ACTIVATED) {
+                               ps_info_ex_co(co_network, "context is already connected");
+                               _ps_context_set_connected(value, TRUE);
+                       }
+                       ps_info_ex_co(co_network, "return rv(%d)", rv);
+//                     break;
+               }
+
+               if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(value)))) {
+                       rv = _ps_service_activate_context(service, value);
+                       ps_info_ex_co(_ps_service_ref_co_network(service), "return rv(%d)", rv);
+                       ims_activation_requested = FALSE;
                }
        }
 
@@ -1087,7 +1215,7 @@ int _ps_service_update_roaming_apn(gpointer object)
        g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
        g_return_val_if_fail(modem != NULL, TCORE_RETURN_FAILURE);
 
-       dbg("roaming status: %d", service->roaming);
+       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "roaming status: %d", service->roaming);
        /* 1) Remove all contexts
         * 2) Load Home/Roaming profiles from database.
 
@@ -1123,7 +1251,7 @@ int _ps_service_update_roaming_apn(gpointer object)
                        }
 
                        /* De-activate context as home and roam pdp protocol type mismatched */
-                       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
+                       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
                                home_pdp_protocol, roam_pdp_protocol);
                        _ps_service_reset_connection_timer(pscontext);
                        _ps_service_deactivate_context(service, pscontext);
@@ -1135,18 +1263,21 @@ int _ps_service_update_roaming_apn(gpointer object)
 
 gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attached, gboolean roaming)
 {
+#ifdef PREPAID_SIM_APN_SUPPORT
        gboolean ret = TRUE;
+#endif
        ps_service_t *service = object;
        CoreObject *co_network = NULL;
        gboolean prev_roaming_status;
        g_return_val_if_fail(service != NULL, FALSE);
 
-
-       prev_roaming_status = _ps_service_get_roaming(service);
-
        co_network = _ps_service_ref_co_network(service);
+       prev_roaming_status = _ps_service_get_roaming(service);
+       if(__ps_service_check_is_network_in_serivce(service) != TRUE)
+               ps_warn_ex_co(co_network, "Update roaming status only in IN SRV");
+       else
+               _ps_service_set_roaming(service, roaming);
        _ps_service_set_ps_attached(service, ps_attached);
-       _ps_service_set_roaming(service, roaming);
        _ps_update_cellular_state_key(service);
 
        if (prev_roaming_status != _ps_service_get_roaming(service)) {
@@ -1155,7 +1286,7 @@ gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attac
                _ps_service_update_roaming_apn(object);
 
                if (!roaming_allowed && roaming) {
-                       ps_dbg_ex_co(co_network, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
+                       ps_info_ex_co(co_network, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
                        _ps_service_disconnect_contexts(service);
                        return TRUE;
                }
@@ -1167,31 +1298,65 @@ gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attac
                dbg("ret[%d]", ret);
                if (ret == TRUE)
                        return ret; /* No need to activate default context */
+#else
+               gpointer defined_context = NULL;
+               unsigned int index;
+
+               for (index = 0; index < g_slist_length(service->contexts); index++) {
+                       gpointer value = g_slist_nth_data(service->contexts, index);
+                       CoreObject *co_context = NULL;
+                       gboolean b_define = FALSE;
+                       int context_state = 0; int cid = 0;
+
+                       b_define = _ps_context_get_ps_defined(value);
+                       co_context = (CoreObject *)_ps_context_ref_co_context(value);
+                       context_state = tcore_context_get_state(co_context);
+                       cid = tcore_context_get_id(co_context);
+
+                       ps_dbg_ex_co(co_network, "context(%p) defined(%d) cid(%d) activated(%d)", value, b_define, cid, context_state);
+                       if (b_define && cid == 1 && context_state == CONTEXT_STATE_DEACTIVATED) {
+                               ps_dbg_ex_co(co_network, "defined context(%p) is found", value);
+                               defined_context = value;
+                               break;
+                       }
+               }
+
+               if (defined_context) {
+                       int rv = 0;
+                       rv = _ps_service_activate_context(service, defined_context);
+                       ps_dbg_ex_co(co_network, "activation result (%d)", rv);
+               } else {
+                       _ps_service_connect_default_context(service);
+               }
+
+               return TRUE;
 #endif
-               _ps_service_connect_default_context(service);
        }
 
-       return ret;
+       if (service->ps_attached)
+               _ps_service_connect_default_context(service);
+
+       return TRUE;
 }
 
 gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean enabled)
 {
        unsigned int index;
-       gboolean def_awo = FALSE, b_def_conn = FALSE;
+       gboolean def_awo = FALSE, def_ims_activation = FALSE, b_def_conn = FALSE;
        gpointer def_conn = NULL;
        gpointer requested_conn = NULL;
 
-       ps_service_t *service = NULL;
+       ps_service_t *service = (ps_service_t *) object;
+       ps_master_t *master = _ps_modem_ref_master(_ps_service_ref_modem(object));
        struct tnoti_ps_call_status *call_status = NULL;
        CoreObject *co_network;
 
-       service = (ps_service_t *) object;
        co_network = _ps_service_ref_co_network(service);
        call_status = (struct tnoti_ps_call_status *)cstatus;
 
-       if (enabled && service->initial_pdp_conn == FALSE) {
-               ps_dbg_ex_co(co_network, "Initial PDP connection.");
-               service->initial_pdp_conn = TRUE;
+       if (enabled && master && master->initial_pdp_conn == FALSE) {
+               ps_info_ex_co(co_network, "Initial PDP connection.");
+               master->initial_pdp_conn = TRUE;
        }
 
        for (index = 0; index < g_slist_length(service->contexts); index++) {
@@ -1220,16 +1385,12 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
 
                if (!enabled) {
                        gchar *ipv4 = NULL;
-                       gchar *devname = NULL;
 
-                       ps_dbg_ex_co(co_network, "Reset socket connections.");
+                       ps_info_ex_co(co_network, "Reset socket connections.");
 
                        tcore_ps_clear_context_id(service->co_ps, context);
                        ipv4 = tcore_context_get_ipv4_addr(context);
-                       devname = tcore_context_get_ipv4_devname(context);
-                       tcore_util_reset_ipv4_socket((const char *)devname, (const char *)ipv4);
-                       free(ipv4);
-                       g_free(devname);
+                       tcore_util_reset_ipv4_socket(tcore_context_get_ipv4_devname(context), (const char *)ipv4);
                }
 
                _ps_context_set_connected(value, enabled);
@@ -1237,7 +1398,7 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
 
        /* connect to request profile */
        if (!enabled && requested_conn) {
-               ps_dbg_ex_co(co_network, "connect to request profile (%p)", requested_conn);
+               ps_info_ex_co(co_network, "connect to request profile (%p)", requested_conn);
                _ps_connection_hdlr(requested_conn);
                _ps_service_reset_connection_timer(def_conn);
                _ps_context_reset_user_data(def_conn);
@@ -1249,9 +1410,56 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
                gint ps_mode = 0;
                def_conn = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
                def_awo = _ps_context_get_alwayson_enable(def_conn);
+#if 1
+               if (def_awo) {
+                       /*
+                        * In case of ME in LCD off & UPS mode.
+                        * Do not enable PDP retry timer for default internet context.
+                        */
+                       ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
+                       if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
+                               Storage *strg_vconf = tcore_server_find_storage(_ps_service_ref_plugin(service), "vconf");
+                               gint pm_state = tcore_storage_get_int(strg_vconf, STORAGE_KEY_PM_STATE);
+                               if (pm_state == 3) {
+                                       ps_warn_ex_co(co_network, "PDP retry timer is not allowed in LCD off & UPS mode.");
+                                       return TRUE;
+                               }
+                       }
+
+                       /* always on TRUE and default connection - NORMAL RETRY */
+                       /* always on TRUE and no default connection - WAIT 5 Secs for retry from application */
+                       if (b_def_conn) {
+                               /* retry connection */
+                               _ps_service_connection_timer(service, def_conn);
+                       } else {
+
+                               /* disconnect from user intention */
+#if defined(CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
+                               if (call_status->result == 2000) {
+                                       ps_dbg_ex_co(co_network, "user intended disconnect / connect default connection without timer");
+                                       __ps_service_connetion_timeout_handler(((ps_context_t *)def_conn)->timer_src, (ps_context_t *)def_conn);
+                                       return TRUE;
+                               }
+#endif
+                               /* with unexpected disconnection from network/me */
+                               _ps_service_set_retry_timeout_value(def_conn, TIMEOUT_DEFAULT);
+                               _ps_service_connection_timer(service, def_conn);
+                       }
+               }
+
+               def_ims_activation = _ps_service_get_ims_activation_requested(service);
+               if (def_ims_activation) {
+                       gpointer def_ims = NULL;
 
+                       def_ims =  _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
+                       ps_info_ex_co(co_network, "Continue re-try for IMS PDN");
+
+                       /* retry connection */
+                       _ps_service_connection_timer(service, def_ims);
+               }
+#else
                if (!def_awo) {
-                       ps_dbg_ex_co(co_network, "there is no always on connection");
+                       ps_info_ex_co(co_network, "there is no always on connection");
                        return TRUE;
                }
 
@@ -1273,35 +1481,37 @@ gboolean _ps_service_set_connected(gpointer object, gpointer cstatus, gboolean e
                if (b_def_conn) {
                        /* retry connection */
                        _ps_service_connection_timer(service, def_conn);
+               } else if (b_def_ims) {
+                       /* retry connection */
+                       _ps_service_connection_timer(service, def_ims);
                } else {
 
                        /* disconnect from user intention */
 #if defined(CONNECT_DEFAULT_CONNECTION_WITHOUT_TIMER)
                        if (call_status->result == 2000) {
                                ps_dbg_ex_co(co_network, "user intended disconnect / connect default connection without timer");
-                               __ps_service_connetion_timeout_handler(service->timer_src, def_conn);
+                               __ps_service_connetion_timeout_handler(def_conn->timer_src, def_conn);
                                return TRUE;
                        }
 #endif
                        /* with unexpected disconnection from network/me */
-                       _ps_service_set_retry_timeout_value(service, TIMEOUT_DEFAULT);
+                       _ps_service_set_retry_timeout_value(def_conn, TIMEOUT_DEFAULT);
                        _ps_service_connection_timer(service, def_conn);
                }
-
+#endif
        }
 
        /* To send deactivation request of default profile */
        if (enabled && requested_conn) {
-               ps_dbg_ex_co(co_network, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
+               ps_info_ex_co(co_network, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
                return FALSE;
        }
 
        return TRUE;
 }
 
-void _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid)
+void _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid)
 {
-       ps_service_t *service = (ps_service_t *)object;
        unsigned int index;
        CoreObject *co_network;
 
@@ -1313,13 +1523,13 @@ void _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid)
                CoreObject *co_context = _ps_context_ref_co_context(ps_context);
                unsigned char context_id = tcore_context_get_id(co_context);
                if (context_id == cid) {
-                       gboolean attach_apn = tcore_context_get_attach_apn(co_context);
+                       //gboolean attach_apn = tcore_context_get_attach_apn(co_context);
                        gboolean proceed_activation = TRUE;
 
                        /* Check attach apn complete */
-                       if (value && attach_apn && !service->attach_apn_complete) {
+                       if (value /*&& attach_apn*/ && !service->attach_apn_complete) {
                                int role = tcore_context_get_role(co_context);
-                               ps_dbg_ex_co(co_network, "Initial define of attach APN is complete for profile role(%d)", role);
+                               ps_info_ex_co(co_network, "Initial define of attach APN is complete for profile role(%d)", role);
                                service->attach_apn_complete = TRUE;
 
                                if(TRUE == _ps_context_get_default_context(ps_context, CONTEXT_ROLE_INTERNET) && service->ps_attached)
@@ -1338,7 +1548,7 @@ void _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid)
                                /* Activate if define is completed */
                                ps_dbg_ex_co(co_network, "define is complete, activate context for cid(%d)", cid);
                                if (_ps_service_activate_context(service, ps_context) == TCORE_RETURN_SUCCESS) {
-                                       dbg("Successful activate context");
+                                       ps_dbg_ex_co(co_network, "Successful activate context");
                                        tcore_ps_set_cid_active(service->co_ps, cid, TRUE);
                                }
                        }
@@ -1354,10 +1564,11 @@ gboolean _ps_service_set_ps_attached(gpointer object, gboolean value)
        ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       service->ps_attached = value;
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service(%p) ps_attached(%d)", service, service->ps_attached);
-       __ps_service_emit_property_changed_signal(service);
-
+       if (service->ps_attached != value) {
+               service->ps_attached = value;
+               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) ps_attached(%d)", service, service->ps_attached);
+               __ps_service_emit_property_changed_signal(service);
+       }
        return TRUE;
 }
 
@@ -1374,25 +1585,72 @@ gboolean _ps_service_set_restricted(gpointer object, gboolean value)
        ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       service->restricted = value;
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service(%p) restricted(%d)", service, service->restricted);
+       if (service->restricted != value) {
+               service->restricted = value;
+               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) restricted(%d)", service, service->restricted);
+               _ps_update_cellular_state_key(service);
+       }
+       return TRUE;
+}
+
+gboolean _ps_service_set_ims_activation_requested(gpointer object, gboolean enabled)
+{
+       ps_service_t *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       service->ims_activation_requested = enabled;
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
+       return TRUE;
+}
+
+gboolean _ps_service_get_ims_activation_requested(gpointer object)
+{
+       ps_service_t *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
+       if (_ps_service_get_epdg_status(service) == TRUE)
+               return FALSE;
+
+       return service->ims_activation_requested;
+}
+
+gboolean _ps_service_set_epdg_status(gpointer object, gboolean available)
+{
+       ps_service_t *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       service->is_epdg_available = available;
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) available (%d) ", service, service->is_epdg_available);
 
-       _ps_update_cellular_state_key(service);
        return TRUE;
 }
 
+gboolean _ps_service_get_epdg_status(gpointer object)
+{
+       ps_service_t *service = object;
+       g_return_val_if_fail(service != NULL, FALSE);
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "service (%p) available (%d) ", service, service->is_epdg_available);
+
+       return service->is_epdg_available;
+}
+
 gboolean _ps_service_set_number_of_pdn_cnt(gpointer object, gchar *operator)
 {
        int rv = 0;
        int num_of_pdn = 0;
        ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
+
        ps_dbg_ex_co(_ps_service_ref_co_network(service), "Entered");
        num_of_pdn = _ps_context_get_number_of_pdn(operator, _ps_modem_ref_cp_name(_ps_service_ref_modem(object)));
        rv = tcore_ps_set_num_of_pdn(service->co_ps, num_of_pdn);
 
        if (rv != TCORE_RETURN_SUCCESS)
-               ps_dbg_ex_co(_ps_service_ref_co_network(service), "error to get maximum number of pdn");
+               ps_err_ex_co(_ps_service_ref_co_network(service), "error to get maximum number of pdn");
 
        dbg("Exiting");
        return TRUE;
@@ -1411,9 +1669,11 @@ gboolean _ps_service_set_roaming(gpointer object, gboolean value)
        ps_service_t *service = object;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       service->roaming = value;
-       ps_dbg_ex_co(_ps_service_ref_co_network(service), "service(%p) roaming(%d)", service, service->roaming);
-       __ps_service_emit_property_changed_signal(service);
+       if (service->roaming != value) {
+               service->roaming = value;
+               ps_info_ex_co(_ps_service_ref_co_network(service), "service(%p) roaming(%d)", service, service->roaming);
+               __ps_service_emit_property_changed_signal(service);
+       }
 
        return TRUE;
 }
@@ -1427,9 +1687,9 @@ static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer us
 
        list = g_resolver_lookup_by_name_finish((GResolver *)src, res, &error);
        if (!list) {
-               dbg("fail to get dns resolving");
+               err("fail to get dns resolving");
                if (error) {
-                       dbg("error:%d, %s", error->code, error->message);
+                       err("error:%d, %s", error->code, error->message);
                        g_error_free(error);
                }
                return;
@@ -1440,7 +1700,7 @@ static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer us
                str_addr = g_inet_address_to_string(addr);
                if (!str_addr)
                        continue;
-               dbg("addr(%s)", str_addr);
+               info("addr(%s)", str_addr);
 
                g_free(str_addr);
                g_object_unref(cur->data);
@@ -1455,38 +1715,42 @@ static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer us
 gboolean _ps_service_set_access_technology(gpointer object,
                enum telephony_network_access_technology value)
 {
+#ifdef PREPAID_SIM_APN_SUPPORT
        gboolean ret = TRUE;
+#endif
        ps_service_t *service = object;
        CoreObject *co_network = NULL;
        enum telephony_network_access_technology p_act = 0;
        g_return_val_if_fail(service != NULL, FALSE);
 
-       co_network = _ps_service_ref_co_network(service);
-       p_act = service->act;
-       service->act = value;
-       ps_dbg_ex_co(co_network, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
+       if (service->act != value) {
+               p_act = service->act;
+               service->act = value;
+               co_network = _ps_service_ref_co_network(service);
+               ps_info_ex_co(co_network, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
 
-       if (p_act == NETWORK_ACT_LTE && (service->act >= NETWORK_ACT_GSM && service->act < NETWORK_ACT_LTE)) {
-               GResolver *r = NULL;
+               if (p_act == NETWORK_ACT_LTE && (service->act >= NETWORK_ACT_GSM && service->act < NETWORK_ACT_LTE)) {
+                       GResolver *r = NULL;
 
-               ps_dbg_ex_co(co_network, "send the dns pkt for keeping connection");
+                       ps_dbg_ex_co(co_network, "send the dns pkt for keeping connection");
 
-               r = g_resolver_get_default();
-               g_resolver_lookup_by_name_async(r, "www.google.com", NULL, _indicator_cb_dns_reply, NULL);
-       }
+                       r = g_resolver_get_default();
+                       g_resolver_lookup_by_name_async(r, "www.google.com", NULL, _indicator_cb_dns_reply, NULL);
+               }
 
-       if (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED) {
-               _ps_update_cellular_state_key(service);
+               if (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED) {
+                       _ps_update_cellular_state_key(service);
 #ifdef PREPAID_SIM_APN_SUPPORT
-               ret = _ps_service_connect_last_connected_context(service);
-               dbg("ret[%d]", ret);
-               if (ret == TRUE)
-                       return ret; /* No need to activate default context */
+                       ret = _ps_service_connect_last_connected_context(service);
+                       dbg("ret[%d]", ret);
+                       if (ret == TRUE)
+                               return ret; /* No need to activate default context */
 #endif
-               _ps_service_connect_default_context(service);
+                       _ps_service_connect_default_context(service);
+               }
        }
 
-       return ret;
+       return TRUE;
 }
 
 enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
@@ -1523,13 +1787,14 @@ enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
 
        return TELEPHONY_PS_ON;
 }
+
 static gboolean on_service_get_properties(PacketServiceService *obj_service,
                GDBusMethodInvocation *invocation,
                gpointer user_data)
 {
        GVariant *gv = NULL;
        GVariantBuilder property;
-       ps_dbg_ex_co(_ps_service_ref_co_network(user_data), "get service properties");
+       ps_info_ex_co(_ps_service_ref_co_network(user_data), "get service properties");
 
        gv = _ps_service_get_properties(user_data, &property);
        packet_service_service_complete_get_properties(obj_service, invocation, gv);
@@ -1548,7 +1813,7 @@ on_service_get_context(PacketServiceService *obj_service,
        ps_service_t *service = user_data;
        CoreObject *co_network = _ps_service_ref_co_network(service);
 
-       ps_dbg_ex_co(co_network, "modem get contexts interface");
+       ps_info_ex_co(co_network, "modem get contexts interface");
 
        if (service->contexts == NULL) {
                ps_err_ex_co(co_network, "No context present for service");
@@ -1561,9 +1826,10 @@ on_service_get_context(PacketServiceService *obj_service,
                gpointer value = g_slist_nth_data(service->contexts, index);
                gchar *path = NULL;
                g_variant_builder_open(&b_context, G_VARIANT_TYPE("{sa{ss}}"));
-               path = _ps_service_ref_path(value);
+               path = _ps_context_ref_path(value);
+               ps_info_ex_co(co_network, "path: [%s]", path);
 
-               g_variant_builder_add(&b_context, "s", path);
+               g_variant_builder_add(&b_context, "s", g_strdup(path));
                if (FALSE == _ps_context_get_properties_handler(value, &b_context)) {
                        ps_err_ex_co(co_network, "Failed to get property");
                        g_variant_builder_close(&b_context);
@@ -1581,7 +1847,7 @@ on_service_get_context(PacketServiceService *obj_service,
 
 static void _ps_service_setup_interface(PacketServiceService *service, ps_service_t *service_data)
 {
-       dbg("Entered");
+       ps_info_ex_co(_ps_service_ref_co_network(service_data), "Entered");
        g_signal_connect(service,
                        "handle-get-properties",
                        G_CALLBACK(on_service_get_properties),
@@ -1592,6 +1858,6 @@ static void _ps_service_setup_interface(PacketServiceService *service, ps_servic
                        G_CALLBACK(on_service_get_context),
                        service_data);
 
-       dbg("Exiting");
+       ps_dbg_ex_co(_ps_service_ref_co_network(service_data), "Exiting");
 }
 
index 8617e3f..3650878 100644 (file)
@@ -35,6 +35,8 @@
 #endif
 #include <user_request.h>
 
+#define MODULE_TAG "PS-INF"
+
 #define TIMEOUT_MAX                    1280
 
 enum ps_call_state {
@@ -43,6 +45,7 @@ enum ps_call_state {
        PS_CALL_STATE_RESULT_NO_CARRIER = 0x03
 };
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 struct work_queue_data {
        unsigned int id;
        UserRequest *ur;
@@ -51,13 +54,36 @@ struct work_queue_data {
 static void __ps_modem_set_hook_flag(ps_modem_t *modem , enum tcore_request_command cmd);
 static void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur);
 
-
 #ifdef POWER_SAVING_FEATURE_WEARABLE
 static gboolean __ps_is_any_call_in_progress(TcorePlugin *plugin, __ps_call_flow_type type, enum tcore_notification_command command);
 static enum tcore_hook_return __on_hook_voice_call_status(Server *s, CoreObject *co_call,
                enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data);
 #endif
 
+static UserRequest *ps_util_peek_waiting_job(GQueue *queue, unsigned int id)
+{
+       int iter = 0;
+       struct work_queue_data *wqd = NULL;
+
+       g_return_val_if_fail((NULL != queue), NULL);
+
+       do {
+               wqd = g_queue_peek_nth(queue, iter);
+               if (NULL == wqd)
+                       break;
+               if (wqd->id == id) {
+                       break;
+               }
+               iter++;
+       } while (TRUE);
+
+       if (NULL == wqd) {
+               warn("Work queue data is 0");
+               return NULL;
+       }
+
+       return wqd->ur;
+}
 
 static gboolean ps_util_add_waiting_job(GQueue *queue, unsigned int id, UserRequest *ur)
 {
@@ -139,6 +165,48 @@ static UserRequest *ps_util_pop_waiting_job(GQueue *queue, unsigned int id)
 
        return ur;
 }
+#endif
+
+static void __ps_handle_prop_dnet_connection_status(CoreObject *co_ps, void *user_data)
+{
+       const char *value = NULL;
+       int context_id;
+       guint index;
+       ps_service_t *service = (ps_service_t *)user_data;
+
+       value = tcore_object_ref_property (co_ps, PROP_DNET_CONNECTION_STATUS);
+       ps_info_ex_co(co_ps, "Dnet connection status = %s", value);
+
+       if (!value || strlen(value) == 0)
+               return;
+
+       if (g_strrstr (value, "disconnected")) {
+               for (index = 0; index < g_slist_length(service->contexts); index++) {
+                       gpointer ps_context = g_slist_nth_data(service->contexts, index);
+                       CoreObject *co_context = _ps_context_ref_co_context(ps_context);
+                       if (tcore_context_get_role(co_context) == CONTEXT_ROLE_INTERNET) {
+                               context_id = value[0];
+                               ps_info_ex_co(co_ps, "TNOTI_PS_CALL_STATUS - CID: [%d] State: [%d]", context_id, PS_CALL_STATE_RESULT_NO_CARRIER);
+                               _ps_context_set_ps_defined(ps_context, FALSE);
+                               tcore_ps_set_cid_active(co_ps, context_id, FALSE);
+                               tcore_ps_set_cid_connected(co_ps, context_id, FALSE);
+                               _ps_context_set_connected(ps_context, FALSE);
+                               break;
+                       }
+               }
+       }
+}
+
+static gboolean __ps_on_prop_changed (CoreObject *co_ps, const void *event_info,
+               void *user_data)
+{
+       GSList *key = (GSList *)event_info;
+
+       if (CORE_OBJECT_KEY_FIND(key, PROP_DNET_CONNECTION_STATUS)) {
+               __ps_handle_prop_dnet_connection_status(co_ps, user_data);
+       }
+       return TRUE;
+}
 
 static gboolean __ps_check_pdp_permanent_reject_cause(int cause)
 {
@@ -163,6 +231,7 @@ static gboolean __ps_check_pdp_permanent_reject_cause(int cause)
        return ret;
 }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 static gboolean __ps_set_network_mode(int mode, void *data)
 {
        int c_mode = 0;
@@ -179,24 +248,18 @@ static gboolean __ps_set_network_mode(int mode, void *data)
        co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
                        CORE_OBJECT_TYPE_NETWORK);
        c_mode = mode;
-       dbg("current network mode (%d)", c_mode);
 
        if (modem->data_allowed)
                c_mode |= NETWORK_MODE_LTE;
        else
                c_mode &= ~NETWORK_MODE_LTE;
 
-       dbg("network mode(%d) - data allowed(%d)", c_mode, modem->data_allowed);
-
        roaming = tcore_network_get_roaming_state(co_network);
        if (modem->data_allowed && roaming)
                c_mode &= ~NETWORK_MODE_LTE;
 
-       dbg("network mode(%d) - roaming(%d)", c_mode, roaming);
-
-       dbg("candidate mode(%d), current mode(%d)", c_mode, mode);
+       ps_dbg_ex_co(co_network, "candidate mode(%d), current mode(%d), roaming(%d), data allowed(%d)", c_mode, mode, roaming, modem->data_allowed);
        if (c_mode == mode) {
-               dbg("mode is the same as before, do not send");
                return FALSE;
        }
 
@@ -207,7 +270,7 @@ static gboolean __ps_set_network_mode(int mode, void *data)
        tcore_user_request_set_command(ur, TREQ_NETWORK_SET_MODE);
 
        if (TCORE_RETURN_SUCCESS != tcore_server_dispatch_request(tcore_plugin_ref_server(tcore_object_ref_plugin(modem->co_modem)), ur)) {
-               err("Failed to dispatch ");
+               ps_err_ex_co(co_network, "Failed to dispatch");
                tcore_user_request_unref(ur);
        }
 
@@ -217,7 +280,7 @@ static gboolean __ps_set_network_mode(int mode, void *data)
 /* Function will be used in case any dispatch request failed in ps plugin */
 static void __ps_send_ur_dispatch_failure_response(UserRequest *ur, enum tcore_response_command command)
 {
-       dbg("User request dispatch failed so need to send response for command [%d]", command);
+       err("User request dispatch failed so need to send response for command [%d]", command);
        switch (command) {
        case TRESP_NETWORK_SEARCH: {
                struct tresp_network_search search_rsp;
@@ -318,13 +381,14 @@ void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
                        co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
                                CORE_OBJECT_TYPE_NETWORK);
 
-                       ps_dbg_ex_co(co_modem, "Sending Pending Request of type = id", id);
+                       ps_info_ex_co(co_modem, "Sending Pending Request of type = id", id);
                        tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
                        if ((command == TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH)
                                        || (command == TRESP_NETWORK_SEARCH)
                                        || (command == TRESP_NETWORK_SET_PLMN_SELECTION_MODE)
                                        || (command == TRESP_NETWORK_SET_MODE)
-                                       || (command == TRESP_NETWORK_GET_MODE))
+                                       || (command == TRESP_NETWORK_GET_MODE)
+                                       || (command == TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION))
                                ret = tcore_object_dispatch_request(co_network , ur);
                        else if ((command == TRESP_MODEM_SET_FLIGHTMODE)
                                        || (command == TRESP_MODEM_POWER_LOW)
@@ -332,7 +396,6 @@ void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
                                ret = tcore_object_dispatch_request(modem->co_modem , ur);
                        if (TCORE_RETURN_SUCCESS != ret) {
                                /* send responce wrt to command */
-                               err("Failed to dispatch request, need to sent response to dbus");
                                __ps_send_ur_dispatch_failure_response(ur, command);
                        }
                        return;
@@ -356,22 +419,25 @@ void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
        case TRESP_NETWORK_SET_MODE: {
                ps_dbg_ex_co(co_modem, "TRESP_NETWORK_SET_MODE response received ");
 
-               if (count == 0)
+               if (count == 0) {
                        modem->hook_flag &= PS_NETWORK_RESET_SELECT_MODE_FLAG;
+                       modem->mode_pref_changed = FALSE;
+               }
+               ps_dbg_ex_co(co_modem, "mode_pref_changed : %d", modem->mode_pref_changed);
        }
        break;
 
        case TRESP_NETWORK_GET_MODE: {
                gboolean rv = FALSE;
                const struct tresp_network_get_mode *resp_get_mode = data;
-               dbg("TRESP_NETWORK_GET_MODE response received mode (mode:[%d])", resp_get_mode->mode);
+               ps_dbg_ex_co(co_modem, "TRESP_NETWORK_GET_MODE response received mode (mode:[%d])", resp_get_mode->mode);
 
                if (count == 0)
                        modem->hook_flag &= PS_NETWORK_RESET_GET_MODE_FLAG;
 
                rv = __ps_set_network_mode(resp_get_mode->mode, modem);
                if (rv) {
-                       dbg("network set mode request!");
+                       ps_dbg_ex_co(co_modem, "network set mode request!");
                        return;
                }
        }
@@ -408,17 +474,17 @@ void __ps_hook_response_cb(UserRequest *ur, enum tcore_response_command command,
        break;
 
        default: {
-               ps_dbg_ex_co(co_modem, "Unexpected response ");
+               ps_warn_ex_co(co_modem, "Unexpected response ");
        }
        break;
        }
-       ps_dbg_ex_co(co_modem, " FLAG %x", modem->hook_flag);
 
+       ps_info_ex_co(co_modem, "After unset - FLAG %x", modem->hook_flag);
        if (modem->hook_flag == PS_NO_PENDING_REQUEST
-               && command != TRESP_MODEM_POWER_LOW
-                && command != TRESP_MODEM_POWER_OFF
-                && modem->mode_pref_changed == FALSE) {
-               _ps_modem_set_data_allowed(modem, modem->data_allowed);
+                       && command != TRESP_MODEM_POWER_LOW
+                       && command != TRESP_MODEM_POWER_OFF
+                       && modem->mode_pref_changed == FALSE) {
+               _ps_modem_connect_default_context(modem);
        }
 }
 
@@ -431,7 +497,7 @@ void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur)
 
        cmd = tcore_user_request_get_command(ur);
        if (cmd != TREQ_NETWORK_SET_MODE) {
-               err("Not a TREQ_NETWORK_SET_MODE");
+               ps_warn_ex_co(_ps_modem_ref_co_modem(modem), "Not a TREQ_NETWORK_SET_MODE");
                modem->mode_pref_changed = FALSE;
                return;
        }
@@ -442,7 +508,7 @@ void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur)
        req = tcore_user_request_ref_data(ur, NULL);
 
        tcore_network_get_service_type(co_network, &svc_type);
-       dbg("mode_pref[0x%x], svc_type[%d]", req->mode, svc_type);
+       ps_dbg_ex_co(co_network, "mode_pref[0x%x], svc_type[%d]", req->mode, svc_type);
        switch (svc_type) {
        case NETWORK_SERVICE_TYPE_2G:
        case NETWORK_SERVICE_TYPE_2_5G:
@@ -469,7 +535,7 @@ void __ps_modem_get_mode_pref_change(ps_modem_t *modem, UserRequest *ur)
        break;
        }
 
-       dbg("mode_pref_changed : %d", modem->mode_pref_changed);
+       ps_dbg_ex_co(co_network, "mode_pref_changed : %d", modem->mode_pref_changed);
 }
 
 void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
@@ -478,7 +544,7 @@ void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
        ps_modem_t *modem = data;
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
 
-       ps_dbg_ex_co(co_modem, "Entered");
+       ps_info_ex_co(co_modem, "Entered");
        queue_data = g_queue_pop_head(modem->work_queue);
        while (queue_data) {
                struct work_queue_data *wqd = (struct work_queue_data *)queue_data;
@@ -528,7 +594,6 @@ void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
                                set_flight_mode.result = TCORE_RETURN_FAILURE;
                                tcore_user_request_send_response(wqd->ur, TRESP_MODEM_SET_FLIGHTMODE,
                                sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
-
                        } else if (cmd == TREQ_MODEM_POWER_OFF) {
                                struct tresp_modem_power_off set_power_off;
                                memset(&set_power_off,  0, sizeof(struct tresp_modem_power_off));
@@ -554,7 +619,7 @@ void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
                                sizeof(struct tresp_sim_set_powerstate), &set_power);
 
                        } else {
-                               err("Unexpected command ");
+                               ps_err_ex_co(co_modem, "Unexpected command ");
                        }
                        tcore_user_request_unref(wqd->ur);
 
@@ -564,20 +629,34 @@ void __ps_modem_cp_reset_send_pending_request_response(gpointer data)
                queue_data = g_queue_pop_head(modem->work_queue);
        }
 }
+#endif
 
 static void __ps_modem_cp_reset_handler(gpointer object)
 {
+       unsigned int index;
        ps_modem_t *modem = object;
 
-       dbg("Entred");
+       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "disconnect all contexts");
+       /* send deactivation request to clear resources. */
+       for (index = 0; index < g_slist_length(modem->contexts); index++) {
+               gpointer context = g_slist_nth_data(modem->contexts, index);
+               ps_service_t *service = _ps_context_ref_service(context);
+               CoreObject *co_context = _ps_context_ref_co_context(context);
+               if(service == NULL)
+                       continue;
+               tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
+               tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
+       }
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
        /* check for any pending request in modem queue and respond with error */
        __ps_modem_cp_reset_send_pending_request_response(modem);
 
        /* reset modem flag */
        modem->hook_flag  &= PS_NO_PENDING_REQUEST;
+#endif
 }
 
-
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 void __ps_modem_set_hook_flag(ps_modem_t *modem , enum tcore_request_command cmd)
 {
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
@@ -628,6 +707,7 @@ void __ps_modem_set_hook_flag(ps_modem_t *modem , enum tcore_request_command cmd
                ps_dbg_ex_co(co_modem, "Not handled request");
        break;
        }
+       ps_info_ex_co(co_modem, "After set - FLAG %x", modem->hook_flag);
 }
 
 enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_data)
@@ -641,6 +721,8 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
        guint job_cnt = 0;
        ps_modem_t *modem = user_data;
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
+       GHashTableIter iter;
+       gpointer key, service;
 
        char *modem_name = NULL;
        enum tcore_request_command cmd = tcore_user_request_get_command(ur);
@@ -651,46 +733,141 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
        if (!modem_name)
                return TCORE_HOOK_RETURN_CONTINUE;
 
+       if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+               const struct treq_modem_set_flightmode *req;
+
+               req = tcore_user_request_ref_data(ur, NULL);
+               if (req->enable == TRUE) {
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                               _ps_service_set_ims_activation_requested(service, FALSE);
+               }
+       }
+
        target_plg = tcore_object_ref_plugin(modem->co_modem);
        if (g_strcmp0(tcore_server_get_cp_name_by_plugin(target_plg), modem_name) != 0) {
-               ps_dbg_ex_co(co_modem, "request modem (%s) not matched current modem(%s)",
+               ps_info_ex_co(co_modem, "request modem (%s) not matched current modem(%s)",
                                modem_name,
                                tcore_server_get_cp_name_by_plugin(target_plg));
+               free(modem_name);
 
-               if (cmd == TREQ_NETWORK_SEARCH) {
+               if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_MODEM_SET_FLIGHTMODE
+                       || cmd == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION
+                       || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
                        co_ps = tcore_plugin_ref_core_object(target_plg, CORE_OBJECT_TYPE_PS);
                        if (!co_ps) {
-                               ps_dbg_ex_co(co_modem, "No ps core object present ");
-                               free(modem_name);
+                               ps_err_ex_co(co_modem, "No ps core object present ");
                                return TCORE_HOOK_RETURN_CONTINUE;
                        }
 
-                       if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
-                               ps_dbg_ex_co(co_modem, "No activating/activated context present");
-                               /* Block PS always-on while network operations. */
-                               __ps_modem_set_hook_flag(modem, cmd);
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-                               free(modem_name);
+                       if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
+                               if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
+                                       ps_info_ex_co(co_modem, "No internet/mms/tethering activating/activated context present");
+                                       /* Block PS always-on while network operations. */
+                                       __ps_modem_set_hook_flag(modem, cmd);
+                                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                                       return TCORE_HOOK_RETURN_CONTINUE;
+                               }
+                               ps_info_ex_co(co_modem, "Value returned [%d]", value);
+                               if (CONTEXT_STATE_ACTIVATED == value) {
+                                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATED state. Send deactivate requests");
+                                       g_hash_table_iter_init(&iter, modem->services);
+                                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+                               } else if (CONTEXT_STATE_ACTIVATING == value) {
+                                       ps_info_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATING state. Wait for activation successful ");
+                               }
+                       } else {
+                               if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
+                                       ps_info_ex_co(co_modem, "No internet/mms/tethering/IMS/UT activating/activated context present");
+                                       /* Block PS always-on while network operations. */
+                                       __ps_modem_set_hook_flag(modem, cmd);
+                                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                                       return TCORE_HOOK_RETURN_CONTINUE;
+                               }
+                               ps_info_ex_co(co_modem, "Value returned [%d]", value);
+                               if (CONTEXT_STATE_ACTIVATED == value) {
+                                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATED state. Send deactivate requests");
+                                       rv = tcore_ps_deactivate_contexts(co_ps);
+                                       if (rv != TCORE_RETURN_SUCCESS) {
+                                               ps_dbg_ex_co(co_modem, "fail to deactivation");
+                                               return TCORE_HOOK_RETURN_CONTINUE;
+                                       }
+                               } else if (CONTEXT_STATE_ACTIVATING == value) {
+                                       if (cmd == TREQ_MODEM_SET_FLIGHTMODE)  {
+                                               ps_info_ex_co(co_modem, "No need to stop these request for pdp in activating state ");
+                                               return TCORE_HOOK_RETURN_CONTINUE;
+                                       }
+                                       ps_info_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATING state. Wait for activation successful ");
+                               }
+                       }
+
+                       if (!modem->work_queue) {
+                               ps_err_ex_co(co_modem, "no queue present unable to handle request");
                                return TCORE_HOOK_RETURN_CONTINUE;
                        }
 
-                       ps_dbg_ex_co(co_modem, "Value returned [%d]", value);
-                       if ((CONTEXT_STATE_ACTIVATING == value) || (CONTEXT_STATE_ACTIVATED == value)) {
-                               ps_dbg_ex_co(co_modem, "Activated/Activating context present need to deactivate them");
-                               rv = tcore_ps_deactivate_contexts(co_ps);
-                               if (rv != TCORE_RETURN_SUCCESS) {
-                                       ps_dbg_ex_co(co_modem, "fail to deactivation");
-                                       free(modem_name);
-                                       return TCORE_HOOK_RETURN_CONTINUE;
+                       job_cnt = ps_util_get_count_waiting_job(modem->work_queue, cmd);
+                       if (job_cnt) {
+                               ps_err_ex_co(co_modem, "duplicated job for cmd(%d)", cmd);
+
+                               if (cmd == TREQ_NETWORK_SEARCH) {
+                                       struct tresp_network_search search_rsp;
+                                       memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+
+                                       search_rsp.result = TCORE_RETURN_OPERATION_ABORTED;
+                                       search_rsp.list_count = 0;
+                                       tcore_user_request_send_response(ur, TRESP_NETWORK_SEARCH,
+                                               sizeof(struct tresp_network_search), &search_rsp);
+                               } else if (cmd == TREQ_MODEM_SET_FLIGHTMODE) {
+                                       struct tresp_modem_set_flightmode set_flight_mode;
+                                       memset(&set_flight_mode, 0, sizeof(struct tresp_modem_set_flightmode));
+
+                                       set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
+                                       tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
+                                               sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
                                }
-                               __ps_modem_set_hook_flag(modem, cmd);
-                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+
+                               tcore_user_request_unref(ur);
+                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
                        }
-               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                       ret = ps_util_add_waiting_job(modem->work_queue, cmd , ur);
+                       if (!ret) {
+                               ps_err_ex_co(co_modem, "fail to add the request to queue");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+
+                       __ps_modem_get_mode_pref_change(modem, ur);
                        __ps_modem_set_hook_flag(modem, cmd);
-                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                       return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+               } else if (cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) {
+                       UserRequest *ur_pending = NULL;
+                       ur_pending = ps_util_pop_waiting_job(modem->work_queue, TREQ_NETWORK_SEARCH);
+
+                       if (!ur_pending) {
+                               ps_dbg_ex_co(co_modem, "no pendig search request");
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       } else {
+                               struct tresp_network_search search_rsp;
+                               struct tresp_network_set_cancel_manual_search search_cancel_rsp;
+
+                               memset(&search_rsp, 0, sizeof(struct tresp_network_search));
+                               memset(&search_cancel_rsp, 0, sizeof(struct tresp_network_set_cancel_manual_search));
+
+                               search_rsp.list_count = 0;
+                               ps_dbg_ex_co(co_modem, "send search response to upper layer");
+                               tcore_user_request_send_response(ur_pending, TRESP_NETWORK_SEARCH, sizeof(struct tresp_network_search), &search_rsp);
+                               tcore_user_request_unref(ur_pending);
+
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               search_cancel_rsp.result = TCORE_RETURN_SUCCESS;
+                               tcore_user_request_send_response(ur, TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH,
+                                       sizeof(struct tresp_network_set_cancel_manual_search), &search_cancel_rsp);
+
+                               return TCORE_HOOK_RETURN_STOP_PROPAGATION;
+                       }
                }
-               free(modem_name);
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
@@ -705,15 +882,15 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
                if (modem->powered == PS_MODEM_STATE_ONLINE) {
                        struct tresp_modem_power_on set_power_on;
                        memset(&set_power_on,  0, sizeof(struct tresp_modem_power_on));
-                       dbg("FLAG: 0x%x", modem->hook_flag);
+                       ps_dbg_ex_co(co_modem, "FLAG: 0x%x", modem->hook_flag);
 
                        if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW) {
-                               dbg("LOW power request is pending, send abort response");
+                               ps_dbg_ex_co(co_modem, "LOW power request is pending, send abort response");
                                set_power_on.result = TCORE_RETURN_OPERATION_ABORTED;
                                tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
                                        sizeof(struct tresp_modem_power_on), &set_power_on);
                        } else {
-                               dbg("No pending LOW power request, send success response.");
+                               ps_dbg_ex_co(co_modem, "No pending LOW power request, send success response.");
                                set_power_on.result = TCORE_RETURN_EALREADY;
                                tcore_user_request_send_response(ur, TRESP_MODEM_POWER_ON,
                                        sizeof(struct tresp_modem_power_on), &set_power_on);
@@ -723,46 +900,65 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
                }
                return TCORE_HOOK_RETURN_CONTINUE;
        }
-       if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
-               ps_dbg_ex_co(co_modem, "No activating/activated context present");
-               /* Block PS always-on while network operations. */
-#ifdef POWER_SAVING_FEATURE_WEARABLE
-               if ((cmd != TREQ_MODEM_POWER_LOW)
-                               || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
+
+       if (cmd == TREQ_NETWORK_SEARCH || cmd == TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH
+                        || cmd == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
+               if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
+                       ps_info_ex_co(co_modem, "No internet/mms/tethering activating/activated context present");
+                       __ps_modem_get_mode_pref_change(modem, ur);
                        __ps_modem_set_hook_flag(modem, cmd);
                        tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
                        return TCORE_HOOK_RETURN_CONTINUE;
                }
-#else
-               __ps_modem_get_mode_pref_change(modem, ur);
-               __ps_modem_set_hook_flag(modem, cmd);
-               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
-               return TCORE_HOOK_RETURN_CONTINUE;
-
-#endif
-       }
-
-       ps_dbg_ex_co(co_modem, "Value returned [%d]", value);
-       if (CONTEXT_STATE_ACTIVATED == value) {
-               ps_dbg_ex_co(co_modem, "Activated/Activating context present need to deactivate them");
-               rv = tcore_ps_deactivate_contexts(co_ps);
-               if (rv != TCORE_RETURN_SUCCESS) {
-                       ps_dbg_ex_co(co_modem, "fail to deactivation");
-                       return TCORE_HOOK_RETURN_CONTINUE;
+               ps_info_ex_co(co_modem, "Value returned [%d]", value);
+               if (CONTEXT_STATE_ACTIVATED == value) {
+                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATED state. Send deactivate requests");
+                       g_hash_table_iter_init(&iter, modem->services);
+                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+               } else if (CONTEXT_STATE_ACTIVATING == value) {
+                       ps_info_ex_co(co_modem, "Internet/mms/tethering context present in ACTIVATING state. Wait for activation successful ");
                }
-       } else if (CONTEXT_STATE_ACTIVATING == value) {
+       } else {
+               if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
+                       ps_info_ex_co(co_modem, "No internet/mms/tethering/IMS/UT activating/activated context present");
+                       /* Block PS always-on while network operations. */
 #ifdef POWER_SAVING_FEATURE_WEARABLE
-               if ((cmd != TREQ_MODEM_POWER_LOW)
-                               || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
-                       return TCORE_HOOK_RETURN_CONTINUE;
-               }
+                       if ((cmd != TREQ_MODEM_POWER_LOW)
+                                       || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
+                               __ps_modem_set_hook_flag(modem, cmd);
+                               tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
 #else
-               if ((cmd == TREQ_MODEM_SET_FLIGHTMODE) || (cmd == TREQ_MODEM_POWER_OFF)) {
-                       ps_dbg_ex_co(co_modem, "No need to stop these request for pdp in activating state ");
+                       __ps_modem_get_mode_pref_change(modem, ur);
+                       __ps_modem_set_hook_flag(modem, cmd);
+                       tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
                        return TCORE_HOOK_RETURN_CONTINUE;
+#endif
                }
+               ps_info_ex_co(co_modem, "Value returned [%d]", value);
+               if (CONTEXT_STATE_ACTIVATED == value) {
+                       ps_dbg_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATED state. Send deactivate requests");
+                       rv = tcore_ps_deactivate_contexts(co_ps);
+                       if (rv != TCORE_RETURN_SUCCESS) {
+                               ps_dbg_ex_co(co_modem, "fail to deactivation");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+               } else if (CONTEXT_STATE_ACTIVATING == value) {
+#ifdef POWER_SAVING_FEATURE_WEARABLE
+                       if ((cmd != TREQ_MODEM_POWER_LOW)
+                                       || (FALSE == __ps_is_any_call_in_progress(tcore_object_ref_plugin(modem->co_modem), ON_REQUEST, TNOTI_UNKNOWN))) {
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
+#else
+                       if ((cmd == TREQ_MODEM_SET_FLIGHTMODE) || (cmd == TREQ_MODEM_POWER_OFF)) {
+                               ps_info_ex_co(co_modem, "No need to stop these request for pdp in activating state ");
+                               return TCORE_HOOK_RETURN_CONTINUE;
+                       }
 #endif
-               ps_dbg_ex_co(co_modem, "For rest command will wait for activation successful ");
+                       ps_info_ex_co(co_modem, "Internet/mms/tethering/IMS/UT context present in ACTIVATING state. Wait for activation successful ");
+               }
        }
 
        if (!modem->work_queue) {
@@ -817,7 +1013,6 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
                        set_flight_mode.result = TCORE_RETURN_OPERATION_ABORTED;
                        tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE,
                                sizeof(struct tresp_modem_set_flightmode), &set_flight_mode);
-
                } else if (cmd == TREQ_MODEM_POWER_OFF) {
                        struct tresp_modem_power_off set_power_off;
                        memset(&set_power_off,  0, sizeof(struct tresp_modem_power_off));
@@ -847,7 +1042,7 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
                return TCORE_HOOK_RETURN_STOP_PROPAGATION;
        }
 
-       ps_dbg_ex_co(co_modem, "Deactivation request is sent, wait for call disconnect notification ");
+       ps_info_ex_co(co_modem, "Deactivation request is sent, wait for call disconnect notification ");
 
        if (TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH == cmd) {
                UserRequest *ur_pending = NULL;
@@ -880,7 +1075,7 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
 
        ret = ps_util_add_waiting_job(modem->work_queue, cmd , ur);
        if (!ret) {
-               ps_dbg_ex_co(co_modem, "fail to add the request to queue");
+               ps_err_ex_co(co_modem, "fail to add the request to queue");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
@@ -892,21 +1087,24 @@ enum tcore_hook_return ps_handle_hook(Server *s, UserRequest *ur, void *user_dat
 void __ps_send_pending_user_request(gpointer data)
 {
        ps_modem_t *modem =  data;
+       TcorePlugin *plugin = NULL;
        CoreObject *co_network = NULL;
        CoreObject *co_sim = NULL;
        gpointer *queue_data = NULL;
+#ifdef POWER_SAVING_FEATURE_WEARABLE
+       UserRequest *ur_power_low = NULL;
+#endif
 
-       co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-                       CORE_OBJECT_TYPE_NETWORK);
-       co_sim = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
-                       CORE_OBJECT_TYPE_SIM);
+       plugin = tcore_object_ref_plugin(modem->co_modem);
+       co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+       co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
 
        ps_dbg_ex_co(co_network, "Extracting the user request from the work queue");
 
        queue_data = g_queue_pop_head(modem->work_queue);
        while (queue_data) {
                struct work_queue_data *wqd = (struct work_queue_data *)queue_data;
-               ps_dbg_ex_co(co_network, " sending Pending request [%x]", wqd->id);
+               ps_info_ex_co(co_network, " sending Pending request [%x]", wqd->id);
                if (wqd->ur) {
                        ps_dbg_ex_co(co_network, "Setting responce hook for request ");
                        tcore_user_request_set_response_hook(wqd->ur, __ps_hook_response_cb, modem);
@@ -915,20 +1113,85 @@ void __ps_send_pending_user_request(gpointer data)
                        case TREQ_NETWORK_SEARCH:
                        case TREQ_NETWORK_SET_MODE:
                        case TREQ_NETWORK_SET_PLMN_SELECTION_MODE:
-                       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION:
+                       case TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION: {
+                               char *modem_name;
+                               TcorePlugin *modem_plugin, *ur_modem_plugin;
+
+                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
+                               if (!modem_name)
+                                       return;
+
+                               modem_plugin = tcore_object_ref_plugin(modem->co_modem);
+                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
+                               if (modem_plugin != ur_modem_plugin) {
+                                       ps_info_ex_co(co_network, "request modem (%s) not matched current modem(%s)",
+                                                       modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
+                                       /* Network search request enqueued for other sim, so dispatch it */
+                                       if (wqd->id == TREQ_NETWORK_SEARCH || wqd->id == TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION
+                                               || wqd->id == TREQ_NETWORK_SET_PLMN_SELECTION_MODE) {
+                                               CoreObject *co_other_network;
+
+                                               co_other_network = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_NETWORK);
+                                               if (co_other_network == NULL) {
+                                                       ps_warn_ex_co(co_network, "No network core object in other modem plugin");
+                                               } else {
+                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_network, wqd->ur))
+                                                               ps_err_ex_co(co_network, "Failed to dispatch ");
+                                               }
+                                               free(modem_name);
+                                               break;
+                                       } else {
+                                               return;
+                                       }
+                               }
+                               free(modem_name);
                                if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_network, wqd->ur))
-                                       err("Failed to dispatch ");
+                                       ps_err_ex_co(co_network, "Failed to dispatch ");
+                       }
                        break;
 
                        case TREQ_MODEM_SET_FLIGHTMODE:
-                       case TREQ_MODEM_POWER_OFF:
+                       case TREQ_MODEM_POWER_OFF: {
+                               char *modem_name;
+                               TcorePlugin *modem_plugin, *ur_modem_plugin;
+
+                               modem_name = tcore_user_request_get_modem_name(wqd->ur);
+                               if (!modem_name)
+                                       return;
+
+                               modem_plugin = tcore_object_ref_plugin(modem->co_modem);
+                               ur_modem_plugin = tcore_server_find_plugin(tcore_plugin_ref_server(modem_plugin), modem_name);
+                               if (modem_plugin != ur_modem_plugin) {
+                                       ps_info_ex_co(co_network, "request modem (%s) not matched current modem(%s)",
+                                                       modem_name, tcore_server_get_cp_name_by_plugin(modem_plugin));
+                                       /* Flight mode request enqueued for other sim, so dispatch it */
+                                       if (wqd->id == TREQ_MODEM_SET_FLIGHTMODE) {
+                                               CoreObject *co_other_modem;
+
+                                               co_other_modem = tcore_plugin_ref_core_object(ur_modem_plugin, CORE_OBJECT_TYPE_MODEM);
+                                               if (co_other_modem == NULL) {
+                                                       ps_warn_ex_co(co_network, "No modem core object in other modem plugin");
+                                               } else {
+                                                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_other_modem, wqd->ur))
+                                                               ps_err_ex_co(co_network, "Failed to dispatch ");
+                                               }
+                                               free(modem_name);
+                                               break;
+                                       } else {
+                                               free(modem_name);
+                                               return;
+                                       }
+                               }
+                               free(modem_name);
+
                                if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, wqd->ur))
-                                       err("Failed to dispatch ");
+                                       ps_err_ex_co(co_network, "Failed to dispatch ");
+                       }
                        break;
 
                        case TREQ_MODEM_POWER_LOW:
 #ifdef POWER_SAVING_FEATURE_WEARABLE
-                               __ps_check_handle_modem_off_request(modem, ON_REQUEST, TNOTI_UNKNOWN);
+                               ur_power_low = wqd->ur;
 #else
                                if (modem->hook_flag & PS_NETWORK_SET_POWER_LOW)
                                        if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, wqd->ur))
@@ -938,7 +1201,7 @@ void __ps_send_pending_user_request(gpointer data)
 
                        case TREQ_SIM_SET_POWERSTATE:
                                if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_sim, wqd->ur))
-                                       err("Failed to dispatch ");
+                                       ps_err_ex_co(co_network, "Failed to dispatch ");
                        break;
 
                        default:
@@ -950,15 +1213,30 @@ void __ps_send_pending_user_request(gpointer data)
                free(wqd);
                queue_data = g_queue_pop_head(modem->work_queue);
        }
+
+#ifdef POWER_SAVING_FEATURE_WEARABLE
+       if (ur_power_low) {
+               if(FALSE == ps_util_add_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW, ur_power_low)) {
+                       err("fail to add the request to queue");
+                       if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, ur_power_low)) {
+                               __ps_send_ur_dispatch_failure_response(ur_power_low, TRESP_MODEM_POWER_LOW);
+                               modem->hook_flag &= PS_NETWORK_RESET_SET_POWER_LOW_FLAG;
+                       }
+               } else
+                       __ps_check_handle_modem_off_request(modem, ON_REQUEST, TNOTI_UNKNOWN);
+       }
+#endif
+
        ps_dbg_ex_co(co_network, "All pending request sent ");
 }
+#endif
 
 static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *source,
                enum tcore_notification_command command, unsigned int data_len, void *data,
                void *user_data)
 {
-       gpointer modem = NULL;
-       gpointer service = user_data;
+       ps_modem_t *modem = NULL;
+       ps_service_t *ps_service = user_data;
        CoreObject *co_network;
        gpointer co_ps = NULL;
        GSList *co_list;
@@ -977,18 +1255,18 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
        int profile_id;
 #endif
 
-       dbg("call status event");
-       g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
+       dbg("ps call status event");
+       g_return_val_if_fail(ps_service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION);
 
-       co_network = _ps_service_ref_co_network(service);
+       co_network = _ps_service_ref_co_network(ps_service);
        cstatus = (struct tnoti_ps_call_status *) data;
-       co_ps = (CoreObject *)_ps_service_ref_co_ps(service);
+       co_ps = (CoreObject *)_ps_service_ref_co_ps(ps_service);
        if (co_ps != source) {
                ps_warn_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       modem = _ps_service_ref_modem(service);
+       modem = _ps_service_ref_modem(ps_service);
        if (!modem) {
                ps_err_ex_co(co_network, "modem does not exist");
                return TCORE_HOOK_RETURN_CONTINUE;
@@ -1008,7 +1286,7 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                        b_mms_checker = TRUE;
                        break;
                }
-               if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY) {
+               if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT) {
                        b_ims_checker = TRUE;
                        break;
                }
@@ -1019,12 +1297,12 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                b_mms_checker = FALSE;
 #endif
 
-       if ((_ps_modem_get_roaming(modem)) && !(_ps_modem_get_data_roaming_allowed(modem))) {
-               ps_dbg_ex_co(co_network, "roaming network is not allowed");
+       if (!b_ims_checker && (_ps_modem_get_roaming(modem)) && !(_ps_modem_get_data_roaming_allowed(modem))) {
+               ps_info_ex_co(co_network, "roaming network is not allowed");
                b_roaming_checker = FALSE;
        }
 
-       ps_dbg_ex_co(co_network, "data_allowed(%d) call status event cid(%d) state(%d) reason(%d)",
+       ps_info_ex_co(co_network, "data_allowed(%d) call status event cid(%d) state(%d) reason(%d)",
                        b_data_allowed, cstatus->context_id, cstatus->state, cstatus->result);
 
        if (!b_roaming_checker || (!b_data_allowed && !b_mms_checker && !b_ims_checker)) {
@@ -1038,23 +1316,23 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                         * although define process is triggered, 'attach_apn_complete' flag does not set TRUE.
                         * So, when Data Roaming option is enabled, pdp activation is not triggered.
                         */
-                       if (((ps_service_t *)service)->attach_apn_complete) {
-                               _ps_service_set_connected(service, cstatus, FALSE);
+                       if (((ps_service_t *)ps_service)->attach_apn_complete) {
+                               _ps_service_set_connected(ps_service, cstatus, FALSE);
                                tcore_ps_set_cid_active(co_ps, cstatus->context_id, FALSE);
                        } else {
-                               _ps_service_set_ps_defined(service, TRUE, cstatus->context_id);
+                               _ps_service_set_ps_defined(ps_service, TRUE, cstatus->context_id);
                        }
                        return TCORE_HOOK_RETURN_CONTINUE;
                } else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {
-                       _ps_service_set_connected(service, cstatus, TRUE);
-                       _ps_service_disconnect_contexts(service);
+                       _ps_service_set_connected(ps_service, cstatus, TRUE);
+                       _ps_service_disconnect_contexts(ps_service);
                        return TCORE_HOOK_RETURN_CONTINUE;
                }
        }
 
-       ps_dbg_ex_co(co_network, "service(%p) status(%d)", service, cstatus->state);
+       ps_dbg_ex_co(co_network, "service(%p) status(%d)", ps_service, cstatus->state);
        if (cstatus->state == PS_CALL_STATE_RESULT_OK) {                /* DEFINE */
-               _ps_service_set_ps_defined(service, TRUE, cstatus->context_id);
+               _ps_service_set_ps_defined(ps_service, TRUE, cstatus->context_id);
        } else if (cstatus->state == PS_CALL_STATE_RESULT_CONNECT) {    /* CONNECTED */
                TReturn rv;
 
@@ -1064,49 +1342,42 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                        /* De-activate context */
                        rv = tcore_ps_deactivate_contexts(co_ps);
                        if (rv != TCORE_RETURN_SUCCESS) {
-                               ps_dbg_ex_co(co_network, "fail to deactivation");
+                               ps_err_ex_co(co_network, "fail to deactivation");
                                return TCORE_HOOK_RETURN_CONTINUE;
                        }
                } else {
                        gboolean ret = TRUE;
 
-                       ret = _ps_service_set_connected(service, cstatus, TRUE);
+                       ret = _ps_service_set_connected(ps_service, cstatus, TRUE);
                        tcore_ps_set_cid_connected(co_ps, cstatus->context_id, TRUE);
-
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
                        if (ret == FALSE || g_queue_get_length((GQueue *)_ps_modem_ref_work_queue(modem)) || (_ps_modem_get_reset_profile(modem) == TRUE)) {
-                               ps_dbg_ex_co(co_network, "Special request present in queue or pending activation request");
-
-                               rv = tcore_ps_deactivate_contexts(co_ps);
-                               if (rv != TCORE_RETURN_SUCCESS) {
-                                       ps_dbg_ex_co(co_network,  "fail to deactivation");
-                                       return TCORE_HOOK_RETURN_CONTINUE;
-                               }
-                       }
-#ifdef PREPAID_SIM_APN_SUPPORT
-                       plg = _ps_service_ref_plugin(service);
-                       strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(plg), "vconf");
-                       if (strg_vconf) {
-                               /* Set operator */
-                               operator = _ps_modem_ref_operator(modem);
-                               dbg("set operator[%s] for last connected profile", operator);
-                               tcore_storage_set_string(strg_vconf, STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN,
-                                               (const char *)operator);
-                               /* Get context*/
-                               context = _ps_service_return_context_by_cid(service, cstatus->context_id);
-                               dbg("context[%p]", context);
-                               if (context) {
-                                       /*Set profile ID */
-                                       profile_id = _ps_context_get_profile_id(context);
-                                       dbg("profile_id[%d]", profile_id);
-                                       tcore_storage_set_int(strg_vconf, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID,
-                                               profile_id);
-                                       /* set vconf last connected profile */
-                                       dbg("set vconf last connected profile to TRUE");
-                                       tcore_storage_set_bool(strg_vconf, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, TRUE);
-
+#else
+                       if (ret == FALSE || (_ps_modem_get_reset_profile(modem) == TRUE)) {
+#endif
+                               ps_info_ex_co(co_network, "Special request present in queue or pending activation request");
+
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
+                               if (ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem), TREQ_NETWORK_SEARCH) ||
+                                       ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem), TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH) ||
+                                       ps_util_peek_waiting_job((GQueue *)_ps_modem_ref_work_queue(modem),  TREQ_NETWORK_SET_PLMN_SELECTION_MODE)) {
+                                       GHashTableIter iter;
+                                       gpointer key, service;
+
+                                       ps_info_ex_co(co_network, "Network search/selection/cancel searchrequest is in queue");
+                                       g_hash_table_iter_init(&iter, modem->services);
+                                       while (g_hash_table_iter_next(&iter, &key, &service) == TRUE)
+                                               _ps_service_disconnect_internet_mms_tethering_contexts(service);
+                               } else
+#endif
+                               {
+                                       rv = tcore_ps_deactivate_contexts(co_ps);
+                                       if (rv != TCORE_RETURN_SUCCESS) {
+                                               ps_dbg_ex_co(co_network, "fail to deactivation");
+                                               return TCORE_HOOK_RETURN_CONTINUE;
+                                       }
                                }
                        }
-#endif
                }
        } else if (cstatus->state == PS_CALL_STATE_RESULT_NO_CARRIER) { /* DISCONNECTED-NO CARRIER */
                gpointer def_context = NULL;
@@ -1124,9 +1395,9 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                /* if retry not permitted by network */
                if (FALSE == retry) {
                        ps_dbg_ex_co(co_network, "DO NOT RETRY NETWORK CONNECTION AUTOMATICALLY");
-                       ps_dbg_ex_co(co_network, "permanent reject cause (%d)", cstatus->result);
+                       ps_info_ex_co(co_network, "permanent reject cause (%d)", cstatus->result);
 
-                       def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                       def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_INTERNET);
                        if (def_context) {
                                gpointer co_context = NULL;
                                co_context = _ps_context_ref_co_context(def_context);
@@ -1136,7 +1407,7 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
 
 #ifdef PREPAID_SIM_APN_SUPPORT
                if (def_context == NULL) {
-                       def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
+                       def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_INTERNET);
                        if (def_context) {
                                gpointer co_context = NULL;
                                co_context = _ps_context_ref_co_context(def_context);
@@ -1144,7 +1415,7 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                        }
                }
 
-               prepaid_def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_PREPAID_INTERNET);
+               prepaid_def_context = _ps_service_return_default_context(ps_service, CONTEXT_ROLE_PREPAID_INTERNET);
                dbg("prepaid_def_context[%p]", prepaid_def_context);
                if (prepaid_def_context) {
                        gpointer co_context = NULL;
@@ -1154,22 +1425,22 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                dbg("prepaid_cid[%d]", prepaid_cid);
 #endif
 
-               _ps_service_set_ps_defined(service, FALSE, cstatus->context_id);
+               _ps_service_set_ps_defined(ps_service, FALSE, cstatus->context_id);
                tcore_ps_set_cid_active(co_ps, cstatus->context_id, FALSE);
                tcore_ps_set_cid_connected(co_ps, cstatus->context_id, FALSE);
-               _ps_service_set_connected(service, cstatus, FALSE);
-
-               if (FALSE == tcore_ps_any_context_activating_activated(co_ps, &value)) {
-                       ps_dbg_ex_co(co_network, "No open connections, publish disconnected signal");
+               _ps_service_set_connected(ps_service, cstatus, FALSE);
 
+               if (FALSE == tcore_ps_any_internet_mms_tethering_context_activating_activated(co_ps, &value)) {
+                       ps_dbg_ex_co(co_network, "No internet/mms/tethering open connections, publish disconnected signal");
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
                        /* Handle any pending request if present */
-                       modem = _ps_service_ref_modem(service);
+                       modem = _ps_service_ref_modem(ps_service);
                        __ps_send_pending_user_request(modem);
-
+#endif
                        /* Ensured that set_reset_profile is always done default thread's context */
                        if (_ps_modem_get_reset_profile(modem) == TRUE) {
                                /* Initiate Reset Profile */
-                               ps_dbg_ex_co(co_network, "Profiles are being reset");
+                               ps_info_ex_co(co_network, "Profiles are being reset");
                                /* Shouldn't invoke set profile directly, as it will remove hooks registered to server while being hook callback*/
                                if (NULL == _ps_modem_get_profile_reset_gsource(modem)) {
                                        GSource *gsource = NULL;
@@ -1190,7 +1461,7 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                                _ps_service_reset_connection_timer(def_context);
 
                                /* Connect to default prepaid internet */
-                               rv = _ps_service_connect_default_prepaid_context(service);
+                               rv = _ps_service_connect_default_prepaid_context(ps_service);
                                dbg("prepaid internet connect - rv[%d]", rv);
                        } else if (cstatus->context_id == prepaid_cid) {
                                /* Reset connection */
@@ -1198,20 +1469,20 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                                _ps_service_reset_connection_timer(prepaid_def_context);
 
                                /* Connect to default internet */
-                               rv =  _ps_service_connect_default_context(service);
+                               rv =  _ps_service_connect_default_context(ps_service);
                                dbg("default internet connect - rv[%d]", rv);
                        }
 
                        /* Reset Last connected, Profile ID and Operator vconf keys. */
                        dbg("Reset vconf keys...");
-                       plg = _ps_service_ref_plugin(service);
+                       plg = _ps_service_ref_plugin(ps_service);
                        strg_vconf = tcore_server_find_storage(tcore_plugin_ref_server(plg),
                                                        "vconf");
                        if (strg_vconf) {
                                tcore_storage_set_string(strg_vconf,
                                        STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN, NULL);
                                /* Get context*/
-                               context = _ps_service_return_context_by_cid(service,
+                               context = _ps_service_return_context_by_cid(ps_service,
                                                        cstatus->context_id);
                                dbg("context[%p]", context);
                                if (context) {
@@ -1228,7 +1499,7 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc
                }
 #endif
 
-               ps_dbg_ex_co(co_network, "any context activating or activated [%d]", value);
+               ps_info_ex_co(co_network, "Internet/mms/tethering context activating or activated [%d]", value);
                if (FALSE == retry)
                        if (cstatus->context_id == def_cid)
                                _ps_service_reset_connection_timer(def_context);
@@ -1295,7 +1566,7 @@ static enum tcore_hook_return __on_hook_dedicated_bearerinfo(Server *s, CoreObje
 
        _ps_service_set_context_bearerinfo(service, bearer_info);
 
-       ps_dbg_ex_co(co_ps, "dedicated bearer information event");
+       ps_info_ex_co(co_ps, "dedicated bearer information event");
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
@@ -1313,6 +1584,63 @@ static enum tcore_hook_return __on_hook_dedicated_bearerinfo_1(Server *s, CoreOb
        return __on_hook_dedicated_bearerinfo(s, source, command, data_len, data, user_data);
 }
 
+static enum tcore_hook_return __on_hook_default_data_subscription(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       const struct tnoti_network_default_data_subs *default_data_subs_info = data;
+
+       if (default_data_subs_info->default_subs != (enum telephony_network_default_data_subs)tcore_object_ref_subscription_type(_ps_service_ref_co_ps(service)))
+               return TCORE_HOOK_RETURN_CONTINUE;
+
+       ps_info_ex_co(_ps_service_ref_co_network(service), "'default' data subscription information event");
+       _ps_service_connect_default_context(service);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return __on_hook_default_data_subscription_0(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       return __on_hook_default_data_subscription(s, source, command, data_len, data, user_data);
+}
+
+static enum tcore_hook_return __on_hook_default_data_subscription_1(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       return __on_hook_default_data_subscription(s, source, command, data_len, data, user_data);
+}
+
+static enum tcore_hook_return __on_hook_epdg_status(Server *s, CoreObject *source,
+               enum tcore_notification_command command, unsigned int data_len, void *data,
+               void *user_data)
+{
+       gpointer service = user_data;
+       const struct tnoti_network_epdg_status *noti = (const struct tnoti_network_epdg_status *)data;
+       gboolean available = FALSE;
+       gboolean restart_connection = FALSE;
+       CoreObject *co_network = _ps_service_ref_co_network(service);
+
+       if (noti) {
+               if ((noti->status == NETWORK_EPDG_STATUS_AVAILABLE) ||
+                               (noti->status == NETWORK_EPDG_STATUS_CONNECTED) ||
+                               (noti->status == NETWORK_EPDG_STATUS_HO_LTE_TO_IWLAN)) {
+                       available = TRUE;
+               } else if (noti->status == NETWORK_EPDG_STATUS_UNAVAILABLE) {
+                       restart_connection = TRUE;
+               }
+       }
+
+       ps_info_ex_co(co_network, "ePDG: [%s]", ((available == TRUE) ? "AVAILABLE" : "UNAVAILABLE"));
+
+       _ps_service_set_epdg_status(service, available);
+
+       return TCORE_HOOK_RETURN_CONTINUE;
+}
+
 static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *source,
                enum tcore_notification_command command, unsigned int data_len, void *data,
                void *user_data)
@@ -1333,7 +1661,7 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-       ps_dbg_ex_co(co_network, "ip configuration event");
+       ps_info_ex_co(co_network, "ip configuration event");
 
        /*
         * In case IPv4 address is available and DNS address
@@ -1349,7 +1677,7 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
                        devinfo->primary_dns[0], devinfo->primary_dns[1],
                        devinfo->primary_dns[2], devinfo->primary_dns[3]);
                if (g_str_equal(ipv4_dns_1, "0.0.0.0")) {
-                       err("[IPV4]primary dns address is 0");
+                       ps_err_ex_co(co_network, "[IPV4]primary dns address is 0");
 
                        /* google dns 1st */
                        devinfo->primary_dns[0] = 8;
@@ -1363,7 +1691,7 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
                        devinfo->secondary_dns[2], devinfo->secondary_dns[3]);
                if (g_str_equal(ipv4_dns_2, "0.0.0.0")) {
                        /* open dns 2nd */
-                       err("[IPV4]secondary dns address is 0");
+                       ps_err_ex_co(co_network, "[IPV4]secondary dns address is 0");
                        devinfo->secondary_dns[0] = 208;
                        devinfo->secondary_dns[1] = 67;
                        devinfo->secondary_dns[2] = 222;
@@ -1379,12 +1707,12 @@ static enum tcore_hook_return __on_hook_ipconfiguration(Server *s, CoreObject *s
         */
        if (devinfo->ipv6_address != NULL) {
                if (devinfo->ipv6_primary_dns == NULL) {
-                       err("[IPV6]primary dns address is 0");
+                       ps_err_ex_co(co_network, "[IPV6]primary dns address is 0");
                        devinfo->ipv6_primary_dns = g_strdup("2001:4860:4860::8888");
 
                }
                if (devinfo->ipv6_secondary_dns == NULL) {
-                       err("[IPV6]secondary dns address is 0");
+                       ps_err_ex_co(co_network, "[IPV6]secondary dns address is 0");
                        devinfo->ipv6_secondary_dns = g_strdup("2620:0:ccc::2");
                }
        }
@@ -1421,14 +1749,14 @@ static enum tcore_hook_return __on_hook_powered(Server *s, CoreObject *source,
 
        g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_CONTINUE);
        co_modem = _ps_modem_ref_co_modem(modem);
-       if (source != co_modem) {
-               ps_warn_ex_co(co_modem, "Powered event for other subscription ");
+       if (co_modem != source) {
+               ps_dbg_ex_co(co_modem, "Notification for other modem!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
        modem_power = (struct tnoti_modem_power *)data;
        g_return_val_if_fail(modem_power != NULL, TCORE_HOOK_RETURN_CONTINUE);
-       ps_dbg_ex_co(co_modem, "powered event called: state [%d]", modem_power->state);
+       ps_info_ex_co(co_modem, "powered event called: state [%d]", modem_power->state);
 
        switch (modem_power->state) {
        case MODEM_STATE_ONLINE:
@@ -1477,12 +1805,7 @@ static enum tcore_hook_return __on_hook_flight(Server *s, CoreObject *source,
        struct tnoti_modem_flight_mode *modem_flight = NULL;
 
        g_return_val_if_fail(modem != NULL, TCORE_HOOK_RETURN_CONTINUE);
-       if (source != co_modem) {
-               ps_warn_ex_co(co_modem, "flight mode event for other subscription ");
-               return TCORE_HOOK_RETURN_CONTINUE;
-       }
-
-       ps_dbg_ex_co(co_modem, "flight mode event called");
+       ps_info_ex_co(co_modem, "flight mode event called");
 
        modem_flight = (struct tnoti_modem_flight_mode *)data;
        _ps_modem_processing_flight_mode(modem, modem_flight->enable);
@@ -1510,16 +1833,12 @@ static enum tcore_hook_return __on_hook_net_register(Server *s, CoreObject *sour
        gboolean ps_attached = FALSE;
        struct tnoti_network_registration_status *regist_status;
        CoreObject *co_network;
-       dbg("network register event called");
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
-
        co_network = (CoreObject *)_ps_service_ref_co_network(service);
-       if (co_network != source) {
-               ps_dbg_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
+       if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
-       }
 
        regist_status = (struct tnoti_network_registration_status *) data;
        if (regist_status->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
@@ -1552,15 +1871,12 @@ static enum tcore_hook_return __on_hook_net_change(Server *s, CoreObject *source
        gpointer service = user_data;
        struct tnoti_network_change *network_change;
        CoreObject *co_network;
-       dbg("network change event called");
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
        co_network = (CoreObject *)_ps_service_ref_co_network(service);
-       if (co_network != source) {
-               ps_dbg_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
+       if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
-       }
 
        network_change = (struct tnoti_network_change *) data;
        ps_dbg_ex_co(co_network, "plmn(%s) act(%d)", network_change->plmn, network_change->act);
@@ -1590,15 +1906,12 @@ static enum tcore_hook_return __on_hook_net_restricted_state(Server *s, CoreObje
        gpointer service = user_data;
        struct tnoti_network_restricted_state *network_restricted;
        CoreObject *co_network;
-       dbg("network restricted event called");
 
        g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
        co_network = (CoreObject *)_ps_service_ref_co_network(service);
-       if (co_network != source) {
-               ps_warn_ex_co(co_network, "Received notification for different Subscription - neglecting the notification!!!");
+       if (co_network != source)
                return TCORE_HOOK_RETURN_CONTINUE;
-       }
 
        network_restricted = (struct tnoti_network_restricted_state *) data;
        ps_dbg_ex_co(co_network, "network restricted state(%d)", network_restricted->restricted_state);
@@ -1623,7 +1936,6 @@ static enum tcore_hook_return __on_hook_net_restricted_state_1(Server *s, CoreOb
        return __on_hook_net_restricted_state(s, source, command, data_len, data, user_data);
 }
 
-
 static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
                enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
 {
@@ -1631,20 +1943,20 @@ static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
        ps_modem_t *modem = user_data;
        CoreObject *co_modem = _ps_modem_ref_co_modem(modem);
        gchar *cp_name, *source_cp_name;
-       ps_dbg_ex_co(co_modem, "sim init event called");
+
+       ps_info_ex_co(co_modem, "sim init event called");
 
        g_return_val_if_fail(user_data != NULL, TCORE_HOOK_RETURN_CONTINUE);
 
        cp_name = _ps_modem_ref_cp_name(modem);
        source_cp_name = (gchar *)tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
        if (g_strcmp0(cp_name, source_cp_name) != 0) {
-               ps_warn_ex_co(co_modem, "Received notification for different Subscription - neglecting the notification!!!");
+               ps_dbg_ex_co(co_modem, "Received notification for different Subscription - neglecting the notification!!!");
                return TCORE_HOOK_RETURN_CONTINUE;
        }
 
-
        sim_data = (struct tnoti_sim_status *)data;
-       ps_dbg_ex_co(co_modem, "sim status is (%d)", sim_data->sim_status);
+       ps_info_ex_co(co_modem, "sim status is (%d)", sim_data->sim_status);
 
        switch (sim_data->sim_status) {
        case SIM_STATUS_INIT_COMPLETED: {
@@ -1653,7 +1965,7 @@ static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
                sim_type = tcore_sim_get_type(source);
 
                if (sim_type == SIM_TYPE_NVSIM) {
-                       dbg("initial boot from CDMA network.");
+                       ps_info_ex_co(co_modem, "initial boot from CDMA network.");
                        _ps_modem_processing_sim_complete((gpointer)user_data, TRUE, PS_CDMA_DUMMY_PROFILE_PLMN);
                } else {
                        sim_imsi = tcore_sim_get_imsi(source);
@@ -1682,6 +1994,7 @@ static enum tcore_hook_return __on_hook_sim_init(Server *s, CoreObject *source,
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 #ifdef POWER_SAVING_FEATURE_WEARABLE
 static gboolean __ps_is_any_call_in_progress(TcorePlugin *plugin, __ps_call_flow_type type, enum tcore_notification_command command)
 {
@@ -1693,15 +2006,15 @@ static gboolean __ps_is_any_call_in_progress(TcorePlugin *plugin, __ps_call_flow
        co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
 
        total_call_cnt = tcore_call_object_total_length(co_call);
-       dbg("totall call cnt (%d)", total_call_cnt);
+       ps_info_ex_co(co_call, "totall call cnt (%d)", total_call_cnt);
 
        if (((type == ON_REQUEST || type == ON_NON_CALL_NOTI_HOOK) && total_call_cnt !=  0)
                || ((type == ON_CALL_NOTI_HOOK)
                && ((command != TNOTI_CALL_STATUS_IDLE) || (total_call_cnt > 1))))      {
-               dbg("call is still connected");
+               ps_info_ex_co(co_call, "call is still connected");
                call_in_progress = TRUE;
        } else {
-               dbg("No call is in progress");
+               ps_info_ex_co(co_call, "No call is in progress");
        }
 
        return call_in_progress;
@@ -1721,7 +2034,7 @@ void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type
                ur = ps_util_pop_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW);
                if (ur) {
                        gboolean call_in_progress;
-                       dbg("Sending Pending SET POWER OFF");
+                       ps_info_ex_co(_ps_modem_ref_co_modem(modem), "Sending Pending SET POWER LOW");
 
                        /* Checking if any voice or MMS is in progress, if so, delay Modem power off.
                           Need to hook on both voice call status and MMS profile de-activation.
@@ -1733,7 +2046,7 @@ void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type
                                /* add to the waiting queue and continue and wait till there is no call or MMS */
                                ret = ps_util_add_waiting_job(modem->work_queue, TREQ_MODEM_POWER_LOW , ur);
                                if (!ret) {
-                                       err("fail to add the request to queue");
+                                       ps_err_ex_co(_ps_modem_ref_co_modem(modem), "fail to add the request to queue");
                                        tcore_user_request_set_response_hook(ur, __ps_hook_response_cb, modem);
                                        if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(modem->co_modem, ur)) {
                                                __ps_send_ur_dispatch_failure_response(ur, TRESP_MODEM_POWER_LOW);
@@ -1750,7 +2063,7 @@ void __ps_check_handle_modem_off_request(gpointer data, __ps_call_flow_type type
                        }
                }
        } else {
-               dbg("No pending TREQ_MODEM_POWER_LOW reqeust");
+               ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "No pending TREQ_MODEM_POWER_LOW reqeust");
        }
 }
 
@@ -1761,6 +2074,7 @@ static enum tcore_hook_return __on_hook_voice_call_status(Server *s, CoreObject
        return TCORE_HOOK_RETURN_CONTINUE;
 }
 #endif
+#endif
 
 static enum tcore_hook_return __on_hook_sim_init_0(Server *s, CoreObject *source,
                enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
@@ -1774,18 +2088,18 @@ static enum tcore_hook_return __on_hook_sim_init_1(Server *s, CoreObject *source
        return  __on_hook_sim_init(s, source, command,  data_len, data, user_data);
 }
 
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 void _ps_get_network_mode(gpointer data)
 {
        UserRequest *ur = NULL;
        ps_modem_t *modem =  data;
-
        CoreObject *co_network = NULL;
 
-       ps_dbg_ex_co(_ps_modem_ref_co_modem(modem), "network get mode by data allowed option");
-
        co_network = tcore_plugin_ref_core_object(tcore_object_ref_plugin(modem->co_modem),
                        CORE_OBJECT_TYPE_NETWORK);
 
+       ps_dbg_ex_co(co_network, "network get mode by data allowed option");
+
        ur = tcore_user_request_new(NULL, NULL);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_MODE);
@@ -1794,13 +2108,13 @@ void _ps_get_network_mode(gpointer data)
        __ps_modem_set_hook_flag(modem, TREQ_NETWORK_GET_MODE);
 
        if (TCORE_RETURN_SUCCESS != tcore_object_dispatch_request(co_network, ur)) {
-               err("Failed to dispatch ");
                __ps_send_ur_dispatch_failure_response(ur, TRESP_NETWORK_GET_MODE);
                modem->hook_flag &= PS_NETWORK_RESET_GET_MODE_FLAG;
        }
 
        return;
 }
+#endif
 
 gboolean _ps_hook_co_modem_event(gpointer modem)
 {
@@ -1819,6 +2133,7 @@ gboolean _ps_hook_co_modem_event(gpointer modem)
                tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, __on_hook_powered_0, modem);
                tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, __on_hook_flight_0, modem);
                tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, __on_hook_sim_init_0, modem);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 #ifdef POWER_SAVING_FEATURE_WEARABLE /* TODO: Modify for DSDS support */
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_IDLE, __on_hook_voice_call_status, modem);
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ACTIVE, __on_hook_voice_call_status, modem);
@@ -1828,10 +2143,12 @@ gboolean _ps_hook_co_modem_event(gpointer modem)
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_INCOMING, __on_hook_voice_call_status, modem);
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_WAITING, __on_hook_voice_call_status, modem);
 #endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
+#endif
        } else {
                tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, __on_hook_powered_1, modem);
                tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, __on_hook_flight_1, modem);
                tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, __on_hook_sim_init_1, modem);
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 #ifdef POWER_SAVING_FEATURE_WEARABLE /* TODO: Modify for DSDS support */
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_IDLE, __on_hook_voice_call_status, modem);
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_ACTIVE, __on_hook_voice_call_status, modem);
@@ -1841,6 +2158,7 @@ gboolean _ps_hook_co_modem_event(gpointer modem)
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_INCOMING, __on_hook_voice_call_status, modem);
                tcore_server_add_notification_hook(s, TNOTI_CALL_STATUS_WAITING, __on_hook_voice_call_status, modem);
 #endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
+#endif
        }
        return TRUE;
 }
@@ -1878,7 +2196,7 @@ enum tcore_hook_return __on_hook_modem_added(Server *s,
        TcorePlugin *plg = data;
 
        if (FALSE == _ps_master_create_modems(master, plg))
-               err("Failed to create modem");
+               err("[%s] Failed to create modem", tcore_server_get_cp_name_by_plugin(plg));
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
@@ -1891,7 +2209,7 @@ enum tcore_hook_return __on_hook_modem_removed(Server *s,
        TcorePlugin *plg = data;
 
        if (FALSE == _ps_master_destroy_modem(master, plg))
-               err("Failed to destroy modem");
+               err("Failed to destroy modem[%s]", tcore_server_get_cp_name_by_plugin(plg));
 
        return TCORE_HOOK_RETURN_CONTINUE;
 }
@@ -1901,15 +2219,18 @@ gboolean _ps_get_co_modem_values(gpointer modem)
        TcorePlugin *plg;
        CoreObject *co_modem = NULL;
        CoreObject *co_sim = NULL;
+       ps_modem_t *ps_modem = modem;
 
-       gboolean sim_init = FALSE, modem_powered = FALSE, flight_mode = FALSE;
+       gboolean sim_init = FALSE, flight_mode = FALSE;
+       enum modem_state modem_power_state = MODEM_STATE_UNKNOWN;
        int sim_status = 0;
        enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN;
        struct tel_sim_imsi *sim_imsi = NULL;
+       int  power = PS_MODEM_STATE_UNKNOWN;
 
-       g_return_val_if_fail(modem != NULL, FALSE);
+       g_return_val_if_fail(ps_modem != NULL, FALSE);
 
-       co_modem = _ps_modem_ref_co_modem(modem);
+       co_modem = _ps_modem_ref_co_modem(ps_modem);
        if (!co_modem)
                return FALSE;
 
@@ -1924,18 +2245,35 @@ gboolean _ps_get_co_modem_values(gpointer modem)
                sim_init = TRUE;
 
        sim_imsi = tcore_sim_get_imsi(co_sim);
-       modem_powered = tcore_modem_get_powered(co_modem);
        flight_mode = tcore_modem_get_flight_mode_state(co_modem);
+       tcore_modem_get_modem_power_state(co_modem, &modem_power_state);
 
-       _ps_modem_processing_flight_mode(modem, flight_mode);
-       _ps_modem_processing_power_enable(modem, modem_powered);
+       switch (modem_power_state) {
+       case MODEM_STATE_ONLINE:
+               power = PS_MODEM_STATE_ONLINE;
+       break;
+
+       case MODEM_STATE_LOW:
+               power = PS_MODEM_STATE_LOW;
+       break;
+
+       case MODEM_STATE_ERROR:
+       case MODEM_STATE_RESET:
+       default:
+               ps_warn_ex_co(co_modem, "Unhandled modem power event.");
+       break;
+       }
+
+       _ps_modem_processing_flight_mode(ps_modem, flight_mode);
+       if (power != PS_MODEM_STATE_UNKNOWN)
+               _ps_modem_processing_power_enable(modem, power);
 
        sim_type = tcore_sim_get_type(co_sim);
 
        if (sim_type == SIM_TYPE_NVSIM)
-               _ps_modem_processing_sim_complete(modem, sim_init, PS_CDMA_DUMMY_PROFILE_PLMN);
+               _ps_modem_processing_sim_complete(ps_modem, sim_init, PS_CDMA_DUMMY_PROFILE_PLMN);
        else
-               _ps_modem_processing_sim_complete(modem, sim_init, (gchar *)sim_imsi->plmn);
+               _ps_modem_processing_sim_complete(ps_modem, sim_init, (gchar *)sim_imsi->plmn);
        g_free(sim_imsi);
        return TRUE;
 }
@@ -2010,17 +2348,23 @@ gboolean _ps_hook_co_ps_event(gpointer service)
        co_ps = _ps_service_ref_co_ps(service);
 
        modem_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co_ps));
+       tcore_object_add_callback (co_ps, CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed, service);
        if (TRUE == g_str_has_suffix(modem_name , "0")) {
                tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status_0, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, __on_hook_session_data_counter_0, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration_0, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_DEDICATED_BEARER_INFO, __on_hook_dedicated_bearerinfo_0, service);
+               tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, __on_hook_default_data_subscription_0, service);
        } else {
                tcore_server_add_notification_hook(s, TNOTI_PS_CALL_STATUS, __on_hook_call_status_1, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_CURRENT_SESSION_DATA_COUNTER, __on_hook_session_data_counter_1, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_PDP_IPCONFIGURATION, __on_hook_ipconfiguration_1, service);
                tcore_server_add_notification_hook(s, TNOTI_PS_DEDICATED_BEARER_INFO, __on_hook_dedicated_bearerinfo_1, service);
+               tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, __on_hook_default_data_subscription_1, service);
        }
+
+       tcore_server_add_notification_hook(s, TNOTI_NETWORK_EPDG_STATUS, __on_hook_epdg_status, service);
+
        return TRUE;
 }
 
@@ -2036,11 +2380,11 @@ gboolean _ps_free_modem_event(gpointer modem)
        tcore_server_remove_notification_hook(s, __on_hook_powered);
        tcore_server_remove_notification_hook(s, __on_hook_flight);
        tcore_server_remove_notification_hook(s, __on_hook_sim_init);
-
+#ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
 #ifdef POWER_SAVING_FEATURE_WEARABLE
        tcore_server_remove_notification_hook(s, __on_hook_voice_call_status);
 #endif /* #ifdef POWER_SAVING_FEATURE_WEARABLE */
-
+#endif
        return TRUE;
 
 }
@@ -2065,6 +2409,7 @@ gboolean _ps_free_co_ps_event(gpointer service)
        if (modem_name)
                ps_dbg_ex_co(co_network, "modem name %s", modem_name);
 
+       tcore_object_del_callback(co_ps, CORE_OBJECT_EVENT_PROPERTY_CHANGED, __ps_on_prop_changed);
        if (TRUE == g_str_has_suffix(modem_name , "0")) {
                tcore_server_remove_notification_hook(s, __on_hook_call_status_0);
                tcore_server_remove_notification_hook(s, __on_hook_session_data_counter_0);
@@ -2112,16 +2457,16 @@ gboolean _ps_update_cellular_state_key(gpointer object)
        ps_service_t *service = object;
        CoreObject *co_network = _ps_service_ref_co_network(service);
        ps_modem_t *modem = _ps_service_ref_modem(service);
-       ps_subs_type subs_type = _ps_modem_get_subs_type(modem);
+       ps_subs_type subscription_type = _ps_modem_get_subs_type(modem);
        int selected_sim = -1;
 
-       ps_dbg_ex_co(co_network, "Update cellular state for [SIM%d]", subs_type + 1);
+       ps_dbg_ex_co(co_network, "Update cellular state for [SIM%d]", subscription_type + 1);
 
        s = tcore_plugin_ref_server(_ps_service_ref_plugin(service));
        strg = tcore_server_find_storage(s, "vconf");
 
        selected_sim = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
-       if ((selected_sim != -1) && (selected_sim != (int)subs_type)) {
+       if ((selected_sim != -1) && (selected_sim != (int)subscription_type)) {
                ps_warn_ex_co(co_network, "Update for only [SIM%d] selected by Setting", selected_sim + 1);
                return FALSE;
        }
@@ -2132,9 +2477,10 @@ gboolean _ps_update_cellular_state_key(gpointer object)
                current_state = TELEPHONY_PS_FLIGHT_MODE;
 
        stored_state = tcore_storage_get_int(strg, STORAGE_KEY_CELLULAR_STATE);
-       ps_dbg_ex_co(co_network, "Cellular state, current: [%d], stored: [%d]", current_state, stored_state);
-       if (current_state != stored_state)
+       if (current_state != stored_state) {
+               ps_info_ex_co(co_network, "Cellular state, current: [%d], stored: [%d]", current_state, stored_state);
                tcore_storage_set_int(strg, STORAGE_KEY_CELLULAR_STATE, current_state);
+       }
 
        return TRUE;
 }