blob: 3424c225a91415094b3ad305aea90264a70b5377 [file] [log] [blame]
lhb07f4e12022-02-17 22:08:54 -08001//SPDX-License-Identifier: MediaTekProprietary
lh7b0674a2022-01-10 00:34:35 -08002/* Copyright Statement:
3 *
4 * This software/firmware and related documentation ("MediaTek Software") are
5 * protected under relevant copyright laws. The information contained herein
6 * is confidential and proprietary to MediaTek Inc. and/or its licensors.
7 * Without the prior written permission of MediaTek inc. and/or its licensors,
8 * any reproduction, modification, use or disclosure of MediaTek Software,
9 * and information contained herein, in whole or in part, shall be strictly prohibited.
10 */
11/* MediaTek Inc. (C) 2010. All rights reserved.
12 *
13 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
14 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
15 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
16 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
19 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
20 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
21 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
22 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
23 * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
24 * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
25 * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
26 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
27 * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
28 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
29 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
30 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
31 *
32 * The following software/firmware and/or related documentation ("MediaTek Software")
33 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
34 * applicable license agreements with MediaTek Inc.
35 */
36
37#include <unistd.h>
38#include <string.h>
39#include <log/log.h>
40#include <vendor-ril/telephony/ril.h>
41extern "C" {
42#include <gio/gio.h>
43#include <glib.h>
44}
45
46#include "common.h"
47/*Warren add for t800 ril service 2021/12/25 start*/
48#include "lynq_common.h"
49#include "lynq_interface.h"
50#include <binder/Parcel.h>
ll6e73f202022-12-28 14:59:46 +080051#include "ATCI.h"
llf6e3ffd2023-01-12 22:31:29 +080052#include "atci_lynq_data_cmd.h"
ll6e73f202022-12-28 14:59:46 +080053#ifdef LED_SUPPORT
54#include "led.h"
55#endif
lh7b0674a2022-01-10 00:34:35 -080056using android::Parcel;
57
58/*Warren add for t800 ril service 2021/12/25 end*/
59
60#define LOG_TAG "DEMO_DATA_GDBUS"
61#define TELEPHONY_SERVICE "mtk.telephony" /*well-known bus name */
62#define TELEPHONY_DATA_INTERFACE "mtk.telephony.Data" /*interface name*/
63#define TELEPHONY_DATA_PATH "/mtk/telephony/data" /*object name*/
ll62a2b402022-11-16 21:19:04 +080064#define DEBUG 0
lh7b0674a2022-01-10 00:34:35 -080065
66GMainLoop *loop = NULL;
67GDBusProxy *proxy = NULL;
68MTK_Data_Call_Response_v1 req_response;
69MTK_Data_Call_Response_v1 urc_response;
ll90a255c2022-04-07 09:09:55 +000070
ll62a2b402022-11-16 21:19:04 +080071
rjw20006d12022-04-21 16:29:04 +080072/*Typethree add for t800 ril service 2022/04/14 start*/
73
74int lynq_data_modify_apn(gchar *reason,int lynq_request_id)
75{
76 Parcel p;
77 if(reason == NULL)
78 {
79 RLOGD("modify apn reason apn");
80 return -1;
81 }
82 p.writeInt32(1);
83 p.writeInt32(lynq_request_id);
84 p.writeInt32(0);
85 writeStringToParcel(p,reason);
rjw7ee7bb42023-01-18 11:34:28 +080086 android::LYNQ_RIL_urcBroadcast(p,lynq_request_id);
rjw20006d12022-04-21 16:29:04 +080087 return 0;
88}
89
90/*Typethree add for t800 ril service 2022/04/14 end*/
91
ll90a255c2022-04-07 09:09:55 +000092/*Warren add for t103 szzt atsvc 2022/1/5 start*/
ll62a2b402022-11-16 21:19:04 +080093/*lei modify on 2022/11/16*/
ll62a2b402022-11-16 21:19:04 +080094/*lei modify on 2022/11/16*/
ll90a255c2022-04-07 09:09:55 +000095/*Warren add for t103 szzt atsvc 2022/1/5 end*/
96
lh7b0674a2022-01-10 00:34:35 -080097/*Warren add for t800 ril service 2021/12/25 start*/
98int lynq_data_management(MTK_Data_Call_Response_v1 *urc_response)
99{
100 char apn_t[LYNQ_APN_LEN_MAX] = {};
101 char apnType_t[LYNQ_APNTPYE_LEN_MAX] = {};
102 char iface_t[LYNQ_APNTPYE_LEN_MAX] = {};
103 if(!urc_response)
104 {
105 RLOGD("urc_response is null!!!");
106 return -1;
107 }
108 bool apnHasCreated = FALSE;
lh7b0674a2022-01-10 00:34:35 -0800109 Parcel p;
110 if(urc_response->cId > 0)
111 {
112 if(urc_response->pdnState==PDN_DISCONNECTED)//if user disable data call,the pdn state wiil change to disconnected.
113 {
114 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
115 {
ll62a2b402022-11-16 21:19:04 +0800116 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800117 printf("line %d [PDN_DISCONNECTED]apn_table[%d],apntype:%s,apnstatus:%d,,,urc_response->apnName:%s\n",__LINE__, i,apn_table[i].apntype,apn_table[i].apnstatus,urc_response->apnType);
ll62a2b402022-11-16 21:19:04 +0800118 #endif
lh7b0674a2022-01-10 00:34:35 -0800119 RLOGD("[PDN_DISCONNECTED]apn_table[%d],apntype:%s,apnstatus:%d,,,urc_response->apnName:%s\n",i,apn_table[i].apntype,apn_table[i].apnstatus,urc_response->apnType);
120 if((strcmp(apn_table[i].apntype,urc_response->apnType)==0)&&(apn_table[i].apnstatus==0))
121 {
122 bzero(apn_table[i].apn,LYNQ_APN_LEN_MAX);
123 bzero(apn_table[i].apntype,LYNQ_APNTPYE_LEN_MAX);
ll62a2b402022-11-16 21:19:04 +0800124 apn_table[i].used = 0;
125 apn_table[i].netId = 0;
126 apn_table[i].pdpstate = PDN_DISCONNECTED;
lh7b0674a2022-01-10 00:34:35 -0800127 apn_count--;
128 p.writeInt32 (1);
129 p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND);
130 p.writeInt32 (0);//temporary plan
131 p.writeInt32(PDN_DISCONNECTED);
Hong_Liu6149f182023-05-12 02:15:14 -0700132 writeStringToParcel(p,urc_response->apnName);
rjw5d2a50e2022-02-28 15:01:49 +0800133 writeStringToParcel(p,urc_response->apnType);
Hong_Liu6149f182023-05-12 02:15:14 -0700134 writeStringToParcel(p,urc_response->ifname);
rjw7ee7bb42023-01-18 11:34:28 +0800135 android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
lh7b0674a2022-01-10 00:34:35 -0800136 RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype);
lh7b0674a2022-01-10 00:34:35 -0800137 break;
138 }
139 }
140 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
141 {
142 RLOGD("for apn_table[%d].apn:%s,apntype:%s,used:%d,apnstatus:%d\n",i,apn_table[i].apn,
143 apn_table[i].apntype,apn_table[i].used,apn_table[i].apnstatus);
144 }
145 }
146 else
147 {
148 /*if the pdn status change,tele-fwk will send pdn status to me.
149 **The reason for the status change may be that enable data call,
150 **the user disable the data call, and the signal is interrupted.
151 */
152 if(apn_count==0)//first new apn has created
153 {
154 RLOGD("first apn_count:%d\n",apn_count);
155 memcpy(apn_table[apn_count].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
156 memcpy(apn_table[apn_count].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
157 memcpy(apn_table[apn_count].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
ll62a2b402022-11-16 21:19:04 +0800158 memcpy(apn_table[apn_count].address,urc_response->addresses,strlen(urc_response->addresses)+1);
159 apn_table[apn_count].pdpstate = urc_response->pdnState;
160 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800161 printf("line %d apn_table[%d].apn:%s,apntype:%s,,,urc_response->apnName:%s,urc_response->apntype:%s\n",__LINE__,apn_count,apn_table[apn_count].apn,apn_table[apn_count].apntype,urc_response->apnName,urc_response->apnType);
ll62a2b402022-11-16 21:19:04 +0800162 #endif
lh7b0674a2022-01-10 00:34:35 -0800163 RLOGD("apn_table[%d].apn:%s,apntype:%s,,,urc_response->apnName:%s,urc_response->apntype:%s\n",apn_count,apn_table[apn_count].apn,apn_table[apn_count].apntype,urc_response->apnName,urc_response->apnType);
164 apn_table[apn_count].apnstatus=1;
165 apn_table[apn_count].used=1;
166 apn_table[apn_count].netId=urc_response->netId;
167 apn_count++;
168 p.writeInt32(1);
169 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
170 p.writeInt32(0);//temporary plan
171 p.writeInt32(PDN_CONNECTED);
172 writeStringToParcel(p,urc_response->apnName);
173 writeStringToParcel(p,urc_response->apnType);
174 writeStringToParcel(p,urc_response->ifname);
rjw7ee7bb42023-01-18 11:34:28 +0800175 android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
176#ifdef LED_SUPPORT
177 mbtk_netled_state_update(GPIO_NETLED_PPP_CONNECT);
178#endif
lh7b0674a2022-01-10 00:34:35 -0800179 }
180 else
181 {
ll62a2b402022-11-16 21:19:04 +0800182 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)//means apn state changed,need update
lh7b0674a2022-01-10 00:34:35 -0800183 {
ll62a2b402022-11-16 21:19:04 +0800184 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800185 printf("line %d for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",__LINE__,i,apn_table[i].apn,urc_response->apnName);
ll62a2b402022-11-16 21:19:04 +0800186 #endif
lh7b0674a2022-01-10 00:34:35 -0800187 RLOGD("for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",i,apn_table[i].apn,urc_response->apnName);
188 if(strcmp(apn_table[i].apn,urc_response->apnName)==0)
189 {
ll62a2b402022-11-16 21:19:04 +0800190 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800191 printf("line %d This apn has been created update???!!!\n",__LINE__);
ll62a2b402022-11-16 21:19:04 +0800192 #endif
lh7b0674a2022-01-10 00:34:35 -0800193 RLOGD("This apn has been created!!!");
lh7b0674a2022-01-10 00:34:35 -0800194 apnHasCreated = TRUE;
195 if(apn_table[i].netId!=urc_response->netId)
196 {
ll62a2b402022-11-16 21:19:04 +0800197 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800198 printf("update???\n");
ll62a2b402022-11-16 21:19:04 +0800199 #endif
200 apn_table[i].netId = urc_response->netId;
201 apn_table[i].pdpstate = urc_response->pdnState;
202 memcpy(apn_table[i].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
203 memcpy(apn_table[i].address,urc_response->addresses,strlen(urc_response->addresses)+1);
lh7b0674a2022-01-10 00:34:35 -0800204 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
205 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
206 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
207 /*send urc to client
208 send apn_t,apnType_t,urc_response->pdnState,iface_t to client
209 */
210 p.writeInt32(1);
211 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
212 p.writeInt32(0);//temporary plan
213 p.writeInt32(urc_response->pdnState);
214 writeStringToParcel(p,apn_t);
215 writeStringToParcel(p,apnType_t);
216 writeStringToParcel(p,iface_t);
rjw7ee7bb42023-01-18 11:34:28 +0800217 android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
lh7b0674a2022-01-10 00:34:35 -0800218 }
219 break;
220 }
221 }
ll62a2b402022-11-16 21:19:04 +0800222 if(!apnHasCreated)//Multiple APNs are established new apn has created
lh7b0674a2022-01-10 00:34:35 -0800223 {
224 bool getLable = FALSE;
225 int lable = 0;
ll62a2b402022-11-16 21:19:04 +0800226 for(lable;lable < LYNQ_APN_CHANNEL_MAX;lable++)//to find not used array element subscript
lh7b0674a2022-01-10 00:34:35 -0800227 {
228 if(apn_table[lable].used==0)
229 {
230 getLable = TRUE;
231 break;
232 }
233 }
234 if(getLable)
235 {
ll62a2b402022-11-16 21:19:04 +0800236 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800237 printf("line %d Multiple APNs are established\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800238 #endif
lh7b0674a2022-01-10 00:34:35 -0800239 RLOGD("[getLable]:label==%d\n",lable);
240 memcpy(apn_table[lable].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
241 memcpy(apn_table[lable].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
242 memcpy(apn_table[lable].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
ll62a2b402022-11-16 21:19:04 +0800243 apn_table[lable].pdpstate = urc_response->pdnState;
244 memcpy(apn_table[lable].address,urc_response->addresses,strlen(urc_response->addresses)+1);
lh7b0674a2022-01-10 00:34:35 -0800245 RLOGD("new apn_table[%d].apn:%s,apntype:%s,,,urc_response->apnName:%s,urc_response->apntype:%s\n",lable,apn_table[lable].apn,apn_table[lable].apntype,urc_response->apnName,urc_response->apnType);
246 apn_table[lable].apnstatus=1;
247 apn_table[lable].used=1;
248 apn_table[lable].netId=urc_response->netId;
249 apn_count++;
250 p.writeInt32(1);
251 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
252 p.writeInt32(0);//temporary plan
253 p.writeInt32(urc_response->pdnState);
254 writeStringToParcel(p,urc_response->apnName);
255 writeStringToParcel(p,urc_response->apnType);
256 writeStringToParcel(p,urc_response->ifname);
rjw7ee7bb42023-01-18 11:34:28 +0800257 android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
lh7b0674a2022-01-10 00:34:35 -0800258 }
259 else
260 {
261 RLOGD("unkown error");
262 }
263 }
264 }
265 }
266 }
ll62a2b402022-11-16 21:19:04 +0800267 else //cid < 0 it means:when at+cfun=0 will into this or when connecting
lh7b0674a2022-01-10 00:34:35 -0800268 {
269 apnHasCreated = FALSE;
270 RLOGD("[cid < 0] apn_count:%d\n",apn_count);
271 if(apn_count>0)
272 {
273 int i = 0;
274 for(i;i < LYNQ_APN_CHANNEL_MAX;i++)
275 {
ll62a2b402022-11-16 21:19:04 +0800276 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800277 printf("line %d don't know\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800278 #endif
lh7b0674a2022-01-10 00:34:35 -0800279 RLOGD("[cid<0]apn_table[%d].apntype:%s,,,,urc_response->apntype:%s\n",i,apn_table[i].apntype,urc_response->apnType);
280 if(strcmp(apn_table[i].apntype,urc_response->apnType)==0)
281 {
282 RLOGD("apntype:%s PDN status has changed!!!\n",urc_response->apnType);
283 apnHasCreated = TRUE;
284 break;
285 }
286 }
287 if(apnHasCreated)
288 {
ll62a2b402022-11-16 21:19:04 +0800289 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800290 printf("line %d don't know\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800291 #endif
292 apn_table[i].pdpstate = urc_response->pdnState;
293 char ptr[1] = "";
294 if(NULL == urc_response->ifname)
295 {
296 memcpy(apn_table[i].ifaceName, ptr,strlen(ptr)+1);
297 }
298 if(NULL == urc_response->addresses)
299 {
300 memcpy(apn_table[i].address, ptr, strlen(ptr)+1);
301 }
lh7b0674a2022-01-10 00:34:35 -0800302 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
303 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
304 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
305 p.writeInt32(1);
306 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
307 p.writeInt32(0);//temporary plan
308 p.writeInt32(urc_response->pdnState);
309 writeStringToParcel(p,apn_t);
310 writeStringToParcel(p,apnType_t);
311 writeStringToParcel(p,iface_t);
rjw7ee7bb42023-01-18 11:34:28 +0800312 android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
lh7b0674a2022-01-10 00:34:35 -0800313 }
314 }
315 }
316 return 0;
317}
318/*Warren add for t800 ril service 2021/12/25 end*/
319void freeMem(MTK_Data_Call_Response_v1 response)
320{
321 g_free(response.apnType);
322 g_free(response.type);
323 g_free(response.ifname);
324 g_free(response.addresses);
325 g_free(response.dnses);
326 g_free(response.gateways);
327 g_free(response.pcscf);
328}
329
330char* apnState2string(RIL_Data_Call_PdnState apnState) {
331 switch (apnState) {
332 case RIL_Data_Call_PdnState::PDN_CONNECTED:
333 return "PDN_CONNECTED";
334 case RIL_Data_Call_PdnState::PDN_CONNECTING:
335 return "PDN_CONNECTING";
336 case RIL_Data_Call_PdnState::PDN_DISCONNECTED:
337 return "PDN_DISCONNECTED";
338 case RIL_Data_Call_PdnState::PDN_DISCONNECTING:
339 return "PDN_DISCONNECTING";
340 case RIL_Data_Call_PdnState::PDN_FAILED:
341 return "PDN_FAILED";
342 case RIL_Data_Call_PdnState::PDN_IDLE:
343 return "PDN_IDLE";
344 case RIL_Data_Call_PdnState::PDN_RETRYING:
345 return "PDN_RETRYING";
346 case RIL_Data_Call_PdnState::PDN_SCANNING:
347 return "PDN_SCANNING";
348 default:
349 return "UNKNOWN";
350 }
351}
352
353void dumpResponse(MTK_Data_Call_Response_v1 *dataCallResponse)
354{
355 RLOGD("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s,"
356 " protocolType: %s, ifaceName: %s, address: %s, dns: %s, gateway: %s, pcscf: %s, mtu: %d, apn: %s",
357 dataCallResponse->netId, apnState2string(RIL_Data_Call_PdnState(dataCallResponse->pdnState)),
358 dataCallResponse->status, dataCallResponse->cId, dataCallResponse->apnType, dataCallResponse->type,
359 dataCallResponse->ifname, dataCallResponse->addresses, dataCallResponse->dnses,
360 dataCallResponse->gateways, dataCallResponse->pcscf, dataCallResponse->mtu, dataCallResponse->apnName);
361}
362
363void parse(GVariant* result, MTK_Data_Call_Response_v1* data) {
364 g_variant_get(result, "((iiiisssssssis))", &(data->netId),
365 &(data->pdnState), &(data->status),
366 &(data->cId), &(data->apnType), &(data->type),
367 &(data->ifname), &(data->addresses),
368 &(data->dnses), &(data->gateways),
369 &(data->pcscf), &(data->mtu),&(data->apnName));
370}
371
372void proxy_method_cb (GDBusProxy *proxy,
373 GAsyncResult *res,
374 gpointer user_data)
375{
376 RLOGD("method call back");
377 GError *error;
378 GVariant *result;
379
380 error = NULL;
381 result = g_dbus_proxy_call_finish(proxy, res, &error);
382
383 if(error != NULL)
384 {
385 RLOGD("method call back error %s", error->message);
386 g_error_free(error);
387 return;
388 }
389 freeMem(req_response);
390 parse(result, &req_response);
391 dumpResponse(&req_response);
392 g_variant_unref(result);
393}
394
395int enableData (bool isEnable, gchar *apn_type)
396{
397 RLOGD("send: %s, %s", (isEnable ? "TRUE": "FALSE"), apn_type);
398 g_dbus_proxy_call(proxy,
399 "enableData",
400 g_variant_new("(bs)", isEnable, apn_type),
401 G_DBUS_CALL_FLAGS_NONE,
402 -1,
403 NULL,
404 (GAsyncReadyCallback) proxy_method_cb,
405 NULL);
406 return 1;
407}
rjw20006d12022-04-21 16:29:04 +0800408/*Typethree add for t800 RIL Service 2022/04/14 start*/
lh7b0674a2022-01-10 00:34:35 -0800409void modifyApnDB_method_cb (GDBusProxy *proxy,
410 GAsyncResult *res,
411 gpointer user_data)
412{
413 RLOGD("method call back");
414 GError *error;
415 GVariant *result;
416 gchar* reason = NULL;
417
418 error = NULL;
419 result = g_dbus_proxy_call_finish(proxy, res, &error);
420
421 if(error != NULL)
422 {
423 RLOGD("method call back error %s", error->message);
424 printf("modify apn db error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800425 lynq_data_modify_apn(error->message,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800426 g_error_free(error);
427 return;
428 }
429 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
430 g_variant_get (result, "(&s)", &reason);
431 RLOGD("modifyApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
432 printf("modify apn db success, return message: %s\n", ((reason == NULL)? "":reason));
433 //printf("modifyApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
ll6e73f202022-12-28 14:59:46 +0800434 /*lei add for AT+LEAPNMOD*/
llf6e3ffd2023-01-12 22:31:29 +0800435 if(g_flag_apn)
436 {
437 char apn_buf[256];
438 sprintf(apn_buf, "+LEAPNMOD:%s", ((reason == NULL)? "":reason));
439 ATCIResponseNoToken(0, apn_buf, 666);//tmp plan
440 }
ll6e73f202022-12-28 14:59:46 +0800441 /*lei add for AT+LEAPNMOD*/
lh7b0674a2022-01-10 00:34:35 -0800442 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800443 lynq_data_modify_apn(reason,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800444}
445
446int modifyApnDB(int cmd, gchar *record) {
447 RLOGD("%s: cmd: %d, record:%s", __FUNCTION__, cmd, record);
448 g_dbus_proxy_call(proxy,
449 "modifyApnDB",
450 g_variant_new("(is)", cmd, record),
451 G_DBUS_CALL_FLAGS_NONE,
452 -1,
453 NULL,
454 (GAsyncReadyCallback) modifyApnDB_method_cb,
455 NULL);
456 return 1;
457}
458
459void resetApnDB_method_cb (GDBusProxy *proxy,
460 GAsyncResult *res,
461 gpointer user_data)
462{
463 RLOGD("resetApnDB_method_cb call back");
464 GError *error;
465 GVariant *result;
466 gchar* reason = NULL;
467
468 error = NULL;
469 result = g_dbus_proxy_call_finish(proxy, res, &error);
470
471 if(error != NULL)
472 {
473 RLOGD("method call back error %s", error->message);
474 printf("reset apn DB error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800475 lynq_data_modify_apn(error->message,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800476 g_error_free(error);
477 return;
478 }
479 g_variant_get (result, "(&s)", &reason);
480 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
481 RLOGD("resetApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
482 printf("reset apn DB success, return message: %s\n", ((reason == NULL)? "":reason));
483 //printf("resetApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
484 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800485 lynq_data_modify_apn(reason,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800486}
rjw20006d12022-04-21 16:29:04 +0800487/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -0800488
489int resetApnDB() {
490 RLOGD("%s", __FUNCTION__);
491 g_dbus_proxy_call(proxy,
492 "resetApnDB",NULL,
493 G_DBUS_CALL_FLAGS_NONE,
494 -1,
495 NULL,
496 (GAsyncReadyCallback) resetApnDB_method_cb,
497 NULL);
498 return 1;
499}
500
ll90a255c2022-04-07 09:09:55 +0000501
lh7b0674a2022-01-10 00:34:35 -0800502void proxy_signals_on_signal (GDBusProxy *proxy,
503 const gchar *sender_name,
504 const gchar *signal_name,
505 GVariant *parameters,
506 gpointer user_data)
507{
508 RLOGD("signal_name: %s", signal_name);
509 printf("signal_name: %s\n", signal_name);
510 freeMem(urc_response);
511 parse(parameters, &urc_response);
512 dumpResponse(&urc_response);
513 if(g_strcmp0(signal_name, "lynq_data_resp") == 0)
514 {
515 printf("[lynq_data_resp]do something\n");
516 return;
517 }
518 lynq_data_management(&urc_response);
519 if(g_strcmp0(signal_name, "LYNQ_TEST") == 0)
520 {
521 printf("do something\n");
522 }
523 if(g_strcmp0(signal_name, "default") == 0)
524 {
525 if(urc_response.pdnState == RIL_Data_Call_PdnState::PDN_DISCONNECTED) {
526 notifyDataSignal();
xja1c30b82022-01-25 16:13:48 +0800527 } else if (urc_response.pdnState == RIL_Data_Call_PdnState::PDN_FAILED) {
528 updataDataConnectState(get_default_sim_data(), false);
lh7b0674a2022-01-10 00:34:35 -0800529 }
530 }
531 return;
532
533}
534
535void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
536 GError *error;
537
538 error = NULL;
539 proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
540 if (proxy == NULL) {
541 RLOGE("create proxy fail");
542 return ;
543 }
544 RLOGD("proxy is ready");
545 gulong signal_handler_id;
546
547 signal_handler_id = g_signal_connect(proxy, "g-signal",
548 G_CALLBACK (proxy_signals_on_signal), NULL);
549 if (signal_handler_id == 0) {
550 RLOGE("listen singal fail!");
551 }
552}
553
554void* init_data_gdbus_cb(void *param)
555{
556 /* all the tests rely on a shared main loop */
557 loop = g_main_loop_new(NULL, FALSE);
558
559 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
560 G_DBUS_PROXY_FLAGS_NONE,
561 NULL, /* GDBusInterfaceInfo */
562 TELEPHONY_SERVICE, /* name */
563 TELEPHONY_DATA_PATH, /* object path */
564 TELEPHONY_DATA_INTERFACE, /* interface */
565 NULL, /* GCancellable */
566 proxy_ready,
567 NULL);
568
569 g_main_loop_run(loop);
570
571 RLOGD("data gdbus main loop run()");
572 if(proxy != NULL) {
573 g_object_unref (proxy);
574 }
575 if(loop != NULL) {
576 g_main_loop_unref(loop);
577 }
xja1c30b82022-01-25 16:13:48 +0800578 return NULL;
lh7b0674a2022-01-10 00:34:35 -0800579}
580