blob: f77106291766a1a9a2146b5fb02fe864e332a3c6 [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>
51using android::Parcel;
52
53/*Warren add for t800 ril service 2021/12/25 end*/
54
55#define LOG_TAG "DEMO_DATA_GDBUS"
56#define TELEPHONY_SERVICE "mtk.telephony" /*well-known bus name */
57#define TELEPHONY_DATA_INTERFACE "mtk.telephony.Data" /*interface name*/
58#define TELEPHONY_DATA_PATH "/mtk/telephony/data" /*object name*/
59
60GMainLoop *loop = NULL;
61GDBusProxy *proxy = NULL;
62MTK_Data_Call_Response_v1 req_response;
63MTK_Data_Call_Response_v1 urc_response;
ll90a255c2022-04-07 09:09:55 +000064
rjw20006d12022-04-21 16:29:04 +080065/*Typethree add for t800 ril service 2022/04/14 start*/
66
67int lynq_data_modify_apn(gchar *reason,int lynq_request_id)
68{
69 Parcel p;
70 if(reason == NULL)
71 {
72 RLOGD("modify apn reason apn");
73 return -1;
74 }
75 p.writeInt32(1);
76 p.writeInt32(lynq_request_id);
77 p.writeInt32(0);
78 writeStringToParcel(p,reason);
79 android::LYNQ_RIL_urcBroadcast(p);
80 return 0;
81}
82
83/*Typethree add for t800 ril service 2022/04/14 end*/
84
ll90a255c2022-04-07 09:09:55 +000085/*Warren add for t103 szzt atsvc 2022/1/5 start*/
86int lynqUpdateApnStatus(char *apn,char *apntype,int pdnState,char *ifname)
87{
88 char BUF[32] = {};
89 int len = -1;
90 if(pdnState==PDN_CONNECTED)
91 {
92 sprintf(BUF,"+LAPNST:%s,%s,%d,%s\n",apn,apntype,pdnState,ifname);
93 printf("eBuf:%s\n",BUF);
94 len = write(ttyGS3_fd,BUF,strlen(BUF));
95 }
96 else
97 {
98 sprintf(BUF,"+LAPNST:%s,%s,%d\n",apn,apntype,pdnState);
99 printf("eBuf:%s\n",BUF);
100 len = write(ttyGS3_fd,BUF,strlen(BUF));
101 }
102 if(len < 0)
103 {
104 perror("lynq resp write:");
105 return -1;
106 }
107 return 0;
108}
109/*Warren add for t103 szzt atsvc 2022/1/5 end*/
110
lh7b0674a2022-01-10 00:34:35 -0800111/*Warren add for t800 ril service 2021/12/25 start*/
112int lynq_data_management(MTK_Data_Call_Response_v1 *urc_response)
113{
114 char apn_t[LYNQ_APN_LEN_MAX] = {};
115 char apnType_t[LYNQ_APNTPYE_LEN_MAX] = {};
116 char iface_t[LYNQ_APNTPYE_LEN_MAX] = {};
117 if(!urc_response)
118 {
119 RLOGD("urc_response is null!!!");
120 return -1;
121 }
122 bool apnHasCreated = FALSE;
123 char Buf[1024] = {0};
124 bzero(Buf, 1024);
125 Parcel p;
126 if(urc_response->cId > 0)
127 {
128 if(urc_response->pdnState==PDN_DISCONNECTED)//if user disable data call,the pdn state wiil change to disconnected.
129 {
130 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
131 {
132 //printf("data test 002:count:%d\n",i);
133 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);
134 if((strcmp(apn_table[i].apntype,urc_response->apnType)==0)&&(apn_table[i].apnstatus==0))
135 {
136 bzero(apn_table[i].apn,LYNQ_APN_LEN_MAX);
137 bzero(apn_table[i].apntype,LYNQ_APNTPYE_LEN_MAX);
138 apn_table[i].used=0;
139 apn_table[i].netId=0;
140 apn_count--;
ll90a255c2022-04-07 09:09:55 +0000141 int n = write(ttyGS3_fd,"OK\n",3);
142 if(n<0)
143 {
144 perror("lynq resp write:");
145 }
lh7b0674a2022-01-10 00:34:35 -0800146 p.writeInt32 (1);
147 p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND);
148 p.writeInt32 (0);//temporary plan
149 p.writeInt32(PDN_DISCONNECTED);
rjw5d2a50e2022-02-28 15:01:49 +0800150 writeStringToParcel(p,urc_response->apnType);
lh7b0674a2022-01-10 00:34:35 -0800151 android::LYNQ_RIL_urcBroadcast(p);
152 RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype);
153 //printf("removed apn:%s,apntype:%s\n",apn_table[i].apn,apn_table[i].apntype);
154 break;
155 }
156 }
157 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
158 {
159 RLOGD("for apn_table[%d].apn:%s,apntype:%s,used:%d,apnstatus:%d\n",i,apn_table[i].apn,
160 apn_table[i].apntype,apn_table[i].used,apn_table[i].apnstatus);
161 }
162 }
163 else
164 {
165 /*if the pdn status change,tele-fwk will send pdn status to me.
166 **The reason for the status change may be that enable data call,
167 **the user disable the data call, and the signal is interrupted.
168 */
169 if(apn_count==0)//first new apn has created
170 {
171 RLOGD("first apn_count:%d\n",apn_count);
172 memcpy(apn_table[apn_count].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
173 memcpy(apn_table[apn_count].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
174 memcpy(apn_table[apn_count].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
175 //printf("apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",apn_count,apn_table[apn_count].apn,urc_response->apnName);
176 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);
177 apn_table[apn_count].apnstatus=1;
178 apn_table[apn_count].used=1;
179 apn_table[apn_count].netId=urc_response->netId;
180 apn_count++;
ll90a255c2022-04-07 09:09:55 +0000181 lynqUpdateApnStatus(urc_response->apnName,urc_response->apnType,urc_response->pdnState,urc_response->ifname);
lh7b0674a2022-01-10 00:34:35 -0800182 p.writeInt32(1);
183 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
184 p.writeInt32(0);//temporary plan
185 p.writeInt32(PDN_CONNECTED);
186 writeStringToParcel(p,urc_response->apnName);
187 writeStringToParcel(p,urc_response->apnType);
188 writeStringToParcel(p,urc_response->ifname);
189 android::LYNQ_RIL_urcBroadcast(p);
190 }
191 else
192 {
193 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
194 {
195 RLOGD("for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",i,apn_table[i].apn,urc_response->apnName);
196 if(strcmp(apn_table[i].apn,urc_response->apnName)==0)
197 {
198 RLOGD("This apn has been created!!!");
199 printf("This apn has been created!!!\n");
200 apnHasCreated = TRUE;
201 if(apn_table[i].netId!=urc_response->netId)
202 {
203 apn_table[i].netId=urc_response->netId;
ll90a255c2022-04-07 09:09:55 +0000204 lynqUpdateApnStatus(urc_response->apnName,urc_response->apnType,urc_response->pdnState,urc_response->ifname);
lh7b0674a2022-01-10 00:34:35 -0800205 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
206 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
207 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
208 /*send urc to client
209 send apn_t,apnType_t,urc_response->pdnState,iface_t to client
210 */
211 p.writeInt32(1);
212 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
213 p.writeInt32(0);//temporary plan
214 p.writeInt32(urc_response->pdnState);
215 writeStringToParcel(p,apn_t);
216 writeStringToParcel(p,apnType_t);
217 writeStringToParcel(p,iface_t);
218 android::LYNQ_RIL_urcBroadcast(p);
219 //lynq_data_callback(apn_t,apnType_t,urc_response->pdnState,iface_t);
220 //sprintf(Buf,"+LAPNST:%s,%s,%d,%s\n",apn_table[i].apn,apn_table[i].apntype,urc_response->pdnState,urc_response->ifname);
221 //printf("eBuf:%s\n",Buf);
222 //int n = write(ttyGS3_fd,Buf,strlen(Buf));
223 //if(n<0)
224 //{
225 // perror("lynq resp write:");
226 //}
227 }
228 break;
229 }
230 }
231 if(!apnHasCreated)//new apn has created
232 {
233 bool getLable = FALSE;
234 int lable = 0;
235 for(lable;lable < LYNQ_APN_CHANNEL_MAX;lable++)
236 {
237 if(apn_table[lable].used==0)
238 {
239 getLable = TRUE;
240 break;
241 }
242 }
243 if(getLable)
244 {
245 RLOGD("[getLable]:label==%d\n",lable);
246 memcpy(apn_table[lable].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
247 memcpy(apn_table[lable].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
248 memcpy(apn_table[lable].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
249 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);
250 apn_table[lable].apnstatus=1;
251 apn_table[lable].used=1;
252 apn_table[lable].netId=urc_response->netId;
253 apn_count++;
ll90a255c2022-04-07 09:09:55 +0000254 lynqUpdateApnStatus(urc_response->apnName,urc_response->apnType,urc_response->pdnState,urc_response->ifname);
lh7b0674a2022-01-10 00:34:35 -0800255 p.writeInt32(1);
256 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
257 p.writeInt32(0);//temporary plan
258 p.writeInt32(urc_response->pdnState);
259 writeStringToParcel(p,urc_response->apnName);
260 writeStringToParcel(p,urc_response->apnType);
261 writeStringToParcel(p,urc_response->ifname);
262 android::LYNQ_RIL_urcBroadcast(p);
263 }
264 else
265 {
266 RLOGD("unkown error");
267 }
268 }
269 }
270 }
271 }
272 else
273 {
274 apnHasCreated = FALSE;
275 RLOGD("[cid < 0] apn_count:%d\n",apn_count);
276 if(apn_count>0)
277 {
278 int i = 0;
279 for(i;i < LYNQ_APN_CHANNEL_MAX;i++)
280 {
281 RLOGD("[cid<0]apn_table[%d].apntype:%s,,,,urc_response->apntype:%s\n",i,apn_table[i].apntype,urc_response->apnType);
282 if(strcmp(apn_table[i].apntype,urc_response->apnType)==0)
283 {
284 RLOGD("apntype:%s PDN status has changed!!!\n",urc_response->apnType);
285 apnHasCreated = TRUE;
286 break;
287 }
288 }
289 if(apnHasCreated)
290 {
291 //sprintf(Buf,"+LAPNST:%s,%s,%d\n",apn_table[i].apn,apn_table[i].apntype,urc_response->pdnState);
292 //printf("Buf:%s\n",Buf);
ll90a255c2022-04-07 09:09:55 +0000293 lynqUpdateApnStatus(apn_table[i].apn,apn_table[i].apntype,urc_response->pdnState,NULL);
lh7b0674a2022-01-10 00:34:35 -0800294 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
295 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
296 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
297 p.writeInt32(1);
298 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
299 p.writeInt32(0);//temporary plan
300 p.writeInt32(urc_response->pdnState);
301 writeStringToParcel(p,apn_t);
302 writeStringToParcel(p,apnType_t);
303 writeStringToParcel(p,iface_t);
304 android::LYNQ_RIL_urcBroadcast(p);
305 //int n = write(ttyGS3_fd,Buf,strlen(Buf));
306 //if(n<0)
307 //{
308 // perror("lynq resp write:");
309 //}
310 }
311 }
312 }
313 return 0;
314}
315/*Warren add for t800 ril service 2021/12/25 end*/
316void freeMem(MTK_Data_Call_Response_v1 response)
317{
318 g_free(response.apnType);
319 g_free(response.type);
320 g_free(response.ifname);
321 g_free(response.addresses);
322 g_free(response.dnses);
323 g_free(response.gateways);
324 g_free(response.pcscf);
325}
326
327char* apnState2string(RIL_Data_Call_PdnState apnState) {
328 switch (apnState) {
329 case RIL_Data_Call_PdnState::PDN_CONNECTED:
330 return "PDN_CONNECTED";
331 case RIL_Data_Call_PdnState::PDN_CONNECTING:
332 return "PDN_CONNECTING";
333 case RIL_Data_Call_PdnState::PDN_DISCONNECTED:
334 return "PDN_DISCONNECTED";
335 case RIL_Data_Call_PdnState::PDN_DISCONNECTING:
336 return "PDN_DISCONNECTING";
337 case RIL_Data_Call_PdnState::PDN_FAILED:
338 return "PDN_FAILED";
339 case RIL_Data_Call_PdnState::PDN_IDLE:
340 return "PDN_IDLE";
341 case RIL_Data_Call_PdnState::PDN_RETRYING:
342 return "PDN_RETRYING";
343 case RIL_Data_Call_PdnState::PDN_SCANNING:
344 return "PDN_SCANNING";
345 default:
346 return "UNKNOWN";
347 }
348}
349
350void dumpResponse(MTK_Data_Call_Response_v1 *dataCallResponse)
351{
352 RLOGD("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s,"
353 " protocolType: %s, ifaceName: %s, address: %s, dns: %s, gateway: %s, pcscf: %s, mtu: %d, apn: %s",
354 dataCallResponse->netId, apnState2string(RIL_Data_Call_PdnState(dataCallResponse->pdnState)),
355 dataCallResponse->status, dataCallResponse->cId, dataCallResponse->apnType, dataCallResponse->type,
356 dataCallResponse->ifname, dataCallResponse->addresses, dataCallResponse->dnses,
357 dataCallResponse->gateways, dataCallResponse->pcscf, dataCallResponse->mtu, dataCallResponse->apnName);
358}
359
360void parse(GVariant* result, MTK_Data_Call_Response_v1* data) {
361 g_variant_get(result, "((iiiisssssssis))", &(data->netId),
362 &(data->pdnState), &(data->status),
363 &(data->cId), &(data->apnType), &(data->type),
364 &(data->ifname), &(data->addresses),
365 &(data->dnses), &(data->gateways),
366 &(data->pcscf), &(data->mtu),&(data->apnName));
367}
368
369void proxy_method_cb (GDBusProxy *proxy,
370 GAsyncResult *res,
371 gpointer user_data)
372{
373 RLOGD("method call back");
374 GError *error;
375 GVariant *result;
376
377 error = NULL;
378 result = g_dbus_proxy_call_finish(proxy, res, &error);
379
380 if(error != NULL)
381 {
382 RLOGD("method call back error %s", error->message);
383 g_error_free(error);
384 return;
385 }
386 freeMem(req_response);
387 parse(result, &req_response);
388 dumpResponse(&req_response);
389 g_variant_unref(result);
390}
391
392int enableData (bool isEnable, gchar *apn_type)
393{
394 RLOGD("send: %s, %s", (isEnable ? "TRUE": "FALSE"), apn_type);
395 g_dbus_proxy_call(proxy,
396 "enableData",
397 g_variant_new("(bs)", isEnable, apn_type),
398 G_DBUS_CALL_FLAGS_NONE,
399 -1,
400 NULL,
401 (GAsyncReadyCallback) proxy_method_cb,
402 NULL);
403 return 1;
404}
rjw20006d12022-04-21 16:29:04 +0800405/*Typethree add for t800 RIL Service 2022/04/14 start*/
lh7b0674a2022-01-10 00:34:35 -0800406void modifyApnDB_method_cb (GDBusProxy *proxy,
407 GAsyncResult *res,
408 gpointer user_data)
409{
410 RLOGD("method call back");
411 GError *error;
412 GVariant *result;
413 gchar* reason = NULL;
414
415 error = NULL;
416 result = g_dbus_proxy_call_finish(proxy, res, &error);
417
418 if(error != NULL)
419 {
420 RLOGD("method call back error %s", error->message);
421 printf("modify apn db error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800422 lynq_data_modify_apn(error->message,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800423 g_error_free(error);
424 return;
425 }
426 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
427 g_variant_get (result, "(&s)", &reason);
428 RLOGD("modifyApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
429 printf("modify apn db success, return message: %s\n", ((reason == NULL)? "":reason));
430 //printf("modifyApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
431 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800432 lynq_data_modify_apn(reason,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800433}
434
435int modifyApnDB(int cmd, gchar *record) {
436 RLOGD("%s: cmd: %d, record:%s", __FUNCTION__, cmd, record);
437 g_dbus_proxy_call(proxy,
438 "modifyApnDB",
439 g_variant_new("(is)", cmd, record),
440 G_DBUS_CALL_FLAGS_NONE,
441 -1,
442 NULL,
443 (GAsyncReadyCallback) modifyApnDB_method_cb,
444 NULL);
445 return 1;
446}
447
448void resetApnDB_method_cb (GDBusProxy *proxy,
449 GAsyncResult *res,
450 gpointer user_data)
451{
452 RLOGD("resetApnDB_method_cb call back");
453 GError *error;
454 GVariant *result;
455 gchar* reason = NULL;
456
457 error = NULL;
458 result = g_dbus_proxy_call_finish(proxy, res, &error);
459
460 if(error != NULL)
461 {
462 RLOGD("method call back error %s", error->message);
463 printf("reset apn DB error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800464 lynq_data_modify_apn(error->message,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800465 g_error_free(error);
466 return;
467 }
468 g_variant_get (result, "(&s)", &reason);
469 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
470 RLOGD("resetApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
471 printf("reset apn DB success, return message: %s\n", ((reason == NULL)? "":reason));
472 //printf("resetApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
473 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800474 lynq_data_modify_apn(reason,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800475}
rjw20006d12022-04-21 16:29:04 +0800476/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -0800477
478int resetApnDB() {
479 RLOGD("%s", __FUNCTION__);
480 g_dbus_proxy_call(proxy,
481 "resetApnDB",NULL,
482 G_DBUS_CALL_FLAGS_NONE,
483 -1,
484 NULL,
485 (GAsyncReadyCallback) resetApnDB_method_cb,
486 NULL);
487 return 1;
488}
489
ll90a255c2022-04-07 09:09:55 +0000490
lh7b0674a2022-01-10 00:34:35 -0800491void proxy_signals_on_signal (GDBusProxy *proxy,
492 const gchar *sender_name,
493 const gchar *signal_name,
494 GVariant *parameters,
495 gpointer user_data)
496{
497 RLOGD("signal_name: %s", signal_name);
498 printf("signal_name: %s\n", signal_name);
499 freeMem(urc_response);
500 parse(parameters, &urc_response);
501 dumpResponse(&urc_response);
502 if(g_strcmp0(signal_name, "lynq_data_resp") == 0)
503 {
504 printf("[lynq_data_resp]do something\n");
505 return;
506 }
507 lynq_data_management(&urc_response);
508 if(g_strcmp0(signal_name, "LYNQ_TEST") == 0)
509 {
510 printf("do something\n");
511 }
512 if(g_strcmp0(signal_name, "default") == 0)
513 {
514 if(urc_response.pdnState == RIL_Data_Call_PdnState::PDN_DISCONNECTED) {
515 notifyDataSignal();
xja1c30b82022-01-25 16:13:48 +0800516 } else if (urc_response.pdnState == RIL_Data_Call_PdnState::PDN_FAILED) {
517 updataDataConnectState(get_default_sim_data(), false);
lh7b0674a2022-01-10 00:34:35 -0800518 }
519 }
520 return;
521
522}
523
524void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
525 GError *error;
526
527 error = NULL;
528 proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
529 if (proxy == NULL) {
530 RLOGE("create proxy fail");
531 return ;
532 }
533 RLOGD("proxy is ready");
534 gulong signal_handler_id;
535
536 signal_handler_id = g_signal_connect(proxy, "g-signal",
537 G_CALLBACK (proxy_signals_on_signal), NULL);
538 if (signal_handler_id == 0) {
539 RLOGE("listen singal fail!");
540 }
541}
542
543void* init_data_gdbus_cb(void *param)
544{
545 /* all the tests rely on a shared main loop */
546 loop = g_main_loop_new(NULL, FALSE);
547
548 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
549 G_DBUS_PROXY_FLAGS_NONE,
550 NULL, /* GDBusInterfaceInfo */
551 TELEPHONY_SERVICE, /* name */
552 TELEPHONY_DATA_PATH, /* object path */
553 TELEPHONY_DATA_INTERFACE, /* interface */
554 NULL, /* GCancellable */
555 proxy_ready,
556 NULL);
557
558 g_main_loop_run(loop);
559
560 RLOGD("data gdbus main loop run()");
561 if(proxy != NULL) {
562 g_object_unref (proxy);
563 }
564 if(loop != NULL) {
565 g_main_loop_unref(loop);
566 }
xja1c30b82022-01-25 16:13:48 +0800567 return NULL;
lh7b0674a2022-01-10 00:34:35 -0800568}
569