| 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> |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 51 | #include "ATCI.h" |
| 52 | #ifdef LED_SUPPORT |
| 53 | #include "led.h" |
| 54 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 55 | using 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*/ |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 63 | #define DEBUG 0 |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 64 | |
| 65 | GMainLoop *loop = NULL; |
| 66 | GDBusProxy *proxy = NULL; |
| 67 | MTK_Data_Call_Response_v1 req_response; |
| 68 | MTK_Data_Call_Response_v1 urc_response; |
| ll | 90a255c | 2022-04-07 09:09:55 +0000 | [diff] [blame] | 69 | |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 70 | |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 71 | /*Typethree add for t800 ril service 2022/04/14 start*/ |
| 72 | |
| 73 | int 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 | |
| ll | 90a255c | 2022-04-07 09:09:55 +0000 | [diff] [blame] | 91 | /*Warren add for t103 szzt atsvc 2022/1/5 start*/ |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 92 | /*lei modify on 2022/11/16*/ |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 93 | /*lei modify on 2022/11/16*/ |
| ll | 90a255c | 2022-04-07 09:09:55 +0000 | [diff] [blame] | 94 | /*Warren add for t103 szzt atsvc 2022/1/5 end*/ |
| 95 | |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 96 | /*Warren add for t800 ril service 2021/12/25 start*/ |
| 97 | int 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; |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 108 | 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 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 115 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 116 | 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); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 117 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 118 | 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); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 123 | apn_table[i].used = 0; |
| 124 | apn_table[i].netId = 0; |
| 125 | apn_table[i].pdpstate = PDN_DISCONNECTED; |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 126 | apn_count--; |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 127 | printf("\nOK\n"); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 128 | p.writeInt32 (1); |
| 129 | p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND); |
| 130 | p.writeInt32 (0);//temporary plan |
| 131 | p.writeInt32(PDN_DISCONNECTED); |
| rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 132 | writeStringToParcel(p,urc_response->apnType); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 133 | android::LYNQ_RIL_urcBroadcast(p); |
| 134 | RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 135 | 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); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 156 | 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 |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 159 | 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); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 160 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 161 | 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 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 177 | for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)//means apn state changed,need update |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 178 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 179 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 180 | printf("line %d for apn_table[%d].apn:%s,,,,urc_response->apnName:%s\n",__LINE__,i,apn_table[i].apn,urc_response->apnName); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 181 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 182 | 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 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 185 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 186 | printf("line %d This apn has been created update???!!!\n",__LINE__); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 187 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 188 | RLOGD("This apn has been created!!!"); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 189 | apnHasCreated = TRUE; |
| 190 | if(apn_table[i].netId!=urc_response->netId) |
| 191 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 192 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 193 | printf("update???\n"); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 194 | #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); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 199 | 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); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 213 | } |
| 214 | break; |
| 215 | } |
| 216 | } |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 217 | if(!apnHasCreated)//Multiple APNs are established new apn has created |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 218 | { |
| 219 | bool getLable = FALSE; |
| 220 | int lable = 0; |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 221 | for(lable;lable < LYNQ_APN_CHANNEL_MAX;lable++)//to find not used array element subscript |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 222 | { |
| 223 | if(apn_table[lable].used==0) |
| 224 | { |
| 225 | getLable = TRUE; |
| 226 | break; |
| 227 | } |
| 228 | } |
| 229 | if(getLable) |
| 230 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 231 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 232 | printf("line %d Multiple APNs are established\n", __LINE__); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 233 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 234 | 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); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 238 | apn_table[lable].pdpstate = urc_response->pdnState; |
| 239 | memcpy(apn_table[lable].address,urc_response->addresses,strlen(urc_response->addresses)+1); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 240 | 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 | } |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 262 | else //cid < 0 it means:when at+cfun=0 will into this or when connecting |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 263 | { |
| 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 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 271 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 272 | printf("line %d don't know\n", __LINE__); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 273 | #endif |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 274 | 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 | { |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 284 | #if DEBUG |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 285 | printf("line %d don't know\n", __LINE__); |
| ll | 62a2b40 | 2022-11-16 21:19:04 +0800 | [diff] [blame] | 286 | #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 | } |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 297 | 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); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | } |
| 311 | return 0; |
| 312 | } |
| 313 | /*Warren add for t800 ril service 2021/12/25 end*/ |
| 314 | void 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 | |
| 325 | char* 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 | |
| 348 | void 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 | |
| 358 | void 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 | |
| 367 | void 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 | |
| 390 | int 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 | } |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 403 | /*Typethree add for t800 RIL Service 2022/04/14 start*/ |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 404 | void 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); |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 420 | lynq_data_modify_apn(error->message,LYNQ_URC_MODIFY_APNDB); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 421 | 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)); |
| ll | 6e73f20 | 2022-12-28 14:59:46 +0800 | [diff] [blame] | 429 | /*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*/ |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 434 | g_variant_unref(result); |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 435 | lynq_data_modify_apn(reason,LYNQ_URC_MODIFY_APNDB); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | int 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 | |
| 451 | void 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); |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 467 | lynq_data_modify_apn(error->message,LYNQ_URC_RESET_APNDB); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 468 | 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); |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 477 | lynq_data_modify_apn(reason,LYNQ_URC_RESET_APNDB); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 478 | } |
| rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 479 | /*Typethree add for t800 RIL Service 2022/04/14 end*/ |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 480 | |
| 481 | int 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 | |
| ll | 90a255c | 2022-04-07 09:09:55 +0000 | [diff] [blame] | 493 | |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 494 | void 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(); |
| xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 519 | } else if (urc_response.pdnState == RIL_Data_Call_PdnState::PDN_FAILED) { |
| 520 | updataDataConnectState(get_default_sim_data(), false); |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | return; |
| 524 | |
| 525 | } |
| 526 | |
| 527 | void 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 | |
| 546 | void* 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 | } |
| xj | a1c30b8 | 2022-01-25 16:13:48 +0800 | [diff] [blame] | 570 | return NULL; |
| lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 571 | } |
| 572 | |