lh | b07f4e1 | 2022-02-17 22:08:54 -0800 | [diff] [blame] | 1 | //SPDX-License-Identifier: MediaTekProprietary |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 2 | /* 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> |
| 41 | extern "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> |
| 51 | using 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 | |
| 60 | GMainLoop *loop = NULL; |
| 61 | GDBusProxy *proxy = NULL; |
| 62 | MTK_Data_Call_Response_v1 req_response; |
| 63 | MTK_Data_Call_Response_v1 urc_response; |
| 64 | /*Warren add for t800 ril service 2021/12/25 start*/ |
| 65 | int lynq_data_management(MTK_Data_Call_Response_v1 *urc_response) |
| 66 | { |
| 67 | char apn_t[LYNQ_APN_LEN_MAX] = {}; |
| 68 | char apnType_t[LYNQ_APNTPYE_LEN_MAX] = {}; |
| 69 | char iface_t[LYNQ_APNTPYE_LEN_MAX] = {}; |
| 70 | if(!urc_response) |
| 71 | { |
| 72 | RLOGD("urc_response is null!!!"); |
| 73 | return -1; |
| 74 | } |
| 75 | bool apnHasCreated = FALSE; |
| 76 | char Buf[1024] = {0}; |
| 77 | bzero(Buf, 1024); |
| 78 | Parcel p; |
| 79 | if(urc_response->cId > 0) |
| 80 | { |
| 81 | if(urc_response->pdnState==PDN_DISCONNECTED)//if user disable data call,the pdn state wiil change to disconnected. |
| 82 | { |
| 83 | for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++) |
| 84 | { |
| 85 | //printf("data test 002:count:%d\n",i); |
| 86 | 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); |
| 87 | if((strcmp(apn_table[i].apntype,urc_response->apnType)==0)&&(apn_table[i].apnstatus==0)) |
| 88 | { |
| 89 | bzero(apn_table[i].apn,LYNQ_APN_LEN_MAX); |
| 90 | bzero(apn_table[i].apntype,LYNQ_APNTPYE_LEN_MAX); |
| 91 | apn_table[i].used=0; |
| 92 | apn_table[i].netId=0; |
| 93 | apn_count--; |
| 94 | p.writeInt32 (1); |
| 95 | p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND); |
| 96 | p.writeInt32 (0);//temporary plan |
| 97 | p.writeInt32(PDN_DISCONNECTED); |
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame^] | 98 | writeStringToParcel(p,urc_response->apnType); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 99 | android::LYNQ_RIL_urcBroadcast(p); |
| 100 | RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype); |
| 101 | //printf("removed apn:%s,apntype:%s\n",apn_table[i].apn,apn_table[i].apntype); |
| 102 | break; |
| 103 | } |
| 104 | } |
| 105 | for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++) |
| 106 | { |
| 107 | RLOGD("for apn_table[%d].apn:%s,apntype:%s,used:%d,apnstatus:%d\n",i,apn_table[i].apn, |
| 108 | apn_table[i].apntype,apn_table[i].used,apn_table[i].apnstatus); |
| 109 | } |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | /*if the pdn status change,tele-fwk will send pdn status to me. |
| 114 | **The reason for the status change may be that enable data call, |
| 115 | **the user disable the data call, and the signal is interrupted. |
| 116 | */ |
| 117 | if(apn_count==0)//first new apn has created |
| 118 | { |
| 119 | RLOGD("first apn_count:%d\n",apn_count); |
| 120 | memcpy(apn_table[apn_count].apn,urc_response->apnName,strlen(urc_response->apnName)+1); |
| 121 | memcpy(apn_table[apn_count].apntype,urc_response->apnType,strlen(urc_response->apnType)+1); |
| 122 | memcpy(apn_table[apn_count].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1); |
| 123 | //printf("apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",apn_count,apn_table[apn_count].apn,urc_response->apnName); |
| 124 | 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); |
| 125 | apn_table[apn_count].apnstatus=1; |
| 126 | apn_table[apn_count].used=1; |
| 127 | apn_table[apn_count].netId=urc_response->netId; |
| 128 | apn_count++; |
| 129 | p.writeInt32(1); |
| 130 | p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND); |
| 131 | p.writeInt32(0);//temporary plan |
| 132 | p.writeInt32(PDN_CONNECTED); |
| 133 | writeStringToParcel(p,urc_response->apnName); |
| 134 | writeStringToParcel(p,urc_response->apnType); |
| 135 | writeStringToParcel(p,urc_response->ifname); |
| 136 | android::LYNQ_RIL_urcBroadcast(p); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++) |
| 141 | { |
| 142 | RLOGD("for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",i,apn_table[i].apn,urc_response->apnName); |
| 143 | if(strcmp(apn_table[i].apn,urc_response->apnName)==0) |
| 144 | { |
| 145 | RLOGD("This apn has been created!!!"); |
| 146 | printf("This apn has been created!!!\n"); |
| 147 | apnHasCreated = TRUE; |
| 148 | if(apn_table[i].netId!=urc_response->netId) |
| 149 | { |
| 150 | apn_table[i].netId=urc_response->netId; |
| 151 | memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1); |
| 152 | memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1); |
| 153 | memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1); |
| 154 | /*send urc to client |
| 155 | send apn_t,apnType_t,urc_response->pdnState,iface_t to client |
| 156 | */ |
| 157 | p.writeInt32(1); |
| 158 | p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND); |
| 159 | p.writeInt32(0);//temporary plan |
| 160 | p.writeInt32(urc_response->pdnState); |
| 161 | writeStringToParcel(p,apn_t); |
| 162 | writeStringToParcel(p,apnType_t); |
| 163 | writeStringToParcel(p,iface_t); |
| 164 | android::LYNQ_RIL_urcBroadcast(p); |
| 165 | //lynq_data_callback(apn_t,apnType_t,urc_response->pdnState,iface_t); |
| 166 | //sprintf(Buf,"+LAPNST:%s,%s,%d,%s\n",apn_table[i].apn,apn_table[i].apntype,urc_response->pdnState,urc_response->ifname); |
| 167 | //printf("eBuf:%s\n",Buf); |
| 168 | //int n = write(ttyGS3_fd,Buf,strlen(Buf)); |
| 169 | //if(n<0) |
| 170 | //{ |
| 171 | // perror("lynq resp write:"); |
| 172 | //} |
| 173 | } |
| 174 | break; |
| 175 | } |
| 176 | } |
| 177 | if(!apnHasCreated)//new apn has created |
| 178 | { |
| 179 | bool getLable = FALSE; |
| 180 | int lable = 0; |
| 181 | for(lable;lable < LYNQ_APN_CHANNEL_MAX;lable++) |
| 182 | { |
| 183 | if(apn_table[lable].used==0) |
| 184 | { |
| 185 | getLable = TRUE; |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | if(getLable) |
| 190 | { |
| 191 | RLOGD("[getLable]:label==%d\n",lable); |
| 192 | memcpy(apn_table[lable].apn,urc_response->apnName,strlen(urc_response->apnName)+1); |
| 193 | memcpy(apn_table[lable].apntype,urc_response->apnType,strlen(urc_response->apnType)+1); |
| 194 | memcpy(apn_table[lable].ifaceName,urc_response->ifname,strlen(urc_response->ifname)+1); |
| 195 | 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); |
| 196 | apn_table[lable].apnstatus=1; |
| 197 | apn_table[lable].used=1; |
| 198 | apn_table[lable].netId=urc_response->netId; |
| 199 | apn_count++; |
| 200 | p.writeInt32(1); |
| 201 | p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND); |
| 202 | p.writeInt32(0);//temporary plan |
| 203 | p.writeInt32(urc_response->pdnState); |
| 204 | writeStringToParcel(p,urc_response->apnName); |
| 205 | writeStringToParcel(p,urc_response->apnType); |
| 206 | writeStringToParcel(p,urc_response->ifname); |
| 207 | android::LYNQ_RIL_urcBroadcast(p); |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | RLOGD("unkown error"); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | apnHasCreated = FALSE; |
| 220 | RLOGD("[cid < 0] apn_count:%d\n",apn_count); |
| 221 | if(apn_count>0) |
| 222 | { |
| 223 | int i = 0; |
| 224 | for(i;i < LYNQ_APN_CHANNEL_MAX;i++) |
| 225 | { |
| 226 | RLOGD("[cid<0]apn_table[%d].apntype:%s,,,,urc_response->apntype:%s\n",i,apn_table[i].apntype,urc_response->apnType); |
| 227 | if(strcmp(apn_table[i].apntype,urc_response->apnType)==0) |
| 228 | { |
| 229 | RLOGD("apntype:%s PDN status has changed!!!\n",urc_response->apnType); |
| 230 | apnHasCreated = TRUE; |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | if(apnHasCreated) |
| 235 | { |
| 236 | //sprintf(Buf,"+LAPNST:%s,%s,%d\n",apn_table[i].apn,apn_table[i].apntype,urc_response->pdnState); |
| 237 | //printf("Buf:%s\n",Buf); |
| 238 | memcpy(iface_t,apn_table[i].ifaceName,strlen(apn_table[i].ifaceName)+1); |
| 239 | memcpy(apnType_t,apn_table[i].apntype,strlen(apn_table[i].apntype)+1); |
| 240 | memcpy(apn_t,apn_table[i].apn,strlen(apn_table[i].apn)+1); |
| 241 | p.writeInt32(1); |
| 242 | p.writeInt32(LYNQ_URC_DATA_CALL_STATUS_IND); |
| 243 | p.writeInt32(0);//temporary plan |
| 244 | p.writeInt32(urc_response->pdnState); |
| 245 | writeStringToParcel(p,apn_t); |
| 246 | writeStringToParcel(p,apnType_t); |
| 247 | writeStringToParcel(p,iface_t); |
| 248 | android::LYNQ_RIL_urcBroadcast(p); |
| 249 | //int n = write(ttyGS3_fd,Buf,strlen(Buf)); |
| 250 | //if(n<0) |
| 251 | //{ |
| 252 | // perror("lynq resp write:"); |
| 253 | //} |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | return 0; |
| 258 | } |
| 259 | /*Warren add for t800 ril service 2021/12/25 end*/ |
| 260 | void freeMem(MTK_Data_Call_Response_v1 response) |
| 261 | { |
| 262 | g_free(response.apnType); |
| 263 | g_free(response.type); |
| 264 | g_free(response.ifname); |
| 265 | g_free(response.addresses); |
| 266 | g_free(response.dnses); |
| 267 | g_free(response.gateways); |
| 268 | g_free(response.pcscf); |
| 269 | } |
| 270 | |
| 271 | char* apnState2string(RIL_Data_Call_PdnState apnState) { |
| 272 | switch (apnState) { |
| 273 | case RIL_Data_Call_PdnState::PDN_CONNECTED: |
| 274 | return "PDN_CONNECTED"; |
| 275 | case RIL_Data_Call_PdnState::PDN_CONNECTING: |
| 276 | return "PDN_CONNECTING"; |
| 277 | case RIL_Data_Call_PdnState::PDN_DISCONNECTED: |
| 278 | return "PDN_DISCONNECTED"; |
| 279 | case RIL_Data_Call_PdnState::PDN_DISCONNECTING: |
| 280 | return "PDN_DISCONNECTING"; |
| 281 | case RIL_Data_Call_PdnState::PDN_FAILED: |
| 282 | return "PDN_FAILED"; |
| 283 | case RIL_Data_Call_PdnState::PDN_IDLE: |
| 284 | return "PDN_IDLE"; |
| 285 | case RIL_Data_Call_PdnState::PDN_RETRYING: |
| 286 | return "PDN_RETRYING"; |
| 287 | case RIL_Data_Call_PdnState::PDN_SCANNING: |
| 288 | return "PDN_SCANNING"; |
| 289 | default: |
| 290 | return "UNKNOWN"; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void dumpResponse(MTK_Data_Call_Response_v1 *dataCallResponse) |
| 295 | { |
| 296 | RLOGD("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s," |
| 297 | " protocolType: %s, ifaceName: %s, address: %s, dns: %s, gateway: %s, pcscf: %s, mtu: %d, apn: %s", |
| 298 | dataCallResponse->netId, apnState2string(RIL_Data_Call_PdnState(dataCallResponse->pdnState)), |
| 299 | dataCallResponse->status, dataCallResponse->cId, dataCallResponse->apnType, dataCallResponse->type, |
| 300 | dataCallResponse->ifname, dataCallResponse->addresses, dataCallResponse->dnses, |
| 301 | dataCallResponse->gateways, dataCallResponse->pcscf, dataCallResponse->mtu, dataCallResponse->apnName); |
| 302 | } |
| 303 | |
| 304 | void parse(GVariant* result, MTK_Data_Call_Response_v1* data) { |
| 305 | g_variant_get(result, "((iiiisssssssis))", &(data->netId), |
| 306 | &(data->pdnState), &(data->status), |
| 307 | &(data->cId), &(data->apnType), &(data->type), |
| 308 | &(data->ifname), &(data->addresses), |
| 309 | &(data->dnses), &(data->gateways), |
| 310 | &(data->pcscf), &(data->mtu),&(data->apnName)); |
| 311 | } |
| 312 | |
| 313 | void proxy_method_cb (GDBusProxy *proxy, |
| 314 | GAsyncResult *res, |
| 315 | gpointer user_data) |
| 316 | { |
| 317 | RLOGD("method call back"); |
| 318 | GError *error; |
| 319 | GVariant *result; |
| 320 | |
| 321 | error = NULL; |
| 322 | result = g_dbus_proxy_call_finish(proxy, res, &error); |
| 323 | |
| 324 | if(error != NULL) |
| 325 | { |
| 326 | RLOGD("method call back error %s", error->message); |
| 327 | g_error_free(error); |
| 328 | return; |
| 329 | } |
| 330 | freeMem(req_response); |
| 331 | parse(result, &req_response); |
| 332 | dumpResponse(&req_response); |
| 333 | g_variant_unref(result); |
| 334 | } |
| 335 | |
| 336 | int enableData (bool isEnable, gchar *apn_type) |
| 337 | { |
| 338 | RLOGD("send: %s, %s", (isEnable ? "TRUE": "FALSE"), apn_type); |
| 339 | g_dbus_proxy_call(proxy, |
| 340 | "enableData", |
| 341 | g_variant_new("(bs)", isEnable, apn_type), |
| 342 | G_DBUS_CALL_FLAGS_NONE, |
| 343 | -1, |
| 344 | NULL, |
| 345 | (GAsyncReadyCallback) proxy_method_cb, |
| 346 | NULL); |
| 347 | return 1; |
| 348 | } |
| 349 | |
| 350 | void modifyApnDB_method_cb (GDBusProxy *proxy, |
| 351 | GAsyncResult *res, |
| 352 | gpointer user_data) |
| 353 | { |
| 354 | RLOGD("method call back"); |
| 355 | GError *error; |
| 356 | GVariant *result; |
| 357 | gchar* reason = NULL; |
| 358 | |
| 359 | error = NULL; |
| 360 | result = g_dbus_proxy_call_finish(proxy, res, &error); |
| 361 | |
| 362 | if(error != NULL) |
| 363 | { |
| 364 | RLOGD("method call back error %s", error->message); |
| 365 | printf("modify apn db error: %s\n", error->message); |
| 366 | g_error_free(error); |
| 367 | return; |
| 368 | } |
| 369 | //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL)); |
| 370 | g_variant_get (result, "(&s)", &reason); |
| 371 | RLOGD("modifyApnDB_method_cb reason %s", ((reason == NULL)? "":reason)); |
| 372 | printf("modify apn db success, return message: %s\n", ((reason == NULL)? "":reason)); |
| 373 | //printf("modifyApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason)); |
| 374 | g_variant_unref(result); |
| 375 | } |
| 376 | |
| 377 | int modifyApnDB(int cmd, gchar *record) { |
| 378 | RLOGD("%s: cmd: %d, record:%s", __FUNCTION__, cmd, record); |
| 379 | g_dbus_proxy_call(proxy, |
| 380 | "modifyApnDB", |
| 381 | g_variant_new("(is)", cmd, record), |
| 382 | G_DBUS_CALL_FLAGS_NONE, |
| 383 | -1, |
| 384 | NULL, |
| 385 | (GAsyncReadyCallback) modifyApnDB_method_cb, |
| 386 | NULL); |
| 387 | return 1; |
| 388 | } |
| 389 | |
| 390 | void resetApnDB_method_cb (GDBusProxy *proxy, |
| 391 | GAsyncResult *res, |
| 392 | gpointer user_data) |
| 393 | { |
| 394 | RLOGD("resetApnDB_method_cb call back"); |
| 395 | GError *error; |
| 396 | GVariant *result; |
| 397 | gchar* reason = NULL; |
| 398 | |
| 399 | error = NULL; |
| 400 | result = g_dbus_proxy_call_finish(proxy, res, &error); |
| 401 | |
| 402 | if(error != NULL) |
| 403 | { |
| 404 | RLOGD("method call back error %s", error->message); |
| 405 | printf("reset apn DB error: %s\n", error->message); |
| 406 | g_error_free(error); |
| 407 | return; |
| 408 | } |
| 409 | g_variant_get (result, "(&s)", &reason); |
| 410 | //reason = const_cast<gchar*>(g_variant_dup_string(result, NULL)); |
| 411 | RLOGD("resetApnDB_method_cb reason %s", ((reason == NULL)? "":reason)); |
| 412 | printf("reset apn DB success, return message: %s\n", ((reason == NULL)? "":reason)); |
| 413 | //printf("resetApnDB_method_cb reason %s\n", ((reason == NULL)? "":reason)); |
| 414 | g_variant_unref(result); |
| 415 | } |
| 416 | |
| 417 | int resetApnDB() { |
| 418 | RLOGD("%s", __FUNCTION__); |
| 419 | g_dbus_proxy_call(proxy, |
| 420 | "resetApnDB",NULL, |
| 421 | G_DBUS_CALL_FLAGS_NONE, |
| 422 | -1, |
| 423 | NULL, |
| 424 | (GAsyncReadyCallback) resetApnDB_method_cb, |
| 425 | NULL); |
| 426 | return 1; |
| 427 | } |
| 428 | |
| 429 | void proxy_signals_on_signal (GDBusProxy *proxy, |
| 430 | const gchar *sender_name, |
| 431 | const gchar *signal_name, |
| 432 | GVariant *parameters, |
| 433 | gpointer user_data) |
| 434 | { |
| 435 | RLOGD("signal_name: %s", signal_name); |
| 436 | printf("signal_name: %s\n", signal_name); |
| 437 | freeMem(urc_response); |
| 438 | parse(parameters, &urc_response); |
| 439 | dumpResponse(&urc_response); |
| 440 | if(g_strcmp0(signal_name, "lynq_data_resp") == 0) |
| 441 | { |
| 442 | printf("[lynq_data_resp]do something\n"); |
| 443 | return; |
| 444 | } |
| 445 | lynq_data_management(&urc_response); |
| 446 | if(g_strcmp0(signal_name, "LYNQ_TEST") == 0) |
| 447 | { |
| 448 | printf("do something\n"); |
| 449 | } |
| 450 | if(g_strcmp0(signal_name, "default") == 0) |
| 451 | { |
| 452 | if(urc_response.pdnState == RIL_Data_Call_PdnState::PDN_DISCONNECTED) { |
| 453 | notifyDataSignal(); |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 454 | } else if (urc_response.pdnState == RIL_Data_Call_PdnState::PDN_FAILED) { |
| 455 | updataDataConnectState(get_default_sim_data(), false); |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 456 | } |
| 457 | } |
| 458 | return; |
| 459 | |
| 460 | } |
| 461 | |
| 462 | void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) { |
| 463 | GError *error; |
| 464 | |
| 465 | error = NULL; |
| 466 | proxy = g_dbus_proxy_new_for_bus_finish(result, &error); |
| 467 | if (proxy == NULL) { |
| 468 | RLOGE("create proxy fail"); |
| 469 | return ; |
| 470 | } |
| 471 | RLOGD("proxy is ready"); |
| 472 | gulong signal_handler_id; |
| 473 | |
| 474 | signal_handler_id = g_signal_connect(proxy, "g-signal", |
| 475 | G_CALLBACK (proxy_signals_on_signal), NULL); |
| 476 | if (signal_handler_id == 0) { |
| 477 | RLOGE("listen singal fail!"); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | void* init_data_gdbus_cb(void *param) |
| 482 | { |
| 483 | /* all the tests rely on a shared main loop */ |
| 484 | loop = g_main_loop_new(NULL, FALSE); |
| 485 | |
| 486 | g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, |
| 487 | G_DBUS_PROXY_FLAGS_NONE, |
| 488 | NULL, /* GDBusInterfaceInfo */ |
| 489 | TELEPHONY_SERVICE, /* name */ |
| 490 | TELEPHONY_DATA_PATH, /* object path */ |
| 491 | TELEPHONY_DATA_INTERFACE, /* interface */ |
| 492 | NULL, /* GCancellable */ |
| 493 | proxy_ready, |
| 494 | NULL); |
| 495 | |
| 496 | g_main_loop_run(loop); |
| 497 | |
| 498 | RLOGD("data gdbus main loop run()"); |
| 499 | if(proxy != NULL) { |
| 500 | g_object_unref (proxy); |
| 501 | } |
| 502 | if(loop != NULL) { |
| 503 | g_main_loop_unref(loop); |
| 504 | } |
xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 505 | return NULL; |
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 506 | } |
| 507 | |