ace35c9360e86f8a4119213959822ec2db5f5d5f
[platform/core/telephony/tel-plugin-packetservice.git] / src / ps_service.c
1 /*
2  * tel-plugin-packetservice
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: DongHoo Park <donghoo.park@samsung.com>
7  *          Arun Shukla <arun.shukla@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include "ps_common.h"
24 #include "ps_context.h"
25 #include "ps_master.h"
26 #include "ps_modem.h"
27 #include "ps_service.h"
28 #include "ps_hook.h"
29 #include "ps_tcore_interface.h"
30 #include "ps_service_interface.h"
31
32 #include <core_object.h>
33 #include <co_ps.h>
34 #include <co_context.h>
35 #include <co_network.h>
36 #include <storage.h>
37 #include <vconf.h>
38 #include <arpa/inet.h>
39
40 #include <tfeature.h>
41 #include <user_request.h>
42
43 #include "ps_log.h"
44
45 static guint __ps_service_convert_ipv4_address_int(char *ip_address)
46 {
47 #define HEX_ENCODING_VALUE 16
48         gchar **temp_str = NULL;
49         char *temp_address;
50         guint address;
51
52         if (!ip_address)
53                 return 0;
54
55         temp_str = g_strsplit(ip_address, ".", 5);
56         temp_address = g_strdup_printf("%02x%02x%02x%02x", atoi(temp_str[0]), atoi(temp_str[1]), atoi(temp_str[2]), atoi(temp_str[3]));
57         /* Free resources */
58         g_strfreev(temp_str);
59
60         address = strtoul(temp_address, (char **)NULL, HEX_ENCODING_VALUE);
61         g_free(temp_address);
62         return address;
63 }
64
65 void __remove_service_handler(gpointer data)
66 {
67         ps_service_t *service = data;
68
69         if (!service) {
70                 err("Service is Null");
71                 return;
72         }
73
74         ps_info_ex_svc(service, "Entered");
75         /*Need to remove the compelete hash table*/
76         g_slist_free(service->contexts);
77
78         /*Need to UNexport and Unref the master Object */
79         if (service->if_obj) {
80                 g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(service->if_obj));
81                 g_object_unref(service->if_obj);
82                 service->if_obj = NULL;
83         }
84
85         /*Need to free the memory of the internal structure*/
86         g_free(service->path);
87         g_free(service);
88 }
89
90 static char *__ps_service_act2string(enum telephony_network_access_technology act)
91 {
92         switch (act) {
93         case NETWORK_ACT_GSM:
94         case NETWORK_ACT_GPRS:
95         case NETWORK_ACT_EGPRS:
96         case NETWORK_ACT_UMTS:
97         case NETWORK_ACT_GSM_UTRAN:
98                 return "GSM";
99
100         case NETWORK_ACT_IS95A:
101         case NETWORK_ACT_IS95B:
102         case NETWORK_ACT_CDMA_1X:
103         case NETWORK_ACT_EVDO_REV0:
104         case NETWORK_ACT_CDMA_1X_EVDO_REV0:
105         case NETWORK_ACT_EVDO_REVA:
106         case NETWORK_ACT_CDMA_1X_EVDO_REVA:
107         case NETWORK_ACT_EVDV:
108                 return "CDMA";
109
110         case NETWORK_ACT_LTE:
111                 return "LTE";
112
113         case NETWORK_ACT_NR:
114                 return "5G";
115
116         case NETWORK_ACT_UNKNOWN:
117         default:
118                 return "unknown";
119         }
120
121         return NULL;
122 }
123
124 static gboolean __ps_service_check_connection_option(ps_service_t *service, ps_context_t *context)
125 {
126         gboolean b_connect = TRUE;
127         gboolean power = FALSE, sim = FALSE, data = FALSE, flight = FALSE;
128         gboolean profile_reset = FALSE;
129
130         enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
131         gint ps_mode;
132 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
133         guchar hook_flag;
134         gboolean nw_ops = FALSE;
135 #endif
136
137         ps_modem_t *modem = _ps_service_ref_modem(service);
138         ps_master_t *master = _ps_modem_ref_master(modem);
139         CoreObject *co_context = _ps_context_ref_co_context(context);
140
141         if (TRUE != _ps_context_get_profile_enable(context)) {
142                 ps_warn_ex_svc(service, "Profile is disabled.");
143                 return FALSE;
144         }
145
146         sim = _ps_modem_get_sim_init(modem);
147         data = _ps_modem_get_data_allowed(modem);
148         flight = _ps_modem_get_flght_mode(modem);
149         profile_reset = _ps_modem_get_reset_profile(modem);
150 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
151         hook_flag = _ps_hook_get_hook_flag(modem);
152         if (hook_flag != PS_NO_PENDING_REQUEST)
153                 nw_ops = TRUE;
154 #endif
155         if (PS_MODEM_STATE_ONLINE == _ps_modem_get_power(modem))
156                 power = TRUE;
157
158         b_connect &= power;
159
160         role = tcore_context_get_role(co_context);
161         if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT
162             || role == CONTEXT_ROLE_FOTA || role == CONTEXT_ROLE_BIP) {
163                 ps_info_ex_svc(service, "Do not check data and data roaming allowed value in case of IMS type");
164         } else {
165                 if (service->roaming) {
166                         gboolean roaming_allowed = FALSE;
167                         roaming_allowed = _ps_modem_get_data_roaming_allowed(modem);
168                         ps_warn_ex_svc(service, "roaming_allowed:[%d]", roaming_allowed);
169                         b_connect &= roaming_allowed;
170                 }
171
172                 b_connect &= data;
173         }
174
175         b_connect &= !flight;
176 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
177         b_connect &= !nw_ops;
178 #endif
179         b_connect &= !service->restricted;
180         b_connect &= !profile_reset;
181         if (role != CONTEXT_ROLE_IMS_EMERGENCY) {
182                 b_connect &= service->ps_attached;
183                 b_connect &= sim;
184         }
185         ps_mode = _ps_modem_get_psmode(modem);
186
187         /*
188          * Kiran PLM P141017-05702
189          * Problem: PDP retry when Wifi connected.
190          * Reproducible cases:
191          * 1) Wifi auto connected but PDP has never been connected.
192          * 2) Quick switch Wifi On -> Off before PDP establishment is complete.
193          * 2nd exceptional case is handled by Connmand but 1st case should be
194          * taken care of by telephony.
195          * Solution: Do not PDP retry until initial PDP connection when Wifi connected.
196          */
197         if (master && master->initial_pdp_conn == FALSE) {
198                 int wifi_state = PS_WIFI_STATE_OFF;
199
200                 wifi_state = _ps_master_get_storage_value_int(master, KEY_WIFI_STATE);
201                 if (wifi_state == PS_WIFI_STATE_CONNECTED) {
202                         if (service->wifi_connected_checked == FALSE) {
203                                 ps_info_ex_svc(service, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
204                                 b_connect = FALSE;
205                                 service->wifi_connected_checked = TRUE;
206                         } else {
207                                 ps_info_ex_svc(service, "Wifi connected state was already checked.");
208                         }
209                 }
210         }
211 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
212         ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), hook_flag(%d)",
213                        b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode, hook_flag);
214 #else
215         ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d)",
216                        b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode);
217 #endif
218         /* In case of ME in LCD off & UPS mode.
219          * Do not allow PDP activation.
220          */
221         if (b_connect) {
222                 int ups_mode, emc_data_allowed;
223                 ups_mode = ps_mode & ~POWER_SAVING_MODE_DATA_ALLOWED;
224                 emc_data_allowed = ps_mode & POWER_SAVING_MODE_DATA_ALLOWED;
225                 if (emc_data_allowed == FALSE &&
226                     (ups_mode > POWER_SAVING_MODE_NORMAL && ups_mode < POWER_SAVING_MODE_WEARABLE)) {
227                         gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
228                         if (pm_state == 3 &&
229                             (role != CONTEXT_ROLE_IMS &&  role != CONTEXT_ROLE_IMS_EMERGENCY &&  role != CONTEXT_ROLE_IMS_UT)) {
230                                 ps_warn_ex_svc(service, "PDP activation is not allowed in LCD off & UPS mode.");
231                                 b_connect = FALSE;
232                         }
233                 }
234         }
235         return b_connect;
236 }
237
238 static int __ps_service_connetion_timeout_handler(alarm_id_t alarm_id, void *context)
239 {
240         int rv = 0;
241         ps_context_t *ps_context = context;
242         ps_service_t *service = _ps_context_ref_service(ps_context);
243         enum co_context_role role;
244         if (service == NULL) {
245                 err("service is NULL!!!");
246                 return rv;
247         }
248
249         if (ps_context->timer_src > 0) {
250                 ps_info_ex_svc(service, "remove connection retry timer (%d)", ps_context->timer_src);
251                 alarmmgr_remove_alarm(ps_context->timer_src);
252                 ps_context->timer_src = 0;
253         }
254
255         role = tcore_context_get_role(_ps_context_ref_co_context(ps_context));
256         ps_info_ex_svc(service, "Re-try for %d type is_epdg_available: %d",
257                        role, service->is_epdg_available);
258         if ((role == CONTEXT_ROLE_IMS) && (service->is_epdg_available == TRUE)) {
259                 ps_info_ex_svc(service, "Do not re-try for IMS PDN as ePDG is available");
260                 return rv;
261         }
262
263         ps_info_ex_svc(service, "Re-try for context role [%d]", tcore_context_get_role(_ps_context_ref_co_context(ps_context)));
264         rv = _ps_service_activate_context(service, ps_context);
265         ps_info_ex_svc(service, "return rv(%d)", rv);
266         return rv;
267 }
268
269 static gboolean __ps_service_check_is_network_in_serivce(ps_service_t *service)
270 {
271         CoreObject *co_network = _ps_service_ref_co_network(service);
272         enum telephony_network_service_type service_type = NETWORK_SERVICE_TYPE_UNKNOWN;
273         gboolean rv = FALSE;
274
275         tcore_network_get_service_type(co_network, &service_type);
276         ps_warn_ex_svc(service, "service_type[%d]", service_type);
277         switch (service_type) {
278         case NETWORK_SERVICE_TYPE_UNKNOWN:
279         case NETWORK_SERVICE_TYPE_NO_SERVICE:
280         case NETWORK_SERVICE_TYPE_EMERGENCY:
281         case NETWORK_SERVICE_TYPE_SEARCH:
282                 break;
283
284         default:
285                 rv = TRUE;
286                 break;
287         }
288         return rv;
289 }
290
291 static TReturn __ps_service_set_attach_apn(ps_service_t *service, CoreObject *co_context, int set_cid)
292 {
293         TReturn rv;
294         char *apn = tcore_context_get_apn(co_context);
295         CoreObject *co_ps = _ps_service_ref_co_ps(service);
296
297         ps_dbg_ex_svc(service, "'Attach APN(%d)' [%s]", tcore_context_get_role(co_context), apn);
298
299         if (set_cid)
300                 tcore_context_set_id(co_context, set_cid);  // internet
301
302         if (tfeature_is_supported(TFEATURE_FUNCTION_SEND_APN_INFO)) {
303                 gboolean is_refresh_apn_info = FALSE;
304                 rv = tcore_ps_set_data_profile(co_ps, co_context, &is_refresh_apn_info);
305                 if (rv != TCORE_RETURN_SUCCESS)
306                         ps_err_ex_svc(service, "fail to set data profile");
307         } else {
308                 rv = tcore_ps_define_context(co_ps, co_context, NULL);
309                 if (rv != TCORE_RETURN_SUCCESS)
310                         ps_err_ex_svc(service, "fail to define context");
311         }
312
313         g_free(apn);
314         return rv;
315 }
316
317 void _ps_service_set_attach_apn(ps_service_t *service)
318 {
319         unsigned int index;
320         int default_data_subs;
321         ps_subs_type subs_type;
322         ps_modem_t *modem = NULL;
323         ps_master_t *master = NULL;
324
325         modem = _ps_service_ref_modem(service);
326         master = _ps_modem_ref_master(modem);
327
328         /* Check for default data subscription value if matchs for modem then only attach */
329         subs_type = _ps_modem_get_subs_type(modem);
330         default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
331         if (default_data_subs != (int)subs_type) {
332                 ps_warn_ex_svc(service, "Ignore Attach APN for non-dds sim [DDS - SIM%d]", default_data_subs + 1);
333                 return;
334         }
335
336         for (index = 0; index < g_slist_length(service->contexts); index++) {
337                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
338                 CoreObject *co_context = _ps_context_ref_co_context(context);
339                 gboolean attach_apn = tcore_context_get_attach_apn(co_context);
340                 if (attach_apn) {
341                         __ps_service_set_attach_apn(service, co_context, 0);
342                         /* Attach APN is only one. */
343                         break;
344                 }
345         }
346 }
347
348 ps_service_t *_ps_service_create_service(GDBusConnection *conn, TcorePlugin *p, ps_modem_t *modem,
349                                          CoreObject *co_network, CoreObject *co_ps, gchar *path)
350 {
351         ps_service_t *new_service;
352
353         g_return_val_if_fail(conn != NULL, NULL);
354         g_return_val_if_fail(modem != NULL, NULL);
355
356         ps_dbg_ex_modem(modem, "service object create");
357
358         /*Initializing the modem list for internal referencing*/
359         new_service = g_try_malloc0(sizeof(ps_service_t));
360         if (NULL == new_service) {
361                 ps_err_ex_modem(modem, "Unable to allocate memory for master");
362                 goto FAILURE;
363         }
364
365         new_service->conn = conn;
366         new_service->plg = p;
367         new_service->p_modem = modem;
368         new_service->co_network = co_network;
369         new_service->co_ps = co_ps;
370         new_service->path = g_strdup(path);
371         new_service->subs_type = modem->subs_type;
372
373         _ps_add_co_network_event(new_service);
374         _ps_get_co_network_values(new_service);
375         _ps_add_co_ps_event(new_service);
376
377         /*Setting up the interface for the service */
378         if (!ps_service_setup_interface(new_service)) {
379                 g_free(new_service->path);
380                 goto FAILURE;
381         }
382
383 //      new_service->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
384         ps_info_ex_modem(modem, "Successfully Created the service");
385         return new_service;
386
387  FAILURE:
388         /*To Do: Handle failure case*/
389         g_free(new_service);
390         return NULL;
391 }
392
393 gboolean _ps_service_ref_context(ps_service_t *service, ps_context_t *context)
394 {
395         gpointer tmp = NULL;
396
397         g_return_val_if_fail(service != NULL, FALSE);
398
399         ps_dbg_ex_svc(service, "service refer to context");
400
401         tmp = g_slist_find(service->contexts, context);
402         if (tmp) {
403                 ps_dbg_ex_svc(service, "context(%p) already existed", tmp);
404                 return FALSE;
405         }
406
407         _ps_context_set_service(context, service);
408         tcore_ps_add_context(_ps_service_ref_co_ps(service), _ps_context_ref_co_context(context));
409         service->contexts = g_slist_append(service->contexts, context);
410
411         ps_info_ex_svc(service, "context(%p) insert to linked-list", context);
412         ps_service_emit_context_added_signal(service, context);
413
414         return TRUE;
415 }
416
417 gboolean _ps_service_ref_contexts(ps_service_t *service, GSList *contexts, gchar *operator)
418 {
419         gboolean ret = TRUE;
420         int rv;
421         unsigned int index, count;
422
423         g_return_val_if_fail(service != NULL, FALSE);
424
425         count = g_slist_length(contexts);
426         ps_dbg_ex_svc(service, "service refer to contexts: count(%d)", count);
427
428         for (index = 0; index < count; index++) {
429                 gpointer tmp = NULL;
430                 ps_context_t *context = g_slist_nth_data(contexts, index);
431                 CoreObject *co_context = _ps_context_ref_co_context(context);
432
433                 tmp = g_slist_find(service->contexts, context);
434                 if (tmp) {
435                         ps_dbg_ex_svc(service, "context(%p) already existed", tmp);
436                         continue;
437                 }
438
439                 _ps_context_set_service(context, service);
440                 tcore_ps_add_context(_ps_service_ref_co_ps(service), co_context);
441                 service->contexts = g_slist_append(service->contexts, context);
442
443                 ps_info_ex_svc(service, "context(%p) path(%s) insert to linked-list", context, _ps_context_ref_path(context));
444                 ps_service_emit_context_added_signal(service, context);
445
446 #ifdef PREPAID_SIM_APN_SUPPORT
447                 ret = _ps_service_connect_last_connected_context_ex(service, context, NULL, operator);
448                 ps_info_ex_svc(service, "ret[%d]", ret);
449                 if (ret == TRUE) {
450                         /* process next available profile */
451                         continue;
452                 }
453 #endif
454
455                 if (service->ps_attached) {
456                         gboolean f_awo = _ps_context_get_alwayson_enable(context);
457                         gboolean ims_activation_requested = FALSE;
458
459                         if (f_awo) {
460                                 rv = _ps_service_define_context(service, context);
461                                 ps_info_ex_svc(service, "Always-on started, return rv(%d)", rv);
462                         }
463
464                         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
465                         if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context))) {
466                                 rv = _ps_service_define_context(service, context);
467                                 ps_info_ex_svc(service, "IMS PDN rv(%d)", rv);
468                                 ims_activation_requested = FALSE;
469                         }
470                 }
471         }
472         ps_dbg_ex_svc(service, "service->contexts: count(%d)", g_slist_length(service->contexts));
473         _ps_update_cellular_state_key(service);
474         return ret;
475 }
476
477 gboolean _ps_service_get_properties_handler(ps_service_t *service, GVariantBuilder *properties)
478 {
479         g_return_val_if_fail(service != NULL, FALSE);
480         g_return_val_if_fail(properties != NULL, FALSE);
481
482         ps_info_ex_svc(service, "get service properties");
483
484         g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
485         g_variant_builder_add(properties, "{ss}", "path", service->path);
486         g_variant_builder_add(properties, "{ss}", "ps_attached", BOOL2STRING(service->ps_attached));
487         g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
488         g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
489         g_variant_builder_close(properties);
490
491         ps_dbg_ex_svc(service, "Exiting");
492         return TRUE;
493 }
494
495 GVariant *_ps_service_get_properties(ps_service_t *service, GVariantBuilder *properties)
496 {
497         g_return_val_if_fail(service != NULL, FALSE);
498         g_return_val_if_fail(properties != NULL, FALSE);
499
500         ps_info_ex_svc(service, "get service properties");
501
502         g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
503
504         g_variant_builder_add(properties, "{ss}", "path", service->path);
505         g_variant_builder_add(properties, "{ss}", "ps_attached", BOOL2STRING(service->ps_attached));
506         g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
507         g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
508
509         ps_dbg_ex_svc(service, "Exiting");
510         return g_variant_builder_end(properties);
511 }
512
513 gchar *_ps_service_ref_path(ps_service_t *service)
514 {
515         g_return_val_if_fail(service != NULL, NULL);
516         return service->path;
517 }
518
519 TcorePlugin *_ps_service_ref_plugin(ps_service_t *service)
520 {
521         g_return_val_if_fail(service != NULL, NULL);
522         return service->plg;
523 }
524
525 CoreObject *_ps_service_ref_co_network(ps_service_t *service)
526 {
527         g_return_val_if_fail(service != NULL, NULL);
528         return service->co_network;
529 }
530
531 CoreObject *_ps_service_ref_co_ps(ps_service_t *service)
532 {
533         g_return_val_if_fail(service != NULL, NULL);
534         return service->co_ps;
535 }
536
537 ps_modem_t *_ps_service_ref_modem(ps_service_t *service)
538 {
539         g_return_val_if_fail(service != NULL, NULL);
540         return service->p_modem;
541 }
542
543 gboolean _ps_service_set_context_devinfo(ps_service_t *service, struct tnoti_ps_pdp_ipconfiguration *devinfo)
544 {
545         GSList *co_contexts = NULL;
546         CoreObject *co_context = NULL;
547
548         g_return_val_if_fail(service != NULL, FALSE);
549         g_return_val_if_fail(devinfo != NULL, FALSE);
550
551         ps_info_ex_svc(service, "set context device info for cid %d", devinfo->context_id);
552
553         co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), devinfo->context_id);
554         if (!co_contexts) {
555                 ps_err_ex_svc(service, "fail to ref context by cid.");
556                 return FALSE;
557         }
558
559         while (co_contexts) {
560                 ps_modem_t *modem = NULL;
561                 int role = CONTEXT_ROLE_UNKNOWN;
562
563                 co_context = co_contexts->data;
564                 if (!co_context) {
565                         co_contexts = co_contexts->next;
566                         continue;
567                 }
568
569                 /*TEMP*/
570                 role = tcore_context_get_role(co_context);
571                 modem = _ps_service_ref_modem(service);
572                 if (g_strcmp0(modem->operator, "45005") == 0 && role == CONTEXT_ROLE_IMS) {
573                         ps_dbg_ex_svc(service, "SKT IMS PDN");
574                         /*IPv4*/
575                         if (devinfo->pcscf_ipv4_count == 0) {
576                                 char ipv4[16];
577                                 snprintf(ipv4, 16, "%d.%d.%d.%d",
578                                          devinfo->ip_address[0], devinfo->ip_address[1],
579                                          devinfo->ip_address[2], devinfo->ip_address[3]);
580                                 if (!g_str_equal(ipv4, "0.0.0.0")) {
581                                         devinfo->pcscf_ipv4 = g_try_malloc0(sizeof(char *));
582                                         if (devinfo->pcscf_ipv4 == NULL)
583                                                 continue;
584                                         devinfo->pcscf_ipv4[0] = g_strdup("220.103.220.10");
585                                         devinfo->pcscf_ipv4_count = 1;
586                                 }
587                         }
588                         /*IPv6*/
589                         if (devinfo->pcscf_ipv6_count == 0) {
590                                 if (devinfo->ipv6_address != NULL) {
591                                         devinfo->pcscf_ipv6 = g_try_malloc0(sizeof(char *));
592                                         if (devinfo->pcscf_ipv6 == NULL)
593                                                 continue;
594                                         devinfo->pcscf_ipv6[0] = g_strdup("2001:2d8:00e0:0220::10");
595                                         devinfo->pcscf_ipv6_count = 1;
596                                 }
597                         }
598                 }
599
600                 tcore_context_set_devinfo(co_context, devinfo);
601
602                 co_contexts = co_contexts->next;
603         }
604
605         return TRUE;
606 }
607
608 gboolean _ps_service_set_context_bearerinfo(ps_service_t *service, struct tnoti_ps_dedicated_bearer_info *bearer_info)
609 {
610         GSList *co_contexts = NULL;
611         CoreObject *co_context = NULL;
612
613         g_return_val_if_fail(service != NULL, FALSE);
614         g_return_val_if_fail(bearer_info != NULL, FALSE);
615
616         ps_info_ex_svc(service, "set context bearer info");
617
618         co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), bearer_info->primary_context_id);
619         if (!co_contexts) {
620                 ps_err_ex_svc(service, "fail to ref context by cid.");
621                 return FALSE;
622         }
623
624         while (co_contexts) {
625                 unsigned int index;
626
627                 co_context = co_contexts->data;
628                 if (!co_context) {
629                         co_contexts = co_contexts->next;
630                         continue;
631                 }
632
633                 for (index = 0; index < g_slist_length(service->contexts); index++) {
634                         ps_context_t *context = g_slist_nth_data(service->contexts, index);
635                         if (co_context == _ps_context_ref_co_context(context)) {
636                                 _ps_context_set_bearer_info(context, bearer_info);
637                                 break;
638                         }
639                 }
640
641                 co_contexts = co_contexts->next;
642         }
643
644         return TRUE;
645 }
646
647 int _ps_service_define_context(ps_service_t *service, ps_context_t *context)
648 {
649         CoreObject *co_context = NULL;
650         gboolean b_connect = TRUE;
651
652         g_return_val_if_fail(service != NULL, FALSE);
653         ps_dbg_ex_svc(service, "define context(%p)", context);
654
655         b_connect = __ps_service_check_connection_option(service, context);
656         if (!b_connect)
657                 return TCORE_RETURN_EPERM;
658
659         return tcore_ps_define_context(_ps_service_ref_co_ps(service), co_context, NULL);
660 }
661
662 int _ps_service_activate_context(ps_service_t *service, ps_context_t *context)
663 {
664         ps_modem_t *modem = NULL;
665         ps_master_t *master = NULL;
666         CoreObject *co_context = NULL;
667         gboolean b_connect = TRUE;
668         gboolean ps_defined;
669         int ret = TCORE_RETURN_SUCCESS;
670         int default_data_subs = 1;
671         ps_subs_type subs_type = 1;
672         CoreObject *co_ps = _ps_service_ref_co_ps(service);
673
674         g_return_val_if_fail(service != NULL, FALSE);
675
676         ps_dbg_ex_svc(service, "activate context(%p)", context);
677
678         modem = _ps_service_ref_modem(service);
679         master = _ps_modem_ref_master(modem);
680         ps_defined = _ps_context_get_ps_defined(context);
681         co_context = _ps_context_ref_co_context(context);
682 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
683         if (modem->hook_flag != PS_NO_PENDING_REQUEST) {
684                 ps_info_ex_svc(service, "Pending request present in queue with flag %x", modem->hook_flag);
685                 ret = TCORE_RETURN_FAILURE;
686                 goto EXIT;
687         }
688 #endif
689         /* Check for default data subscription value if matchs for modem then only activate */
690         subs_type = _ps_modem_get_subs_type(modem);
691         default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
692         if ((default_data_subs != -1) && (default_data_subs != (int)subs_type)) {
693                 ps_warn_ex_svc(service, "activation  for only [SIM%d] selected by Setting", default_data_subs + 1);
694                 ret = TCORE_RETURN_FAILURE;
695                 goto EXIT;
696         }
697
698         b_connect = __ps_service_check_connection_option(service, context);
699         if (!b_connect) {
700                 ret = TCORE_RETURN_EPERM;
701                 goto EXIT;
702         }
703
704 #ifdef TIZEN_SUPPORT_VOLTE
705         if (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context)) {
706                 enum telephony_network_service_type svc_type;
707                 CoreObject *co_network = _ps_service_ref_co_network(service);
708                 tcore_network_get_service_type(co_network, &svc_type);
709
710                 if (svc_type != NETWORK_SERVICE_TYPE_LTE) {
711                         ps_warn_ex_svc(service, "IMS PDN is not allowed in %d network", svc_type);
712                         goto EXIT;
713                 }
714                 tcore_network_set_ims_on_deregistering(_ps_service_ref_co_network(service), FALSE);
715         }
716 #endif
717
718         if (!ps_defined) {
719                 ps_info_ex_svc(service, "pdp profile is not defined yet, define first. ");
720                 ret = tcore_ps_define_context(co_ps, co_context, NULL);
721         } else {
722                 ps_info_ex_svc(service, "pdp profile is defined, activate context. ");
723                 ret = tcore_ps_activate_context(co_ps, co_context, NULL);
724         }
725  EXIT:
726         if (ret != TCORE_RETURN_SUCCESS) {
727                 if (ps_defined) {
728                         /*
729                          * CONTEXT_STATE_ACTIVATING : Never be happen.
730                          * CONTEXT_STATE_ACTIVATED : Never be happen.
731                          * CONTEXT_STATE_DEACTIVATING: Do not clear resources.
732                          */
733                         if (CONTEXT_STATE_DEACTIVATED == tcore_context_get_state(co_context)) {
734                                 ps_warn_ex_svc(service, "fail to activate context after PDP define complete, clear resources.");
735                                 _ps_context_set_ps_defined(context, FALSE);
736                                 tcore_ps_clear_context_id(co_ps, co_context);
737                         } else {
738                                 ps_err_ex_svc(service, "invalid context state.");
739                         }
740                 }
741         }
742         return ret;
743 }
744
745 int _ps_service_deactivate_context(ps_service_t *service, ps_context_t *context)
746 {
747 #ifdef TIZEN_SUPPORT_VOLTE
748         enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
749         ps_modem_t *modem = NULL;
750         gboolean ims_registered = FALSE, ims_deregistering = FALSE;
751         struct tel_network_ims_registration_info ims_reg_info = { 0, };
752 #endif
753         CoreObject *co_context = _ps_context_ref_co_context(context);
754         CoreObject *co_ps = _ps_service_ref_co_ps(service);
755         TReturn ret = TCORE_RETURN_SUCCESS;
756
757         g_return_val_if_fail(service != NULL, FALSE);
758         ps_info_ex_svc(service, "deactivate context(%p)", context);
759
760 #ifdef TIZEN_SUPPORT_VOLTE
761         role = tcore_context_get_role(co_context);
762         modem = _ps_service_ref_modem(service);
763
764         tcore_network_get_ims_reg_info(_ps_service_ref_co_network(service), &ims_reg_info);
765         if (ims_reg_info.feature_mask & NET_IMS_MASK_REGI)
766                 ims_registered = TRUE;
767
768         ims_deregistering = tcore_network_get_ims_on_deregistering(_ps_service_ref_co_network(service));
769
770         ps_dbg_ex_svc(service, "role(%d), ims_registered(%d), ims_deregistering(%d), context_state(%d), flight_mode(%d)",
771                       role, ims_registered, ims_deregistering, tcore_context_get_state(co_context), modem->flight_mode);
772
773         if (!modem->flight_mode) {
774                 if (role == CONTEXT_ROLE_IMS && (tcore_context_get_state(co_context) == CONTEXT_STATE_ACTIVATED) && ims_registered && !ims_deregistering)
775                         if (_ps_context_deregister_ims(context) == TCORE_RETURN_SUCCESS)
776                                 return TCORE_RETURN_SUCCESS;
777
778                 ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
779         }
780 #else
781         ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
782 #endif
783         if (ret == TCORE_RETURN_PS_DEACTIVATED) {
784                         ps_info_ex_svc(service, "context is deactivated");
785                 return TCORE_RETURN_SUCCESS;
786         }
787         return ret;
788 }
789
790 void _ps_service_set_retry_timeout_value(ps_context_t *context, guint value)
791 {
792         ps_service_t *service = _ps_context_ref_service(context);
793         g_return_if_fail(context != NULL);
794
795         if (context->connection_timeout != value) {
796                 context->connection_timeout = value;
797                 ps_dbg_ex_svc(service, "current timeout (%d)", context->connection_timeout);
798         }
799 }
800
801 void _ps_service_connection_timer(ps_service_t *service, ps_context_t *context)
802 {
803         int result = 0;
804         gboolean f_awo = FALSE;
805         gboolean ims_activation_requested = FALSE;
806         int ret;
807         CoreObject *co_context = _ps_context_ref_co_context(context);
808
809         g_return_if_fail(service != NULL);
810
811         f_awo = _ps_context_get_alwayson_enable(context);
812         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
813         if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(co_context))))
814                 return;
815
816         if (context->timer_src > 0) {
817                 ps_info_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
818                 alarmmgr_remove_alarm(context->timer_src);
819                 context->timer_src = 0;
820         }
821
822         /* Acquire lock */
823         ret = device_power_request_lock(POWER_LOCK_CPU, 0);
824         if (ret < 0)
825                 ps_err_ex_svc(service, "ret : (0x%x)", ret);
826
827         result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(context->connection_timeout),
828                                            0, __ps_service_connetion_timeout_handler, context, &(context->timer_src));
829
830         /* Release lock */
831         ret = device_power_release_lock(POWER_LOCK_CPU);
832         if (ret < 0)
833                 ps_err_ex_svc(service, "ret : (0x%x)", ret);
834
835         if (result != ALARMMGR_RESULT_SUCCESS) {
836                 ps_err_ex_svc(service, "Failed to add alarm(%d)", result);
837                 return;
838         }
839
840         ps_info_ex_svc(service, "cellular service timer started timer src(%d), timeout(%d)",
841                        context->timer_src, context->connection_timeout);
842         context->connection_timeout = (context->connection_timeout) * 2;
843         if (context->connection_timeout >= PDP_RETRY_TIME_OUT_MAX)
844                 context->connection_timeout = PDP_RETRY_TIME_OUT_MAX;
845 }
846
847 void _ps_service_reset_connection_timer(ps_context_t *context)
848 {
849         gboolean f_awo = FALSE;
850 #ifdef PREPAID_SIM_APN_SUPPORT
851         gboolean p_awo = FALSE;
852 #endif
853         gboolean ims_activation_requested = FALSE;
854         ps_service_t *service = NULL;
855
856         f_awo = _ps_context_get_alwayson_enable(context);
857         service = _ps_context_ref_service(context);
858         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
859         if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(context)))))
860                 return;
861
862 #ifdef PREPAID_SIM_APN_SUPPORT
863         p_awo = _ps_context_get_prepaid_alwayson_enable(context);
864         if (!f_awo && !p_awo)
865                 return;
866 #endif
867
868         service = _ps_context_ref_service(context);
869         if (service == NULL) {
870                 err("service is NULL!!!");
871                 return;
872         }
873         context->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
874
875         if (context->timer_src > 0) {
876                 ps_warn_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
877                 alarmmgr_remove_alarm(context->timer_src);
878                 context->timer_src = 0;
879         }
880 }
881
882 gboolean _ps_service_unref_context(ps_service_t *service, ps_context_t *context)
883 {
884         ps_modem_t *modem = _ps_service_ref_modem(service);
885
886         g_return_val_if_fail(service != NULL, FALSE);
887         g_return_val_if_fail(modem != NULL, FALSE);
888         g_return_val_if_fail(context != NULL, FALSE);
889         g_return_val_if_fail(context->path != NULL, FALSE);
890
891         ps_dbg_ex_modem(modem, "service unref context (%s)", context->path);
892
893         _ps_service_deactivate_context(service, context);
894         /* remove context from the list (modem, service) */
895         modem->contexts = g_slist_remove(modem->contexts, context);
896         ps_service_emit_context_removed_signal(service, context);
897         return TRUE;
898 }
899
900 void _ps_service_remove_contexts(ps_service_t *service)
901 {
902         unsigned int index;
903         guint count;
904
905         g_return_if_fail(service != NULL);
906         count = g_slist_length(service->contexts);
907         ps_info_ex_svc(service, "service remove all contexts: count(%d)", count);
908
909         for (index = 0; index < count; index++) {
910                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
911                 ps_dbg_ex_svc(service, "path(%s), context(%p)", _ps_context_ref_path(context), context);
912                 _ps_service_unref_context(service, context);
913                 _ps_context_remove_context(context);
914         }
915         g_slist_free(service->contexts);
916         service->contexts = NULL;
917 }
918
919 void _ps_service_disconnect_contexts(ps_service_t *service)
920 {
921         unsigned int index;
922
923         g_return_if_fail(service != NULL);
924         ps_info_ex_svc(service, "service disconnect all contexts");
925
926         for (index = 0; index < g_slist_length(service->contexts); index++) {
927                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
928                 _ps_service_reset_connection_timer(context);
929                 _ps_service_deactivate_context(service, context);
930         }
931 }
932
933 void _ps_service_disconnect_internet_mms_tethering_contexts(ps_service_t *service)
934 {
935         unsigned int index;
936
937         g_return_if_fail(service != NULL);
938         ps_info_ex_svc(service, "Service disconnect Internet/MMS/Tethering contexts");
939
940         for (index = 0; index < g_slist_length(service->contexts); index++) {
941                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
942                 CoreObject *co_context = _ps_context_ref_co_context(context);
943                 enum co_context_role role = tcore_context_get_role(co_context);
944
945                 /*
946                  * Deactivate following type of contexts -
947                  *      - INTERNET
948                  *      - INTERNET_PREPAID
949                  *      - MMS
950                  *      - MMS_PREPAID
951                  *      - TETHERING
952                  */
953                 switch (role) {
954                 case CONTEXT_ROLE_INTERNET:
955                 case CONTEXT_ROLE_MMS:
956                 case CONTEXT_ROLE_PREPAID_INTERNET:
957                 case CONTEXT_ROLE_PREPAID_MMS:
958                 case CONTEXT_ROLE_TETHERING:
959                         _ps_service_reset_connection_timer(context);
960                         _ps_service_deactivate_context(service, context);
961                         break;
962
963                 default:
964                         ps_warn_ex_svc(service, "Need not deactivate for %d PDN type", role);
965                         continue;
966                 }
967         }
968 }
969
970 int _ps_service_connect_default_context(ps_service_t *service)
971 {
972         int rv = 0;
973         unsigned int index;
974         gboolean ims_activation_requested = FALSE;
975         gboolean reset_profile = FALSE;
976         ps_modem_t *modem = NULL;
977
978         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
979
980         ps_dbg_ex_svc(service, "service connect default context");
981
982         modem = _ps_service_ref_modem(service);
983         reset_profile = _ps_modem_get_reset_profile(modem);
984         if (reset_profile) {
985                 ps_err_ex_svc(service, "reset_profile(%d) retun", reset_profile);
986                 return 0;
987         }
988
989         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
990
991         for (index = 0; index < g_slist_length(service->contexts); index++) {
992                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
993                 gboolean f_awo = FALSE;
994
995                 f_awo = _ps_context_get_alwayson_enable(context);
996                 if (f_awo) {
997                         enum co_context_state context_state;
998
999                         /*  FIX: Kiran PLM P141111-07502 */
1000                         /* _ps_service_reset_connection_timer(value); */
1001                         rv = _ps_service_activate_context(service, context);
1002                         context_state = tcore_context_get_state(_ps_context_ref_co_context(context));
1003                         if (context_state == CONTEXT_STATE_ACTIVATED) {
1004                                 ps_info_ex_svc(service, "context is already connected");
1005                                 _ps_context_set_connected(context, TRUE);
1006                         }
1007                         ps_info_ex_svc(service, "return rv(%d)", rv);
1008 //                      break;
1009                 }
1010
1011                 if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(context)))) {
1012                         rv = _ps_service_activate_context(service, context);
1013                         ps_info_ex_svc(service, "return rv(%d)", rv);
1014                         ims_activation_requested = FALSE;
1015                 }
1016         }
1017
1018         return rv;
1019 }
1020
1021 #ifdef PREPAID_SIM_APN_SUPPORT
1022 gboolean _ps_service_connect_last_connected_context_ex(ps_service_t *service, ps_context_t *context,
1023                                                        gboolean *defined, char *operator)
1024 {
1025         ps_modem_t *modem = NULL;
1026         ps_master_t *master = NULL;
1027         int profile_id = -1;
1028         int current_profile_id = -1;
1029         gchar *last_connected_operator = NULL;
1030         gboolean last_connected_profile = FALSE;
1031         int rv;
1032
1033         ps_info_ex_svc(service, "Entry");
1034         modem = _ps_service_ref_modem(service);
1035         master = _ps_modem_ref_master(modem);
1036         last_connected_profile = _ps_master_get_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL);
1037         ps_info_ex_svc(service, "last_connected_profile [%s]", last_connected_profile ? "TRUE" : "FALSE");
1038         /* Last connected profile exist */
1039         if (last_connected_profile) {
1040                 /* Fetch last connected profile's operator */
1041                 last_connected_operator = _ps_master_get_storage_value_string(master, STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN);
1042                 ps_info_ex_svc(service, "last_connected_operator[%s] current operator[%s]", last_connected_operator, operator);
1043
1044                 if (g_strcmp0(last_connected_operator, operator) != 0) {
1045                         /* different SIM, So reset STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL
1046                            and continue to activate default profile */
1047                         ps_info_ex_svc(service, "Different SIM, reset last connected context");
1048                         _ps_master_set_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
1049
1050                         /* should be freed due to dynamic memory allocated by tcore_storage_get_string() */
1051                         if (last_connected_operator) {
1052                                 free(last_connected_operator);
1053                                 last_connected_operator = NULL;
1054                         }
1055
1056                 } else {
1057                         /* Fetch last connected context profile id */
1058                         ps_info_ex_svc(service, "Fetch last connected context profile id");
1059                         profile_id = _ps_master_get_storage_value_int(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID);
1060
1061                         /* Fetch current context profile id */
1062                         current_profile_id = _ps_context_get_profile_id(context);
1063                         ps_info_ex_svc(service, "last connected context profile id[%d], current context profile id[%d]", profile_id, current_profile_id);
1064
1065                         /* should be freed due to dynamic memory allocated by tcore_storage_get_string() */
1066                         if (last_connected_operator) {
1067                                 free(last_connected_operator);
1068                                 last_connected_operator = NULL;
1069                         }
1070
1071                         if (profile_id != current_profile_id) {
1072                                 ps_info_ex_svc(service, "Current context profile id and last connected profile does not match ..");
1073                                 /* Current context profile id and last connected profile does not match
1074                                    Check for next available profile */
1075                                 return TRUE;
1076                         } else {
1077                                 /* activate last connected context */
1078                                 ps_info_ex_svc(service, "activate last connected context");
1079                                 rv = _ps_service_define_context(service, context);
1080                                 ps_info_ex_svc(service, "return rv(%d)", rv);
1081                                 if (defined)
1082                                         *defined = TRUE;
1083                                 return TRUE;
1084                         }
1085                 }
1086         } else {
1087                 ps_info_ex_svc(service, "There is no last connected profile");
1088         }
1089
1090         return FALSE;
1091 }
1092
1093 gboolean _ps_service_connect_last_connected_context(ps_service_t *service)
1094 {
1095         gboolean ret;
1096         gboolean defined = FALSE;
1097         gchar *operator = NULL;
1098         unsigned int index;
1099
1100         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1101         operator = _ps_modem_ref_operator(_ps_service_ref_modem(service));
1102
1103         for (index = 0; index < g_slist_length(service->contexts); index++) {
1104                 ps_context_t *ps_context = g_slist_nth_data(service->contexts, index);
1105                 ret = _ps_service_connect_last_connected_context_ex(service, ps_context, &defined, operator);
1106                 ps_info_ex_svc(service, "ret[%d]", ret);
1107                 if (defined == TRUE) {
1108                         ps_info_ex_svc(service, "context[%p]", ps_context);
1109                         return defined;
1110                 }
1111         }
1112         return FALSE;
1113 }
1114
1115 int _ps_service_connect_default_prepaid_context(ps_service_t *service)
1116 {
1117         int rv = 0;
1118         unsigned int index;
1119
1120         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1121
1122         for (index = 0; index < g_slist_length(service->contexts); index++) {
1123                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1124                 gboolean f_awo = FALSE;
1125                 f_awo = _ps_context_get_prepaid_alwayson_enable(context);
1126                 if (f_awo) {
1127                         _ps_service_reset_connection_timer(context);
1128                         rv = _ps_service_activate_context(service, context);
1129                         ps_info_ex_svc(service, "return rv(%d)", rv);
1130                         break;
1131                 }
1132         }
1133         ps_info_ex_svc(service, "Exit - rv[%d]", rv);
1134         return rv;
1135 }
1136
1137 ps_context_t *_ps_service_return_context_by_cid(ps_service_t *service, int context_id)
1138 {
1139         unsigned int index;
1140
1141         g_return_val_if_fail(service != NULL, NULL);
1142
1143         for (index = 0; index < g_slist_length(service->contexts); index++) {
1144                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1145                 CoreObject *co_context = _ps_context_ref_co_context(context);
1146                 int tmp_cid = tcore_context_get_id(co_context);
1147
1148                 if (tmp_cid != context_id)
1149                         continue;
1150
1151                 return context;
1152         }
1153         return NULL;
1154 }
1155 #endif
1156
1157 ps_context_t *_ps_service_return_default_context(ps_service_t *service, int svc_cat_id)
1158 {
1159         unsigned int index;
1160
1161         g_return_val_if_fail(service != NULL, NULL);
1162
1163         for (index = 0; index < g_slist_length(service->contexts); index++) {
1164                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1165                 gboolean b_default = FALSE;
1166                 b_default = _ps_context_get_default_context(context, svc_cat_id);
1167
1168                 if (b_default)
1169                         return context;
1170         }
1171
1172         return NULL;
1173 }
1174
1175 int _ps_service_update_roaming_apn(ps_service_t *service)
1176 {
1177         int rv = 0;
1178         ps_modem_t *modem = _ps_service_ref_modem(service);
1179         gboolean p_from = FALSE; /* default <FLASE> : Home newtwork */
1180         GSList *contexts = NULL;
1181
1182         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1183         g_return_val_if_fail(modem != NULL, TCORE_RETURN_FAILURE);
1184
1185         ps_dbg_ex_svc(service, "roaming status: %d", service->roaming);
1186         /* 1) Remove all contexts
1187          * 2) Load Home/Roaming profiles from database.
1188
1189          * Home -> Roaming network:
1190          * 3-2) If Any roaming profile is not provided by service provider,
1191          *      load Home profiles from database.
1192          */
1193
1194         p_from = _ps_modem_get_roaming_apn_support(modem);
1195         if (p_from) {
1196                 _ps_service_remove_contexts(service);
1197                 contexts = _ps_context_create_hashtable((gpointer)modem, service->roaming);
1198                 if (contexts != NULL) {
1199                         rv = _ps_service_set_number_of_pdn_cnt(service, modem->operator);
1200                         rv = _ps_service_ref_contexts(service, contexts, modem->operator);
1201                 }
1202         } else {
1203                 /* Iterate through each context and check home and roaming pdp protocol type.
1204                   * If its same NO need to deactivate context.
1205                   * Otherwise de-activate context as home and roam pdp protocol type mismatched
1206                   */
1207                 enum co_context_type home_pdp_protocol, roam_pdp_protocol;
1208                 guint index;
1209
1210                 for (index = 0; index < g_slist_length(service->contexts); index++) {
1211                         ps_context_t *context = g_slist_nth_data(service->contexts, index);
1212                         home_pdp_protocol = tcore_context_get_type(_ps_context_ref_co_context(context));
1213                         roam_pdp_protocol = tcore_context_get_roam_pdp_type(_ps_context_ref_co_context(context));
1214                         if (home_pdp_protocol == roam_pdp_protocol) {
1215                                 ps_dbg_ex_svc(service, "home and roam pdp protocol type matched. No need to de-activate");
1216                                 continue;
1217                         }
1218
1219                         /* De-activate context as home and roam pdp protocol type mismatched */
1220                         ps_info_ex_modem(modem, "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
1221                                          home_pdp_protocol, roam_pdp_protocol);
1222                         _ps_service_reset_connection_timer(context);
1223                         _ps_service_deactivate_context(service, context);
1224                 }
1225         }
1226         dbg("rv: %d", rv);
1227         return rv;
1228 }
1229
1230 gboolean _ps_service_processing_network_event(ps_service_t *service, gboolean ps_attached, gboolean roaming)
1231 {
1232 #ifdef PREPAID_SIM_APN_SUPPORT
1233         gboolean ret = TRUE;
1234 #endif
1235         gboolean prev_roaming_status;
1236         g_return_val_if_fail(service != NULL, FALSE);
1237
1238         prev_roaming_status = _ps_service_get_roaming(service);
1239         if (__ps_service_check_is_network_in_serivce(service) != TRUE &&
1240             !_ps_modem_get_roaming_apn_support(_ps_service_ref_modem(service)))
1241                 ps_warn_ex_svc(service, "Update roaming status only in IN SRV");
1242         else
1243                 _ps_service_set_roaming(service, roaming);
1244
1245         _ps_service_set_ps_attached(service, ps_attached);
1246         _ps_update_cellular_state_key(service);
1247
1248         if (prev_roaming_status != _ps_service_get_roaming(service)) {
1249                 gboolean roaming_allowed = FALSE;
1250                 roaming_allowed = _ps_modem_get_data_roaming_allowed(_ps_service_ref_modem(service));
1251                 _ps_service_update_roaming_apn(service);
1252
1253                 if (!roaming_allowed && roaming) {
1254                         ps_info_ex_svc(service, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
1255                         _ps_service_disconnect_contexts(service);
1256                         return TRUE;
1257                 }
1258         }
1259
1260         if (service->ps_attached) {
1261                 ps_context_t *def_context = NULL;
1262 #ifdef PREPAID_SIM_APN_SUPPORT
1263                 ret = _ps_service_connect_last_connected_context(service);
1264                 ps_dbg_ex_svc(service, "ret[%d]", ret);
1265                 if (ret == TRUE)
1266                         return TRUE; /* No need to activate default context */
1267 #endif
1268                 def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
1269                 if (def_context)
1270                         _ps_context_set_alwayson_enable(def_context, TRUE);
1271                 _ps_service_connect_default_context(service);
1272         }
1273
1274         return TRUE;
1275 }
1276
1277 gboolean _ps_service_set_connected(ps_service_t *service, gpointer cstatus, gboolean enabled)
1278 {
1279         unsigned int index;
1280         gboolean def_awo = FALSE, b_def_conn = FALSE;
1281         gpointer def_conn = NULL;
1282         gpointer requested_conn = NULL;
1283 #ifdef TIZEN_SUPPORT_VOLTE
1284         gboolean def_ims_activation = FALSE;
1285         ps_modem_t *modem = _ps_service_ref_modem(service);
1286 #endif
1287         ps_master_t *master = _ps_modem_ref_master(_ps_service_ref_modem(service));
1288
1289         struct tnoti_ps_call_status *call_status = NULL;
1290
1291         call_status = (struct tnoti_ps_call_status *)cstatus;
1292
1293         if (enabled && master && master->initial_pdp_conn == FALSE) {
1294                 ps_info_ex_svc(service, "Initial PDP connection.");
1295                 master->initial_pdp_conn = TRUE;
1296         }
1297
1298         for (index = 0; index < g_slist_length(service->contexts); index++) {
1299                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1300                 CoreObject *co_context = _ps_context_ref_co_context(context);
1301                 int tmp_cid;
1302                 gboolean b_tmp_def = FALSE;
1303                 gpointer b_user_data = NULL;
1304
1305                 tmp_cid = tcore_context_get_id(co_context);
1306                 if (tmp_cid != call_status->context_id)
1307                         continue;
1308
1309                 /* if there is default context in disconnected cid, it has to retry auto connection */
1310                 b_tmp_def = _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET);
1311                 if (!b_def_conn)
1312                         b_def_conn = b_tmp_def;
1313
1314                 /* if disconnected connection has the user data, it is a priority connection. */
1315                 b_user_data = _ps_context_get_user_data(context);
1316                 if (b_user_data) {
1317                         def_conn = context;
1318                         requested_conn = b_user_data;
1319                 }
1320
1321                 if (!enabled) {
1322                         gchar *ipv4 = NULL;
1323                         gchar *devname = NULL;
1324                         ps_info_ex_svc(service, "Reset socket connections.");
1325                         tcore_ps_clear_context_id(_ps_service_ref_co_ps(service), co_context);
1326                         ipv4 = tcore_context_get_ipv4_addr(co_context);
1327                         devname = tcore_context_get_ipv4_devname(co_context);
1328                         tcore_util_reset_ipv4_socket((const char *)devname, (const char *)ipv4);
1329                         free(ipv4);
1330                         g_free(devname);
1331                 }
1332                 _ps_context_set_connected(context, enabled);
1333         }
1334
1335         /* connect to request profile */
1336         if (!enabled && requested_conn) {
1337                 ps_info_ex_svc(service, "connect to request profile (%p)", requested_conn);
1338                 _ps_connection_hdlr(requested_conn);
1339                 _ps_service_reset_connection_timer(def_conn);
1340                 _ps_context_reset_user_data(def_conn);
1341                 return TRUE;
1342         }
1343
1344         /* default context and always on is true. - request to connect */
1345         if (!enabled) {
1346                 gint ps_mode = 0;
1347                 def_conn = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
1348                 def_awo = _ps_context_get_alwayson_enable(def_conn);
1349
1350                 if (def_awo) {
1351                         /*
1352                          * In case of ME in LCD off & UPS mode.
1353                          * Do not enable PDP retry timer for default internet context.
1354                          */
1355                         ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
1356                         if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
1357                                 gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
1358                                 if (pm_state == 3) {
1359                                         ps_warn_ex_svc(service, "PDP retry timer is not allowed in LCD off & UPS mode.");
1360                                         return TRUE;
1361                                 }
1362                         }
1363
1364                         /* always on TRUE and default connection - NORMAL RETRY */
1365                         /* always on TRUE and no default connection - WAIT 5 Secs for retry from application */
1366                         if (b_def_conn) {
1367                                 /* retry connection */
1368                                 _ps_service_connection_timer(service, def_conn);
1369                         } else {
1370
1371                                 /* with unexpected disconnection from network/me */
1372                                 _ps_service_set_retry_timeout_value(def_conn, PDP_RETRY_TIME_OUT_DEFAULT);
1373                                 _ps_service_connection_timer(service, def_conn);
1374                         }
1375                 }
1376
1377 #ifdef TIZEN_SUPPORT_VOLTE
1378                 if (tfeature_is_supported(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE))
1379                         def_ims_activation = _ps_service_get_ims_activation_requested(service);
1380
1381                 if (def_ims_activation) {
1382                         ps_context_t *def_ims = NULL;
1383                         CoreObject *co_network = NULL;
1384                         gboolean reset_profile = FALSE;
1385                         enum telephony_network_service_type svc_type;
1386
1387                         co_network = _ps_service_ref_co_network(service);
1388                         tcore_network_get_service_type(co_network, &svc_type);
1389                         def_ims = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
1390                         reset_profile = _ps_modem_get_reset_profile(modem);
1391
1392                         ps_dbg_ex_svc(service, "svc_type[%d], reset_profile(%d)", svc_type, reset_profile);
1393
1394                         if (def_ims && svc_type == NETWORK_SERVICE_TYPE_LTE && !reset_profile) {
1395                                 ps_info_ex_svc(service, "Continue re-try for IMS PDN");
1396                                 _ps_service_connection_timer(service, def_ims);
1397                         } else {
1398                                 ps_warn_ex_svc(service, "IMS PDN retry timer is allowed in LTE mode.");
1399                         }
1400                 }
1401 #endif
1402         }
1403
1404         /* To send deactivation request of default profile */
1405         if (enabled && requested_conn) {
1406                 ps_info_ex_svc(service, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
1407                 return FALSE;
1408         }
1409
1410         return TRUE;
1411 }
1412
1413 void _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid)
1414 {
1415         unsigned int index;
1416
1417         g_return_if_fail(service != NULL);
1418
1419         for (index = 0; index < g_slist_length(service->contexts); index++) {
1420                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1421                 CoreObject *co_context = _ps_context_ref_co_context(context);
1422                 CoreObject *co_ps = _ps_service_ref_co_ps(service);
1423                 unsigned char context_id = tcore_context_get_id(co_context);
1424                 int role = tcore_context_get_role(co_context);
1425                 if (context_id == cid) {
1426                         gboolean proceed_activation = TRUE;
1427
1428                         /* Check attach apn complete */
1429                         if (value && (!service->attach_apn_complete && role != CONTEXT_ROLE_IMS_EMERGENCY)) {
1430                                 ps_info_ex_svc(service, "Initial define of attach APN is complete for profile role(%d)", role);
1431                                 service->attach_apn_complete = TRUE;
1432
1433                                 if (TRUE == _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET) && service->ps_attached)
1434                                         proceed_activation = TRUE;
1435                                 else {
1436                                         proceed_activation = FALSE;
1437                                         tcore_ps_clear_context_id(co_ps, co_context);
1438                                 }
1439                         }
1440                         proceed_activation &= value;
1441
1442                         /* Set 'ps_defined' */
1443                         _ps_context_set_ps_defined(context, proceed_activation);
1444
1445                         if (proceed_activation) {
1446                                 /* Activate if define is completed */
1447                                 ps_dbg_ex_svc(service, "define is complete, activate context for cid(%d)", cid);
1448                                 if (_ps_service_activate_context(service, context) == TCORE_RETURN_SUCCESS) {
1449                                         ps_dbg_ex_svc(service, "Successful activate context");
1450                                         tcore_ps_set_cid_active(co_ps, cid, TRUE);
1451                                 }
1452                         }
1453                         break;
1454                 }
1455         }
1456
1457 }
1458
1459 gboolean _ps_service_set_ps_attached(ps_service_t *service, gboolean value)
1460 {
1461         g_return_val_if_fail(service != NULL, FALSE);
1462
1463         if (service->ps_attached != value) {
1464                 service->ps_attached = value;
1465                 ps_info_ex_svc(service, "service(%p) ps_attached(%d)", service, service->ps_attached);
1466                 ps_service_emit_property_changed_signal(service);
1467         }
1468         return TRUE;
1469 }
1470
1471 gboolean _ps_service_get_restricted(ps_service_t *service)
1472 {
1473         g_return_val_if_fail(service != NULL, FALSE);
1474         return service->restricted;
1475 }
1476
1477 gboolean _ps_service_set_restricted(ps_service_t *service, gboolean value)
1478 {
1479         g_return_val_if_fail(service != NULL, FALSE);
1480
1481         if (service->restricted != value) {
1482                 service->restricted = value;
1483                 ps_info_ex_svc(service, "service(%p) restricted(%d)", service, service->restricted);
1484                 _ps_update_cellular_state_key(service);
1485         }
1486         return TRUE;
1487 }
1488
1489 gboolean _ps_service_set_ims_activation_requested(ps_service_t *service, gboolean enabled)
1490 {
1491         g_return_val_if_fail(service != NULL, FALSE);
1492         service->ims_activation_requested = enabled;
1493         ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
1494         return TRUE;
1495 }
1496
1497 gboolean _ps_service_get_ims_activation_requested(ps_service_t *service)
1498 {
1499         g_return_val_if_fail(service != NULL, FALSE);
1500         ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
1501
1502         if (_ps_service_get_epdg_status(service) == TRUE)
1503                 return FALSE;
1504
1505         return service->ims_activation_requested;
1506 }
1507
1508 gboolean _ps_service_set_epdg_ip_configuration(ps_service_t *service, gint cid, char *ipv4_addr, char *ipv6_addr)
1509 {
1510         GSList *contexts = NULL;
1511         CoreObject *co_context = NULL;
1512         guint pdp_address;
1513         unsigned char ip_address[IPV4_ADDR_LEN];
1514
1515         g_return_val_if_fail(service != NULL, FALSE);
1516
1517         ps_info_ex_svc(service, "service (%p) ipv4_addr (%s) ipv6_addr (%s)", service, ipv4_addr, ipv6_addr);
1518
1519         contexts = tcore_ps_ref_context_by_id(service->co_ps, cid);
1520         while (contexts) {
1521                 co_context = contexts->data;
1522                 if (!co_context) {
1523                         contexts = contexts->next;
1524                         continue;
1525                 }
1526                 if (tcore_context_get_role(co_context) == CONTEXT_ROLE_IMS) {
1527                         if (ipv4_addr) {
1528                                 char addr_buf[40];
1529                                 pdp_address = __ps_service_convert_ipv4_address_int(ipv4_addr);
1530                                 pdp_address = htonl(pdp_address);
1531                                 memcpy(&ip_address, &pdp_address, IPV4_ADDR_LEN);
1532                                 tcore_context_set_ipv4_addr(co_context, ip_address);
1533                                 snprintf(addr_buf, 20, "%d.%d.%d.%d", ip_address[0], ip_address[1], ip_address[2], ip_address[3]);
1534                                 ps_info_ex_svc(service, "[IPv4] IP Address: [%s]", addr_buf);
1535                         }
1536                         tcore_context_set_ipv6_addr(co_context, ipv6_addr);
1537                         break;
1538                 }
1539                 contexts = contexts->next;
1540         }
1541
1542         return TRUE;
1543 }
1544
1545 gboolean _ps_service_set_epdg_status(ps_service_t *service, gboolean available)
1546 {
1547         g_return_val_if_fail(service != NULL, FALSE);
1548         service->is_epdg_available = available;
1549         ps_info_ex_svc(service, "service (%p) available (%d) ", service, service->is_epdg_available);
1550
1551         return TRUE;
1552 }
1553
1554 gboolean _ps_service_get_epdg_status(ps_service_t *service)
1555 {
1556         g_return_val_if_fail(service != NULL, FALSE);
1557         return service->is_epdg_available;
1558 }
1559
1560 gboolean _ps_service_set_number_of_pdn_cnt(ps_service_t *service, gchar *operator)
1561 {
1562         int rv = 0;
1563         int num_of_pdn = 0;
1564         g_return_val_if_fail(service != NULL, FALSE);
1565
1566         ps_dbg_ex_svc(service, "Entered");
1567         num_of_pdn = _ps_context_get_number_of_pdn(operator, service);
1568         rv = tcore_ps_set_num_of_pdn(_ps_service_ref_co_ps(service), num_of_pdn);
1569
1570         if (rv != TCORE_RETURN_SUCCESS)
1571                 ps_err_ex_svc(service, "error to get maximum number of pdn");
1572
1573         dbg("Exiting");
1574         return TRUE;
1575 }
1576
1577 gboolean _ps_service_get_roaming(ps_service_t *service)
1578 {
1579         g_return_val_if_fail(service != NULL, FALSE);
1580         return service->roaming;
1581 }
1582
1583 gboolean _ps_service_set_roaming(ps_service_t *service, gboolean value)
1584 {
1585         g_return_val_if_fail(service != NULL, FALSE);
1586
1587         if (service->roaming != value) {
1588                 service->roaming = value;
1589                 ps_info_ex_svc(service, "service(%p) roaming(%d)", service, service->roaming);
1590                 ps_service_emit_property_changed_signal(service);
1591         }
1592
1593         return TRUE;
1594 }
1595
1596 static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer user_data)
1597 {
1598         GList *list, *cur;
1599         GInetAddress *addr;
1600         gchar *str_addr;
1601         GError *error = NULL;
1602
1603         list = g_resolver_lookup_by_name_finish((GResolver *)src, res, &error);
1604         if (!list) {
1605                 err("fail to get dns resolving");
1606                 if (error) {
1607                         err("error:%d, %s", error->code, error->message);
1608                         g_error_free(error);
1609                 }
1610                 return;
1611         }
1612
1613         for (cur = list; cur; cur = cur->next) {
1614                 addr = cur->data;
1615                 str_addr = g_inet_address_to_string(addr);
1616                 if (!str_addr)
1617                         continue;
1618                 info("addr(%s)", str_addr);
1619
1620                 g_free(str_addr);
1621                 g_object_unref(cur->data);
1622                 break;
1623         }
1624
1625         g_object_unref(src);
1626         g_list_free(list);
1627         return;
1628 }
1629
1630 gboolean _ps_service_set_access_technology(ps_service_t *service,
1631                                            enum telephony_network_access_technology value)
1632 {
1633 #ifdef PREPAID_SIM_APN_SUPPORT
1634         gboolean ret = TRUE;
1635 #endif
1636         enum telephony_network_access_technology p_act = 0;
1637         g_return_val_if_fail(service != NULL, FALSE);
1638
1639         if (service->act != value) {
1640                 p_act = service->act;
1641                 service->act = value;
1642                 ps_info_ex_svc(service, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
1643
1644                 if ((p_act == NETWORK_ACT_LTE || p_act == NETWORK_ACT_NR) && (service->act >= NETWORK_ACT_GSM && service->act < NETWORK_ACT_LTE)) {
1645                         GResolver *r = NULL;
1646
1647                         ps_dbg_ex_svc(service, "send the dns pkt for keeping connection");
1648
1649                         r = g_resolver_get_default();
1650                         g_resolver_lookup_by_name_async(r, "www.tizen.org", NULL, _indicator_cb_dns_reply, NULL);
1651                 }
1652
1653                 if (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED) {
1654                         _ps_update_cellular_state_key(service);
1655 #ifdef PREPAID_SIM_APN_SUPPORT
1656                         ret = _ps_service_connect_last_connected_context(service);
1657                         ps_info_ex_svc(service, "ret[%d]", ret);
1658                         if (ret == TRUE)
1659                                 return ret;  /* No need to activate default context */
1660 #endif
1661                         _ps_service_connect_default_context(service);
1662                 }
1663         }
1664
1665         return TRUE;
1666 }
1667
1668 enum telephony_ps_state _ps_service_check_cellular_state(ps_service_t *service)
1669 {
1670         gboolean state = FALSE;
1671         ps_modem_t *modem;
1672
1673         g_return_val_if_fail(service != NULL, TELEPHONY_PS_NO_SERVICE);
1674
1675         modem = _ps_service_ref_modem(service);
1676
1677         state = _ps_modem_get_flght_mode(modem);
1678         if (state)
1679                 return TELEPHONY_PS_FLIGHT_MODE;
1680
1681         state = _ps_modem_get_power(modem);
1682         if (!state)
1683                 return TELEPHONY_PS_NO_SERVICE;
1684
1685         state = _ps_modem_get_sim_init(modem);
1686         if (!state)
1687                 return TELEPHONY_PS_NO_SERVICE;
1688
1689         if (service->restricted)
1690                 return TELEPHONY_PS_RESTRICTED_SERVICE;
1691
1692         if (!service->ps_attached)
1693                 return TELEPHONY_PS_NO_SERVICE;
1694
1695         state = _ps_modem_get_data_allowed(modem);
1696         if (!state)
1697                 return TELEPHONY_PS_3G_OFF;
1698
1699         state = _ps_modem_get_data_roaming_allowed(modem);
1700         if (service->roaming && !state)
1701                 return TELEPHONY_PS_ROAMING_OFF;
1702
1703         return TELEPHONY_PS_ON;
1704 }
1705
1706 void _ps_service_handling_nas_timer(ps_service_t *service, gboolean state)
1707 {
1708         unsigned int index;
1709
1710         g_return_if_fail(service != NULL);
1711         ps_info_ex_svc(service, "Handleing nas timer, state(%d)", state);
1712
1713         for (index = 0; index < g_slist_length(service->contexts); index++) {
1714                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1715                 CoreObject *co_context = _ps_context_ref_co_context(context);
1716                 enum co_context_state co_state = tcore_context_get_state(co_context);
1717
1718                 if (co_state == CONTEXT_STATE_ACTIVATED) {
1719                         enum co_context_role role = tcore_context_get_role(co_context);
1720                         enum ims_data_pdn data_pdn = IMS_DATA_PDN_UNKNOWN;
1721                         enum ims_data_state data_state = IMS_DATA_STATE_RESUME;
1722                         gboolean drop_packet = FALSE;
1723
1724                         if (role == CONTEXT_ROLE_INTERNET)
1725                                 data_pdn = IMS_DATA_PDN_INTERNET;
1726                         else if (role == CONTEXT_ROLE_IMS)
1727                                 data_pdn = IMS_DATA_PDN_IMS;
1728                         else if (role == CONTEXT_ROLE_IMS_EMERGENCY)
1729                                 data_pdn = IMS_DATA_PDN_EMERGENCY;
1730                         else if (role == CONTEXT_ROLE_MMS)
1731                                 data_pdn = IMS_DATA_PDN_CBS;
1732
1733                         if (state == PS_NAS_TIMER_STATE_START) {
1734                                 data_state = IMS_DATA_STATE_SUSPEND;
1735                                 drop_packet = TRUE;
1736                         } else {
1737                                 data_state = IMS_DATA_STATE_RESUME;
1738                                 drop_packet = FALSE;
1739                         }
1740
1741                         ps_info_ex_svc(service, "co_context(%p) co_state(%d) role(%d) data_pdn(%d) data_state(%d) drop_packet(%d)",
1742                                 co_context, co_state, role, data_pdn, data_state, drop_packet);
1743
1744 /*
1745                         if (tcore_context_get_drop_packet(co_context) != drop_packet) {
1746                                 tcore_context_set_drop_packet(co_context, drop_packet);
1747                                 _ps_context_handling_nas_timer(context, drop_packet);
1748
1749                                 if (role == CONTEXT_ROLE_IMS)
1750                                         tcore_ps_set_ims_data_state(_ps_service_ref_co_ps(service), data_pdn, data_state);
1751                         }
1752 */
1753                 }
1754         }
1755 }