blob: 5e4f8f5d3fbde82d62150a97e01341233b0b0a1b [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"
52#ifdef LED_SUPPORT
53#include "led.h"
54#endif
lh7b0674a2022-01-10 00:34:35 -080055using android::Parcel;
56
57/*Warren add for t800 ril service 2021/12/25 end*/
58
59#define LOG_TAG "DEMO_DATA_GDBUS"
60#define TELEPHONY_SERVICE "mtk.telephony" /*well-known bus name */
61#define TELEPHONY_DATA_INTERFACE "mtk.telephony.Data" /*interface name*/
62#define TELEPHONY_DATA_PATH "/mtk/telephony/data" /*object name*/
ll62a2b402022-11-16 21:19:04 +080063#define DEBUG 0
lh7b0674a2022-01-10 00:34:35 -080064
65GMainLoop *loop = NULL;
66GDBusProxy *proxy = NULL;
67MTK_Data_Call_Response_v1 req_response;
68MTK_Data_Call_Response_v1 urc_response;
ll90a255c2022-04-07 09:09:55 +000069
ll62a2b402022-11-16 21:19:04 +080070
rjw20006d12022-04-21 16:29:04 +080071/*Typethree add for t800 ril service 2022/04/14 start*/
72
73int lynq_data_modify_apn(gchar *reason,int lynq_request_id)
74{
75 Parcel p;
76 if(reason == NULL)
77 {
78 RLOGD("modify apn reason apn");
79 return -1;
80 }
81 p.writeInt32(1);
82 p.writeInt32(lynq_request_id);
83 p.writeInt32(0);
84 writeStringToParcel(p,reason);
85 android::LYNQ_RIL_urcBroadcast(p);
86 return 0;
87}
88
89/*Typethree add for t800 ril service 2022/04/14 end*/
90
ll90a255c2022-04-07 09:09:55 +000091/*Warren add for t103 szzt atsvc 2022/1/5 start*/
ll62a2b402022-11-16 21:19:04 +080092/*lei modify on 2022/11/16*/
ll62a2b402022-11-16 21:19:04 +080093/*lei modify on 2022/11/16*/
ll90a255c2022-04-07 09:09:55 +000094/*Warren add for t103 szzt atsvc 2022/1/5 end*/
95
lh7b0674a2022-01-10 00:34:35 -080096/*Warren add for t800 ril service 2021/12/25 start*/
97int lynq_data_management(MTK_Data_Call_Response_v1 *urc_response)
98{
99 char apn_t[LYNQ_APN_LEN_MAX] = {};
100 char apnType_t[LYNQ_APNTPYE_LEN_MAX] = {};
101 char iface_t[LYNQ_APNTPYE_LEN_MAX] = {};
102 if(!urc_response)
103 {
104 RLOGD("urc_response is null!!!");
105 return -1;
106 }
107 bool apnHasCreated = FALSE;
lh7b0674a2022-01-10 00:34:35 -0800108 Parcel p;
109 if(urc_response->cId > 0)
110 {
111 if(urc_response->pdnState==PDN_DISCONNECTED)//if user disable data call,the pdn state wiil change to disconnected.
112 {
113 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
114 {
ll62a2b402022-11-16 21:19:04 +0800115 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800116 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 +0800117 #endif
lh7b0674a2022-01-10 00:34:35 -0800118 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);
119 if((strcmp(apn_table[i].apntype,urc_response->apnType)==0)&&(apn_table[i].apnstatus==0))
120 {
121 bzero(apn_table[i].apn,LYNQ_APN_LEN_MAX);
122 bzero(apn_table[i].apntype,LYNQ_APNTPYE_LEN_MAX);
ll62a2b402022-11-16 21:19:04 +0800123 apn_table[i].used = 0;
124 apn_table[i].netId = 0;
125 apn_table[i].pdpstate = PDN_DISCONNECTED;
lh7b0674a2022-01-10 00:34:35 -0800126 apn_count--;
ll6e73f202022-12-28 14:59:46 +0800127 printf("\nOK\n");
lh7b0674a2022-01-10 00:34:35 -0800128 p.writeInt32 (1);
129 p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND);
130 p.writeInt32 (0);//temporary plan
131 p.writeInt32(PDN_DISCONNECTED);
rjw5d2a50e2022-02-28 15:01:49 +0800132 writeStringToParcel(p,urc_response->apnType);
lh7b0674a2022-01-10 00:34:35 -0800133 android::LYNQ_RIL_urcBroadcast(p);
134 RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype);
lh7b0674a2022-01-10 00:34:35 -0800135 break;
136 }
137 }
138 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
139 {
140 RLOGD("for apn_table[%d].apn:%s,apntype:%s,used:%d,apnstatus:%d\n",i,apn_table[i].apn,
141 apn_table[i].apntype,apn_table[i].used,apn_table[i].apnstatus);
142 }
143 }
144 else
145 {
146 /*if the pdn status change,tele-fwk will send pdn status to me.
147 **The reason for the status change may be that enable data call,
148 **the user disable the data call, and the signal is interrupted.
149 */
150 if(apn_count==0)//first new apn has created
151 {
152 RLOGD("first apn_count:%d\n",apn_count);
153 memcpy(apn_table[apn_count].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
154 memcpy(apn_table[apn_count].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
155 memcpy(apn_table[apn_count].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
ll62a2b402022-11-16 21:19:04 +0800156 memcpy(apn_table[apn_count].address,urc_response->addresses,strlen(urc_response->addresses)+1);
157 apn_table[apn_count].pdpstate = urc_response->pdnState;
158 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800159 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 +0800160 #endif
lh7b0674a2022-01-10 00:34:35 -0800161 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);
162 apn_table[apn_count].apnstatus=1;
163 apn_table[apn_count].used=1;
164 apn_table[apn_count].netId=urc_response->netId;
165 apn_count++;
166 p.writeInt32(1);
167 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
168 p.writeInt32(0);//temporary plan
169 p.writeInt32(PDN_CONNECTED);
170 writeStringToParcel(p,urc_response->apnName);
171 writeStringToParcel(p,urc_response->apnType);
172 writeStringToParcel(p,urc_response->ifname);
173 android::LYNQ_RIL_urcBroadcast(p);
174 }
175 else
176 {
ll62a2b402022-11-16 21:19:04 +0800177 for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)//means apn state changed,need update
lh7b0674a2022-01-10 00:34:35 -0800178 {
ll62a2b402022-11-16 21:19:04 +0800179 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800180 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 +0800181 #endif
lh7b0674a2022-01-10 00:34:35 -0800182 RLOGD("for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",i,apn_table[i].apn,urc_response->apnName);
183 if(strcmp(apn_table[i].apn,urc_response->apnName)==0)
184 {
ll62a2b402022-11-16 21:19:04 +0800185 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800186 printf("line %d This apn has been created update???!!!\n",__LINE__);
ll62a2b402022-11-16 21:19:04 +0800187 #endif
lh7b0674a2022-01-10 00:34:35 -0800188 RLOGD("This apn has been created!!!");
lh7b0674a2022-01-10 00:34:35 -0800189 apnHasCreated = TRUE;
190 if(apn_table[i].netId!=urc_response->netId)
191 {
ll62a2b402022-11-16 21:19:04 +0800192 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800193 printf("update???\n");
ll62a2b402022-11-16 21:19:04 +0800194 #endif
195 apn_table[i].netId = urc_response->netId;
196 apn_table[i].pdpstate = urc_response->pdnState;
197 memcpy(apn_table[i].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
198 memcpy(apn_table[i].address,urc_response->addresses,strlen(urc_response->addresses)+1);
lh7b0674a2022-01-10 00:34:35 -0800199 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
200 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
201 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
202 /*send urc to client
203 send apn_t,apnType_t,urc_response->pdnState,iface_t to client
204 */
205 p.writeInt32(1);
206 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
207 p.writeInt32(0);//temporary plan
208 p.writeInt32(urc_response->pdnState);
209 writeStringToParcel(p,apn_t);
210 writeStringToParcel(p,apnType_t);
211 writeStringToParcel(p,iface_t);
212 android::LYNQ_RIL_urcBroadcast(p);
lh7b0674a2022-01-10 00:34:35 -0800213 }
214 break;
215 }
216 }
ll62a2b402022-11-16 21:19:04 +0800217 if(!apnHasCreated)//Multiple APNs are established new apn has created
lh7b0674a2022-01-10 00:34:35 -0800218 {
219 bool getLable = FALSE;
220 int lable = 0;
ll62a2b402022-11-16 21:19:04 +0800221 for(lable;lable < LYNQ_APN_CHANNEL_MAX;lable++)//to find not used array element subscript
lh7b0674a2022-01-10 00:34:35 -0800222 {
223 if(apn_table[lable].used==0)
224 {
225 getLable = TRUE;
226 break;
227 }
228 }
229 if(getLable)
230 {
ll62a2b402022-11-16 21:19:04 +0800231 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800232 printf("line %d Multiple APNs are established\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800233 #endif
lh7b0674a2022-01-10 00:34:35 -0800234 RLOGD("[getLable]:label==%d\n",lable);
235 memcpy(apn_table[lable].apn,urc_response->apnName,strlen(urc_response->apnName)+1);
236 memcpy(apn_table[lable].apntype,urc_response->apnType,strlen(urc_response->apnType)+1);
237 memcpy(apn_table[lable].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1);
ll62a2b402022-11-16 21:19:04 +0800238 apn_table[lable].pdpstate = urc_response->pdnState;
239 memcpy(apn_table[lable].address,urc_response->addresses,strlen(urc_response->addresses)+1);
lh7b0674a2022-01-10 00:34:35 -0800240 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);
241 apn_table[lable].apnstatus=1;
242 apn_table[lable].used=1;
243 apn_table[lable].netId=urc_response->netId;
244 apn_count++;
245 p.writeInt32(1);
246 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
247 p.writeInt32(0);//temporary plan
248 p.writeInt32(urc_response->pdnState);
249 writeStringToParcel(p,urc_response->apnName);
250 writeStringToParcel(p,urc_response->apnType);
251 writeStringToParcel(p,urc_response->ifname);
252 android::LYNQ_RIL_urcBroadcast(p);
253 }
254 else
255 {
256 RLOGD("unkown error");
257 }
258 }
259 }
260 }
261 }
ll62a2b402022-11-16 21:19:04 +0800262 else //cid < 0 it means:when at+cfun=0 will into this or when connecting
lh7b0674a2022-01-10 00:34:35 -0800263 {
264 apnHasCreated = FALSE;
265 RLOGD("[cid < 0] apn_count:%d\n",apn_count);
266 if(apn_count>0)
267 {
268 int i = 0;
269 for(i;i < LYNQ_APN_CHANNEL_MAX;i++)
270 {
ll62a2b402022-11-16 21:19:04 +0800271 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800272 printf("line %d don't know\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800273 #endif
lh7b0674a2022-01-10 00:34:35 -0800274 RLOGD("[cid<0]apn_table[%d].apntype:%s,,,,urc_response->apntype:%s\n",i,apn_table[i].apntype,urc_response->apnType);
275 if(strcmp(apn_table[i].apntype,urc_response->apnType)==0)
276 {
277 RLOGD("apntype:%s PDN status has changed!!!\n",urc_response->apnType);
278 apnHasCreated = TRUE;
279 break;
280 }
281 }
282 if(apnHasCreated)
283 {
ll62a2b402022-11-16 21:19:04 +0800284 #if DEBUG
ll6e73f202022-12-28 14:59:46 +0800285 printf("line %d don't know\n", __LINE__);
ll62a2b402022-11-16 21:19:04 +0800286 #endif
287 apn_table[i].pdpstate = urc_response->pdnState;
288 char ptr[1] = "";
289 if(NULL == urc_response->ifname)
290 {
291 memcpy(apn_table[i].ifaceName, ptr,strlen(ptr)+1);
292 }
293 if(NULL == urc_response->addresses)
294 {
295 memcpy(apn_table[i].address, ptr, strlen(ptr)+1);
296 }
lh7b0674a2022-01-10 00:34:35 -0800297 memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1);
298 memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1);
299 memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1);
300 p.writeInt32(1);
301 p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND);
302 p.writeInt32(0);//temporary plan
303 p.writeInt32(urc_response->pdnState);
304 writeStringToParcel(p,apn_t);
305 writeStringToParcel(p,apnType_t);
306 writeStringToParcel(p,iface_t);
307 android::LYNQ_RIL_urcBroadcast(p);
lh7b0674a2022-01-10 00:34:35 -0800308 }
309 }
310 }
311 return 0;
312}
313/*Warren add for t800 ril service 2021/12/25 end*/
314void freeMem(MTK_Data_Call_Response_v1 response)
315{
316 g_free(response.apnType);
317 g_free(response.type);
318 g_free(response.ifname);
319 g_free(response.addresses);
320 g_free(response.dnses);
321 g_free(response.gateways);
322 g_free(response.pcscf);
323}
324
325char* apnState2string(RIL_Data_Call_PdnState apnState) {
326 switch (apnState) {
327 case RIL_Data_Call_PdnState::PDN_CONNECTED:
328 return "PDN_CONNECTED";
329 case RIL_Data_Call_PdnState::PDN_CONNECTING:
330 return "PDN_CONNECTING";
331 case RIL_Data_Call_PdnState::PDN_DISCONNECTED:
332 return "PDN_DISCONNECTED";
333 case RIL_Data_Call_PdnState::PDN_DISCONNECTING:
334 return "PDN_DISCONNECTING";
335 case RIL_Data_Call_PdnState::PDN_FAILED:
336 return "PDN_FAILED";
337 case RIL_Data_Call_PdnState::PDN_IDLE:
338 return "PDN_IDLE";
339 case RIL_Data_Call_PdnState::PDN_RETRYING:
340 return "PDN_RETRYING";
341 case RIL_Data_Call_PdnState::PDN_SCANNING:
342 return "PDN_SCANNING";
343 default:
344 return "UNKNOWN";
345 }
346}
347
348void dumpResponse(MTK_Data_Call_Response_v1 *dataCallResponse)
349{
350 RLOGD("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s,"
351 " protocolType: %s, ifaceName: %s, address: %s, dns: %s, gateway: %s, pcscf: %s, mtu: %d, apn: %s",
352 dataCallResponse->netId, apnState2string(RIL_Data_Call_PdnState(dataCallResponse->pdnState)),
353 dataCallResponse->status, dataCallResponse->cId, dataCallResponse->apnType, dataCallResponse->type,
354 dataCallResponse->ifname, dataCallResponse->addresses, dataCallResponse->dnses,
355 dataCallResponse->gateways, dataCallResponse->pcscf, dataCallResponse->mtu, dataCallResponse->apnName);
356}
357
358void parse(GVariant* result, MTK_Data_Call_Response_v1* data) {
359 g_variant_get(result, "((iiiisssssssis))", &(data->netId),
360 &(data->pdnState), &(data->status),
361 &(data->cId), &(data->apnType), &(data->type),
362 &(data->ifname), &(data->addresses),
363 &(data->dnses), &(data->gateways),
364 &(data->pcscf), &(data->mtu),&(data->apnName));
365}
366
367void proxy_method_cb (GDBusProxy *proxy,
368 GAsyncResult *res,
369 gpointer user_data)
370{
371 RLOGD("method call back");
372 GError *error;
373 GVariant *result;
374
375 error = NULL;
376 result = g_dbus_proxy_call_finish(proxy, res, &error);
377
378 if(error != NULL)
379 {
380 RLOGD("method call back error %s", error->message);
381 g_error_free(error);
382 return;
383 }
384 freeMem(req_response);
385 parse(result, &req_response);
386 dumpResponse(&req_response);
387 g_variant_unref(result);
388}
389
390int enableData (bool isEnable, gchar *apn_type)
391{
392 RLOGD("send: %s, %s", (isEnable ? "TRUE": "FALSE"), apn_type);
393 g_dbus_proxy_call(proxy,
394 "enableData",
395 g_variant_new("(bs)", isEnable, apn_type),
396 G_DBUS_CALL_FLAGS_NONE,
397 -1,
398 NULL,
399 (GAsyncReadyCallback) proxy_method_cb,
400 NULL);
401 return 1;
402}
rjw20006d12022-04-21 16:29:04 +0800403/*Typethree add for t800 RIL Service 2022/04/14 start*/
lh7b0674a2022-01-10 00:34:35 -0800404void modifyApnDB_method_cb (GDBusProxy *proxy,
405 GAsyncResult *res,
406 gpointer user_data)
407{
408 RLOGD("method call back");
409 GError *error;
410 GVariant *result;
411 gchar* reason = NULL;
412
413 error = NULL;
414 result = g_dbus_proxy_call_finish(proxy, res, &error);
415
416 if(error != NULL)
417 {
418 RLOGD("method call back error %s", error->message);
419 printf("modify apn db error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800420 lynq_data_modify_apn(error->message,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800421 g_error_free(error);
422 return;
423 }
424 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
425 g_variant_get (result, "(&s)", &reason);
426 RLOGD("modifyApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
427 printf("modify apn db success, return message: %s\n", ((reason == NULL)? "":reason));
428 //printf("modifyApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
ll6e73f202022-12-28 14:59:46 +0800429 /*lei add for AT+LEAPNMOD*/
430 char apn_buf[1024];
431 sprintf(apn_buf, "+LEAPNMOD:%s", ((reason == NULL)? "":reason));
432 ATCIResponseNoToken(0, apn_buf, 666);//tmp plan
433 /*lei add for AT+LEAPNMOD*/
lh7b0674a2022-01-10 00:34:35 -0800434 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800435 lynq_data_modify_apn(reason,LYNQ_URC_MODIFY_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800436}
437
438int modifyApnDB(int cmd, gchar *record) {
439 RLOGD("%s: cmd: %d, record:%s", __FUNCTION__, cmd, record);
440 g_dbus_proxy_call(proxy,
441 "modifyApnDB",
442 g_variant_new("(is)", cmd, record),
443 G_DBUS_CALL_FLAGS_NONE,
444 -1,
445 NULL,
446 (GAsyncReadyCallback) modifyApnDB_method_cb,
447 NULL);
448 return 1;
449}
450
451void resetApnDB_method_cb (GDBusProxy *proxy,
452 GAsyncResult *res,
453 gpointer user_data)
454{
455 RLOGD("resetApnDB_method_cb call back");
456 GError *error;
457 GVariant *result;
458 gchar* reason = NULL;
459
460 error = NULL;
461 result = g_dbus_proxy_call_finish(proxy, res, &error);
462
463 if(error != NULL)
464 {
465 RLOGD("method call back error %s", error->message);
466 printf("reset apn DB error: %s\n", error->message);
rjw20006d12022-04-21 16:29:04 +0800467 lynq_data_modify_apn(error->message,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800468 g_error_free(error);
469 return;
470 }
471 g_variant_get (result, "(&s)", &reason);
472 //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL));
473 RLOGD("resetApnDB_method_cb reason %s", ((reason == NULL)? "":reason));
474 printf("reset apn DB success, return message: %s\n", ((reason == NULL)? "":reason));
475 //printf("resetApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason));
476 g_variant_unref(result);
rjw20006d12022-04-21 16:29:04 +0800477 lynq_data_modify_apn(reason,LYNQ_URC_RESET_APNDB);
lh7b0674a2022-01-10 00:34:35 -0800478}
rjw20006d12022-04-21 16:29:04 +0800479/*Typethree add for t800 RIL Service 2022/04/14 end*/
lh7b0674a2022-01-10 00:34:35 -0800480
481int resetApnDB() {
482 RLOGD("%s", __FUNCTION__);
483 g_dbus_proxy_call(proxy,
484 "resetApnDB",NULL,
485 G_DBUS_CALL_FLAGS_NONE,
486 -1,
487 NULL,
488 (GAsyncReadyCallback) resetApnDB_method_cb,
489 NULL);
490 return 1;
491}
492
ll90a255c2022-04-07 09:09:55 +0000493
lh7b0674a2022-01-10 00:34:35 -0800494void proxy_signals_on_signal (GDBusProxy *proxy,
495 const gchar *sender_name,
496 const gchar *signal_name,
497 GVariant *parameters,
498 gpointer user_data)
499{
500 RLOGD("signal_name: %s", signal_name);
501 printf("signal_name: %s\n", signal_name);
502 freeMem(urc_response);
503 parse(parameters, &urc_response);
504 dumpResponse(&urc_response);
505 if(g_strcmp0(signal_name, "lynq_data_resp") == 0)
506 {
507 printf("[lynq_data_resp]do something\n");
508 return;
509 }
510 lynq_data_management(&urc_response);
511 if(g_strcmp0(signal_name, "LYNQ_TEST") == 0)
512 {
513 printf("do something\n");
514 }
515 if(g_strcmp0(signal_name, "default") == 0)
516 {
517 if(urc_response.pdnState == RIL_Data_Call_PdnState::PDN_DISCONNECTED) {
518 notifyDataSignal();
xja1c30b82022-01-25 16:13:48 +0800519 } else if (urc_response.pdnState == RIL_Data_Call_PdnState::PDN_FAILED) {
520 updataDataConnectState(get_default_sim_data(), false);
lh7b0674a2022-01-10 00:34:35 -0800521 }
522 }
523 return;
524
525}
526
527void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
528 GError *error;
529
530 error = NULL;
531 proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
532 if (proxy == NULL) {
533 RLOGE("create proxy fail");
534 return ;
535 }
536 RLOGD("proxy is ready");
537 gulong signal_handler_id;
538
539 signal_handler_id = g_signal_connect(proxy, "g-signal",
540 G_CALLBACK (proxy_signals_on_signal), NULL);
541 if (signal_handler_id == 0) {
542 RLOGE("listen singal fail!");
543 }
544}
545
546void* init_data_gdbus_cb(void *param)
547{
548 /* all the tests rely on a shared main loop */
549 loop = g_main_loop_new(NULL, FALSE);
550
551 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
552 G_DBUS_PROXY_FLAGS_NONE,
553 NULL, /* GDBusInterfaceInfo */
554 TELEPHONY_SERVICE, /* name */
555 TELEPHONY_DATA_PATH, /* object path */
556 TELEPHONY_DATA_INTERFACE, /* interface */
557 NULL, /* GCancellable */
558 proxy_ready,
559 NULL);
560
561 g_main_loop_run(loop);
562
563 RLOGD("data gdbus main loop run()");
564 if(proxy != NULL) {
565 g_object_unref (proxy);
566 }
567 if(loop != NULL) {
568 g_main_loop_unref(loop);
569 }
xja1c30b82022-01-25 16:13:48 +0800570 return NULL;
lh7b0674a2022-01-10 00:34:35 -0800571}
572