tizen 2.4 release
[apps/home/quickpanel.git] / daemon / sim_controller.c
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18
19 #include <Elementary.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <E_DBus.h>
23
24 #include <tapi_common.h>
25 #include <ITapiSim.h>
26 #include <TelCall.h>
27 #include <ITapiCall.h>
28 #include <TelNetwork.h>
29
30 #include <dlog.h>
31 #include <vconf.h>
32 #include <tzsh.h>
33 #include <tzsh_quickpanel_service.h>
34
35 #include "setting_utils.h"
36
37 #include "list_util.h"
38 #include "quickpanel-ui.h"
39 #include "common.h"
40
41 #include "handler_controller.h"
42
43 #define TAPI_HANDLE_MAX  2
44
45 static struct
46 {
47         TapiHandle *handle[TAPI_HANDLE_MAX+1];
48         Eina_Bool sim_card_ready[2];
49
50         Evas_Object *layout;
51
52         int call_state; // 0:none, 1:call
53 }
54 sim_state_info =
55 {
56         .handle[0] = NULL,
57         .handle[1] = NULL,
58         .handle[2] = NULL,
59         .sim_card_ready[0] = EINA_FALSE,
60         .sim_card_ready[1] = EINA_FALSE,
61         .layout = NULL,
62         .call_state = 0,
63 };
64
65 static void register_sim_callbacks();
66 static void unregister_sim_callbacks();
67
68 static char *get_sim_plmn(TapiHandle *handle)
69 {
70         int ret;
71         char *network_name = NULL;
72
73         /* Reading Network (PLMN) name - ‘string’ type Property */
74         ret = tel_get_property_string(handle,
75                         TAPI_PROP_NETWORK_NETWORK_NAME, &network_name);
76         if(ret == TAPI_API_SUCCESS)
77         {
78                 /* ‘network_name’ contains valid Network name based on Display condition */
79                 return network_name;
80         }
81         else
82         {
83                 ERR("Sim = %p PLMN = ERROR[%d]", handle, ret);
84                 /* get property failed */
85         }
86
87         return NULL;
88 }
89
90 static char *get_sim_spn(TapiHandle *handle)
91 {
92         int ret;
93         char *spn_name = NULL;
94
95
96         /* Reading SPN name - ‘string’ type Property */
97         ret = tel_get_property_string(handle,
98                         TAPI_PROP_NETWORK_SPN_NAME, &spn_name);
99         if(ret == TAPI_API_SUCCESS)
100         {
101                 /* ‘spn_name’ contains valid Service provider name */
102                 return spn_name;
103         }
104         else
105         {
106                 ERR("Sim = %p SPN = ERROR[%d]", handle, ret);
107                 /* get property failed */
108                 return NULL;
109         }
110 }
111
112 static char *get_plmn_spn_network(int handle_num, TapiHandle *handle)
113 {
114         int ret = TAPI_API_SUCCESS;
115         int service_type = TAPI_NETWORK_SERVICE_TYPE_UNKNOWN;
116         int name_option = TAPI_NETWORK_DISP_INVALID;
117         char *plmn = NULL;
118         char *spn = NULL;
119         char buf[1024] = { 0, };
120
121         // get service type
122         ret = tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &service_type);
123         if (ret != TAPI_API_SUCCESS) {
124                 ERR("Failed to get service type[%d]", ret);
125         }
126
127         if (service_type >= TAPI_NETWORK_SERVICE_TYPE_2G) {
128                 // get network name option
129                 ret = tel_get_property_int(handle, TAPI_PROP_NETWORK_NAME_OPTION, &name_option);
130                 if (ret != TAPI_API_SUCCESS) {
131                         ERR("Failed to get name option[%d]", ret);
132                 }
133
134                 switch (name_option) {
135                 case TAPI_NETWORK_DISP_SPN:
136                         spn = get_sim_spn(handle);
137                         if (spn != NULL && spn[0] != 0) {
138                                 INFO("PLMN/SPN - Sim %p using SPN: %s", handle, spn);
139                                 snprintf(buf, sizeof(buf), "%s", spn);
140                         }
141                         break;
142                 case TAPI_NETWORK_DISP_PLMN:
143                         plmn = get_sim_plmn(handle);
144                         if (plmn != NULL && plmn[0] != 0) {
145                                 INFO("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn);
146                                 snprintf(buf, sizeof(buf), "%s", plmn);
147                         }
148                         break;
149                 case TAPI_NETWORK_DISP_SPN_PLMN:
150                         spn = get_sim_spn(handle);
151                         plmn = get_sim_plmn(handle);
152                         if (spn != NULL && spn[0] != 0 && plmn != NULL && plmn[0] != 0) {
153                                 INFO("PLMN/SPN - Sim %p using SPN: %s, PLMN: %s", handle, spn, plmn);
154                                 snprintf(buf, sizeof(buf), "%s - %s", plmn, spn);
155                         } else if (spn != NULL && spn[0] != 0) {
156                                 INFO("PLMN/SPN - Sim %p using SPN: %s", handle, spn);
157                                 snprintf(buf, sizeof(buf), "%s", spn);
158                         } else if (plmn != NULL && plmn[0] != 0) {
159                                 INFO("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn);
160                                 snprintf(buf, sizeof(buf), "%s", plmn);
161                         }
162                         break;
163                 default:
164                         ERR("Invalid name option[%d]", name_option);
165                         plmn = get_sim_plmn(handle);
166                         if (plmn != NULL && plmn[0] != 0) {
167                                 INFO("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn);
168                                 snprintf(buf, sizeof(buf), "%s", plmn);
169                         }
170                         break;
171                 }
172         } else {
173                 switch (service_type) {
174                 case TAPI_NETWORK_SERVICE_TYPE_NO_SERVICE:
175                         snprintf(buf, sizeof(buf), "%s", _("IDS_IDLE_BODY_NO_SERVICE"));
176                         break;
177                 case TAPI_NETWORK_SERVICE_TYPE_EMERGENCY:
178                         snprintf(buf, sizeof(buf), "%s", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"));
179                         break;
180                 case TAPI_NETWORK_SERVICE_TYPE_SEARCH:
181                         snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_SEARCHING"));
182                         break;
183                 default:
184                         ERR("invalid service type[%d]", service_type);
185                         plmn = get_sim_plmn(handle);
186                         if (plmn != NULL && plmn[0] != 0) {
187                                 INFO("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn);
188                                 snprintf(buf, sizeof(buf), "%s", plmn);
189                         }
190                         break;
191                 }
192         }
193
194         DBG("handle[%d][%p] service_type[%d], name_option[%d] >> [%s]", handle_num, handle, service_type, name_option, buf);
195
196         if (strlen(buf) == 0) {
197                 ERR("Empty string");
198                 snprintf(buf, sizeof(buf), "%s", _("IDS_IDLE_BODY_NO_SERVICE"));
199         } else if (strncasecmp(buf, "No Service", strlen("No Service")) == 0) {
200                 ERR("USING SPECIAL NETWORK NAME:  %s in handle: %d", _("IDS_IDLE_BODY_NO_SERVICE"), handle_num);
201                 return strdup(_("IDS_IDLE_BODY_NO_SERVICE"));
202         } else if (strncasecmp(buf, "EMERGENCY", strlen("EMERGENCY")) == 0) {
203                 ERR("USING SPECIAL NETWORK NAME:  %s in handle: %d", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"), handle_num);
204                 return strdup(_("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"));
205         } else if (strncasecmp(buf, "Searching", strlen("Searching")) == 0) {
206                 ERR("USING SPECIAL NETWORK NAME:  %s in handle: %d", _("IDS_COM_BODY_SEARCHING"), handle_num);
207                 return strdup(_("IDS_COM_BODY_SEARCHING"));
208         } else if (strncasecmp(buf, "SIM Error", strlen("SIM Error")) == 0) {
209                 ERR("USING SPECIAL NETWORK NAME:  %s in handle: %d", _("IDS_IDLE_BODY_INVALID_SIM_CARD"), handle_num);
210                 return strdup(_("IDS_IDLE_BODY_INVALID_SIM_CARD"));
211         } else if (strncasecmp(buf, "NO SIM", strlen("NO SIM")) == 0) {
212                 ERR("USING SPECIAL NETWORK NAME:  %s in handle: %d", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"), handle_num);
213                 return strdup(_("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"));
214         }
215
216         return strdup(buf);
217 }
218
219 // --------------------------------------------------------------------------------------------
220 static void print_sim_status(TelSimCardStatus_t sim_status, int card_changed)
221 {
222         switch(sim_status) {
223         case TAPI_SIM_STATUS_CARD_ERROR:
224                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_ERROR");
225                 break;
226
227         case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
228                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_NOT_PRESENT");
229                 break;
230
231         case TAPI_SIM_STATUS_SIM_INITIALIZING:
232                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_INITIALIZING");
233                 break;
234
235         case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
236                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_INIT_COMPLETED");
237                 break;
238
239         case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
240                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_PIN_REQUIRED");
241                 break;
242
243         case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
244                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_PUK_REQUIRED");
245                 break;
246
247         case TAPI_SIM_STATUS_CARD_BLOCKED:
248                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_BLOCKED");
249                 break;
250
251         case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
252                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_NCK_REQUIRED");
253                 break;
254
255         case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
256                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_NSCK_REQUIRED");
257                 break;
258
259         case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
260                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_SPCK_REQUIRED");
261                 break;
262
263         case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
264                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_CCK_REQUIRED");
265                 break;
266
267         case TAPI_SIM_STATUS_CARD_REMOVED:
268                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_REMOVED");
269                 break;
270
271         case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
272                 INFO("Sim card status: TAPI_SIM_STATUS_SIM_LOCK_REQUIRED");
273                 break;
274
275         case TAPI_SIM_STATUS_CARD_CRASHED:
276                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_CRASHED");
277                 break;
278
279         case TAPI_SIM_STATUS_CARD_POWEROFF:
280                 INFO("Sim card status: TAPI_SIM_STATUS_CARD_POWEROFF");
281                 break;
282
283         case TAPI_SIM_STATUS_UNKNOWN:
284                 INFO("Sim card status: TAPI_SIM_STATUS_UNKNOWN");
285                 break;
286         }
287
288         INFO("Sim_card_changed: %d", card_changed);
289 }
290
291 static void get_sim_status()
292 {
293         int i;
294         int ret;
295         TelSimCardStatus_t sim_status;
296         int card_changed;
297
298         for (i = 0; i < TAPI_HANDLE_MAX + 1; ++i) {
299                 if (sim_state_info.handle[i]) {
300                         ret = tel_get_sim_init_info (sim_state_info.handle[i], &sim_status, &card_changed);
301                         if(ret == 0) {
302                                 print_sim_status(sim_status, card_changed);
303
304                                 if(sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) {
305                                         if (i < TAPI_HANDLE_MAX) {
306                                                 sim_state_info.sim_card_ready[i] = EINA_TRUE;
307                                         }
308                                 } else {
309                                         ERR("SIM[%d] is not completed initialization [%d]", i, sim_status);
310                                 }
311                         } else {
312                                 ERR("Could not get sim[%d] status[%d]", i, ret);
313                         } // if ret == 0
314                 } // if sim_state_info
315         } // for
316 }
317
318 static void sim_handler_text_set(Eina_Bool flight_mode)
319 {
320         if (flight_mode) {
321                 // if flight mode, No service
322                 quickpanel_handler_text_set(_("IDS_IDLE_BODY_NO_SERVICE"));
323         } else if (sim_state_info.sim_card_ready[0] && sim_state_info.sim_card_ready[1]) {
324                 quickpanel_handler_text_set(NULL);
325         } else if(sim_state_info.sim_card_ready[0]) {
326                 char *plmn_spn1 = get_plmn_spn_network(0, sim_state_info.handle[0]);
327                 quickpanel_handler_text_set(plmn_spn1);
328                 if (plmn_spn1) {
329                         free(plmn_spn1);
330                 }
331         } else if(sim_state_info.sim_card_ready[1]) {
332                 char *plmn_spn1 = get_plmn_spn_network(1, sim_state_info.handle[1]);
333                 quickpanel_handler_text_set(plmn_spn1);
334                 if (plmn_spn1) {
335                         free(plmn_spn1);
336                 }
337         } else {
338                 quickpanel_handler_text_set(_("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"));
339         }
340 }
341
342 static void init_view()
343 {
344         struct appdata *ad = NULL;
345
346         ad = quickpanel_get_app_data();
347         if (ad == NULL) {
348                 ERR("invalid data");
349                 return;
350         }
351
352         int flight_mode_state = EINA_FALSE;
353         int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode_state);
354         if(ret != 0) {
355                 ERR("Could not get 'VCONFKEY_TELEPHONY_FLIGHT_MODE' value");
356         }
357
358         sim_handler_text_set(flight_mode_state);
359 }
360
361 /* Initialize TAPI */
362 static void _init_tel()
363 {
364         char **cp_list = NULL;
365         unsigned int modem_num = 0;
366
367         /* Get CP name list – cp_list */
368         cp_list = tel_get_cp_name_list();
369
370         if(cp_list == NULL) {
371                 ERR("Could not get the cp_name_list");
372                 return;
373         }
374
375         while (cp_list[modem_num]) {
376                 /* Initialize TAPI handle */
377                 sim_state_info.handle[modem_num] = tel_init(cp_list[modem_num]);
378
379                 if (cp_list[modem_num]) {
380                         ERR("sim_state_info.handle[%d] = %s; ptr = %p", modem_num, cp_list[modem_num], sim_state_info.handle[modem_num]);
381                 }
382
383                 /* Move to next CP Name in cp_list */
384                 modem_num++;
385         }
386
387         sim_state_info.handle[modem_num] = NULL;
388
389         /* free cp_list */
390         free(cp_list);
391 }
392
393 /* De-initialize TAPI */
394 static void _deinit_tel()
395 {
396         int i = 0;
397         while (sim_state_info.handle[i]) {
398                 /* De-initialize TAPI handle */
399                 tel_deinit(sim_state_info.handle[i]);
400                 sim_state_info.handle[i] = NULL;
401
402                 /* Move to next handle */
403                 i++;
404         }
405 }
406
407 /* Telephony state change callback */
408 void tel_ready_cb(keynode_t *key, void *data)
409 {
410         Eina_Bool status = EINA_FALSE;
411
412         status = vconf_keynode_get_bool(key);
413
414         if (status == TRUE) {   /* Telephony State - READY */
415                 DBG("tel status[%d]", status);
416                 _init_tel();
417                 register_sim_callbacks();
418                 get_sim_status();
419
420                 init_view();
421         } else {   /* Telephony State – NOT READY */
422                 /* De-initialization is optional here (ONLY if required) */
423                 ERR("tel status[%d]", status);
424                 _deinit_tel();
425                 sim_state_info.sim_card_ready[0] = EINA_FALSE;
426                 sim_state_info.sim_card_ready[1] = EINA_FALSE;
427
428                 unregister_sim_callbacks();
429         }
430 }
431
432 static void tel_flight_mode_cb(keynode_t *key, void *data)
433 {
434         Eina_Bool flight_mode_state = EINA_FALSE;
435
436         flight_mode_state = vconf_keynode_get_bool(key);
437         sim_handler_text_set(flight_mode_state);
438 }
439
440 // --------------------------------------------------------------------------------------------
441 static void on_sim_card_status_changed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
442 {
443         int handle_num;
444         int *sim_status = data;
445
446         /**
447          * @note
448          * Casting the pointer to "long" first for 64 bits architecture.
449          * And then convert it to "int"
450          */
451         handle_num = (int)((long)user_data);
452
453         ERR("SIM[%p][%d] status[%d], [%d][%d]", handle, handle_num, *sim_status, sim_state_info.sim_card_ready[0], sim_state_info.sim_card_ready[1]);
454
455         if(*sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || *sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) {
456                 sim_state_info.sim_card_ready[handle_num] = EINA_TRUE;
457         } else {
458                 sim_state_info.sim_card_ready[handle_num] = EINA_FALSE;
459         }
460
461         init_view();
462 }
463
464 static void on_plmn_spn_changed(TapiHandle *handle, const char *noti_id,
465                 void *data, void *user_data)
466 {
467         if (!handle) {
468                 ERR("handle == NULL");
469                 return;
470         }
471
472         int flight_mode_state = EINA_FALSE;
473         int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode_state);
474         if (ret != 0) {
475                 ERR("Could not get the 'VCONFKEY_TELEPHONY_FLIGHT_MODE' value");
476         }
477         sim_handler_text_set(flight_mode_state);
478 }
479
480 static void register_sim_callbacks()
481 {
482         long i;
483         int ret;
484
485         for (i = 0; i < TAPI_HANDLE_MAX; ++i) {
486                 if (sim_state_info.handle[i]) {
487                         ret = tel_register_noti_event(sim_state_info.handle[i], TAPI_NOTI_SIM_STATUS, on_sim_card_status_changed, (void *)i);
488                         if (ret != TAPI_API_SUCCESS) {
489                                 ERR("Failed to register 'on_sim_card_status_changed' callback to handle[%d][%d]", i, ret);
490                         } else {
491                                 ERR("SIM card status changed event registered");
492                         }
493
494                         ret = tel_register_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_SPN_NAME, on_plmn_spn_changed, (void *)i);
495                         if (ret != TAPI_API_SUCCESS) {
496                                 ERR("Failed to register 'on_plmn_spn_changed' callback to handle[%d][%d]", i, ret);
497                         }
498
499                         ret = tel_register_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_NETWORK_NAME, on_plmn_spn_changed, (void *)i);
500                         if (ret != TAPI_API_SUCCESS) {
501                                 ERR("Failed to register 'on_plmn_spn_changed' callback to handle: %i", i);
502                         }
503
504                         ret = tel_register_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_SERVICE_TYPE, on_plmn_spn_changed, (void *)i);
505                         if (ret != TAPI_API_SUCCESS) {
506                                 ERR("Failed to register network service type[%d][%d]", ret, i);
507                         }
508
509                         ret = tel_register_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_NAME_OPTION, on_plmn_spn_changed, (void *)i);
510                         if (ret != TAPI_API_SUCCESS) {
511                                 ERR("Failed to register network name option[%d][%d]", ret, i);
512                         }
513                 } else {
514                         ERR("No handle [%d]", i);
515                 }
516         }
517 }
518
519 static void unregister_sim_callbacks()
520 {
521         int i;
522         int ret;
523         for(i = 0; i < TAPI_HANDLE_MAX; ++i) {
524                 if(sim_state_info.handle[i]) {
525                         ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_NOTI_SIM_STATUS);
526                         if (ret != TAPI_API_SUCCESS) {
527                                 ERR("Failed to dereregister TAPI_NOTI_SIM_STATUS callback from handle: %i", i);
528                         } else {
529                                 DBG("SIM status changed event deregistered");
530                         }
531
532                         ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_NETWORK_NAME);
533                         if (ret != TAPI_API_SUCCESS) {
534                                 ERR("Failed to dereregister TAPI_PROP_NETWORK_PLMN callback from handle: %i", i);
535                         }
536
537                         ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_SPN_NAME);
538                         if (ret != TAPI_API_SUCCESS) {
539                                 ERR("Failed to dereregister TAPI_PROP_NETWORK_SPN_NAME callback from handle: %i", i);
540                         }
541
542                         ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_SERVICE_TYPE);
543                         if (ret != TAPI_API_SUCCESS) {
544                                 ERR("Failed to deregister network service type[%d][%d]", ret, i);
545                         }
546
547                         ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_PROP_NETWORK_NAME_OPTION);
548                         if (ret != TAPI_API_SUCCESS) {
549                                 ERR("Failed to deregister network name option[%d][%d]", ret, i);
550                         }
551
552                         if(i == 0) {
553                                 ret = tel_deregister_noti_event(sim_state_info.handle[i], TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION);
554                                 if (ret != TAPI_API_SUCCESS) {
555                                         ERR("Failed to dereregister  callback to handle: %d", i);
556                                 }
557                         }
558                 }
559         } // for
560 }
561
562 void sim_controller_init(Evas_Object *master_layout)
563 {
564         int state = EINA_FALSE;
565         int ret;
566         /* Check if Telephony state - READY */
567         ret = vconf_get_bool(VCONFKEY_TELEPHONY_READY, &state);
568
569         DBG("VCONFKEY_TELEPHONY_READY == %d", state);
570
571         if (ret != -1 && state == TRUE) {
572                 /* Telephony State - READY */
573                 /* Initialize TAPI handles */
574
575                 _init_tel();
576                 register_sim_callbacks();
577                 get_sim_status();
578
579                 init_view();
580         } else {        /* Telephony State – NOT READY, register for change in state */
581                 DBG("Telephony state: [NOT Ready]");
582         }
583
584         /* Register for Telephony state change */
585         ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY, tel_ready_cb, master_layout);
586         if(ret != 0) {
587                 ERR("Failed to register VCONFKEY_TELEPHONY_READY key changed callback");
588         }
589
590         ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, tel_flight_mode_cb, master_layout);
591         if(ret != 0) {
592                 ERR("Failed to register VCONFKEY_TELEPHONY_FLIGHT_MODE key changed callback");
593         }
594 }
595
596 void sim_controller_resume()
597 {
598         int state = FALSE;
599         int ret = 0;
600         int i = 0;
601         TelSimCardStatus_t sim_status;
602         int card_changed;
603
604         ret = vconf_get_bool(VCONFKEY_TELEPHONY_READY, &state);
605         if (ret != 0 || state == FALSE) {
606                 ERR("Failed to get telephony state[%d][%d]", state, ret);
607                 return;
608         }
609
610         for (i = 0; i < TAPI_HANDLE_MAX; ++i) {
611                 if (sim_state_info.handle[i]) {
612                         ret = tel_get_sim_init_info(sim_state_info.handle[i], &sim_status, &card_changed);
613                         DBG("SIM[%d] info[%d][%d][%d]", i, ret, sim_status, card_changed);
614                         if (sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) {
615                                 if (sim_state_info.sim_card_ready[i] != EINA_TRUE) {
616                                         ERR("SIM[%d] is init completed but local value is not ture", i);
617                                 }
618                         }
619                 } else {
620                         ERR("No handle[%d]", i);
621                 }
622         }
623 }
624
625 void sim_controller_on_language_change()
626 {
627         on_plmn_spn_changed(sim_state_info.handle[0], "SELF", NULL, (void*) 0);
628         on_plmn_spn_changed(sim_state_info.handle[1], "SELF", NULL, (void*) 1);
629
630         if (sim_state_info.handle[0] == NULL && sim_state_info.handle[1] == NULL) {
631                 int flight_mode = EINA_FALSE;
632                 int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
633                 if (ret != 0) {
634                         ERR("Failed to get flight mode[%d]", ret);
635                 }
636
637                 sim_handler_text_set(flight_mode);
638         }
639 }