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