rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | //#include "common.h" |
| 2 | #include "lynq_common.h" |
| 3 | #include "lynq_network.h" |
| 4 | //#include <stateManager/stateManager.h> |
| 5 | #define CELL_LIST_MAX 10 |
| 6 | #undef LOG_TAG |
| 7 | #define LOG_TAG "LYNQ_NETWORK" |
| 8 | |
| 9 | //moblietek add @2020.12.for add Network api |
| 10 | int copyCellInfoList(Parcel &p,cellInfoList *cellinfo) |
| 11 | { |
| 12 | int32_t v=0; |
| 13 | int64_t v6=0; |
| 14 | int32_t num = 0; |
| 15 | p.readInt32(&v); |
| 16 | cellinfo->cellinfo.cellInfoType = RIL_CellInfoType(v); |
| 17 | p.readInt32(&cellinfo->cellinfo.registered); |
| 18 | p.readInt32(&v); |
| 19 | cellinfo->cellinfo.timeStampType = RIL_TimeStampType(v); |
| 20 | p.readInt64(&v6); |
| 21 | cellinfo->cellinfo.timeStamp = v6; |
| 22 | switch(cellinfo->cellinfo.cellInfoType) { |
| 23 | case RIL_CELL_INFO_TYPE_GSM: { |
| 24 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.cellIdentityGsm.mcc); |
| 25 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.cellIdentityGsm.mnc); |
| 26 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.cellIdentityGsm.lac); |
| 27 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.cellIdentityGsm.cid); |
| 28 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.signalStrengthGsm.signalStrength); |
| 29 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.signalStrengthGsm.bitErrorRate); |
| 30 | p.readInt32(&cellinfo->cellinfo.CellInfo.gsm.signalStrengthGsm.timingAdvance); |
| 31 | break; |
| 32 | } |
| 33 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 34 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mcc); |
| 35 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.cellIdentityWcdma.mnc); |
| 36 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.cellIdentityWcdma.lac); |
| 37 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.cellIdentityWcdma.cid); |
| 38 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.cellIdentityWcdma.psc); |
| 39 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.signalStrengthWcdma.signalStrength); |
| 40 | p.readInt32(&cellinfo->cellinfo.CellInfo.wcdma.signalStrengthWcdma.bitErrorRate); |
| 41 | break; |
| 42 | } |
| 43 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 44 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.cellIdentityCdma.networkId); |
| 45 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.cellIdentityCdma.systemId); |
| 46 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.cellIdentityCdma.basestationId); |
| 47 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.cellIdentityCdma.longitude); |
| 48 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.cellIdentityCdma.latitude); |
| 49 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.signalStrengthCdma.dbm); |
| 50 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.signalStrengthCdma.ecio); |
| 51 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.signalStrengthEvdo.dbm); |
| 52 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.signalStrengthEvdo.ecio); |
| 53 | p.readInt32(&cellinfo->cellinfo.CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio); |
| 54 | |
| 55 | break; |
| 56 | } |
| 57 | case RIL_CELL_INFO_TYPE_LTE: { |
| 58 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.cellIdentityLte.mcc); |
| 59 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.cellIdentityLte.mnc); |
| 60 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.cellIdentityLte.ci); |
| 61 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.cellIdentityLte.pci); |
| 62 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.cellIdentityLte.tac); |
| 63 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.signalStrength); |
| 64 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.rsrp); |
| 65 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.rsrq); |
| 66 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.rssnr); |
| 67 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.cqi); |
| 68 | p.readInt32(&cellinfo->cellinfo.CellInfo.lte.signalStrengthLte.timingAdvance); |
| 69 | break; |
| 70 | } |
| 71 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 72 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mcc); |
| 73 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.mnc); |
| 74 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.lac); |
| 75 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cid); |
| 76 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.cellIdentityTdscdma.cpid); |
| 77 | p.readInt32(&cellinfo->cellinfo.CellInfo.tdscdma.signalStrengthTdscdma.rscp); |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | return 0; |
| 82 | } |
| 83 | int checkRespErrno(const int32_t token,const int time,RIL_Errno & err) |
| 84 | { |
| 85 | int time_net = time; |
| 86 | int status=0; |
| 87 | lynqQueue *node = NULL; |
| 88 | lynqQueue *temp =NULL; |
| 89 | while(time_net--) |
| 90 | { |
| 91 | millli_sleep_with_restart(10); |
| 92 | temp=LynqQueueHead; |
| 93 | if(temp==NULL) |
| 94 | { |
| 95 | LYDBGLOG("[%s][%d][%s] Queue head is NULL, maybe malloc fail!\n",__FUNCTION__,__LINE__,__FILE__); |
| 96 | continue; |
| 97 | } |
| 98 | node = searchTokeninQueue(token, temp); |
| 99 | if(node ==NULL) |
| 100 | { |
| 101 | LYDBGLOG("[%s][%d][%s] can not find token %x\n",__FUNCTION__,__LINE__,__FILE__,token); |
| 102 | err=-1; |
| 103 | return -1; |
| 104 | } |
| 105 | node->parcel.setDataPosition(0); |
| 106 | if (node->parcel.dataAvail() > 0) |
| 107 | { |
| 108 | node->parcel.readInt32(&status); |
| 109 | LYDBGLOG("[%s][%d][%s] message number is %d\n",__FUNCTION__,__LINE__,__FILE__,status); |
| 110 | if(status!=0) |
| 111 | { |
| 112 | if(node->t_Errno!=RIL_E_SUCCESS) |
| 113 | { |
| 114 | LYDBGLOG("[%s][%d][%s] get err success,but the event is fail,the error code is %d\n",__FUNCTION__,__LINE__,__FILE__,node->t_Errno); |
| 115 | err=node->t_Errno; |
| 116 | return -1; |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | LYDBGLOG("[%s][%d][%s] get success, the error code is %d",__FUNCTION__,__LINE__,__FILE__,node->t_Errno); |
| 121 | err=node->t_Errno; |
| 122 | return 0; |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | continue; |
| 129 | } |
| 130 | } |
| 131 | if(time_net<0) |
| 132 | { |
| 133 | LYDBGLOG("[%s][%d][%s] time out,can not find network selection mode message!",__FUNCTION__,__LINE__,__FILE__); |
| 134 | err=-1; |
| 135 | } |
| 136 | return -1; |
| 137 | } |
| 138 | int checkNetworkSelectionMode(const int32_t token,const int time,networkSelecttionMode *netselMode) |
| 139 | { |
| 140 | int time_net = time; |
| 141 | int num=0; |
| 142 | //int status =0; |
| 143 | Parcel parcel; |
| 144 | RIL_Errno err; |
| 145 | lynqQueue *node = NULL; |
| 146 | lynqQueue *temp =NULL; |
| 147 | node = commonFindParcelmsg(token,time,err); |
| 148 | if(node!=NULL) |
| 149 | { |
| 150 | node->parcel.readInt32(&num); |
| 151 | LYDBGLOG("[%s][%d][%s] message number is %d",__FUNCTION__,__LINE__,__FILE__,num); |
| 152 | node->parcel.readInt32(&netselMode->mode); |
| 153 | netselMode->base.e=err; |
| 154 | return 0; |
| 155 | } |
| 156 | netselMode->base.e=err; |
| 157 | return -1; |
| 158 | } |
| 159 | int updateRegStateInfo(int32_t request,int32_t token,registrationStateInfo *regStateInfo) |
| 160 | { |
| 161 | RIL_Errno err; |
| 162 | Parcel parcel; |
| 163 | int res = 0; |
| 164 | int num=0; |
| 165 | lynqQueue *node=NULL; |
| 166 | regStateInfo->base.request=request; |
| 167 | regStateInfo->base.token = token; |
| 168 | switch(request) |
| 169 | { |
| 170 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: |
| 171 | { |
| 172 | node = commonFindParcelmsg(token, 500,err); |
| 173 | if (node != NULL) |
| 174 | { |
| 175 | node->parcel.setDataPosition(0); |
| 176 | node->parcel.readInt32(&num); |
| 177 | LYDBGLOG("[RIL_REQUEST_DATA_REGISTRATION_STATE] the num is %d\n",num); |
| 178 | if(num==15) |
| 179 | { |
| 180 | regStateInfo->regState = atoi(lynqStrdupReadString(node->parcel)); |
| 181 | lynqStrdupReadString(node->parcel); |
| 182 | lynqStrdupReadString(node->parcel); |
| 183 | regStateInfo->netType =atoi( lynqStrdupReadString(node->parcel)); |
| 184 | } |
| 185 | } |
| 186 | regStateInfo->base.e=err; |
| 187 | break; |
| 188 | } |
| 189 | case RIL_REQUEST_DATA_REGISTRATION_STATE: |
| 190 | { |
| 191 | node = commonFindParcelmsg(token, 500,err); |
| 192 | if (node != NULL) |
| 193 | { |
| 194 | node->parcel.setDataPosition(0); |
| 195 | node->parcel.readInt32(&num); |
| 196 | //char * temp=NULL; |
| 197 | LYDBGLOG("[RIL_REQUEST_DATA_REGISTRATION_STATE] the num is %d\n",num); |
| 198 | if(num==11) |
| 199 | { |
| 200 | regStateInfo->regState = atoi(lynqStrdupReadString(node->parcel)); |
| 201 | regStateInfo->LAC = lynqStrdupReadString(node->parcel); |
| 202 | regStateInfo->CID = lynqStrdupReadString(node->parcel); |
| 203 | regStateInfo->netType =atoi( lynqStrdupReadString(node->parcel)); |
| 204 | } |
| 205 | } |
| 206 | regStateInfo->base.e=err; |
| 207 | break; |
| 208 | } |
| 209 | case RIL_REQUEST_IMS_REGISTRATION_STATE: |
| 210 | { |
| 211 | node = commonFindParcelmsg(token, 500,err); |
| 212 | if (node != NULL) |
| 213 | { |
| 214 | node->parcel.setDataPosition(0); |
| 215 | node->parcel.readInt32(&num); |
| 216 | //char * temp=NULL; |
| 217 | LYDBGLOG("[RIL_REQUEST_DATA_REGISTRATION_STATE] the num is %d\n",num); |
| 218 | if(num==2) |
| 219 | { |
| 220 | node->parcel.readInt32(®StateInfo->imsRegState); |
| 221 | node->parcel.readInt32(&res); |
| 222 | regStateInfo->radioTechFam = (RIL_RadioTechnologyFamily)res; |
| 223 | } |
| 224 | } |
| 225 | regStateInfo->base.e=err; |
| 226 | break; |
| 227 | } |
| 228 | default: |
| 229 | break; |
| 230 | } |
| 231 | return 0; |
| 232 | } |
| 233 | int lynq_query_operater(operatorInfo * currentOperator) |
| 234 | { |
| 235 | int32_t token = 0; |
| 236 | int time_net =100; |
| 237 | int num=0; |
| 238 | lynqQueue *node = NULL; |
| 239 | RIL_Errno err = -1; |
| 240 | char requestStr[MAX_LEN] = {"RIL_REQUEST_OPERATOR"}; |
| 241 | if(token = lynqNoneParame(requestStr)) |
| 242 | { |
| 243 | currentOperator->base.request = RIL_REQUEST_OPERATOR; |
| 244 | currentOperator->base.token=token; |
| 245 | node = commonUpdateEstatus(token, time_net, err); |
| 246 | currentOperator->base.e = err; |
| 247 | if(err!=RIL_E_SUCCESS) |
| 248 | { |
| 249 | currentOperator->OperatorFN = NULL; |
| 250 | currentOperator->OperatorSH = NULL; |
| 251 | currentOperator->MccMnc = NULL; |
| 252 | lynqDeQueue(token); |
| 253 | return token; |
| 254 | } |
| 255 | node->parcel.setDataPosition(0); |
| 256 | if (node->parcel.dataAvail() > 0) |
| 257 | { |
| 258 | node->parcel.readInt32(&num); |
| 259 | LYDBGLOG("[%s][%d][%s] Message number is %d",__FUNCTION__,__LINE__,__FILE__,num); |
| 260 | if(num == 3) |
| 261 | { |
| 262 | currentOperator->OperatorFN = lynqStrdupReadString(node->parcel); |
| 263 | currentOperator->OperatorSH = lynqStrdupReadString(node->parcel); |
| 264 | currentOperator->MccMnc = lynqStrdupReadString(node->parcel); |
| 265 | } |
| 266 | } |
| 267 | lynqDeQueue(token); |
| 268 | } |
| 269 | return token; |
| 270 | } |
| 271 | |
| 272 | int lynq_query_network_selection_mode(networkSelecttionMode *netselMode) |
| 273 | { |
| 274 | int32_t token=0; |
| 275 | int time_net = 100;//1s |
| 276 | //int num=0; |
| 277 | //lynqQueue *node = NULL; |
| 278 | //lynqQueue *temp =NULL; |
| 279 | char requestStr[MAX_LEN] = {"RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE"}; |
| 280 | token=lynqNoneParame(requestStr); |
| 281 | netselMode->base.token=token; |
| 282 | netselMode->base.request=RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE; |
| 283 | checkNetworkSelectionMode(token,time_net,netselMode); |
| 284 | lynqDeQueue(token); |
| 285 | return token; |
| 286 | } |
| 287 | int lynq_set_network_selection_mode(const char *mode,const char* mccmnc,lynqBase *base)//0:auto selection 1:manual selection |
| 288 | { |
| 289 | const char *argv[MAX_LEN] = {}; |
| 290 | int32_t token=0; |
| 291 | RIL_Errno err; |
| 292 | lynqQueue * node = NULL; |
| 293 | int time_net = 100;//1s |
| 294 | char mccmncStr[MAX_QUEST_LEN] = ""; |
| 295 | if(!strcmp(mode,"Auto")) |
| 296 | { |
| 297 | //printf("--------->[%s,%d] Auto!!! \n",__FUNCTION__,__LINE__); |
| 298 | argv[0] = "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC"; |
| 299 | argv[1] = "Auto"; |
| 300 | if(token = android::getRequestData(argv, 1)) |
| 301 | { |
| 302 | base->request=RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC; |
| 303 | base->token = token; |
| 304 | node = commonFindParcelmsg(token,time_net,err); |
| 305 | base->e=err; |
| 306 | lynqDeQueue(token); |
| 307 | } |
| 308 | return token; |
| 309 | }else if(!strcmp(mode,"Manual")){ |
| 310 | //printf("--------->[%s,%d] manual,mccmnc=%d \n",__FUNCTION__,__LINE__,mccmnc); |
| 311 | //sprintf(mccmncStr, "%d", mccmnc); |
| 312 | argv[0] = "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL"; |
| 313 | argv[1] = mccmnc; |
| 314 | //argv[2] = mccmnc; |
| 315 | if(token = android::getRequestData(argv, 2)) |
| 316 | { |
| 317 | base->request=RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL; |
| 318 | base->token = token; |
| 319 | node = commonFindParcelmsg(token,time_net,err); |
| 320 | base->e=err; |
| 321 | lynqDeQueue(token); |
| 322 | } |
| 323 | return token; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | int lynq_query_available_network(availableNetwork *availNet) |
| 328 | { |
| 329 | int32_t token; |
| 330 | char requestStr[MAX_LEN] = {"RIL_REQUEST_QUERY_AVAILABLE_NETWORKS"}; |
| 331 | int time_net =6000;//60second |
| 332 | int num=0;//the number of available network data |
| 333 | int range = 0;/*response is const char ** that should be an array of n*4 strings, where "range" is the number of available networks*/ |
| 334 | RIL_Errno err = -1; |
| 335 | lynqQueue *node = NULL; |
| 336 | lynqQueue *temp =NULL; |
| 337 | if(token = lynqNoneParame(requestStr)) |
| 338 | { |
| 339 | availNet->base.request = RIL_REQUEST_OPERATOR; |
| 340 | availNet->base.token=token; |
| 341 | node = commonFindParcelmsg(token, time_net, err); |
| 342 | availNet->base.e=err; |
| 343 | if (node !=NULL) |
| 344 | { |
| 345 | node->parcel.readInt32(&num); |
| 346 | LYDBGLOG("[%s][%d] message number is %d\n",__FUNCTION__,__LINE__,num); |
| 347 | if((num/4)>0 &&(num%4)==0)//Integer multiples of 4 |
| 348 | { |
| 349 | range = num/4; |
| 350 | /*Temporary plan.the real situation should be for(int i=0;i<range;i++)*/ |
| 351 | availNet->OperatorFN = lynqStrdupReadString(node->parcel); |
| 352 | availNet->OperatorSH = lynqStrdupReadString(node->parcel); |
| 353 | availNet->MccMnc = lynqStrdupReadString(node->parcel); |
| 354 | availNet->NetStatus = lynqStrdupReadString(node->parcel); |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | if(num/4>0) |
| 359 | { |
| 360 | availNet->OperatorFN = lynqStrdupReadString(node->parcel); |
| 361 | availNet->OperatorSH = lynqStrdupReadString(node->parcel); |
| 362 | availNet->MccMnc = lynqStrdupReadString(node->parcel); |
| 363 | availNet->NetStatus = lynqStrdupReadString(node->parcel); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | lynqDeQueue(token); |
| 368 | } |
| 369 | return 0; |
| 370 | } |
| 371 | |
| 372 | //network state |
| 373 | int lynq_query_registration_state(const char *type,registrationStateInfo *regStateInfo)//type:vioce/data/ims |
| 374 | { |
| 375 | char requestStr[MAX_LEN]=""; |
| 376 | int32_t request=0; |
| 377 | int32_t token=0; |
| 378 | char str[10]; |
| 379 | if (strlen(type)>10) |
| 380 | { |
| 381 | LYERRLOG("[%s]the parameter is inavaliable !\n",__FUNCTION__); |
| 382 | return -1; |
| 383 | } |
| 384 | memcpy(str,type,strlen(type)+1); |
| 385 | strUpper(str); |
| 386 | //printf("upper str is %s\n",str); |
| 387 | if(!strcmp(str,"VOICE")){ |
| 388 | strcpy(requestStr,"RIL_REQUEST_VOICE_REGISTRATION_STATE"); |
| 389 | request=RIL_REQUEST_VOICE_REGISTRATION_STATE; |
| 390 | }else if(!strcmp(str,"DATA")){ |
| 391 | strcpy(requestStr,"RIL_REQUEST_DATA_REGISTRATION_STATE"); |
| 392 | request= RIL_REQUEST_DATA_REGISTRATION_STATE; |
| 393 | }else if(!strcmp(str,"IMS")){ |
| 394 | strcpy(requestStr,"RIL_REQUEST_IMS_REGISTRATION_STATE"); |
| 395 | request = RIL_REQUEST_IMS_REGISTRATION_STATE; |
| 396 | }else{ |
| 397 | LYERRLOG("[%s,%d] query ims registration state about voice, data, and ims!!! \n",__FUNCTION__,__LINE__); |
| 398 | return -1; |
| 399 | } |
| 400 | token = lynqNoneParame(requestStr); |
| 401 | updateRegStateInfo(request,token,regStateInfo); |
| 402 | lynqDeQueue(token); |
| 403 | return token; |
| 404 | } |
| 405 | //preferred network |
| 406 | int lynq_query_prefferred_networktype(prefferredNetworkType * preNetType) |
| 407 | { |
| 408 | int32_t token=0; |
| 409 | lynqQueue *node =NULL; |
| 410 | RIL_Errno err=-1; |
| 411 | int num =0; |
| 412 | int res = 0; |
| 413 | char requestStr[MAX_LEN] = {"RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE"}; |
| 414 | token = lynqNoneParame(requestStr); |
| 415 | preNetType->base.request = RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE; |
| 416 | preNetType->base.token=token; |
| 417 | node = commonFindParcelmsg(token, 500, err); |
| 418 | if (node !=NULL) |
| 419 | { |
| 420 | node->parcel.readInt32(&num); |
| 421 | node->parcel.readInt32(&res); |
| 422 | preNetType->pnt=res; |
| 423 | } |
| 424 | preNetType->base.e=err; |
| 425 | lynqDeQueue(token); |
| 426 | return token; |
| 427 | } |
| 428 | |
| 429 | int lynq_set_prefferred_networktype(const int preffertype,lynqBase * base)//preffertype:0~22 |
| 430 | { |
| 431 | char *argv[MAX_LEN] = {}; |
| 432 | char preffertypeStr[MAX_QUEST_LEN] = ""; |
| 433 | int32_t token=0; |
| 434 | int status = 0; |
| 435 | RIL_Errno err=-1; |
| 436 | lynqQueue * node = NULL; |
| 437 | |
| 438 | sprintf(preffertypeStr, "%d", preffertype); |
| 439 | argv[0] = "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE"; |
| 440 | argv[1] = preffertypeStr; |
| 441 | if(token = android::getRequestData(argv, 2)) |
| 442 | { |
| 443 | base->request = RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE; |
| 444 | base->token=token; |
| 445 | node = commonFindParcelmsg(token,500,err); |
| 446 | base->e=err; |
| 447 | lynqDeQueue(token); |
| 448 | } |
| 449 | return token; |
| 450 | } |
| 451 | |
| 452 | //cell info |
| 453 | int lynq_query_cell_info(cellInfoList ** cellinfo,const int listNum,int *realNum) |
| 454 | { |
| 455 | int32_t token = 0; |
| 456 | lynqQueue *node = NULL; |
| 457 | RIL_Errno err = -1; |
| 458 | int num = 0; |
| 459 | *realNum = 0; |
| 460 | if(listNum>CELL_LIST_MAX) |
| 461 | { |
| 462 | LYERRLOG("the list number is more than 10\n"); |
| 463 | return -1; |
| 464 | } |
| 465 | char requestStr[MAX_LEN] = {"RIL_REQUEST_GET_CELL_INFO_LIST"}; |
| 466 | if(token = lynqNoneParame(requestStr)) |
| 467 | { |
| 468 | cellinfo[0]->base.request=RIL_REQUEST_GET_CELL_INFO_LIST; |
| 469 | cellinfo[0]->base.token = token; |
| 470 | //node = commonFindParcelmsg(token,500,err); |
| 471 | if(node = commonFindParcelmsg(token,500,err)) |
| 472 | { |
| 473 | node->parcel.readInt32(&num); |
| 474 | if (listNum<num) |
| 475 | { |
| 476 | num=listNum; |
| 477 | LYDBGLOG("[%s,%d]listNum<num!",__FUNCTION__,__LINE__); |
| 478 | } |
| 479 | *realNum = num; |
| 480 | for(int i = 0;i<num;i++) |
| 481 | { |
| 482 | copyCellInfoList(node->parcel,cellinfo[i]); |
| 483 | //cellinfo[i]->base.request=RIL_REQUEST_GET_CELL_INFO_LIST; |
| 484 | //cellinfo[i]->base.token = token; |
| 485 | } |
| 486 | } |
| 487 | cellinfo[0]->base.e=err; |
| 488 | lynqDeQueue(token); |
| 489 | } |
| 490 | cellinfo[0]->base.e=err; |
| 491 | return token; |
| 492 | } |
| 493 | |
| 494 | int lynq_set_unsol_cell_info_listrate(const int rate,lynqBase * base) //rate:0<=rate<=0x7fffffff, minimum time in milliseconds |
| 495 | { |
| 496 | int32_t token=0; |
| 497 | char *argv[MAX_LEN] = {}; |
| 498 | char rateStr[MAX_QUEST_LEN] = ""; |
| 499 | int status = 0; |
| 500 | RIL_Errno err=-1; |
| 501 | lynqQueue * node = NULL; |
| 502 | sprintf(rateStr, "%d", rate); |
| 503 | argv[0] = "RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE"; |
| 504 | argv[1] = rateStr; |
| 505 | if(token = android::getRequestData(argv, 2)) |
| 506 | { |
| 507 | base->request = RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE; |
| 508 | base->token=token; |
| 509 | node = commonFindParcelmsg(token,500,err); |
| 510 | base->e=err; |
| 511 | lynqDeQueue(token); |
| 512 | } |
| 513 | return token; |
| 514 | } |
| 515 | |
| 516 | int lynq_query_neighboring_cellids(neighboringCellIDs **neiCeIDs,const int listNum,int *realNum) |
| 517 | { |
| 518 | int32_t token = 0; |
| 519 | lynqQueue *node = NULL; |
| 520 | RIL_Errno err = -1; |
| 521 | int num = 0; |
| 522 | int res=0; |
| 523 | *realNum = 0; |
| 524 | if(listNum>CELL_LIST_MAX) |
| 525 | { |
| 526 | LYERRLOG("the list number is more than 10\n"); |
| 527 | return -1; |
| 528 | } |
| 529 | char requestStr[MAX_LEN] = {"RIL_REQUEST_GET_NEIGHBORING_CELL_IDS"}; |
| 530 | if(token = lynqNoneParame(requestStr)) |
| 531 | { |
| 532 | neiCeIDs[0]->base.request=RIL_REQUEST_GET_NEIGHBORING_CELL_IDS; |
| 533 | neiCeIDs[0]->base.token = token; |
| 534 | //node = commonFindParcelmsg(token,500,err); |
| 535 | if(node = commonFindParcelmsg(token,500,err)) |
| 536 | { |
| 537 | node->parcel.readInt32(&num); |
| 538 | if (listNum<num) |
| 539 | { |
| 540 | num=listNum; |
| 541 | LYDBGLOG("[%s,%d]listNum<num!",__FUNCTION__,__LINE__); |
| 542 | } |
| 543 | *realNum = num; |
| 544 | for(int i = 0;i<num;i++) |
| 545 | { |
| 546 | neiCeIDs[i]->cid = lynqStrdupReadString(node->parcel); |
| 547 | node->parcel.readInt32(&res); |
| 548 | neiCeIDs[i]->rssi = res; |
| 549 | } |
| 550 | } |
| 551 | neiCeIDs[0]->base.e=err; |
| 552 | lynqDeQueue(token); |
| 553 | } |
| 554 | neiCeIDs[0]->base.e=err; |
| 555 | return token; |
| 556 | } |
| 557 | |
| 558 | //band mode |
| 559 | int lynq_set_band_mode(const int bandmode,lynqBase *base)//bandmode:0~18 |
| 560 | { |
| 561 | char *argv[MAX_LEN] = {}; |
| 562 | int32_t token=0; |
| 563 | char bandmodeStr[MAX_QUEST_LEN] = ""; |
| 564 | int status = 0; |
| 565 | RIL_Errno err=-1; |
| 566 | lynqQueue * node = NULL; |
| 567 | sprintf(bandmodeStr, "%d", bandmode); |
| 568 | argv[0] = "RIL_REQUEST_SET_BAND_MODE"; |
| 569 | argv[1] = bandmodeStr; |
| 570 | token = android::getRequestData(argv, 2); |
| 571 | base->request=RIL_REQUEST_SET_BAND_MODE; |
| 572 | base->token = token; |
| 573 | node = commonFindParcelmsg(token,1000,err); |
| 574 | base->e=err; |
| 575 | lynqDeQueue(token); |
| 576 | return token; |
| 577 | } |
| 578 | |
| 579 | int lynq_query_available_bandmode(availableBandMode*availBanMode) |
| 580 | { |
| 581 | int32_t token = 0; |
| 582 | RIL_Errno err=-1; |
| 583 | lynqQueue * node = NULL; |
| 584 | int num = 0; |
| 585 | int res = 0; |
| 586 | char requestStr[MAX_LEN] = {"RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE"}; |
| 587 | token = lynqNoneParame(requestStr); |
| 588 | availBanMode->base.request = RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE; |
| 589 | availBanMode->base.token = token; |
| 590 | node = commonFindParcelmsg(token,500,err); |
| 591 | for(int i = 0;i<20;i++) |
| 592 | { |
| 593 | availBanMode->bandmode[i]=0; |
| 594 | } |
| 595 | if (node!=NULL) |
| 596 | { |
| 597 | node->parcel.readInt32(&num); |
| 598 | availBanMode->bandmode[0]=num; |
| 599 | LYDBGLOG("[%s] available band mode num is %d\n",__FUNCTION__,num); |
| 600 | for(int i=1;i<=num;i++) |
| 601 | { |
| 602 | node->parcel.readInt32(&res); |
| 603 | availBanMode->bandmode[i]=res; |
| 604 | } |
| 605 | } |
| 606 | availBanMode->base.e=err; |
| 607 | lynqDeQueue(token); |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | //radio power |
| 612 | int lynq_radio_on(const int data,lynqBase *base)//0:off other:on |
| 613 | { |
| 614 | char *argv[MAX_LEN] = {}; |
| 615 | char dataStr[MAX_QUEST_LEN] = ""; |
| 616 | int32_t token = 0; |
| 617 | lynqQueue *node = NULL; |
| 618 | RIL_Errno err=-1; |
| 619 | sprintf(dataStr, "%d", data); |
| 620 | argv[0] = "RIL_REQUEST_RADIO_POWER"; |
| 621 | argv[1] = dataStr; |
| 622 | if(token = android::getRequestData(argv, 2)) |
| 623 | { |
| 624 | base->request=RIL_REQUEST_RADIO_POWER; |
| 625 | base->token = token; |
| 626 | node = commonFindParcelmsg(token,500,err); |
| 627 | base->e=err; |
| 628 | lynqDeQueue(token); |
| 629 | } |
| 630 | return token; |
| 631 | } |
| 632 | |
| 633 | //radio tech |
| 634 | int lynq_query_radio_tech(radioTechnology *radioTech) |
| 635 | { |
| 636 | char requestStr[MAX_LEN] = {"RIL_REQUEST_VOICE_RADIO_TECH"}; |
| 637 | int32_t token=0; |
| 638 | RIL_Errno err=-1; |
| 639 | lynqQueue *node =NULL; |
| 640 | int num = 0; |
| 641 | int res = 0; |
| 642 | token = lynqNoneParame(requestStr); |
| 643 | radioTech->base.request = RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE; |
| 644 | radioTech->base.token=token; |
| 645 | node = commonFindParcelmsg(token, 500, err); |
| 646 | if (node !=NULL) |
| 647 | { |
| 648 | node->parcel.readInt32(&num); |
| 649 | node->parcel.readInt32(&res); |
| 650 | radioTech->radioTech=res; |
| 651 | } |
| 652 | radioTech->base.e=err; |
| 653 | lynqDeQueue(token); |
| 654 | return token; |
| 655 | } |
| 656 | |
| 657 | //signal strength |
| 658 | int lynq_solicited_signal_strength(solicitedSignalStrength *solSigStren) |
| 659 | { |
| 660 | char requestStr[MAX_LEN] = {"RIL_REQUEST_SIGNAL_STRENGTH"}; |
| 661 | int32_t token=0; |
| 662 | RIL_Errno err=-1; |
| 663 | lynqQueue *node =NULL; |
| 664 | int num = 0; |
| 665 | int res = 0; |
| 666 | token = lynqNoneParame(requestStr); |
| 667 | solSigStren->base.request = RIL_REQUEST_SIGNAL_STRENGTH; |
| 668 | solSigStren->base.token=token; |
| 669 | node = commonFindParcelmsg(token, 500, err); |
| 670 | solSigStren->base.e=err; |
| 671 | if (node !=NULL) |
| 672 | { |
| 673 | node->parcel.readInt32(&num); |
| 674 | if(num ==0) |
| 675 | { |
| 676 | LYDBGLOG("[%s] the signal strength is null!\n",__FUNCTION__); |
| 677 | if(err==RIL_E_SUCCESS) |
| 678 | { |
| 679 | solSigStren->base.e=-1; |
| 680 | } |
| 681 | lynqDeQueue(token); |
| 682 | return token; |
| 683 | } |
| 684 | node->parcel.readInt32(&solSigStren->signalStrength.GW_SignalStrength.signalStrength); |
| 685 | node->parcel.readInt32(&solSigStren->signalStrength.GW_SignalStrength.bitErrorRate); |
| 686 | node->parcel.readInt32(&solSigStren->signalStrength.GW_SignalStrength.timingAdvance); |
| 687 | node->parcel.readInt32(&solSigStren->signalStrength.CDMA_SignalStrength.dbm); |
| 688 | node->parcel.readInt32(&solSigStren->signalStrength.CDMA_SignalStrength.ecio); |
| 689 | node->parcel.readInt32(&solSigStren->signalStrength.EVDO_SignalStrength.dbm); |
| 690 | node->parcel.readInt32(&solSigStren->signalStrength.EVDO_SignalStrength.ecio); |
| 691 | node->parcel.readInt32(&solSigStren->signalStrength.EVDO_SignalStrength.signalNoiseRatio); |
| 692 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.signalStrength); |
| 693 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.rsrp); |
| 694 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.rsrq); |
| 695 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.rssnr); |
| 696 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.cqi); |
| 697 | node->parcel.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.timingAdvance); |
| 698 | node->parcel.readInt32(&solSigStren->signalStrength.TD_SCDMA_SignalStrength.signalStrength); |
| 699 | node->parcel.readInt32(&solSigStren->signalStrength.TD_SCDMA_SignalStrength.bitErrorRate); |
| 700 | node->parcel.readInt32(&solSigStren->signalStrength.TD_SCDMA_SignalStrength.rscp); |
| 701 | node->parcel.readInt32(&solSigStren->signalStrength.WCDMA_SignalStrength.signalStrength); |
| 702 | node->parcel.readInt32(&solSigStren->signalStrength.WCDMA_SignalStrength.bitErrorRate); |
| 703 | node->parcel.readInt32(&solSigStren->signalStrength.WCDMA_SignalStrength.rscp); |
| 704 | node->parcel.readInt32(&solSigStren->signalStrength.WCDMA_SignalStrength.ecno); |
| 705 | } |
| 706 | lynqDeQueue(token); |
| 707 | return token; |
| 708 | |
| 709 | } |
| 710 | |
| 711 | //modem |
| 712 | int lynq_modem_on(const int data,lynqBase *base)//data: 0:off,other:on |
| 713 | { |
| 714 | char *argv[MAX_LEN] = {}; |
| 715 | char dataStr[MAX_QUEST_LEN] = ""; |
| 716 | argv[0] = data == 0 ? "RIL_REQUEST_MODEM_POWEROFF" : "RIL_REQUEST_MODEM_POWERON" ; |
| 717 | sprintf(dataStr, "%d", data); |
| 718 | argv[1] = dataStr; |
| 719 | int32_t token = 0; |
| 720 | lynqQueue *node = NULL; |
| 721 | RIL_Errno err=-1; |
| 722 | if(token = android::getRequestData(argv, 2)) |
| 723 | { |
| 724 | base->request=(data == 0 ? RIL_REQUEST_MODEM_POWEROFF:RIL_REQUEST_MODEM_POWERON ); |
| 725 | base->token = token; |
| 726 | node = commonFindParcelmsg(token,500,err); |
| 727 | base->e=err; |
| 728 | lynqDeQueue(token); |
| 729 | } |
| 730 | return token; |
| 731 | } |
| 732 | |
| 733 | #if 0 |
| 734 | int lynq_enter_network_depersonalization(char *code)//code:network/depersonalization code |
| 735 | { |
| 736 | char *argv[MAX_LEN] = {}; |
| 737 | char dataStr[MAX_QUEST_LEN] = ""; |
| 738 | |
| 739 | argv[0] = "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION"; |
| 740 | argv[1] = code; |
| 741 | |
| 742 | return android::getRequestData(argv, 2); |
| 743 | } |
| 744 | #endif |