2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include "wifi-tel-intf.h"
24 #define TAPI_HANDLE_MAX 2
26 #define SIM_SLOT_DUAL 2
27 #define SIM_SLOT_SINGLE 1
29 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
30 #define DEFAULT_DATA_SERVICE_SIM1 0
31 #define DEFAULT_DATA_SERVICE_SIM2 1
33 static TapiHandle *tapi_handle_dual[TAPI_HANDLE_MAX+1];
34 static TapiHandle *tapi_handle = NULL;
36 static int _check_current_sim()
38 #if defined TIZEN_WEARABLE
42 int sim_slot_count = 0;
44 if ((vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT_COUNT, &sim_slot_count) != 0)
45 || sim_slot_count == SIM_SLOT_SINGLE) {
46 ERR("failed to get sim slot count (%d)", sim_slot_count);
50 if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, ¤t_sim) != 0) {
51 ERR("failed to get default data service = %d\n", current_sim);
55 DBG("default data service [SIM%d]", current_sim);
60 TapiHandle * netconfig_tel_init(void)
62 char **cp_list = NULL;
63 int current_sim = _check_current_sim();
65 if (current_sim < 0) {
66 if (tapi_handle == NULL) {
67 tapi_handle = tel_init(NULL);
68 if (tapi_handle == NULL)
69 ERR("tel_init() Failed - modem %d", current_sim);
73 if (tapi_handle_dual[current_sim] == NULL) {
74 cp_list = tel_get_cp_name_list();
76 ERR("tel_get_cp_name_list() Failed");
80 tapi_handle_dual[current_sim] = tel_init(cp_list[current_sim]);
81 if (tapi_handle_dual[current_sim] == NULL)
82 ERR("tel_init() Failed - modem %d", current_sim);
86 return tapi_handle_dual[current_sim];
90 void netconfig_tel_deinit(void)
92 int current_sim = _check_current_sim();
94 if (current_sim < 0) {
96 tel_deinit(tapi_handle);
101 while (tapi_handle_dual[i]) {
102 tel_deinit(tapi_handle_dual[i]);
103 tapi_handle_dual[i] = NULL;