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