rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <alloca.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <stdio.h> |
| 19 | #include <cutils/jstring.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <binder/Parcel.h> |
| 22 | #include <string.h> |
| 23 | #include <strings.h> |
| 24 | #include <log/log.h> |
| 25 | #include<iconv.h> |
| 26 | |
| 27 | #include "common.h" |
| 28 | #include "ss.h" |
| 29 | |
| 30 | #undef LOG_TAG |
| 31 | #define LOG_TAG "DEMO_SS" |
| 32 | |
| 33 | static int TOA_International = 0x91; |
| 34 | static int TOA_Unknown = 0x81; |
| 35 | |
| 36 | static const int SERVICE_CLASS_NONE = 0; // no user input |
| 37 | static const int SERVICE_CLASS_VOICE = (1 << 0); |
| 38 | static const int SERVICE_CLASS_DATA = (1 << 1); //synonym for 16+32+64+128 |
| 39 | static const int SERVICE_CLASS_FAX = (1 << 2); |
| 40 | static const int SERVICE_CLASS_SMS = (1 << 3); |
| 41 | static const int SERVICE_CLASS_DATA_SYNC = (1 << 4); |
| 42 | static const int SERVICE_CLASS_DATA_ASYNC = (1 << 5); |
| 43 | static const int SERVICE_CLASS_PACKET = (1 << 6); |
| 44 | static const int SERVICE_CLASS_PAD = (1 << 7); |
| 45 | static const int SERVICE_CLASS_MAX = (1 << 9); // Max SERVICE_CLASS value |
| 46 | |
| 47 | // Used for call barring methods below |
| 48 | static char* CB_FACILITY_BAOC = "AO"; |
| 49 | static char* CB_FACILITY_BAOIC = "OI"; |
| 50 | static char* CB_FACILITY_BAOICxH = "OX"; |
| 51 | static char* CB_FACILITY_BAIC = "AI"; |
| 52 | static char* CB_FACILITY_BAICr = "IR"; |
| 53 | static char* CB_FACILITY_BA_ALL = "AB"; |
| 54 | static char* CB_FACILITY_BA_MO = "AG"; |
| 55 | static char* CB_FACILITY_BA_MT = "AC"; |
| 56 | static char* CB_FACILITY_BA_SIM = "SC"; |
| 57 | static char* CB_FACILITY_BA_FD = "FD"; |
| 58 | |
| 59 | |
| 60 | // Used as parameters for call forward methods below |
| 61 | static const int CF_ACTION_DISABLE = 0; |
| 62 | static const int CF_ACTION_ENABLE = 1; |
| 63 | static const int CF_ACTION_INTERROGATE = 2; |
| 64 | static const int CF_ACTION_REGISTRATION = 3; |
| 65 | static const int CF_ACTION_ERASURE = 4; |
| 66 | |
| 67 | static const int CF_REASON_UNCONDITIONAL = 0; |
| 68 | static const int CF_REASON_BUSY = 1; |
| 69 | static const int CF_REASON_NO_REPLY = 2; |
| 70 | static const int CF_REASON_NOT_REACHABLE = 3; |
| 71 | static const int CF_REASON_ALL = 4; |
| 72 | static const int CF_REASON_ALL_CONDITIONAL = 5; |
| 73 | static const int CF_REASON_NOT_REGISTERED = 6; |
| 74 | |
| 75 | //Called line presentation |
| 76 | static const char* SC_CLIP = "30"; |
| 77 | static const char* SC_CLIR = "31"; |
| 78 | |
| 79 | // Call Forwarding |
| 80 | static const char* SC_CFU = "21"; |
| 81 | static const char* SC_CFB = "67"; |
| 82 | static const char* SC_CFNRy = "61"; |
| 83 | static const char* SC_CFNR = "62"; |
| 84 | |
| 85 | static const char* SC_CF_All = "002"; |
| 86 | static const char* SC_CF_All_Conditional = "004"; |
| 87 | |
| 88 | // Call Waiting |
| 89 | static const char* SC_WAIT = "43"; |
| 90 | |
| 91 | // Call Barring |
| 92 | static const char* SC_BAOC = "33"; |
| 93 | static const char* SC_BAOIC = "331"; |
| 94 | static const char* SC_BAOICxH = "332"; |
| 95 | static const char* SC_BAIC = "35"; |
| 96 | static const char* SC_BAICr = "351"; |
| 97 | |
| 98 | static const char* SC_BA_ALL = "330"; |
| 99 | static const char* SC_BA_MO = "333"; |
| 100 | static const char* SC_BA_MT = "353"; |
| 101 | |
| 102 | // Supp Service Password registration |
| 103 | static const char* SC_PWD = "03"; |
| 104 | |
| 105 | // PIN/PIN2/PUK/PUK2 |
| 106 | static const char* SC_PIN = "04"; |
| 107 | static const char* SC_PIN2 = "042"; |
| 108 | static const char* SC_PUK = "05"; |
| 109 | static const char* SC_PUK2 = "052"; |
| 110 | |
| 111 | ///M:For query CNAP |
| 112 | static const char* SC_CNAP = "300"; |
| 113 | |
| 114 | int toaFromString(char* s) { |
| 115 | if (s != NULL && strlen(s) > 0 && *s == '+') { |
| 116 | return TOA_International; |
| 117 | } |
| 118 | |
| 119 | return TOA_Unknown; |
| 120 | } |
| 121 | |
| 122 | char* scToBarringFacility(char* sc) { |
| 123 | if (sc == NULL) { |
| 124 | RLOGE("invalid call barring sc"); |
| 125 | return NULL; |
| 126 | } |
| 127 | |
| 128 | if (strcmp(sc, SC_BAOC) == 0) { |
| 129 | return CB_FACILITY_BAOC; |
| 130 | } else if (strcmp(sc, SC_BAOIC) == 0) { |
| 131 | return CB_FACILITY_BAOIC; |
| 132 | } else if (strcmp(sc, SC_BAOICxH) == 0) { |
| 133 | return CB_FACILITY_BAOICxH; |
| 134 | } else if (strcmp(sc, SC_BAIC) == 0) { |
| 135 | return CB_FACILITY_BAIC; |
| 136 | } else if (strcmp(sc, SC_BAICr) == 0) { |
| 137 | return CB_FACILITY_BAICr; |
| 138 | } else if (strcmp(sc, SC_BA_ALL) == 0) { |
| 139 | return CB_FACILITY_BA_ALL; |
| 140 | } else if (strcmp(sc, SC_BA_MO) == 0) { |
| 141 | return CB_FACILITY_BA_MO; |
| 142 | } else if (strcmp(sc, SC_BA_MT) == 0) { |
| 143 | return CB_FACILITY_BA_MT; |
| 144 | } else if (strcasecmp(sc, CB_FACILITY_BA_FD) == 0 ) { |
| 145 | return CB_FACILITY_BA_FD; |
| 146 | } else if (strcasecmp(sc, CB_FACILITY_BA_SIM) == 0 ) { |
| 147 | return CB_FACILITY_BA_SIM; |
| 148 | } else { |
| 149 | RLOGE("invalid call barring sc"); |
| 150 | return NULL; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | |
| 155 | int scToCallForwardReason(char* sc) { |
| 156 | if (sc == NULL) { |
| 157 | RLOGE("invalid call forward sc"); |
| 158 | return -1; |
| 159 | } |
| 160 | |
| 161 | if (strcmp(sc, SC_CF_All) == 0) { |
| 162 | return CF_REASON_ALL; |
| 163 | } else if (strcmp(sc, SC_CFU) == 0) { |
| 164 | return CF_REASON_UNCONDITIONAL; |
| 165 | } else if (strcmp(sc, SC_CFB) == 0) { |
| 166 | return CF_REASON_BUSY; |
| 167 | } else if (strcmp(sc, SC_CFNR) == 0) { |
| 168 | return CF_REASON_NOT_REACHABLE; |
| 169 | } else if (strcmp(sc, SC_CFNRy) == 0) { |
| 170 | return CF_REASON_NO_REPLY; |
| 171 | } else if (strcmp(sc, SC_CF_All_Conditional) == 0) { |
| 172 | return CF_REASON_ALL_CONDITIONAL; |
| 173 | } else { |
| 174 | RLOGE("invalid call forward sc"); |
| 175 | return -1; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | int siToServiceClass(char* si) |
| 180 | { |
| 181 | if (si == NULL || strcmp(si, "null") == 0) |
| 182 | { |
| 183 | return SERVICE_CLASS_NONE; |
| 184 | } else { |
| 185 | // NumberFormatException should cause MMI fail |
| 186 | int serviceCode = atoi(si); |
| 187 | |
| 188 | switch (serviceCode) { |
| 189 | case 10: return SERVICE_CLASS_SMS + SERVICE_CLASS_FAX + SERVICE_CLASS_VOICE; |
| 190 | case 11: return SERVICE_CLASS_VOICE; |
| 191 | case 12: return SERVICE_CLASS_SMS + SERVICE_CLASS_FAX; |
| 192 | case 13: return SERVICE_CLASS_FAX; |
| 193 | |
| 194 | case 16: return SERVICE_CLASS_SMS; |
| 195 | |
| 196 | case 19: return SERVICE_CLASS_FAX + SERVICE_CLASS_VOICE; |
| 197 | /* |
| 198 | Note for code 20: |
| 199 | From TS 22.030 Annex C: |
| 200 | "All GPRS bearer services" are not included in "All tele and bearer services" |
| 201 | and "All bearer services"." |
| 202 | ....so SERVICE_CLASS_DATA, which (according to 27.007) includes GPRS |
| 203 | */ |
| 204 | case 20: return SERVICE_CLASS_DATA_ASYNC + SERVICE_CLASS_DATA_SYNC; |
| 205 | |
| 206 | case 21: return SERVICE_CLASS_PAD + SERVICE_CLASS_DATA_ASYNC; |
| 207 | case 22: return SERVICE_CLASS_PACKET + SERVICE_CLASS_DATA_SYNC; |
| 208 | case 24: return SERVICE_CLASS_DATA_SYNC; |
| 209 | //don't support video |
| 210 | //case 24: return SERVICE_CLASS_DATA_SYNC + SERVICE_CLASS_VIDEO; |
| 211 | case 25: return SERVICE_CLASS_DATA_ASYNC; |
| 212 | case 26: return SERVICE_CLASS_DATA_SYNC + SERVICE_CLASS_VOICE; |
| 213 | case 99: return SERVICE_CLASS_PACKET; |
| 214 | |
| 215 | default: |
| 216 | RLOGW("unsupported MMI service code:%s ", si); |
| 217 | return SERVICE_CLASS_NONE; |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | int siToTime (char* si) { |
| 223 | if (si == NULL || strcmp(si, "null") == 0) { |
| 224 | return 0; |
| 225 | } else { |
| 226 | // NumberFormatException should cause MMI fail |
| 227 | return atoi(si); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | bool isGBK(unsigned char* data, int len) |
| 232 | { |
| 233 | return false; |
| 234 | int i = 0; |
| 235 | while(i < len) |
| 236 | { |
| 237 | if(data[i] <= 0x7f) |
| 238 | { |
| 239 | //one byte encode |
| 240 | i++; |
| 241 | continue; |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | //two byte encode |
| 246 | if(data[i] >= 0x81 && data[i] <= 0xfe && data[i + 1] >= 0x40 |
| 247 | &&data[i + 1] <= 0xfe && data[i + 1] != 0xf7) |
| 248 | { |
| 249 | i += 2; |
| 250 | continue; |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | return false; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return true; |
| 260 | } |
| 261 | int gbkToUtf8(char* src_str, size_t src_len, char* dst_str, size_t dst_len) |
| 262 | { |
| 263 | iconv_t cd; |
| 264 | char **pin = &src_str; |
| 265 | char **pout = &dst_str; |
| 266 | cd = iconv_open("UTF-8", "GBK"); |
| 267 | if(cd == (iconv_t) - 1) |
| 268 | { |
| 269 | printf("iconv_open error\n"); |
| 270 | RLOGE("iconv_open error"); |
| 271 | return -1; |
| 272 | } |
| 273 | memset(dst_str, 0, dst_len); |
| 274 | if(iconv(cd, pin, &src_len, pout, &dst_len) == -1){ |
| 275 | printf("format error or nosupport\n"); |
| 276 | RLOGE("format error or nosupport"); |
| 277 | return -1; |
| 278 | } |
| 279 | |
| 280 | iconv_close(cd); |
| 281 | // **pout = '\0'; |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | //xxx ussiString |
| 286 | int sendUSSI(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 287 | if(argc != 3) |
| 288 | { |
| 289 | RLOGD("the peremeters numbers isn't right , so return"); |
| 290 | return -1; |
| 291 | } |
| 292 | char* srcstr = argv[2]; |
| 293 | char utf8str[64]; |
| 294 | android::Parcel p; |
| 295 | size_t pos = p.dataPosition(); |
| 296 | p.writeInt32(2); |
| 297 | writeStringToParcel(p, (const char *)argv[1]);//ussdaction |
| 298 | |
| 299 | printf("srcstr:%s\n", srcstr); |
| 300 | printf("srcstr:%s\n", argv[2]); |
| 301 | if(isGBK((unsigned char *)srcstr, strlen(srcstr))) |
| 302 | { |
| 303 | if(gbkToUtf8(srcstr, strlen(srcstr), utf8str, sizeof(utf8str)) < 0) |
| 304 | { |
| 305 | RLOGE("format change error"); |
| 306 | } |
| 307 | printf("gbk to utf8:%s\n", utf8str); |
| 308 | writeStringToParcel(p, (const char *)utf8str);//ussdString |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | printf("--------utf8:%s\n", srcstr); |
| 313 | writeStringToParcel(p, (const char *)srcstr);//ussdString |
| 314 | } |
| 315 | p.setDataPosition(pos); |
| 316 | pRI->pCI->dispatchFunction(p, pRI); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | int cancelPendingUssi(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 322 | if(argc != 1) |
| 323 | { |
| 324 | RLOGD("the peremeters numbers isn't right , so return"); |
| 325 | return -1; |
| 326 | } |
| 327 | |
| 328 | android::Parcel p; |
| 329 | pRI->pCI->dispatchFunction(p, pRI); |
| 330 | |
| 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | //xxx ussdString |
| 335 | int sendUSSD(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 336 | if(argc != 2) |
| 337 | { |
| 338 | RLOGD("the peremeters numbers isn't right , so return"); |
| 339 | return -1; |
| 340 | } |
| 341 | android::Parcel p; |
| 342 | size_t pos = p.dataPosition(); |
| 343 | writeStringToParcel(p, (const char *)argv[1]);//ussdString |
| 344 | p.setDataPosition(pos); |
| 345 | pRI->pCI->dispatchFunction(p, pRI); |
| 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | int cancelPendingUssd(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 351 | if(argc != 1) |
| 352 | { |
| 353 | RLOGD("the peremeters numbers isn't right , so return"); |
| 354 | return -1; |
| 355 | } |
| 356 | |
| 357 | android::Parcel p; |
| 358 | pRI->pCI->dispatchFunction(p, pRI); |
| 359 | |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | int getCLIR(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 364 | if(argc != 1) |
| 365 | { |
| 366 | RLOGD("the peremeters numbers isn't right , so return"); |
| 367 | return -1; |
| 368 | } |
| 369 | |
| 370 | android::Parcel p; |
| 371 | pRI->pCI->dispatchFunction(p, pRI); |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | //xxx clirMode |
| 377 | int setCLIR(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 378 | if(argc != 2) |
| 379 | { |
| 380 | RLOGD("the peremeters numbers isn't right , so return"); |
| 381 | return -1; |
| 382 | } |
| 383 | |
| 384 | android::Parcel p; |
| 385 | size_t pos = p.dataPosition(); |
| 386 | p.writeInt32(1); |
| 387 | //0: "user subscription default value; 1:restrict CLI presentation; 2: allow CLI presentation |
| 388 | p.writeInt32(atoi(argv[1]));//clirMode |
| 389 | p.setDataPosition(pos); |
| 390 | |
| 391 | pRI->pCI->dispatchFunction(p, pRI); |
| 392 | |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | int queryCLIP(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 397 | if(argc != 1) |
| 398 | { |
| 399 | RLOGD("the peremeters numbers isn't right , so return"); |
| 400 | return -1; |
| 401 | } |
| 402 | android::Parcel p; |
| 403 | pRI->pCI->dispatchFunction(p, pRI); |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | //xxx cfReason serviceClass number |
| 409 | // mCi.queryCallForwardStatus(commandInterfaceCFReason,0,null,resp); |
| 410 | int queryCallForwardStatus(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 411 | if(argc != 4) |
| 412 | { |
| 413 | RLOGD("the peremeters numbers isn't right , so return"); |
| 414 | return -1; |
| 415 | } |
| 416 | |
| 417 | android::Parcel p; |
| 418 | size_t pos = p.dataPosition(); |
| 419 | |
| 420 | int cfReason = scToCallForwardReason(argv[1]); |
| 421 | RLOGD("queryCallForwardStatus() cfReason: %d", cfReason); |
| 422 | if(cfReason == -1) return -1; |
| 423 | p.writeInt32(2); |
| 424 | p.writeInt32(cfReason); //cfReason |
| 425 | p.writeInt32(siToServiceClass(argv[2])); //serviceClass |
| 426 | p.writeInt32(toaFromString(argv[3])); //number |
| 427 | writeStringToParcel(p, argv[3]);//number |
| 428 | p.writeInt32(0); |
| 429 | |
| 430 | p.setDataPosition(pos); |
| 431 | pRI->pCI->dispatchFunction(p, pRI); |
| 432 | |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | //xxx action cfReason serviceClass number timeSeconds |
| 437 | int setCallForward(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 438 | if(argc != 6 ) |
| 439 | { |
| 440 | RLOGD("the paremeters isn't enough!"); |
| 441 | return -1; |
| 442 | } |
| 443 | android::Parcel p; |
| 444 | size_t pos = p.dataPosition(); |
| 445 | int action = atoi(argv[1]); //status |
| 446 | int reason = scToCallForwardReason(argv[2]); |
| 447 | if(reason == -1) return -1; |
| 448 | char* number = argv[3]; |
| 449 | int time = siToTime(argv[4]); |
| 450 | int serviceClass = siToServiceClass(argv[5]); |
| 451 | p.writeInt32(action); //action |
| 452 | p.writeInt32(reason); //cfReason |
| 453 | p.writeInt32(serviceClass); //serviceClass |
| 454 | p.writeInt32(toaFromString(number)); //number |
| 455 | writeStringToParcel(p, number); |
| 456 | p.writeInt32(time); //timeSeconds |
| 457 | |
| 458 | p.setDataPosition(pos); |
| 459 | |
| 460 | pRI->pCI->dispatchFunction(p, pRI); |
| 461 | |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | |
| 466 | |
| 467 | //xxx serviceClass |
| 468 | int queryCallWaiting(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 469 | if(argc != 2) |
| 470 | { |
| 471 | RLOGD("the peremeters numbers isn't right , so return"); |
| 472 | return -1; |
| 473 | } |
| 474 | |
| 475 | android::Parcel p; |
| 476 | size_t pos = p.dataPosition(); |
| 477 | p.writeInt32(1); |
| 478 | p.writeInt32(siToServiceClass(argv[1]));//serviceClass |
| 479 | |
| 480 | p.setDataPosition(pos); |
| 481 | pRI->pCI->dispatchFunction(p, pRI); |
| 482 | |
| 483 | return 0; |
| 484 | } |
| 485 | |
| 486 | |
| 487 | //xxx enable serviceClass |
| 488 | int setCallWaiting(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 489 | if(argc != 3) |
| 490 | { |
| 491 | RLOGD("the peremeters numbers isn't right , so return"); |
| 492 | return -1; |
| 493 | } |
| 494 | |
| 495 | |
| 496 | android::Parcel p; |
| 497 | size_t pos = p.dataPosition(); |
| 498 | p.writeInt32(2); |
| 499 | p.writeInt32(atoi(argv[1])? 1 : 0);//enable |
| 500 | p.writeInt32(siToServiceClass(argv[2])); //serviceClass |
| 501 | |
| 502 | p.setDataPosition(pos); |
| 503 | pRI->pCI->dispatchFunction(p, pRI); |
| 504 | |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | //xxx facility oldPwd newPwd |
| 509 | int changeBarringPassword(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 510 | if(argc != 4) |
| 511 | { |
| 512 | RLOGD("the peremeters numbers isn't right , so return"); |
| 513 | return -1; |
| 514 | } |
| 515 | |
| 516 | android::Parcel p; |
| 517 | size_t pos = p.dataPosition(); |
| 518 | p.writeInt32(3); |
| 519 | char* facility = scToBarringFacility(argv[1]); |
| 520 | if(facility == NULL) return -1; |
| 521 | writeStringToParcel(p, facility); //facility |
| 522 | writeStringToParcel(p, (const char *)argv[2]); //oldPwd |
| 523 | writeStringToParcel(p, (const char *)argv[3]); //newPwd |
| 524 | |
| 525 | p.setDataPosition(pos); |
| 526 | pRI->pCI->dispatchFunction(p, pRI); |
| 527 | |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | //xxx enable |
| 532 | int setSuppServiceNotifications(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 533 | if(argc != 2) |
| 534 | { |
| 535 | RLOGD("the peremeters numbers isn't right , so return"); |
| 536 | return -1; |
| 537 | } |
| 538 | |
| 539 | android::Parcel p; |
| 540 | size_t pos = p.dataPosition(); |
| 541 | p.writeInt32(1); |
| 542 | p.writeInt32(atoi(argv[1])? 1 : 0);//enable |
| 543 | |
| 544 | p.setDataPosition(pos); |
| 545 | pRI->pCI->dispatchFunction(p, pRI); |
| 546 | |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | int setCLIP(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 551 | if(argc != 2) |
| 552 | { |
| 553 | RLOGD("the peremeters numbers isn't right , so return"); |
| 554 | return -1; |
| 555 | } |
| 556 | |
| 557 | |
| 558 | android::Parcel p; |
| 559 | size_t pos = p.dataPosition(); |
| 560 | p.writeInt32(1); |
| 561 | p.writeInt32(atoi(argv[1])? 1 : 0);//enable |
| 562 | |
| 563 | p.setDataPosition(pos); |
| 564 | pRI->pCI->dispatchFunction(p, pRI); |
| 565 | |
| 566 | return 0; |
| 567 | |
| 568 | } |
| 569 | |
| 570 | int getCOLP(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 571 | if(argc != 1) |
| 572 | { |
| 573 | RLOGD("the peremeters numbers isn't right , so return"); |
| 574 | return -1; |
| 575 | } |
| 576 | |
| 577 | android::Parcel p; |
| 578 | pRI->pCI->dispatchFunction(p, pRI); |
| 579 | |
| 580 | return 0; |
| 581 | |
| 582 | } |
| 583 | |
| 584 | int setCOLP(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 585 | if(argc != 2) |
| 586 | { |
| 587 | RLOGD("the peremeters numbers isn't right , so return"); |
| 588 | return -1; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | android::Parcel p; |
| 593 | size_t pos = p.dataPosition(); |
| 594 | p.writeInt32(1); |
| 595 | p.writeInt32(atoi(argv[1])? 1 : 0);//enable |
| 596 | |
| 597 | p.setDataPosition(pos); |
| 598 | pRI->pCI->dispatchFunction(p, pRI); |
| 599 | |
| 600 | return 0; |
| 601 | |
| 602 | } |
| 603 | |
| 604 | int getCOLR(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 605 | if(argc != 1) |
| 606 | { |
| 607 | RLOGD("the peremeters numbers isn't right , so return"); |
| 608 | return -1; |
| 609 | } |
| 610 | |
| 611 | android::Parcel p; |
| 612 | pRI->pCI->dispatchFunction(p, pRI); |
| 613 | |
| 614 | return 0; |
| 615 | |
| 616 | } |
| 617 | |
| 618 | int queryFacilityLockForApp(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 619 | if(argc != 4) |
| 620 | { |
| 621 | RLOGD("the peremeters numbers isn't right , so return"); |
| 622 | return -1; |
| 623 | } |
| 624 | |
| 625 | char* facility = scToBarringFacility(argv[1]); |
| 626 | if(facility == NULL) return -1; |
| 627 | |
| 628 | char *password = argv[2]; |
| 629 | if(strcmp(password, "null") == 0){ |
| 630 | password = ""; |
| 631 | } |
| 632 | |
| 633 | int serviceClassX = SERVICE_CLASS_NONE; |
| 634 | if (strcmp(facility, CB_FACILITY_BA_FD) == 0) { |
| 635 | serviceClassX = SERVICE_CLASS_VOICE + SERVICE_CLASS_DATA + SERVICE_CLASS_FAX; |
| 636 | } else if(strcmp(facility, CB_FACILITY_BA_SIM) == 0) { |
| 637 | serviceClassX = SERVICE_CLASS_VOICE + SERVICE_CLASS_DATA + SERVICE_CLASS_FAX; |
| 638 | } else { |
| 639 | serviceClassX = siToServiceClass(argv[3]); |
| 640 | } |
| 641 | char serviceclass[16] = {0}; |
| 642 | sprintf(serviceclass, "%d", serviceClassX); |
| 643 | |
| 644 | char* appId = ""; |
| 645 | if (strcmp(facility, CB_FACILITY_BA_FD) == 0) { |
| 646 | appId = getAid(socket_id); |
| 647 | } else if(strcmp(facility, CB_FACILITY_BA_SIM) == 0) { |
| 648 | appId = getAid(socket_id); |
| 649 | } |
| 650 | |
| 651 | android::Parcel p; |
| 652 | size_t pos = p.dataPosition(); |
| 653 | p.writeInt32(4); |
| 654 | writeStringToParcel(p, facility); |
| 655 | writeStringToParcel(p, password); |
| 656 | writeStringToParcel(p, serviceclass); |
| 657 | writeStringToParcel(p, appId); |
| 658 | |
| 659 | p.setDataPosition(pos); |
| 660 | |
| 661 | pRI->pCI->dispatchFunction(p, pRI); |
| 662 | return 0; |
| 663 | } |
| 664 | |
| 665 | |
| 666 | int setFacilityLockForApp(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 667 | RLOGD("setFacilityLockForApp %d: " , pRI->pCI->requestNumber); |
| 668 | if(argc != 5) |
| 669 | { |
| 670 | RLOGD("the peremeters numbers isn't right , so return"); |
| 671 | return -1; |
| 672 | } |
| 673 | |
| 674 | |
| 675 | char* facility = scToBarringFacility(argv[1]); |
| 676 | if(facility == NULL) return -1; |
| 677 | |
| 678 | char *password = argv[2]; |
| 679 | if(strcmp(password, "null") == 0){ |
| 680 | password = ""; |
| 681 | } |
| 682 | |
| 683 | int serviceClassX = SERVICE_CLASS_NONE; |
| 684 | if (strcmp(facility, CB_FACILITY_BA_FD) == 0) { |
| 685 | serviceClassX = SERVICE_CLASS_VOICE + SERVICE_CLASS_DATA + SERVICE_CLASS_FAX; |
| 686 | } else if(strcmp(facility, CB_FACILITY_BA_SIM) == 0) { |
| 687 | serviceClassX = SERVICE_CLASS_VOICE + SERVICE_CLASS_DATA + SERVICE_CLASS_FAX; |
| 688 | } else { |
| 689 | serviceClassX = siToServiceClass(argv[3]); |
| 690 | } |
| 691 | char serviceclass[16] = {0}; |
| 692 | sprintf(serviceclass, "%d", serviceClassX); |
| 693 | |
| 694 | char* appId = ""; |
| 695 | if (strcmp(facility, CB_FACILITY_BA_FD) == 0) { |
| 696 | appId = getAid(socket_id); |
| 697 | } else if(strcmp(facility, CB_FACILITY_BA_SIM) == 0) { |
| 698 | appId = getAid(socket_id); |
| 699 | } |
| 700 | |
| 701 | |
| 702 | const char *lockStrings = argv[4]; |
| 703 | |
| 704 | android::Parcel p; |
| 705 | size_t pos = p.dataPosition(); |
| 706 | p.writeInt32(5); |
| 707 | writeStringToParcel(p, facility); |
| 708 | writeStringToParcel(p, lockStrings); |
| 709 | writeStringToParcel(p, password); |
| 710 | writeStringToParcel(p, serviceclass); |
| 711 | writeStringToParcel(p, appId); |
| 712 | p.setDataPosition(pos); |
| 713 | pRI->pCI->dispatchFunction(p, pRI); |
| 714 | |
| 715 | return 0; |
| 716 | } |