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 17 package com.android.internal.telephony; 18 19 import static com.android.internal.telephony.RILConstants.*; 20 import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; 21 import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; 22 import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; 23 import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; 24 import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA; 25 import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA; 26 import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA; 27 28 import android.content.BroadcastReceiver; 29 import android.content.Context; 30 import android.content.Intent; 31 import android.content.IntentFilter; 32 import android.net.ConnectivityManager; 33 import android.net.LocalSocket; 34 import android.net.LocalSocketAddress; 35 import android.os.AsyncResult; 36 import android.os.Handler; 37 import android.os.HandlerThread; 38 import android.os.Looper; 39 import android.os.Message; 40 import android.os.Parcel; 41 import android.os.PowerManager; 42 import android.os.SystemProperties; 43 import android.os.PowerManager.WakeLock; 44 import android.telephony.NeighboringCellInfo; 45 import android.telephony.PhoneNumberUtils; 46 import android.telephony.SmsManager; 47 import android.telephony.SmsMessage; 48 import android.text.TextUtils; 49 import android.util.Log; 50 51 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; 52 import com.android.internal.telephony.gsm.SuppServiceNotification; 53 import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; 54 import com.android.internal.telephony.cdma.CdmaInformationRecords; 55 56 import java.io.ByteArrayInputStream; 57 import java.io.DataInputStream; 58 import java.io.IOException; 59 import java.io.InputStream; 60 import java.util.ArrayList; 61 import java.util.Collections; 62 63 /** 64 * {@hide} 65 */ 66 class RILRequest { 67 static final String LOG_TAG = "RILJ"; 68 69 //***** Class Variables 70 static int sNextSerial = 0; 71 static Object sSerialMonitor = new Object(); 72 private static Object sPoolSync = new Object(); 73 private static RILRequest sPool = null; 74 private static int sPoolSize = 0; 75 private static final int MAX_POOL_SIZE = 4; 76 77 //***** Instance Variables 78 int mSerial; 79 int mRequest; 80 Message mResult; 81 Parcel mp; 82 RILRequest mNext; 83 84 /** 85 * Retrieves a new RILRequest instance from the pool. 86 * 87 * @param request RIL_REQUEST_* 88 * @param result sent when operation completes 89 * @return a RILRequest instance from the pool. 90 */ 91 static RILRequest obtain(int request, Message result) { 92 RILRequest rr = null; 93 94 synchronized(sPoolSync) { 95 if (sPool != null) { 96 rr = sPool; 97 sPool = rr.mNext; 98 rr.mNext = null; 99 sPoolSize--; 100 } 101 } 102 103 if (rr == null) { 104 rr = new RILRequest(); 105 } 106 107 synchronized(sSerialMonitor) { 108 rr.mSerial = sNextSerial++; 109 } 110 rr.mRequest = request; 111 rr.mResult = result; 112 rr.mp = Parcel.obtain(); 113 114 if (result != null && result.getTarget() == null) { 115 throw new NullPointerException("Message target must not be null"); 116 } 117 118 // first elements in any RIL Parcel 119 rr.mp.writeInt(request); 120 rr.mp.writeInt(rr.mSerial); 121 122 return rr; 123 } 124 125 /** 126 * Returns a RILRequest instance to the pool. 127 * 128 * Note: This should only be called once per use. 129 */ 130 void release() { 131 synchronized (sPoolSync) { 132 if (sPoolSize < MAX_POOL_SIZE) { 133 this.mNext = sPool; 134 sPool = this; 135 sPoolSize++; 136 mResult = null; 137 } 138 } 139 } 140 141 private RILRequest() { 142 } 143 144 static void 145 resetSerial() { 146 synchronized(sSerialMonitor) { 147 sNextSerial = 0; 148 } 149 } 150 151 String 152 serialString() { 153 //Cheesy way to do %04d 154 StringBuilder sb = new StringBuilder(8); 155 String sn; 156 157 sn = Integer.toString(mSerial); 158 159 //sb.append("J["); 160 sb.append('['); 161 for (int i = 0, s = sn.length() ; i < 4 - s; i++) { 162 sb.append('0'); 163 } 164 165 sb.append(sn); 166 sb.append(']'); 167 return sb.toString(); 168 } 169 170 void 171 onError(int error, Object ret) { 172 CommandException ex; 173 174 ex = CommandException.fromRilErrno(error); 175 176 if (RIL.RILJ_LOGD) Log.d(LOG_TAG, serialString() + "< " 177 + RIL.requestToString(mRequest) 178 + " error: " + ex); 179 180 if (mResult != null) { 181 AsyncResult.forMessage(mResult, ret, ex); 182 mResult.sendToTarget(); 183 } 184 185 if (mp != null) { 186 mp.recycle(); 187 mp = null; 188 } 189 } 190 } 191 192 193 /** 194 * RIL implementation of the CommandsInterface. 195 * FIXME public only for testing 196 * 197 * {@hide} 198 */ 199 public final class RIL extends BaseCommands implements CommandsInterface { 200 static final String LOG_TAG = "RILJ"; 201 static final boolean RILJ_LOGD = true; 202 static final boolean RILJ_LOGV = false; // STOP SHIP if true 203 204 /** 205 * Wake lock timeout should be longer than the longest timeout in 206 * the vendor ril. 207 */ 208 private static final int DEFAULT_WAKE_LOCK_TIMEOUT = 60000; 209 210 //***** Instance Variables 211 212 LocalSocket mSocket; 213 HandlerThread mSenderThread; 214 RILSender mSender; 215 Thread mReceiverThread; 216 RILReceiver mReceiver; 217 WakeLock mWakeLock; 218 int mWakeLockTimeout; 219 // The number of requests pending to be sent out, it increases before calling 220 // EVENT_SEND and decreases while handling EVENT_SEND. It gets cleared while 221 // WAKE_LOCK_TIMEOUT occurs. 222 int mRequestMessagesPending; 223 // The number of requests sent out but waiting for response. It increases while 224 // sending request and decreases while handling response. It should match 225 // mRequestList.size() unless there are requests no replied while 226 // WAKE_LOCK_TIMEOUT occurs. 227 int mRequestMessagesWaiting; 228 229 //I'd rather this be LinkedList or something 230 ArrayList<RILRequest> mRequestsList = new ArrayList<RILRequest>(); 231 232 Object mLastNITZTimeInfo; 233 234 //***** Events 235 236 static final int EVENT_SEND = 1; 237 static final int EVENT_WAKE_LOCK_TIMEOUT = 2; 238 239 //***** Constants 240 241 // match with constant in ril.cpp 242 static final int RIL_MAX_COMMAND_BYTES = (8 * 1024); 243 static final int RESPONSE_SOLICITED = 0; 244 static final int RESPONSE_UNSOLICITED = 1; 245 246 static final String SOCKET_NAME_RIL = "rild"; 247 248 static final int SOCKET_OPEN_RETRY_MILLIS = 4 * 1000; 249 250 // The number of the required config values for broadcast SMS stored in the C struct 251 // RIL_CDMA_BroadcastServiceInfo 252 private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3; 253 254 private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31; 255 256 BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { 257 @Override 258 public void onReceive(Context context, Intent intent) { 259 if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { 260 sendScreenState(true); 261 } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { 262 sendScreenState(false); 263 } else { 264 Log.w(LOG_TAG, "RIL received unexpected Intent: " + intent.getAction()); 265 } 266 } 267 }; 268 269 class RILSender extends Handler implements Runnable { 270 public RILSender(Looper looper) { 271 super(looper); 272 } 273 274 // Only allocated once 275 byte[] dataLength = new byte[4]; 276 277 //***** Runnable implementation 278 public void 279 run() { 280 //setup if needed 281 } 282 283 284 //***** Handler implementation 285 @Override public void 286 handleMessage(Message msg) { 287 RILRequest rr = (RILRequest)(msg.obj); 288 RILRequest req = null; 289 290 switch (msg.what) { 291 case EVENT_SEND: 292 /** 293 * mRequestMessagePending++ already happened for every 294 * EVENT_SEND, thus we must make sure 295 * mRequestMessagePending-- happens once and only once 296 */ 297 boolean alreadySubtracted = false; 298 try { 299 LocalSocket s; 300 301 s = mSocket; 302 303 if (s == null) { 304 rr.onError(RADIO_NOT_AVAILABLE, null); 305 rr.release(); 306 if (mRequestMessagesPending > 0) 307 mRequestMessagesPending--; 308 alreadySubtracted = true; 309 return; 310 } 311 312 synchronized (mRequestsList) { 313 mRequestsList.add(rr); 314 mRequestMessagesWaiting++; 315 } 316 317 if (mRequestMessagesPending > 0) 318 mRequestMessagesPending--; 319 alreadySubtracted = true; 320 321 byte[] data; 322 323 data = rr.mp.marshall(); 324 rr.mp.recycle(); 325 rr.mp = null; 326 327 if (data.length > RIL_MAX_COMMAND_BYTES) { 328 throw new RuntimeException( 329 "Parcel larger than max bytes allowed! " 330 + data.length); 331 } 332 333 // parcel length in big endian 334 dataLength[0] = dataLength[1] = 0; 335 dataLength[2] = (byte)((data.length >> 8) & 0xff); 336 dataLength[3] = (byte)((data.length) & 0xff); 337 338 //Log.v(LOG_TAG, "writing packet: " + data.length + " bytes"); 339 340 s.getOutputStream().write(dataLength); 341 s.getOutputStream().write(data); 342 } catch (IOException ex) { 343 Log.e(LOG_TAG, "IOException", ex); 344 req = findAndRemoveRequestFromList(rr.mSerial); 345 // make sure this request has not already been handled, 346 // eg, if RILReceiver cleared the list. 347 if (req != null || !alreadySubtracted) { 348 rr.onError(RADIO_NOT_AVAILABLE, null); 349 rr.release(); 350 } 351 } catch (RuntimeException exc) { 352 Log.e(LOG_TAG, "Uncaught exception ", exc); 353 req = findAndRemoveRequestFromList(rr.mSerial); 354 // make sure this request has not already been handled, 355 // eg, if RILReceiver cleared the list. 356 if (req != null || !alreadySubtracted) { 357 rr.onError(GENERIC_FAILURE, null); 358 rr.release(); 359 } 360 } finally { 361 // Note: We are "Done" only if there are no outstanding 362 // requests or replies. Thus this code path will only release 363 // the wake lock on errors. 364 releaseWakeLockIfDone(); 365 } 366 367 if (!alreadySubtracted && mRequestMessagesPending > 0) { 368 mRequestMessagesPending--; 369 } 370 371 break; 372 373 case EVENT_WAKE_LOCK_TIMEOUT: 374 // Haven't heard back from the last request. Assume we're 375 // not getting a response and release the wake lock. 376 synchronized (mWakeLock) { 377 if (mWakeLock.isHeld()) { 378 // The timer of WAKE_LOCK_TIMEOUT is reset with each 379 // new send request. So when WAKE_LOCK_TIMEOUT occurs 380 // all requests in mRequestList already waited at 381 // least DEFAULT_WAKE_LOCK_TIMEOUT but no response. 382 // Reset mRequestMessagesWaiting to enable 383 // releaseWakeLockIfDone(). 384 // 385 // Note: Keep mRequestList so that delayed response 386 // can still be handled when response finally comes. 387 if (mRequestMessagesWaiting != 0) { 388 Log.d(LOG_TAG, "NOTE: mReqWaiting is NOT 0 but" 389 + mRequestMessagesWaiting + " at TIMEOUT, reset!" 390 + " There still msg waitng for response"); 391 392 mRequestMessagesWaiting = 0; 393 394 if (RILJ_LOGD) { 395 synchronized (mRequestsList) { 396 int count = mRequestsList.size(); 397 Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " + 398 " mRequestList=" + count); 399 400 for (int i = 0; i < count; i++) { 401 rr = mRequestsList.get(i); 402 Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " 403 + requestToString(rr.mRequest)); 404 } 405 } 406 } 407 } 408 // mRequestMessagesPending shows how many 409 // requests are waiting to be sent (and before 410 // to be added in request list) since star the 411 // WAKE_LOCK_TIMEOUT timer. Since WAKE_LOCK_TIMEOUT 412 // is the expected time to get response, all requests 413 // should already sent out (i.e. 414 // mRequestMessagesPending is 0 )while TIMEOUT occurs. 415 if (mRequestMessagesPending != 0) { 416 Log.e(LOG_TAG, "ERROR: mReqPending is NOT 0 but" 417 + mRequestMessagesPending + " at TIMEOUT, reset!"); 418 mRequestMessagesPending = 0; 419 420 } 421 mWakeLock.release(); 422 } 423 } 424 break; 425 } 426 } 427 } 428 429 /** 430 * Reads in a single RIL message off the wire. A RIL message consists 431 * of a 4-byte little-endian length and a subsequent series of bytes. 432 * The final message (length header omitted) is read into 433 * <code>buffer</code> and the length of the final message (less header) 434 * is returned. A return value of -1 indicates end-of-stream. 435 * 436 * @param is non-null; Stream to read from 437 * @param buffer Buffer to fill in. Must be as large as maximum 438 * message size, or an ArrayOutOfBounds exception will be thrown. 439 * @return Length of message less header, or -1 on end of stream. 440 * @throws IOException 441 */ 442 private static int readRilMessage(InputStream is, byte[] buffer) 443 throws IOException { 444 int countRead; 445 int offset; 446 int remaining; 447 int messageLength; 448 449 // First, read in the length of the message 450 offset = 0; 451 remaining = 4; 452 do { 453 countRead = is.read(buffer, offset, remaining); 454 455 if (countRead < 0 ) { 456 Log.e(LOG_TAG, "Hit EOS reading message length"); 457 return -1; 458 } 459 460 offset += countRead; 461 remaining -= countRead; 462 } while (remaining > 0); 463 464 messageLength = ((buffer[0] & 0xff) << 24) 465 | ((buffer[1] & 0xff) << 16) 466 | ((buffer[2] & 0xff) << 8) 467 | (buffer[3] & 0xff); 468 469 // Then, re-use the buffer and read in the message itself 470 offset = 0; 471 remaining = messageLength; 472 do { 473 countRead = is.read(buffer, offset, remaining); 474 475 if (countRead < 0 ) { 476 Log.e(LOG_TAG, "Hit EOS reading message. messageLength=" + messageLength 477 + " remaining=" + remaining); 478 return -1; 479 } 480 481 offset += countRead; 482 remaining -= countRead; 483 } while (remaining > 0); 484 485 return messageLength; 486 } 487 488 class RILReceiver implements Runnable { 489 byte[] buffer; 490 491 RILReceiver() { 492 buffer = new byte[RIL_MAX_COMMAND_BYTES]; 493 } 494 495 public void 496 run() { 497 int retryCount = 0; 498 499 try {for (;;) { 500 LocalSocket s = null; 501 LocalSocketAddress l; 502 503 try { 504 s = new LocalSocket(); 505 l = new LocalSocketAddress(SOCKET_NAME_RIL, 506 LocalSocketAddress.Namespace.RESERVED); 507 s.connect(l); 508 } catch (IOException ex){ 509 try { 510 if (s != null) { 511 s.close(); 512 } 513 } catch (IOException ex2) { 514 //ignore failure to close after failure to connect 515 } 516 517 // don't print an error message after the the first time 518 // or after the 8th time 519 520 if (retryCount == 8) { 521 Log.e (LOG_TAG, 522 "Couldn't find '" + SOCKET_NAME_RIL 523 + "' socket after " + retryCount 524 + " times, continuing to retry silently"); 525 } else if (retryCount > 0 && retryCount < 8) { 526 Log.i (LOG_TAG, 527 "Couldn't find '" + SOCKET_NAME_RIL 528 + "' socket; retrying after timeout"); 529 } 530 531 try { 532 Thread.sleep(SOCKET_OPEN_RETRY_MILLIS); 533 } catch (InterruptedException er) { 534 } 535 536 retryCount++; 537 continue; 538 } 539 540 retryCount = 0; 541 542 mSocket = s; 543 Log.i(LOG_TAG, "Connected to '" + SOCKET_NAME_RIL + "' socket"); 544 545 int length = 0; 546 try { 547 InputStream is = mSocket.getInputStream(); 548 549 for (;;) { 550 Parcel p; 551 552 length = readRilMessage(is, buffer); 553 554 if (length < 0) { 555 // End-of-stream reached 556 break; 557 } 558 559 p = Parcel.obtain(); 560 p.unmarshall(buffer, 0, length); 561 p.setDataPosition(0); 562 563 //Log.v(LOG_TAG, "Read packet: " + length + " bytes"); 564 565 processResponse(p); 566 p.recycle(); 567 } 568 } catch (java.io.IOException ex) { 569 Log.i(LOG_TAG, "'" + SOCKET_NAME_RIL + "' socket closed", 570 ex); 571 } catch (Throwable tr) { 572 Log.e(LOG_TAG, "Uncaught exception read length=" + length + 573 "Exception:" + tr.toString()); 574 } 575 576 Log.i(LOG_TAG, "Disconnected from '" + SOCKET_NAME_RIL 577 + "' socket"); 578 579 setRadioState (RadioState.RADIO_UNAVAILABLE); 580 581 try { 582 mSocket.close(); 583 } catch (IOException ex) { 584 } 585 586 mSocket = null; 587 RILRequest.resetSerial(); 588 589 // Clear request list on close 590 clearRequestsList(RADIO_NOT_AVAILABLE, false); 591 }} catch (Throwable tr) { 592 Log.e(LOG_TAG,"Uncaught exception", tr); 593 } 594 595 /* We're disconnected so we don't know the ril version */ 596 notifyRegistrantsRilConnectionChanged(-1); 597 } 598 } 599 600 601 602 //***** Constructors 603 604 public RIL(Context context, int preferredNetworkType, int cdmaSubscription) { 605 super(context); 606 if (RILJ_LOGD) { 607 riljLog("RIL(context, preferredNetworkType=" + preferredNetworkType + 608 " cdmaSubscription=" + cdmaSubscription + ")"); 609 } 610 mCdmaSubscription = cdmaSubscription; 611 mPreferredNetworkType = preferredNetworkType; 612 mPhoneType = RILConstants.NO_PHONE; 613 614 PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); 615 mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG); 616 mWakeLock.setReferenceCounted(false); 617 mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT, 618 DEFAULT_WAKE_LOCK_TIMEOUT); 619 mRequestMessagesPending = 0; 620 mRequestMessagesWaiting = 0; 621 622 mSenderThread = new HandlerThread("RILSender"); 623 mSenderThread.start(); 624 625 Looper looper = mSenderThread.getLooper(); 626 mSender = new RILSender(looper); 627 628 ConnectivityManager cm = (ConnectivityManager)context.getSystemService( 629 Context.CONNECTIVITY_SERVICE); 630 if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false) { 631 riljLog("Not starting RILReceiver: wifi-only"); 632 } else { 633 riljLog("Starting RILReceiver"); 634 mReceiver = new RILReceiver(); 635 mReceiverThread = new Thread(mReceiver, "RILReceiver"); 636 mReceiverThread.start(); 637 638 IntentFilter filter = new IntentFilter(); 639 filter.addAction(Intent.ACTION_SCREEN_ON); 640 filter.addAction(Intent.ACTION_SCREEN_OFF); 641 context.registerReceiver(mIntentReceiver, filter); 642 } 643 } 644 645 //***** CommandsInterface implementation 646 647 @Override public void 648 setOnNITZTime(Handler h, int what, Object obj) { 649 super.setOnNITZTime(h, what, obj); 650 651 // Send the last NITZ time if we have it 652 if (mLastNITZTimeInfo != null) { 653 mNITZTimeRegistrant 654 .notifyRegistrant( 655 new AsyncResult (null, mLastNITZTimeInfo, null)); 656 mLastNITZTimeInfo = null; 657 } 658 } 659 660 public void 661 getIccCardStatus(Message result) { 662 //Note: This RIL request has not been renamed to ICC, 663 // but this request is also valid for SIM and RUIM 664 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SIM_STATUS, result); 665 666 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 667 668 send(rr); 669 } 670 671 @Override public void 672 supplyIccPin(String pin, Message result) { 673 supplyIccPinForApp(pin, null, result); 674 } 675 676 @Override public void 677 supplyIccPinForApp(String pin, String aid, Message result) { 678 //Note: This RIL request has not been renamed to ICC, 679 // but this request is also valid for SIM and RUIM 680 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN, result); 681 682 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 683 684 rr.mp.writeInt(2); 685 rr.mp.writeString(pin); 686 rr.mp.writeString(aid); 687 688 send(rr); 689 } 690 691 @Override public void 692 supplyIccPuk(String puk, String newPin, Message result) { 693 supplyIccPukForApp(puk, newPin, null, result); 694 } 695 696 @Override public void 697 supplyIccPukForApp(String puk, String newPin, String aid, Message result) { 698 //Note: This RIL request has not been renamed to ICC, 699 // but this request is also valid for SIM and RUIM 700 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK, result); 701 702 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 703 704 rr.mp.writeInt(3); 705 rr.mp.writeString(puk); 706 rr.mp.writeString(newPin); 707 rr.mp.writeString(aid); 708 709 send(rr); 710 } 711 712 @Override public void 713 supplyIccPin2(String pin, Message result) { 714 supplyIccPin2ForApp(pin, null, result); 715 } 716 717 @Override public void 718 supplyIccPin2ForApp(String pin, String aid, Message result) { 719 //Note: This RIL request has not been renamed to ICC, 720 // but this request is also valid for SIM and RUIM 721 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN2, result); 722 723 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 724 725 rr.mp.writeInt(2); 726 rr.mp.writeString(pin); 727 rr.mp.writeString(aid); 728 729 send(rr); 730 } 731 732 @Override public void 733 supplyIccPuk2(String puk2, String newPin2, Message result) { 734 supplyIccPuk2ForApp(puk2, newPin2, null, result); 735 } 736 737 @Override public void 738 supplyIccPuk2ForApp(String puk, String newPin2, String aid, Message result) { 739 //Note: This RIL request has not been renamed to ICC, 740 // but this request is also valid for SIM and RUIM 741 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK2, result); 742 743 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 744 745 rr.mp.writeInt(3); 746 rr.mp.writeString(puk); 747 rr.mp.writeString(newPin2); 748 rr.mp.writeString(aid); 749 750 send(rr); 751 } 752 753 @Override public void 754 changeIccPin(String oldPin, String newPin, Message result) { 755 changeIccPinForApp(oldPin, newPin, null, result); 756 } 757 758 @Override public void 759 changeIccPinForApp(String oldPin, String newPin, String aid, Message result) { 760 //Note: This RIL request has not been renamed to ICC, 761 // but this request is also valid for SIM and RUIM 762 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN, result); 763 764 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 765 766 rr.mp.writeInt(3); 767 rr.mp.writeString(oldPin); 768 rr.mp.writeString(newPin); 769 rr.mp.writeString(aid); 770 771 send(rr); 772 } 773 774 @Override public void 775 changeIccPin2(String oldPin2, String newPin2, Message result) { 776 changeIccPin2ForApp(oldPin2, newPin2, null, result); 777 } 778 779 @Override public void 780 changeIccPin2ForApp(String oldPin2, String newPin2, String aid, Message result) { 781 //Note: This RIL request has not been renamed to ICC, 782 // but this request is also valid for SIM and RUIM 783 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN2, result); 784 785 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 786 787 rr.mp.writeInt(3); 788 rr.mp.writeString(oldPin2); 789 rr.mp.writeString(newPin2); 790 rr.mp.writeString(aid); 791 792 send(rr); 793 } 794 795 public void 796 changeBarringPassword(String facility, String oldPwd, String newPwd, Message result) { 797 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_BARRING_PASSWORD, result); 798 799 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 800 801 rr.mp.writeInt(3); 802 rr.mp.writeString(facility); 803 rr.mp.writeString(oldPwd); 804 rr.mp.writeString(newPwd); 805 806 send(rr); 807 } 808 809 public void 810 supplyNetworkDepersonalization(String netpin, Message result) { 811 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, result); 812 813 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 814 815 rr.mp.writeInt(1); 816 rr.mp.writeString(netpin); 817 818 send(rr); 819 } 820 821 public void 822 getCurrentCalls (Message result) { 823 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CURRENT_CALLS, result); 824 825 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 826 827 send(rr); 828 } 829 830 @Deprecated public void 831 getPDPContextList(Message result) { 832 getDataCallList(result); 833 } 834 835 public void 836 getDataCallList(Message result) { 837 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DATA_CALL_LIST, result); 838 839 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 840 841 send(rr); 842 } 843 844 public void 845 dial (String address, int clirMode, Message result) { 846 dial(address, clirMode, null, result); 847 } 848 849 public void 850 dial(String address, int clirMode, UUSInfo uusInfo, Message result) { 851 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result); 852 853 rr.mp.writeString(address); 854 rr.mp.writeInt(clirMode); 855 rr.mp.writeInt(0); // UUS information is absent 856 857 if (uusInfo == null) { 858 rr.mp.writeInt(0); // UUS information is absent 859 } else { 860 rr.mp.writeInt(1); // UUS information is present 861 rr.mp.writeInt(uusInfo.getType()); 862 rr.mp.writeInt(uusInfo.getDcs()); 863 rr.mp.writeByteArray(uusInfo.getUserData()); 864 } 865 866 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 867 868 send(rr); 869 } 870 871 public void 872 getIMSI(Message result) { 873 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result); 874 875 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 876 877 send(rr); 878 } 879 880 public void 881 getIMEI(Message result) { 882 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEI, result); 883 884 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 885 886 send(rr); 887 } 888 889 public void 890 getIMEISV(Message result) { 891 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEISV, result); 892 893 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 894 895 send(rr); 896 } 897 898 899 public void 900 hangupConnection (int gsmIndex, Message result) { 901 if (RILJ_LOGD) riljLog("hangupConnection: gsmIndex=" + gsmIndex); 902 903 RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP, result); 904 905 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + 906 gsmIndex); 907 908 rr.mp.writeInt(1); 909 rr.mp.writeInt(gsmIndex); 910 911 send(rr); 912 } 913 914 public void 915 hangupWaitingOrBackground (Message result) { 916 RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND, 917 result); 918 919 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 920 921 send(rr); 922 } 923 924 public void 925 hangupForegroundResumeBackground (Message result) { 926 RILRequest rr 927 = RILRequest.obtain( 928 RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND, 929 result); 930 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 931 932 send(rr); 933 } 934 935 public void 936 switchWaitingOrHoldingAndActive (Message result) { 937 RILRequest rr 938 = RILRequest.obtain( 939 RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, 940 result); 941 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 942 943 send(rr); 944 } 945 946 public void 947 conference (Message result) { 948 RILRequest rr 949 = RILRequest.obtain(RIL_REQUEST_CONFERENCE, result); 950 951 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 952 953 send(rr); 954 } 955 956 957 public void setPreferredVoicePrivacy(boolean enable, Message result) { 958 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, 959 result); 960 961 rr.mp.writeInt(1); 962 rr.mp.writeInt(enable ? 1:0); 963 964 send(rr); 965 } 966 967 public void getPreferredVoicePrivacy(Message result) { 968 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, 969 result); 970 send(rr); 971 } 972 973 public void 974 separateConnection (int gsmIndex, Message result) { 975 RILRequest rr 976 = RILRequest.obtain(RIL_REQUEST_SEPARATE_CONNECTION, result); 977 978 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 979 + " " + gsmIndex); 980 981 rr.mp.writeInt(1); 982 rr.mp.writeInt(gsmIndex); 983 984 send(rr); 985 } 986 987 public void 988 acceptCall (Message result) { 989 RILRequest rr 990 = RILRequest.obtain(RIL_REQUEST_ANSWER, result); 991 992 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 993 994 send(rr); 995 } 996 997 public void 998 rejectCall (Message result) { 999 RILRequest rr 1000 = RILRequest.obtain(RIL_REQUEST_UDUB, result); 1001 1002 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1003 1004 send(rr); 1005 } 1006 1007 public void 1008 explicitCallTransfer (Message result) { 1009 RILRequest rr 1010 = RILRequest.obtain(RIL_REQUEST_EXPLICIT_CALL_TRANSFER, result); 1011 1012 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1013 1014 send(rr); 1015 } 1016 1017 public void 1018 getLastCallFailCause (Message result) { 1019 RILRequest rr 1020 = RILRequest.obtain(RIL_REQUEST_LAST_CALL_FAIL_CAUSE, result); 1021 1022 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1023 1024 send(rr); 1025 } 1026 1027 /** 1028 * @deprecated 1029 */ 1030 public void 1031 getLastPdpFailCause (Message result) { 1032 getLastDataCallFailCause (result); 1033 } 1034 1035 /** 1036 * The preferred new alternative to getLastPdpFailCause 1037 */ 1038 public void 1039 getLastDataCallFailCause (Message result) { 1040 RILRequest rr 1041 = RILRequest.obtain(RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, result); 1042 1043 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1044 1045 send(rr); 1046 } 1047 1048 public void 1049 setMute (boolean enableMute, Message response) { 1050 RILRequest rr 1051 = RILRequest.obtain(RIL_REQUEST_SET_MUTE, response); 1052 1053 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1054 + " " + enableMute); 1055 1056 rr.mp.writeInt(1); 1057 rr.mp.writeInt(enableMute ? 1 : 0); 1058 1059 send(rr); 1060 } 1061 1062 public void 1063 getMute (Message response) { 1064 RILRequest rr 1065 = RILRequest.obtain(RIL_REQUEST_GET_MUTE, response); 1066 1067 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1068 1069 send(rr); 1070 } 1071 1072 public void 1073 getSignalStrength (Message result) { 1074 RILRequest rr 1075 = RILRequest.obtain(RIL_REQUEST_SIGNAL_STRENGTH, result); 1076 1077 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1078 1079 send(rr); 1080 } 1081 1082 public void 1083 getVoiceRegistrationState (Message result) { 1084 RILRequest rr 1085 = RILRequest.obtain(RIL_REQUEST_VOICE_REGISTRATION_STATE, result); 1086 1087 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1088 1089 send(rr); 1090 } 1091 1092 public void 1093 getDataRegistrationState (Message result) { 1094 RILRequest rr 1095 = RILRequest.obtain(RIL_REQUEST_DATA_REGISTRATION_STATE, result); 1096 1097 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1098 1099 send(rr); 1100 } 1101 1102 public void 1103 getOperator(Message result) { 1104 RILRequest rr 1105 = RILRequest.obtain(RIL_REQUEST_OPERATOR, result); 1106 1107 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1108 1109 send(rr); 1110 } 1111 1112 public void 1113 sendDtmf(char c, Message result) { 1114 RILRequest rr 1115 = RILRequest.obtain(RIL_REQUEST_DTMF, result); 1116 1117 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1118 1119 rr.mp.writeString(Character.toString(c)); 1120 1121 send(rr); 1122 } 1123 1124 public void 1125 startDtmf(char c, Message result) { 1126 RILRequest rr 1127 = RILRequest.obtain(RIL_REQUEST_DTMF_START, result); 1128 1129 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1130 1131 rr.mp.writeString(Character.toString(c)); 1132 1133 send(rr); 1134 } 1135 1136 public void 1137 stopDtmf(Message result) { 1138 RILRequest rr 1139 = RILRequest.obtain(RIL_REQUEST_DTMF_STOP, result); 1140 1141 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1142 1143 send(rr); 1144 } 1145 1146 public void 1147 sendBurstDtmf(String dtmfString, int on, int off, Message result) { 1148 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BURST_DTMF, result); 1149 1150 rr.mp.writeInt(3); 1151 rr.mp.writeString(dtmfString); 1152 rr.mp.writeString(Integer.toString(on)); 1153 rr.mp.writeString(Integer.toString(off)); 1154 1155 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1156 + " : " + dtmfString); 1157 1158 send(rr); 1159 } 1160 1161 public void 1162 sendSMS (String smscPDU, String pdu, Message result) { 1163 RILRequest rr 1164 = RILRequest.obtain(RIL_REQUEST_SEND_SMS, result); 1165 1166 rr.mp.writeInt(2); 1167 rr.mp.writeString(smscPDU); 1168 rr.mp.writeString(pdu); 1169 1170 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1171 1172 send(rr); 1173 } 1174 1175 public void 1176 sendCdmaSms(byte[] pdu, Message result) { 1177 int address_nbr_of_digits; 1178 int subaddr_nbr_of_digits; 1179 int bearerDataLength; 1180 ByteArrayInputStream bais = new ByteArrayInputStream(pdu); 1181 DataInputStream dis = new DataInputStream(bais); 1182 1183 RILRequest rr 1184 = RILRequest.obtain(RIL_REQUEST_CDMA_SEND_SMS, result); 1185 1186 try { 1187 rr.mp.writeInt(dis.readInt()); //teleServiceId 1188 rr.mp.writeByte((byte) dis.readInt()); //servicePresent 1189 rr.mp.writeInt(dis.readInt()); //serviceCategory 1190 rr.mp.writeInt(dis.read()); //address_digit_mode 1191 rr.mp.writeInt(dis.read()); //address_nbr_mode 1192 rr.mp.writeInt(dis.read()); //address_ton 1193 rr.mp.writeInt(dis.read()); //address_nbr_plan 1194 address_nbr_of_digits = (byte) dis.read(); 1195 rr.mp.writeByte((byte) address_nbr_of_digits); 1196 for(int i=0; i < address_nbr_of_digits; i++){ 1197 rr.mp.writeByte(dis.readByte()); // address_orig_bytes[i] 1198 } 1199 rr.mp.writeInt(dis.read()); //subaddressType 1200 rr.mp.writeByte((byte) dis.read()); //subaddr_odd 1201 subaddr_nbr_of_digits = (byte) dis.read(); 1202 rr.mp.writeByte((byte) subaddr_nbr_of_digits); 1203 for(int i=0; i < subaddr_nbr_of_digits; i++){ 1204 rr.mp.writeByte(dis.readByte()); //subaddr_orig_bytes[i] 1205 } 1206 1207 bearerDataLength = dis.read(); 1208 rr.mp.writeInt(bearerDataLength); 1209 for(int i=0; i < bearerDataLength; i++){ 1210 rr.mp.writeByte(dis.readByte()); //bearerData[i] 1211 } 1212 }catch (IOException ex){ 1213 if (RILJ_LOGD) riljLog("sendSmsCdma: conversion from input stream to object failed: " 1214 + ex); 1215 } 1216 1217 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1218 1219 send(rr); 1220 } 1221 1222 public void deleteSmsOnSim(int index, Message response) { 1223 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DELETE_SMS_ON_SIM, 1224 response); 1225 1226 rr.mp.writeInt(1); 1227 rr.mp.writeInt(index); 1228 1229 if (false) { 1230 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1231 + requestToString(rr.mRequest) 1232 + " " + index); 1233 } 1234 1235 send(rr); 1236 } 1237 1238 public void deleteSmsOnRuim(int index, Message response) { 1239 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1240 response); 1241 1242 rr.mp.writeInt(1); 1243 rr.mp.writeInt(index); 1244 1245 if (false) { 1246 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1247 + requestToString(rr.mRequest) 1248 + " " + index); 1249 } 1250 1251 send(rr); 1252 } 1253 1254 public void writeSmsToSim(int status, String smsc, String pdu, Message response) { 1255 status = translateStatus(status); 1256 1257 RILRequest rr = RILRequest.obtain(RIL_REQUEST_WRITE_SMS_TO_SIM, 1258 response); 1259 1260 rr.mp.writeInt(status); 1261 rr.mp.writeString(pdu); 1262 rr.mp.writeString(smsc); 1263 1264 if (false) { 1265 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1266 + requestToString(rr.mRequest) 1267 + " " + status); 1268 } 1269 1270 send(rr); 1271 } 1272 1273 public void writeSmsToRuim(int status, String pdu, Message response) { 1274 status = translateStatus(status); 1275 1276 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, 1277 response); 1278 1279 rr.mp.writeInt(status); 1280 rr.mp.writeString(pdu); 1281 1282 if (false) { 1283 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1284 + requestToString(rr.mRequest) 1285 + " " + status); 1286 } 1287 1288 send(rr); 1289 } 1290 1291 /** 1292 * Translates EF_SMS status bits to a status value compatible with 1293 * SMS AT commands. See TS 27.005 3.1. 1294 */ 1295 private int translateStatus(int status) { 1296 switch(status & 0x7) { 1297 case SmsManager.STATUS_ON_ICC_READ: 1298 return 1; 1299 case SmsManager.STATUS_ON_ICC_UNREAD: 1300 return 0; 1301 case SmsManager.STATUS_ON_ICC_SENT: 1302 return 3; 1303 case SmsManager.STATUS_ON_ICC_UNSENT: 1304 return 2; 1305 } 1306 1307 // Default to READ. 1308 return 1; 1309 } 1310 1311 public void 1312 setupDataCall(String radioTechnology, String profile, String apn, 1313 String user, String password, String authType, String protocol, 1314 Message result) { 1315 RILRequest rr 1316 = RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result); 1317 1318 rr.mp.writeInt(7); 1319 1320 rr.mp.writeString(radioTechnology); 1321 rr.mp.writeString(profile); 1322 rr.mp.writeString(apn); 1323 rr.mp.writeString(user); 1324 rr.mp.writeString(password); 1325 rr.mp.writeString(authType); 1326 rr.mp.writeString(protocol); 1327 1328 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1329 + requestToString(rr.mRequest) + " " + radioTechnology + " " 1330 + profile + " " + apn + " " + user + " " 1331 + password + " " + authType + " " + protocol); 1332 1333 send(rr); 1334 } 1335 1336 public void 1337 deactivateDataCall(int cid, int reason, Message result) { 1338 RILRequest rr 1339 = RILRequest.obtain(RIL_REQUEST_DEACTIVATE_DATA_CALL, result); 1340 1341 rr.mp.writeInt(2); 1342 rr.mp.writeString(Integer.toString(cid)); 1343 rr.mp.writeString(Integer.toString(reason)); 1344 1345 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + 1346 requestToString(rr.mRequest) + " " + cid + " " + reason); 1347 1348 send(rr); 1349 } 1350 1351 public void 1352 setRadioPower(boolean on, Message result) { 1353 RILRequest rr = RILRequest.obtain(RIL_REQUEST_RADIO_POWER, result); 1354 1355 rr.mp.writeInt(1); 1356 rr.mp.writeInt(on ? 1 : 0); 1357 1358 if (RILJ_LOGD) { 1359 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1360 + (on ? " on" : " off")); 1361 } 1362 1363 send(rr); 1364 } 1365 1366 public void 1367 setSuppServiceNotifications(boolean enable, Message result) { 1368 RILRequest rr 1369 = RILRequest.obtain(RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, result); 1370 1371 rr.mp.writeInt(1); 1372 rr.mp.writeInt(enable ? 1 : 0); 1373 1374 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1375 + requestToString(rr.mRequest)); 1376 1377 send(rr); 1378 } 1379 1380 public void 1381 acknowledgeLastIncomingGsmSms(boolean success, int cause, Message result) { 1382 RILRequest rr 1383 = RILRequest.obtain(RIL_REQUEST_SMS_ACKNOWLEDGE, result); 1384 1385 rr.mp.writeInt(2); 1386 rr.mp.writeInt(success ? 1 : 0); 1387 rr.mp.writeInt(cause); 1388 1389 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1390 + " " + success + " " + cause); 1391 1392 send(rr); 1393 } 1394 1395 public void 1396 acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message result) { 1397 RILRequest rr 1398 = RILRequest.obtain(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result); 1399 1400 rr.mp.writeInt(success ? 0 : 1); //RIL_CDMA_SMS_ErrorClass 1401 // cause code according to X.S004-550E 1402 rr.mp.writeInt(cause); 1403 1404 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1405 + " " + success + " " + cause); 1406 1407 send(rr); 1408 } 1409 1410 1411 public void 1412 iccIO (int command, int fileid, String path, int p1, int p2, int p3, 1413 String data, String pin2, Message result) { 1414 //Note: This RIL request has not been renamed to ICC, 1415 // but this request is also valid for SIM and RUIM 1416 RILRequest rr 1417 = RILRequest.obtain(RIL_REQUEST_SIM_IO, result); 1418 1419 rr.mp.writeInt(command); 1420 rr.mp.writeInt(fileid); 1421 rr.mp.writeString(path); 1422 rr.mp.writeInt(p1); 1423 rr.mp.writeInt(p2); 1424 rr.mp.writeInt(p3); 1425 rr.mp.writeString(data); 1426 rr.mp.writeString(pin2); 1427 1428 if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: " + requestToString(rr.mRequest) 1429 + " 0x" + Integer.toHexString(command) 1430 + " 0x" + Integer.toHexString(fileid) + " " 1431 + " path: " + path + "," 1432 + p1 + "," + p2 + "," + p3); 1433 1434 send(rr); 1435 } 1436 1437 public void 1438 getCLIR(Message result) { 1439 RILRequest rr 1440 = RILRequest.obtain(RIL_REQUEST_GET_CLIR, result); 1441 1442 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1443 1444 send(rr); 1445 } 1446 1447 public void 1448 setCLIR(int clirMode, Message result) { 1449 RILRequest rr 1450 = RILRequest.obtain(RIL_REQUEST_SET_CLIR, result); 1451 1452 // count ints 1453 rr.mp.writeInt(1); 1454 1455 rr.mp.writeInt(clirMode); 1456 1457 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1458 + " " + clirMode); 1459 1460 send(rr); 1461 } 1462 1463 public void 1464 queryCallWaiting(int serviceClass, Message response) { 1465 RILRequest rr 1466 = RILRequest.obtain(RIL_REQUEST_QUERY_CALL_WAITING, response); 1467 1468 rr.mp.writeInt(1); 1469 rr.mp.writeInt(serviceClass); 1470 1471 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1472 + " " + serviceClass); 1473 1474 send(rr); 1475 } 1476 1477 public void 1478 setCallWaiting(boolean enable, int serviceClass, Message response) { 1479 RILRequest rr 1480 = RILRequest.obtain(RIL_REQUEST_SET_CALL_WAITING, response); 1481 1482 rr.mp.writeInt(2); 1483 rr.mp.writeInt(enable ? 1 : 0); 1484 rr.mp.writeInt(serviceClass); 1485 1486 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1487 + " " + enable + ", " + serviceClass); 1488 1489 send(rr); 1490 } 1491 1492 public void 1493 setNetworkSelectionModeAutomatic(Message response) { 1494 RILRequest rr 1495 = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, 1496 response); 1497 1498 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1499 1500 send(rr); 1501 } 1502 1503 public void 1504 setNetworkSelectionModeManual(String operatorNumeric, Message response) { 1505 RILRequest rr 1506 = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, 1507 response); 1508 1509 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1510 + " " + operatorNumeric); 1511 1512 rr.mp.writeString(operatorNumeric); 1513 1514 send(rr); 1515 } 1516 1517 public void 1518 getNetworkSelectionMode(Message response) { 1519 RILRequest rr 1520 = RILRequest.obtain(RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, 1521 response); 1522 1523 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1524 1525 send(rr); 1526 } 1527 1528 public void 1529 getAvailableNetworks(Message response) { 1530 RILRequest rr 1531 = RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_NETWORKS, 1532 response); 1533 1534 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1535 1536 send(rr); 1537 } 1538 1539 public void 1540 setCallForward(int action, int cfReason, int serviceClass, 1541 String number, int timeSeconds, Message response) { 1542 RILRequest rr 1543 = RILRequest.obtain(RIL_REQUEST_SET_CALL_FORWARD, response); 1544 1545 rr.mp.writeInt(action); 1546 rr.mp.writeInt(cfReason); 1547 rr.mp.writeInt(serviceClass); 1548 rr.mp.writeInt(PhoneNumberUtils.toaFromString(number)); 1549 rr.mp.writeString(number); 1550 rr.mp.writeInt (timeSeconds); 1551 1552 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1553 + " " + action + " " + cfReason + " " + serviceClass 1554 + timeSeconds); 1555 1556 send(rr); 1557 } 1558 1559 public void 1560 queryCallForwardStatus(int cfReason, int serviceClass, 1561 String number, Message response) { 1562 RILRequest rr 1563 = RILRequest.obtain(RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, response); 1564 1565 rr.mp.writeInt(2); // 2 is for query action, not in used anyway 1566 rr.mp.writeInt(cfReason); 1567 rr.mp.writeInt(serviceClass); 1568 rr.mp.writeInt(PhoneNumberUtils.toaFromString(number)); 1569 rr.mp.writeString(number); 1570 rr.mp.writeInt (0); 1571 1572 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1573 + " " + cfReason + " " + serviceClass); 1574 1575 send(rr); 1576 } 1577 1578 public void 1579 queryCLIP(Message response) { 1580 RILRequest rr 1581 = RILRequest.obtain(RIL_REQUEST_QUERY_CLIP, response); 1582 1583 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1584 1585 send(rr); 1586 } 1587 1588 1589 public void 1590 getBasebandVersion (Message response) { 1591 RILRequest rr 1592 = RILRequest.obtain(RIL_REQUEST_BASEBAND_VERSION, response); 1593 1594 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1595 1596 send(rr); 1597 } 1598 1599 @Override 1600 public void 1601 queryFacilityLock(String facility, String password, int serviceClass, 1602 Message response) { 1603 queryFacilityLockForApp(facility, password, serviceClass, null, response); 1604 } 1605 1606 @Override 1607 public void 1608 queryFacilityLockForApp(String facility, String password, int serviceClass, String appId, 1609 Message response) { 1610 RILRequest rr = RILRequest.obtain(RIL_REQUEST_QUERY_FACILITY_LOCK, response); 1611 1612 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1613 1614 // count strings 1615 rr.mp.writeInt(4); 1616 1617 rr.mp.writeString(facility); 1618 rr.mp.writeString(password); 1619 1620 rr.mp.writeString(Integer.toString(serviceClass)); 1621 rr.mp.writeString(appId); 1622 1623 send(rr); 1624 } 1625 1626 @Override 1627 public void 1628 setFacilityLock (String facility, boolean lockState, String password, 1629 int serviceClass, Message response) { 1630 setFacilityLockForApp(facility, lockState, password, serviceClass, null, response); 1631 } 1632 1633 @Override 1634 public void 1635 setFacilityLockForApp(String facility, boolean lockState, String password, 1636 int serviceClass, String appId, Message response) { 1637 String lockString; 1638 RILRequest rr 1639 = RILRequest.obtain(RIL_REQUEST_SET_FACILITY_LOCK, response); 1640 1641 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1642 1643 // count strings 1644 rr.mp.writeInt(5); 1645 1646 rr.mp.writeString(facility); 1647 lockString = (lockState)?"1":"0"; 1648 rr.mp.writeString(lockString); 1649 rr.mp.writeString(password); 1650 rr.mp.writeString(Integer.toString(serviceClass)); 1651 rr.mp.writeString(appId); 1652 1653 send(rr); 1654 1655 } 1656 1657 public void 1658 sendUSSD (String ussdString, Message response) { 1659 RILRequest rr 1660 = RILRequest.obtain(RIL_REQUEST_SEND_USSD, response); 1661 1662 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1663 + " " + ussdString); 1664 1665 rr.mp.writeString(ussdString); 1666 1667 send(rr); 1668 } 1669 1670 // inherited javadoc suffices 1671 public void cancelPendingUssd (Message response) { 1672 RILRequest rr 1673 = RILRequest.obtain(RIL_REQUEST_CANCEL_USSD, response); 1674 1675 if (RILJ_LOGD) riljLog(rr.serialString() 1676 + "> " + requestToString(rr.mRequest)); 1677 1678 send(rr); 1679 } 1680 1681 1682 public void resetRadio(Message result) { 1683 RILRequest rr 1684 = RILRequest.obtain(RIL_REQUEST_RESET_RADIO, result); 1685 1686 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1687 1688 send(rr); 1689 } 1690 1691 public void invokeOemRilRequestRaw(byte[] data, Message response) { 1692 RILRequest rr 1693 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_RAW, response); 1694 1695 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1696 + "[" + IccUtils.bytesToHexString(data) + "]"); 1697 1698 rr.mp.writeByteArray(data); 1699 1700 send(rr); 1701 1702 } 1703 1704 public void invokeOemRilRequestStrings(String[] strings, Message response) { 1705 RILRequest rr 1706 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_STRINGS, response); 1707 1708 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1709 1710 rr.mp.writeStringArray(strings); 1711 1712 send(rr); 1713 } 1714 1715 /** 1716 * Assign a specified band for RF configuration. 1717 * 1718 * @param bandMode one of BM_*_BAND 1719 * @param response is callback message 1720 */ 1721 public void setBandMode (int bandMode, Message response) { 1722 RILRequest rr 1723 = RILRequest.obtain(RIL_REQUEST_SET_BAND_MODE, response); 1724 1725 rr.mp.writeInt(1); 1726 rr.mp.writeInt(bandMode); 1727 1728 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1729 + " " + bandMode); 1730 1731 send(rr); 1732 } 1733 1734 /** 1735 * Query the list of band mode supported by RF. 1736 * 1737 * @param response is callback message 1738 * ((AsyncResult)response.obj).result is an int[] with every 1739 * element representing one avialable BM_*_BAND 1740 */ 1741 public void queryAvailableBandMode (Message response) { 1742 RILRequest rr 1743 = RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, 1744 response); 1745 1746 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1747 1748 send(rr); 1749 } 1750 1751 /** 1752 * {@inheritDoc} 1753 */ 1754 public void sendTerminalResponse(String contents, Message response) { 1755 RILRequest rr = RILRequest.obtain( 1756 RILConstants.RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, response); 1757 1758 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1759 1760 rr.mp.writeString(contents); 1761 send(rr); 1762 } 1763 1764 /** 1765 * {@inheritDoc} 1766 */ 1767 public void sendEnvelope(String contents, Message response) { 1768 RILRequest rr = RILRequest.obtain( 1769 RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, response); 1770 1771 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1772 1773 rr.mp.writeString(contents); 1774 send(rr); 1775 } 1776 1777 /** 1778 * {@inheritDoc} 1779 */ 1780 public void handleCallSetupRequestFromSim( 1781 boolean accept, Message response) { 1782 1783 RILRequest rr = RILRequest.obtain( 1784 RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, 1785 response); 1786 1787 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1788 1789 int[] param = new int[1]; 1790 param[0] = accept ? 1 : 0; 1791 rr.mp.writeIntArray(param); 1792 send(rr); 1793 } 1794 1795 /** 1796 * {@inheritDoc} 1797 */ 1798 public void setPreferredNetworkType(int networkType , Message response) { 1799 RILRequest rr = RILRequest.obtain( 1800 RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response); 1801 1802 rr.mp.writeInt(1); 1803 rr.mp.writeInt(networkType); 1804 1805 mPreferredNetworkType = networkType; 1806 1807 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1808 + " : " + networkType); 1809 1810 send(rr); 1811 } 1812 1813 /** 1814 * {@inheritDoc} 1815 */ 1816 public void getPreferredNetworkType(Message response) { 1817 RILRequest rr = RILRequest.obtain( 1818 RILConstants.RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, response); 1819 1820 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1821 1822 send(rr); 1823 } 1824 1825 /** 1826 * {@inheritDoc} 1827 */ 1828 public void getNeighboringCids(Message response) { 1829 RILRequest rr = RILRequest.obtain( 1830 RILConstants.RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, response); 1831 1832 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1833 1834 send(rr); 1835 } 1836 1837 /** 1838 * {@inheritDoc} 1839 */ 1840 public void setLocationUpdates(boolean enable, Message response) { 1841 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_LOCATION_UPDATES, response); 1842 rr.mp.writeInt(1); 1843 rr.mp.writeInt(enable ? 1 : 0); 1844 1845 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1846 + requestToString(rr.mRequest) + ": " + enable); 1847 1848 send(rr); 1849 } 1850 1851 /** 1852 * {@inheritDoc} 1853 */ 1854 public void getSmscAddress(Message result) { 1855 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SMSC_ADDRESS, result); 1856 1857 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1858 1859 send(rr); 1860 } 1861 1862 /** 1863 * {@inheritDoc} 1864 */ 1865 public void setSmscAddress(String address, Message result) { 1866 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_SMSC_ADDRESS, result); 1867 1868 rr.mp.writeString(address); 1869 1870 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1871 + " : " + address); 1872 1873 send(rr); 1874 } 1875 1876 /** 1877 * {@inheritDoc} 1878 */ 1879 public void reportSmsMemoryStatus(boolean available, Message result) { 1880 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, result); 1881 rr.mp.writeInt(1); 1882 rr.mp.writeInt(available ? 1 : 0); 1883 1884 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1885 + requestToString(rr.mRequest) + ": " + available); 1886 1887 send(rr); 1888 } 1889 1890 /** 1891 * {@inheritDoc} 1892 */ 1893 public void reportStkServiceIsRunning(Message result) { 1894 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, result); 1895 1896 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1897 1898 send(rr); 1899 } 1900 1901 /** 1902 * {@inheritDoc} 1903 */ 1904 public void getGsmBroadcastConfig(Message response) { 1905 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, response); 1906 1907 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1908 1909 send(rr); 1910 } 1911 1912 /** 1913 * {@inheritDoc} 1914 */ 1915 public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) { 1916 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, response); 1917 1918 int numOfConfig = config.length; 1919 rr.mp.writeInt(numOfConfig); 1920 1921 for(int i = 0; i < numOfConfig; i++) { 1922 rr.mp.writeInt(config[i].getFromServiceId()); 1923 rr.mp.writeInt(config[i].getToServiceId()); 1924 rr.mp.writeInt(config[i].getFromCodeScheme()); 1925 rr.mp.writeInt(config[i].getToCodeScheme()); 1926 rr.mp.writeInt(config[i].isSelected() ? 1 : 0); 1927 } 1928 1929 if (RILJ_LOGD) { 1930 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1931 + " with " + numOfConfig + " configs : "); 1932 for (int i = 0; i < numOfConfig; i++) { 1933 riljLog(config[i].toString()); 1934 } 1935 } 1936 1937 send(rr); 1938 } 1939 1940 /** 1941 * {@inheritDoc} 1942 */ 1943 public void setGsmBroadcastActivation(boolean activate, Message response) { 1944 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, response); 1945 1946 rr.mp.writeInt(1); 1947 rr.mp.writeInt(activate ? 0 : 1); 1948 1949 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1950 1951 send(rr); 1952 } 1953 1954 //***** Private Methods 1955 1956 private void sendScreenState(boolean on) { 1957 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SCREEN_STATE, null); 1958 rr.mp.writeInt(1); 1959 rr.mp.writeInt(on ? 1 : 0); 1960 1961 if (RILJ_LOGD) riljLog(rr.serialString() 1962 + "> " + requestToString(rr.mRequest) + ": " + on); 1963 1964 send(rr); 1965 } 1966 1967 protected void 1968 onRadioAvailable() { 1969 // In case screen state was lost (due to process crash), 1970 // this ensures that the RIL knows the correct screen state. 1971 1972 // TODO: Should query Power Manager and send the actual 1973 // screen state. Just send true for now. 1974 sendScreenState(true); 1975 } 1976 1977 private RadioState getRadioStateFromInt(int stateInt) { 1978 RadioState state; 1979 1980 /* RIL_RadioState ril.h */ 1981 switch(stateInt) { 1982 case 0: state = RadioState.RADIO_OFF; break; 1983 case 1: state = RadioState.RADIO_UNAVAILABLE; break; 1984 case 2: state = RadioState.SIM_NOT_READY; break; 1985 case 3: state = RadioState.SIM_LOCKED_OR_ABSENT; break; 1986 case 4: state = RadioState.SIM_READY; break; 1987 case 5: state = RadioState.RUIM_NOT_READY; break; 1988 case 6: state = RadioState.RUIM_READY; break; 1989 case 7: state = RadioState.RUIM_LOCKED_OR_ABSENT; break; 1990 case 8: state = RadioState.NV_NOT_READY; break; 1991 case 9: state = RadioState.NV_READY; break; 1992 1993 default: 1994 throw new RuntimeException( 1995 "Unrecognized RIL_RadioState: " + stateInt); 1996 } 1997 return state; 1998 } 1999 2000 private void switchToRadioState(RadioState newState) { 2001 setRadioState(newState); 2002 } 2003 2004 /** 2005 * Holds a PARTIAL_WAKE_LOCK whenever 2006 * a) There is outstanding RIL request sent to RIL deamon and no replied 2007 * b) There is a request pending to be sent out. 2008 * 2009 * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't 2010 * happen often. 2011 */ 2012 2013 private void 2014 acquireWakeLock() { 2015 synchronized (mWakeLock) { 2016 mWakeLock.acquire(); 2017 mRequestMessagesPending++; 2018 2019 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); 2020 Message msg = mSender.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT); 2021 mSender.sendMessageDelayed(msg, mWakeLockTimeout); 2022 } 2023 } 2024 2025 private void 2026 releaseWakeLockIfDone() { 2027 synchronized (mWakeLock) { 2028 if (mWakeLock.isHeld() && 2029 (mRequestMessagesPending == 0) && 2030 (mRequestMessagesWaiting == 0)) { 2031 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); 2032 mWakeLock.release(); 2033 } 2034 } 2035 } 2036 2037 private void 2038 send(RILRequest rr) { 2039 Message msg; 2040 2041 if (mSocket == null) { 2042 rr.onError(RADIO_NOT_AVAILABLE, null); 2043 rr.release(); 2044 return; 2045 } 2046 2047 msg = mSender.obtainMessage(EVENT_SEND, rr); 2048 2049 acquireWakeLock(); 2050 2051 msg.sendToTarget(); 2052 } 2053 2054 private void 2055 processResponse (Parcel p) { 2056 int type; 2057 2058 type = p.readInt(); 2059 2060 if (type == RESPONSE_UNSOLICITED) { 2061 processUnsolicited (p); 2062 } else if (type == RESPONSE_SOLICITED) { 2063 processSolicited (p); 2064 } 2065 2066 releaseWakeLockIfDone(); 2067 } 2068 2069 /** 2070 * Release each request in mReqeustsList then clear the list 2071 * @param error is the RIL_Errno sent back 2072 * @param loggable true means to print all requests in mRequestslist 2073 */ 2074 private void clearRequestsList(int error, boolean loggable) { 2075 RILRequest rr; 2076 synchronized (mRequestsList) { 2077 int count = mRequestsList.size(); 2078 if (RILJ_LOGD && loggable) { 2079 Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " + 2080 " mReqPending=" + mRequestMessagesPending + 2081 " mRequestList=" + count); 2082 } 2083 2084 for (int i = 0; i < count ; i++) { 2085 rr = mRequestsList.get(i); 2086 if (RILJ_LOGD && loggable) { 2087 Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " + 2088 requestToString(rr.mRequest)); 2089 } 2090 rr.onError(error, null); 2091 rr.release(); 2092 } 2093 mRequestsList.clear(); 2094 mRequestMessagesWaiting = 0; 2095 } 2096 } 2097 2098 private RILRequest findAndRemoveRequestFromList(int serial) { 2099 synchronized (mRequestsList) { 2100 for (int i = 0, s = mRequestsList.size() ; i < s ; i++) { 2101 RILRequest rr = mRequestsList.get(i); 2102 2103 if (rr.mSerial == serial) { 2104 mRequestsList.remove(i); 2105 if (mRequestMessagesWaiting > 0) 2106 mRequestMessagesWaiting--; 2107 return rr; 2108 } 2109 } 2110 } 2111 2112 return null; 2113 } 2114 2115 private void 2116 processSolicited (Parcel p) { 2117 int serial, error; 2118 boolean found = false; 2119 2120 serial = p.readInt(); 2121 error = p.readInt(); 2122 2123 RILRequest rr; 2124 2125 rr = findAndRemoveRequestFromList(serial); 2126 2127 if (rr == null) { 2128 Log.w(LOG_TAG, "Unexpected solicited response! sn: " 2129 + serial + " error: " + error); 2130 return; 2131 } 2132 2133 Object ret = null; 2134 2135 if (error == 0 || p.dataAvail() > 0) { 2136 // either command succeeds or command fails but with data payload 2137 try {switch (rr.mRequest) { 2138 /* 2139 cat libs/telephony/ril_commands.h \ 2140 | egrep "^ *{RIL_" \ 2141 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: ret = \2(p); break;/' 2142 */ 2143 case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break; 2144 case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break; 2145 case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break; 2146 case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break; 2147 case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break; 2148 case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break; 2149 case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break; 2150 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break; 2151 case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break; 2152 case RIL_REQUEST_DIAL: ret = responseVoid(p); break; 2153 case RIL_REQUEST_GET_IMSI: ret = responseString(p); break; 2154 case RIL_REQUEST_HANGUP: ret = responseVoid(p); break; 2155 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break; 2156 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: ret = responseVoid(p); break; 2157 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break; 2158 case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break; 2159 case RIL_REQUEST_UDUB: ret = responseVoid(p); break; 2160 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break; 2161 case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; 2162 case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break; 2163 case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break; 2164 case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break; 2165 case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break; 2166 case RIL_REQUEST_DTMF: ret = responseVoid(p); break; 2167 case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break; 2168 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break; 2169 case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break; 2170 case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break; 2171 case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break; 2172 case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break; 2173 case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break; 2174 case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break; 2175 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break; 2176 case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break; 2177 case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break; 2178 case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break; 2179 case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; 2180 case RIL_REQUEST_GET_IMEI: ret = responseString(p); break; 2181 case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break; 2182 case RIL_REQUEST_ANSWER: ret = responseVoid(p); break; 2183 case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break; 2184 case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break; 2185 case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break; 2186 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break; 2187 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break; 2188 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break; 2189 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break; 2190 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break; 2191 case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break; 2192 case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break; 2193 case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break; 2194 case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break; 2195 case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break; 2196 case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break; 2197 case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break; 2198 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break; 2199 case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break; 2200 case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break; 2201 case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break; 2202 case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break; 2203 case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break; 2204 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break; 2205 case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break; 2206 case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break; 2207 case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break; 2208 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break; 2209 case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break; 2210 case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break; 2211 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break; 2212 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break; 2213 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break; 2214 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break; 2215 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break; 2216 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break; 2217 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseCellList(p); break; 2218 case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break; 2219 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break; 2220 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break; 2221 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break; 2222 case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break; 2223 case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break; 2224 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break; 2225 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break; 2226 case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break; 2227 case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break; 2228 case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break; 2229 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; 2230 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break; 2231 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; 2232 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break; 2233 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break; 2234 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; 2235 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break; 2236 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break; 2237 case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break; 2238 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break; 2239 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break; 2240 case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break; 2241 case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break; 2242 case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break; 2243 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2244 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break; 2245 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break; 2246 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break; 2247 case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break; 2248 default: 2249 throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest); 2250 //break; 2251 }} catch (Throwable tr) { 2252 // Exceptions here usually mean invalid RIL responses 2253 2254 Log.w(LOG_TAG, rr.serialString() + "< " 2255 + requestToString(rr.mRequest) 2256 + " exception, possible invalid RIL response", tr); 2257 2258 if (rr.mResult != null) { 2259 AsyncResult.forMessage(rr.mResult, null, tr); 2260 rr.mResult.sendToTarget(); 2261 } 2262 rr.release(); 2263 return; 2264 } 2265 } 2266 2267 if (error != 0) { 2268 rr.onError(error, ret); 2269 rr.release(); 2270 return; 2271 } 2272 2273 if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) 2274 + " " + retToString(rr.mRequest, ret)); 2275 2276 if (rr.mResult != null) { 2277 AsyncResult.forMessage(rr.mResult, ret, null); 2278 rr.mResult.sendToTarget(); 2279 } 2280 2281 rr.release(); 2282 } 2283 2284 private String 2285 retToString(int req, Object ret) { 2286 if (ret == null) return ""; 2287 switch (req) { 2288 // Don't log these return values, for privacy's sake. 2289 case RIL_REQUEST_GET_IMSI: 2290 case RIL_REQUEST_GET_IMEI: 2291 case RIL_REQUEST_GET_IMEISV: 2292 if (!RILJ_LOGV) { 2293 // If not versbose logging just return and don't display IMSI and IMEI, IMEISV 2294 return ""; 2295 } 2296 } 2297 2298 StringBuilder sb; 2299 String s; 2300 int length; 2301 if (ret instanceof int[]){ 2302 int[] intArray = (int[]) ret; 2303 length = intArray.length; 2304 sb = new StringBuilder("{"); 2305 if (length > 0) { 2306 int i = 0; 2307 sb.append(intArray[i++]); 2308 while ( i < length) { 2309 sb.append(", ").append(intArray[i++]); 2310 } 2311 } 2312 sb.append("}"); 2313 s = sb.toString(); 2314 } else if (ret instanceof String[]) { 2315 String[] strings = (String[]) ret; 2316 length = strings.length; 2317 sb = new StringBuilder("{"); 2318 if (length > 0) { 2319 int i = 0; 2320 sb.append(strings[i++]); 2321 while ( i < length) { 2322 sb.append(", ").append(strings[i++]); 2323 } 2324 } 2325 sb.append("}"); 2326 s = sb.toString(); 2327 }else if (req == RIL_REQUEST_GET_CURRENT_CALLS) { 2328 ArrayList<DriverCall> calls = (ArrayList<DriverCall>) ret; 2329 sb = new StringBuilder(" "); 2330 for (DriverCall dc : calls) { 2331 sb.append("[").append(dc).append("] "); 2332 } 2333 s = sb.toString(); 2334 } else if (req == RIL_REQUEST_GET_NEIGHBORING_CELL_IDS) { 2335 ArrayList<NeighboringCellInfo> cells; 2336 cells = (ArrayList<NeighboringCellInfo>) ret; 2337 sb = new StringBuilder(" "); 2338 for (NeighboringCellInfo cell : cells) { 2339 sb.append(cell).append(" "); 2340 } 2341 s = sb.toString(); 2342 } else { 2343 s = ret.toString(); 2344 } 2345 return s; 2346 } 2347 2348 private void 2349 processUnsolicited (Parcel p) { 2350 int response; 2351 Object ret; 2352 2353 response = p.readInt(); 2354 2355 try {switch(response) { 2356 /* 2357 cat libs/telephony/ril_unsol_commands.h \ 2358 | egrep "^ *{RIL_" \ 2359 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: \2(rr, p); break;/' 2360 */ 2361 2362 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break; 2363 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: ret = responseVoid(p); break; 2364 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: ret = responseVoid(p); break; 2365 case RIL_UNSOL_RESPONSE_NEW_SMS: ret = responseString(p); break; 2366 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: ret = responseString(p); break; 2367 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: ret = responseInts(p); break; 2368 case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break; 2369 case RIL_UNSOL_NITZ_TIME_RECEIVED: ret = responseString(p); break; 2370 case RIL_UNSOL_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; 2371 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: ret = responseDataCallList(p);break; 2372 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: ret = responseSuppServiceNotification(p); break; 2373 case RIL_UNSOL_STK_SESSION_END: ret = responseVoid(p); break; 2374 case RIL_UNSOL_STK_PROACTIVE_COMMAND: ret = responseString(p); break; 2375 case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break; 2376 case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break; 2377 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break; 2378 case RIL_UNSOL_SIM_REFRESH: ret = responseInts(p); break; 2379 case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break; 2380 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break; 2381 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break; 2382 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break; 2383 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseRaw(p); break; 2384 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break; 2385 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2386 case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break; 2387 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: ret = responseInts(p); break; 2388 case RIL_UNSOL_CDMA_INFO_REC: ret = responseCdmaInformationRecord(p); break; 2389 case RIL_UNSOL_OEM_HOOK_RAW: ret = responseRaw(p); break; 2390 case RIL_UNSOL_RINGBACK_TONE: ret = responseInts(p); break; 2391 case RIL_UNSOL_RESEND_INCALL_MUTE: ret = responseVoid(p); break; 2392 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: ret = responseInts(p); break; 2393 case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break; 2394 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2395 case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break; 2396 2397 default: 2398 throw new RuntimeException("Unrecognized unsol response: " + response); 2399 //break; (implied) 2400 }} catch (Throwable tr) { 2401 Log.e(LOG_TAG, "Exception processing unsol response: " + response + 2402 "Exception:" + tr.toString()); 2403 return; 2404 } 2405 2406 switch(response) { 2407 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: 2408 /* has bonus radio state int */ 2409 RadioState newState = getRadioStateFromInt(p.readInt()); 2410 if (RILJ_LOGD) unsljLogMore(response, newState.toString()); 2411 2412 switchToRadioState(newState); 2413 break; 2414 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: 2415 if (RILJ_LOGD) unsljLog(response); 2416 2417 mCallStateRegistrants 2418 .notifyRegistrants(new AsyncResult(null, null, null)); 2419 break; 2420 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: 2421 if (RILJ_LOGD) unsljLog(response); 2422 2423 mVoiceNetworkStateRegistrants 2424 .notifyRegistrants(new AsyncResult(null, null, null)); 2425 break; 2426 case RIL_UNSOL_RESPONSE_NEW_SMS: { 2427 if (RILJ_LOGD) unsljLog(response); 2428 2429 // FIXME this should move up a layer 2430 String a[] = new String[2]; 2431 2432 a[1] = (String)ret; 2433 2434 SmsMessage sms; 2435 2436 sms = SmsMessage.newFromCMT(a); 2437 if (mGsmSmsRegistrant != null) { 2438 mGsmSmsRegistrant 2439 .notifyRegistrant(new AsyncResult(null, sms, null)); 2440 } 2441 break; 2442 } 2443 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: 2444 if (RILJ_LOGD) unsljLogRet(response, ret); 2445 2446 if (mSmsStatusRegistrant != null) { 2447 mSmsStatusRegistrant.notifyRegistrant( 2448 new AsyncResult(null, ret, null)); 2449 } 2450 break; 2451 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: 2452 if (RILJ_LOGD) unsljLogRet(response, ret); 2453 2454 int[] smsIndex = (int[])ret; 2455 2456 if(smsIndex.length == 1) { 2457 if (mSmsOnSimRegistrant != null) { 2458 mSmsOnSimRegistrant. 2459 notifyRegistrant(new AsyncResult(null, smsIndex, null)); 2460 } 2461 } else { 2462 if (RILJ_LOGD) riljLog(" NEW_SMS_ON_SIM ERROR with wrong length " 2463 + smsIndex.length); 2464 } 2465 break; 2466 case RIL_UNSOL_ON_USSD: 2467 String[] resp = (String[])ret; 2468 2469 if (resp.length < 2) { 2470 resp = new String[2]; 2471 resp[0] = ((String[])ret)[0]; 2472 resp[1] = null; 2473 } 2474 if (RILJ_LOGD) unsljLogMore(response, resp[0]); 2475 if (mUSSDRegistrant != null) { 2476 mUSSDRegistrant.notifyRegistrant( 2477 new AsyncResult (null, resp, null)); 2478 } 2479 break; 2480 case RIL_UNSOL_NITZ_TIME_RECEIVED: 2481 if (RILJ_LOGD) unsljLogRet(response, ret); 2482 2483 // has bonus long containing milliseconds since boot that the NITZ 2484 // time was received 2485 long nitzReceiveTime = p.readLong(); 2486 2487 Object[] result = new Object[2]; 2488 2489 result[0] = ret; 2490 result[1] = Long.valueOf(nitzReceiveTime); 2491 2492 if (mNITZTimeRegistrant != null) { 2493 2494 mNITZTimeRegistrant 2495 .notifyRegistrant(new AsyncResult (null, result, null)); 2496 } else { 2497 // in case NITZ time registrant isnt registered yet 2498 mLastNITZTimeInfo = result; 2499 } 2500 break; 2501 2502 case RIL_UNSOL_SIGNAL_STRENGTH: 2503 // Note this is set to "verbose" because it happens 2504 // frequently 2505 if (RILJ_LOGV) unsljLogvRet(response, ret); 2506 2507 if (mSignalStrengthRegistrant != null) { 2508 mSignalStrengthRegistrant.notifyRegistrant( 2509 new AsyncResult (null, ret, null)); 2510 } 2511 break; 2512 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: 2513 if (RILJ_LOGD) unsljLogRet(response, ret); 2514 2515 mDataNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, ret, null)); 2516 break; 2517 2518 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: 2519 if (RILJ_LOGD) unsljLogRet(response, ret); 2520 2521 if (mSsnRegistrant != null) { 2522 mSsnRegistrant.notifyRegistrant( 2523 new AsyncResult (null, ret, null)); 2524 } 2525 break; 2526 2527 case RIL_UNSOL_STK_SESSION_END: 2528 if (RILJ_LOGD) unsljLog(response); 2529 2530 if (mCatSessionEndRegistrant != null) { 2531 mCatSessionEndRegistrant.notifyRegistrant( 2532 new AsyncResult (null, ret, null)); 2533 } 2534 break; 2535 2536 case RIL_UNSOL_STK_PROACTIVE_COMMAND: 2537 if (RILJ_LOGD) unsljLogRet(response, ret); 2538 2539 if (mCatProCmdRegistrant != null) { 2540 mCatProCmdRegistrant.notifyRegistrant( 2541 new AsyncResult (null, ret, null)); 2542 } 2543 break; 2544 2545 case RIL_UNSOL_STK_EVENT_NOTIFY: 2546 if (RILJ_LOGD) unsljLogRet(response, ret); 2547 2548 if (mCatEventRegistrant != null) { 2549 mCatEventRegistrant.notifyRegistrant( 2550 new AsyncResult (null, ret, null)); 2551 } 2552 break; 2553 2554 case RIL_UNSOL_STK_CALL_SETUP: 2555 if (RILJ_LOGD) unsljLogRet(response, ret); 2556 2557 if (mCatCallSetUpRegistrant != null) { 2558 mCatCallSetUpRegistrant.notifyRegistrant( 2559 new AsyncResult (null, ret, null)); 2560 } 2561 break; 2562 2563 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: 2564 if (RILJ_LOGD) unsljLog(response); 2565 2566 if (mIccSmsFullRegistrant != null) { 2567 mIccSmsFullRegistrant.notifyRegistrant(); 2568 } 2569 break; 2570 2571 case RIL_UNSOL_SIM_REFRESH: 2572 if (RILJ_LOGD) unsljLogRet(response, ret); 2573 2574 if (mIccRefreshRegistrants != null) { 2575 mIccRefreshRegistrants.notifyRegistrants( 2576 new AsyncResult (null, ret, null)); 2577 } 2578 break; 2579 2580 case RIL_UNSOL_CALL_RING: 2581 if (RILJ_LOGD) unsljLogRet(response, ret); 2582 2583 if (mRingRegistrant != null) { 2584 mRingRegistrant.notifyRegistrant( 2585 new AsyncResult (null, ret, null)); 2586 } 2587 break; 2588 2589 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: 2590 if (RILJ_LOGD) unsljLogvRet(response, ret); 2591 if (mRestrictedStateRegistrant != null) { 2592 mRestrictedStateRegistrant.notifyRegistrant( 2593 new AsyncResult (null, ret, null)); 2594 } 2595 break; 2596 2597 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: 2598 if (RILJ_LOGD) unsljLog(response); 2599 2600 if (mIccStatusChangedRegistrants != null) { 2601 mIccStatusChangedRegistrants.notifyRegistrants(); 2602 } 2603 break; 2604 2605 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: 2606 if (RILJ_LOGD) unsljLog(response); 2607 2608 SmsMessage sms = (SmsMessage) ret; 2609 2610 if (mCdmaSmsRegistrant != null) { 2611 mCdmaSmsRegistrant 2612 .notifyRegistrant(new AsyncResult(null, sms, null)); 2613 } 2614 break; 2615 2616 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: 2617 if (RILJ_LOGD) unsljLog(response); 2618 2619 if (mGsmBroadcastSmsRegistrant != null) { 2620 mGsmBroadcastSmsRegistrant 2621 .notifyRegistrant(new AsyncResult(null, ret, null)); 2622 } 2623 break; 2624 2625 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: 2626 if (RILJ_LOGD) unsljLog(response); 2627 2628 if (mIccSmsFullRegistrant != null) { 2629 mIccSmsFullRegistrant.notifyRegistrant(); 2630 } 2631 break; 2632 2633 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: 2634 if (RILJ_LOGD) unsljLog(response); 2635 2636 if (mEmergencyCallbackModeRegistrant != null) { 2637 mEmergencyCallbackModeRegistrant.notifyRegistrant(); 2638 } 2639 break; 2640 2641 case RIL_UNSOL_CDMA_CALL_WAITING: 2642 if (RILJ_LOGD) unsljLogRet(response, ret); 2643 2644 if (mCallWaitingInfoRegistrants != null) { 2645 mCallWaitingInfoRegistrants.notifyRegistrants( 2646 new AsyncResult (null, ret, null)); 2647 } 2648 break; 2649 2650 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: 2651 if (RILJ_LOGD) unsljLogRet(response, ret); 2652 2653 if (mOtaProvisionRegistrants != null) { 2654 mOtaProvisionRegistrants.notifyRegistrants( 2655 new AsyncResult (null, ret, null)); 2656 } 2657 break; 2658 2659 case RIL_UNSOL_CDMA_INFO_REC: 2660 ArrayList<CdmaInformationRecords> listInfoRecs; 2661 2662 try { 2663 listInfoRecs = (ArrayList<CdmaInformationRecords>)ret; 2664 } catch (ClassCastException e) { 2665 Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e); 2666 break; 2667 } 2668 2669 for (CdmaInformationRecords rec : listInfoRecs) { 2670 if (RILJ_LOGD) unsljLogRet(response, rec); 2671 notifyRegistrantsCdmaInfoRec(rec); 2672 } 2673 break; 2674 2675 case RIL_UNSOL_OEM_HOOK_RAW: 2676 if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret)); 2677 if (mUnsolOemHookRawRegistrant != null) { 2678 mUnsolOemHookRawRegistrant.notifyRegistrant(new AsyncResult(null, ret, null)); 2679 } 2680 break; 2681 2682 case RIL_UNSOL_RINGBACK_TONE: 2683 if (RILJ_LOGD) unsljLogvRet(response, ret); 2684 if (mRingbackToneRegistrants != null) { 2685 boolean playtone = (((int[])ret)[0] == 1); 2686 mRingbackToneRegistrants.notifyRegistrants( 2687 new AsyncResult (null, playtone, null)); 2688 } 2689 break; 2690 2691 case RIL_UNSOL_RESEND_INCALL_MUTE: 2692 if (RILJ_LOGD) unsljLogRet(response, ret); 2693 2694 if (mResendIncallMuteRegistrants != null) { 2695 mResendIncallMuteRegistrants.notifyRegistrants( 2696 new AsyncResult (null, ret, null)); 2697 } 2698 break; 2699 2700 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: 2701 if (RILJ_LOGD) unsljLogRet(response, ret); 2702 2703 if (mCdmaSubscriptionChangedRegistrants != null) { 2704 mCdmaSubscriptionChangedRegistrants.notifyRegistrants( 2705 new AsyncResult (null, ret, null)); 2706 } 2707 break; 2708 2709 case RIL_UNSOl_CDMA_PRL_CHANGED: 2710 if (RILJ_LOGD) unsljLogRet(response, ret); 2711 2712 if (mCdmaPrlChangedRegistrants != null) { 2713 mCdmaPrlChangedRegistrants.notifyRegistrants( 2714 new AsyncResult (null, ret, null)); 2715 } 2716 break; 2717 2718 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: 2719 if (RILJ_LOGD) unsljLogRet(response, ret); 2720 2721 if (mExitEmergencyCallbackModeRegistrants != null) { 2722 mExitEmergencyCallbackModeRegistrants.notifyRegistrants( 2723 new AsyncResult (null, null, null)); 2724 } 2725 break; 2726 2727 case RIL_UNSOL_RIL_CONNECTED: { 2728 if (RILJ_LOGD) unsljLogRet(response, ret); 2729 2730 // Initial conditions 2731 setRadioPower(false, null); 2732 setPreferredNetworkType(mPreferredNetworkType, null); 2733 setCdmaSubscriptionSource(mCdmaSubscription, null); 2734 notifyRegistrantsRilConnectionChanged(((int[])ret)[0]); 2735 break; 2736 } 2737 } 2738 } 2739 2740 /** 2741 * Notifiy all registrants that the ril has connected or disconnected. 2742 * 2743 * @param rilVer is the version of the ril or -1 if disconnected. 2744 */ 2745 private void notifyRegistrantsRilConnectionChanged(int rilVer) { 2746 mRilVersion = rilVer; 2747 if (mRilConnectedRegistrants != null) { 2748 mRilConnectedRegistrants.notifyRegistrants( 2749 new AsyncResult (null, new Integer(rilVer), null)); 2750 } 2751 } 2752 2753 private Object 2754 responseInts(Parcel p) { 2755 int numInts; 2756 int response[]; 2757 2758 numInts = p.readInt(); 2759 2760 response = new int[numInts]; 2761 2762 for (int i = 0 ; i < numInts ; i++) { 2763 response[i] = p.readInt(); 2764 } 2765 2766 return response; 2767 } 2768 2769 2770 private Object 2771 responseVoid(Parcel p) { 2772 return null; 2773 } 2774 2775 private Object 2776 responseCallForward(Parcel p) { 2777 int numInfos; 2778 CallForwardInfo infos[]; 2779 2780 numInfos = p.readInt(); 2781 2782 infos = new CallForwardInfo[numInfos]; 2783 2784 for (int i = 0 ; i < numInfos ; i++) { 2785 infos[i] = new CallForwardInfo(); 2786 2787 infos[i].status = p.readInt(); 2788 infos[i].reason = p.readInt(); 2789 infos[i].serviceClass = p.readInt(); 2790 infos[i].toa = p.readInt(); 2791 infos[i].number = p.readString(); 2792 infos[i].timeSeconds = p.readInt(); 2793 } 2794 2795 return infos; 2796 } 2797 2798 private Object 2799 responseSuppServiceNotification(Parcel p) { 2800 SuppServiceNotification notification = new SuppServiceNotification(); 2801 2802 notification.notificationType = p.readInt(); 2803 notification.code = p.readInt(); 2804 notification.index = p.readInt(); 2805 notification.type = p.readInt(); 2806 notification.number = p.readString(); 2807 2808 return notification; 2809 } 2810 2811 private Object 2812 responseCdmaSms(Parcel p) { 2813 SmsMessage sms; 2814 sms = SmsMessage.newFromParcel(p); 2815 2816 return sms; 2817 } 2818 2819 private Object 2820 responseString(Parcel p) { 2821 String response; 2822 2823 response = p.readString(); 2824 2825 return response; 2826 } 2827 2828 private Object 2829 responseStrings(Parcel p) { 2830 int num; 2831 String response[]; 2832 2833 response = p.readStringArray(); 2834 2835 if (false) { 2836 num = p.readInt(); 2837 2838 response = new String[num]; 2839 for (int i = 0; i < num; i++) { 2840 response[i] = p.readString(); 2841 } 2842 } 2843 2844 return response; 2845 } 2846 2847 private Object 2848 responseRaw(Parcel p) { 2849 int num; 2850 byte response[]; 2851 2852 response = p.createByteArray(); 2853 2854 return response; 2855 } 2856 2857 private Object 2858 responseSMS(Parcel p) { 2859 int messageRef, errorCode; 2860 String ackPDU; 2861 2862 messageRef = p.readInt(); 2863 ackPDU = p.readString(); 2864 errorCode = p.readInt(); 2865 2866 SmsResponse response = new SmsResponse(messageRef, ackPDU, errorCode); 2867 2868 return response; 2869 } 2870 2871 2872 private Object 2873 responseICC_IO(Parcel p) { 2874 int sw1, sw2; 2875 byte data[] = null; 2876 Message ret; 2877 2878 sw1 = p.readInt(); 2879 sw2 = p.readInt(); 2880 2881 String s = p.readString(); 2882 2883 if (RILJ_LOGV) riljLog("< iccIO: " 2884 + " 0x" + Integer.toHexString(sw1) 2885 + " 0x" + Integer.toHexString(sw2) + " " 2886 + s); 2887 2888 return new IccIoResult(sw1, sw2, s); 2889 } 2890 2891 private Object 2892 responseIccCardStatus(Parcel p) { 2893 IccCardApplication ca; 2894 2895 IccCardStatus status = new IccCardStatus(); 2896 status.setCardState(p.readInt()); 2897 status.setUniversalPinState(p.readInt()); 2898 status.setGsmUmtsSubscriptionAppIndex(p.readInt()); 2899 status.setCdmaSubscriptionAppIndex(p.readInt()); 2900 status.setImsSubscriptionAppIndex(p.readInt()); 2901 int numApplications = p.readInt(); 2902 2903 // limit to maximum allowed applications 2904 if (numApplications > IccCardStatus.CARD_MAX_APPS) { 2905 numApplications = IccCardStatus.CARD_MAX_APPS; 2906 } 2907 status.setNumApplications(numApplications); 2908 2909 for (int i = 0 ; i < numApplications ; i++) { 2910 ca = new IccCardApplication(); 2911 ca.app_type = ca.AppTypeFromRILInt(p.readInt()); 2912 ca.app_state = ca.AppStateFromRILInt(p.readInt()); 2913 ca.perso_substate = ca.PersoSubstateFromRILInt(p.readInt()); 2914 ca.aid = p.readString(); 2915 ca.app_label = p.readString(); 2916 ca.pin1_replaced = p.readInt(); 2917 ca.pin1 = ca.PinStateFromRILInt(p.readInt()); 2918 ca.pin2 = ca.PinStateFromRILInt(p.readInt()); 2919 status.addApplication(ca); 2920 } 2921 return status; 2922 } 2923 2924 private Object 2925 responseCallList(Parcel p) { 2926 int num; 2927 int voiceSettings; 2928 ArrayList<DriverCall> response; 2929 DriverCall dc; 2930 2931 num = p.readInt(); 2932 response = new ArrayList<DriverCall>(num); 2933 2934 for (int i = 0 ; i < num ; i++) { 2935 dc = new DriverCall(); 2936 2937 dc.state = DriverCall.stateFromCLCC(p.readInt()); 2938 dc.index = p.readInt(); 2939 dc.TOA = p.readInt(); 2940 dc.isMpty = (0 != p.readInt()); 2941 dc.isMT = (0 != p.readInt()); 2942 dc.als = p.readInt(); 2943 voiceSettings = p.readInt(); 2944 dc.isVoice = (0 == voiceSettings) ? false : true; 2945 dc.isVoicePrivacy = (0 != p.readInt()); 2946 dc.number = p.readString(); 2947 int np = p.readInt(); 2948 dc.numberPresentation = DriverCall.presentationFromCLIP(np); 2949 dc.name = p.readString(); 2950 dc.namePresentation = p.readInt(); 2951 int uusInfoPresent = p.readInt(); 2952 if (uusInfoPresent == 1) { 2953 dc.uusInfo = new UUSInfo(); 2954 dc.uusInfo.setType(p.readInt()); 2955 dc.uusInfo.setDcs(p.readInt()); 2956 byte[] userData = p.createByteArray(); 2957 dc.uusInfo.setUserData(userData); 2958 riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d", 2959 dc.uusInfo.getType(), dc.uusInfo.getDcs(), 2960 dc.uusInfo.getUserData().length)); 2961 riljLogv("Incoming UUS : data (string)=" 2962 + new String(dc.uusInfo.getUserData())); 2963 riljLogv("Incoming UUS : data (hex): " 2964 + IccUtils.bytesToHexString(dc.uusInfo.getUserData())); 2965 } else { 2966 riljLogv("Incoming UUS : NOT present!"); 2967 } 2968 2969 // Make sure there's a leading + on addresses with a TOA of 145 2970 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA); 2971 2972 response.add(dc); 2973 2974 if (dc.isVoicePrivacy) { 2975 mVoicePrivacyOnRegistrants.notifyRegistrants(); 2976 riljLog("InCall VoicePrivacy is enabled"); 2977 } else { 2978 mVoicePrivacyOffRegistrants.notifyRegistrants(); 2979 riljLog("InCall VoicePrivacy is disabled"); 2980 } 2981 } 2982 2983 Collections.sort(response); 2984 2985 return response; 2986 } 2987 2988 private DataCallState getDataCallState(Parcel p, int version) { 2989 DataCallState dataCall = new DataCallState(); 2990 2991 dataCall.version = version; 2992 if (version < 5) { 2993 dataCall.cid = p.readInt(); 2994 dataCall.active = p.readInt(); 2995 dataCall.type = p.readString(); 2996 String addresses = p.readString(); 2997 if (!TextUtils.isEmpty(addresses)) { 2998 dataCall.addresses = addresses.split(" "); 2999 } 3000 } else { 3001 dataCall.status = p.readInt(); 3002 dataCall.suggestedRetryTime = p.readInt(); 3003 dataCall.cid = p.readInt(); 3004 dataCall.active = p.readInt(); 3005 dataCall.type = p.readString(); 3006 dataCall.ifname = p.readString(); 3007 if ((dataCall.status == DataConnection.FailCause.NONE.getErrorCode()) && 3008 TextUtils.isEmpty(dataCall.ifname)) { 3009 throw new RuntimeException("getDataCallState, no ifname"); 3010 } 3011 String addresses = p.readString(); 3012 if (!TextUtils.isEmpty(addresses)) { 3013 dataCall.addresses = addresses.split(" "); 3014 } 3015 String dnses = p.readString(); 3016 if (!TextUtils.isEmpty(dnses)) { 3017 dataCall.dnses = dnses.split(" "); 3018 } 3019 String gateways = p.readString(); 3020 if (!TextUtils.isEmpty(gateways)) { 3021 dataCall.gateways = gateways.split(" "); 3022 } 3023 } 3024 return dataCall; 3025 } 3026 3027 private Object 3028 responseDataCallList(Parcel p) { 3029 ArrayList<DataCallState> response; 3030 3031 int ver = p.readInt(); 3032 int num = p.readInt(); 3033 riljLog("responseDataCallList ver=" + ver + " num=" + num); 3034 3035 response = new ArrayList<DataCallState>(num); 3036 for (int i = 0; i < num; i++) { 3037 response.add(getDataCallState(p, ver)); 3038 } 3039 3040 return response; 3041 } 3042 3043 private Object 3044 responseSetupDataCall(Parcel p) { 3045 int ver = p.readInt(); 3046 int num = p.readInt(); 3047 if (RILJ_LOGV) riljLog("responseSetupDataCall ver=" + ver + " num=" + num); 3048 3049 DataCallState dataCall; 3050 3051 if (ver < 5) { 3052 dataCall = new DataCallState(); 3053 dataCall.version = ver; 3054 dataCall.cid = Integer.parseInt(p.readString()); 3055 dataCall.ifname = p.readString(); 3056 if (TextUtils.isEmpty(dataCall.ifname)) { 3057 throw new RuntimeException( 3058 "RIL_REQUEST_SETUP_DATA_CALL response, no ifname"); 3059 } 3060 String addresses = p.readString(); 3061 if (!TextUtils.isEmpty(addresses)) { 3062 dataCall.addresses = addresses.split(" "); 3063 } 3064 if (num >= 4) { 3065 String dnses = p.readString(); 3066 if (RILJ_LOGD) riljLog("responseSetupDataCall got dnses=" + dnses); 3067 if (!TextUtils.isEmpty(dnses)) { 3068 dataCall.dnses = dnses.split(" "); 3069 } 3070 } 3071 if (num >= 5) { 3072 String gateways = p.readString(); 3073 if (RILJ_LOGD) riljLog("responseSetupDataCall got gateways=" + gateways); 3074 if (!TextUtils.isEmpty(gateways)) { 3075 dataCall.gateways = gateways.split(" "); 3076 } 3077 } 3078 } else { 3079 if (num != 1) { 3080 throw new RuntimeException( 3081 "RIL_REQUEST_SETUP_DATA_CALL response expecting 1 RIL_Data_Call_response_v5" 3082 + " got " + num); 3083 } 3084 dataCall = getDataCallState(p, ver); 3085 } 3086 3087 return dataCall; 3088 } 3089 3090 private Object 3091 responseOperatorInfos(Parcel p) { 3092 String strings[] = (String [])responseStrings(p); 3093 ArrayList<OperatorInfo> ret; 3094 3095 if (strings.length % 4 != 0) { 3096 throw new RuntimeException( 3097 "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got " 3098 + strings.length + " strings, expected multible of 4"); 3099 } 3100 3101 ret = new ArrayList<OperatorInfo>(strings.length / 4); 3102 3103 for (int i = 0 ; i < strings.length ; i += 4) { 3104 ret.add ( 3105 new OperatorInfo( 3106 strings[i+0], 3107 strings[i+1], 3108 strings[i+2], 3109 strings[i+3])); 3110 } 3111 3112 return ret; 3113 } 3114 3115 private Object 3116 responseCellList(Parcel p) { 3117 int num, rssi; 3118 String location; 3119 ArrayList<NeighboringCellInfo> response; 3120 NeighboringCellInfo cell; 3121 3122 num = p.readInt(); 3123 response = new ArrayList<NeighboringCellInfo>(); 3124 3125 // Determine the radio access type 3126 String radioString = SystemProperties.get( 3127 TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, "unknown"); 3128 int radioType; 3129 if (radioString.equals("GPRS")) { 3130 radioType = NETWORK_TYPE_GPRS; 3131 } else if (radioString.equals("EDGE")) { 3132 radioType = NETWORK_TYPE_EDGE; 3133 } else if (radioString.equals("UMTS")) { 3134 radioType = NETWORK_TYPE_UMTS; 3135 } else if (radioString.equals("HSDPA")) { 3136 radioType = NETWORK_TYPE_HSDPA; 3137 } else if (radioString.equals("HSUPA")) { 3138 radioType = NETWORK_TYPE_HSUPA; 3139 } else if (radioString.equals("HSPA")) { 3140 radioType = NETWORK_TYPE_HSPA; 3141 } else { 3142 radioType = NETWORK_TYPE_UNKNOWN; 3143 } 3144 3145 // Interpret the location based on radio access type 3146 if (radioType != NETWORK_TYPE_UNKNOWN) { 3147 for (int i = 0 ; i < num ; i++) { 3148 rssi = p.readInt(); 3149 location = p.readString(); 3150 cell = new NeighboringCellInfo(rssi, location, radioType); 3151 response.add(cell); 3152 } 3153 } 3154 return response; 3155 } 3156 3157 private Object responseGetPreferredNetworkType(Parcel p) { 3158 int [] response = (int[]) responseInts(p); 3159 3160 if (response.length >= 1) { 3161 // Since this is the response for getPreferredNetworkType 3162 // we'll assume that it should be the value we want the 3163 // vendor ril to take if we reestablish a connection to it. 3164 mPreferredNetworkType = response[0]; 3165 } 3166 return response; 3167 } 3168 3169 private Object responseGmsBroadcastConfig(Parcel p) { 3170 int num; 3171 ArrayList<SmsBroadcastConfigInfo> response; 3172 SmsBroadcastConfigInfo info; 3173 3174 num = p.readInt(); 3175 response = new ArrayList<SmsBroadcastConfigInfo>(num); 3176 3177 for (int i = 0; i < num; i++) { 3178 int fromId = p.readInt(); 3179 int toId = p.readInt(); 3180 int fromScheme = p.readInt(); 3181 int toScheme = p.readInt(); 3182 boolean selected = (p.readInt() == 1); 3183 3184 info = new SmsBroadcastConfigInfo(fromId, toId, fromScheme, 3185 toScheme, selected); 3186 response.add(info); 3187 } 3188 return response; 3189 } 3190 3191 private Object 3192 responseCdmaBroadcastConfig(Parcel p) { 3193 int numServiceCategories; 3194 int response[]; 3195 3196 numServiceCategories = p.readInt(); 3197 3198 if (numServiceCategories == 0) { 3199 // TODO: The logic of providing default values should 3200 // not be done by this transport layer. And needs to 3201 // be done by the vendor ril or application logic. 3202 int numInts; 3203 numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES * CDMA_BSI_NO_OF_INTS_STRUCT + 1; 3204 response = new int[numInts]; 3205 3206 // Faking a default record for all possible records. 3207 response[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES; 3208 3209 // Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as 3210 // default language and selection status to false for all. 3211 for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT ) { 3212 response[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT; 3213 response[i + 1] = 1; 3214 response[i + 2] = 0; 3215 } 3216 } else { 3217 int numInts; 3218 numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1; 3219 response = new int[numInts]; 3220 3221 response[0] = numServiceCategories; 3222 for (int i = 1 ; i < numInts; i++) { 3223 response[i] = p.readInt(); 3224 } 3225 } 3226 3227 return response; 3228 } 3229 3230 private Object 3231 responseSignalStrength(Parcel p) { 3232 int numInts = 12; 3233 int response[]; 3234 3235 /* TODO: Add SignalStrength class to match RIL_SignalStrength */ 3236 response = new int[numInts]; 3237 for (int i = 0 ; i < numInts ; i++) { 3238 response[i] = p.readInt(); 3239 } 3240 3241 return response; 3242 } 3243 3244 private ArrayList<CdmaInformationRecords> 3245 responseCdmaInformationRecord(Parcel p) { 3246 int numberOfInfoRecs; 3247 ArrayList<CdmaInformationRecords> response; 3248 3249 /** 3250 * Loop through all of the information records unmarshalling them 3251 * and converting them to Java Objects. 3252 */ 3253 numberOfInfoRecs = p.readInt(); 3254 response = new ArrayList<CdmaInformationRecords>(numberOfInfoRecs); 3255 3256 for (int i = 0; i < numberOfInfoRecs; i++) { 3257 CdmaInformationRecords InfoRec = new CdmaInformationRecords(p); 3258 response.add(InfoRec); 3259 } 3260 3261 return response; 3262 } 3263 3264 private Object 3265 responseCdmaCallWaiting(Parcel p) { 3266 CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification(); 3267 3268 notification.number = p.readString(); 3269 notification.numberPresentation = notification.presentationFromCLIP(p.readInt()); 3270 notification.name = p.readString(); 3271 notification.namePresentation = notification.numberPresentation; 3272 notification.isPresent = p.readInt(); 3273 notification.signalType = p.readInt(); 3274 notification.alertPitch = p.readInt(); 3275 notification.signal = p.readInt(); 3276 notification.numberType = p.readInt(); 3277 notification.numberPlan = p.readInt(); 3278 3279 return notification; 3280 } 3281 3282 private Object 3283 responseCallRing(Parcel p){ 3284 char response[] = new char[4]; 3285 3286 response[0] = (char) p.readInt(); // isPresent 3287 response[1] = (char) p.readInt(); // signalType 3288 response[2] = (char) p.readInt(); // alertPitch 3289 response[3] = (char) p.readInt(); // signal 3290 3291 return response; 3292 } 3293 3294 private void 3295 notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) { 3296 int response = RIL_UNSOL_CDMA_INFO_REC; 3297 if (infoRec.record instanceof CdmaInformationRecords.CdmaDisplayInfoRec) { 3298 if (mDisplayInfoRegistrants != null) { 3299 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3300 mDisplayInfoRegistrants.notifyRegistrants( 3301 new AsyncResult (null, infoRec.record, null)); 3302 } 3303 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaSignalInfoRec) { 3304 if (mSignalInfoRegistrants != null) { 3305 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3306 mSignalInfoRegistrants.notifyRegistrants( 3307 new AsyncResult (null, infoRec.record, null)); 3308 } 3309 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaNumberInfoRec) { 3310 if (mNumberInfoRegistrants != null) { 3311 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3312 mNumberInfoRegistrants.notifyRegistrants( 3313 new AsyncResult (null, infoRec.record, null)); 3314 } 3315 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaRedirectingNumberInfoRec) { 3316 if (mRedirNumInfoRegistrants != null) { 3317 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3318 mRedirNumInfoRegistrants.notifyRegistrants( 3319 new AsyncResult (null, infoRec.record, null)); 3320 } 3321 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) { 3322 if (mLineControlInfoRegistrants != null) { 3323 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3324 mLineControlInfoRegistrants.notifyRegistrants( 3325 new AsyncResult (null, infoRec.record, null)); 3326 } 3327 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) { 3328 if (mT53ClirInfoRegistrants != null) { 3329 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3330 mT53ClirInfoRegistrants.notifyRegistrants( 3331 new AsyncResult (null, infoRec.record, null)); 3332 } 3333 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53AudioControlInfoRec) { 3334 if (mT53AudCntrlInfoRegistrants != null) { 3335 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3336 mT53AudCntrlInfoRegistrants.notifyRegistrants( 3337 new AsyncResult (null, infoRec.record, null)); 3338 } 3339 } 3340 } 3341 3342 static String 3343 requestToString(int request) { 3344 /* 3345 cat libs/telephony/ril_commands.h \ 3346 | egrep "^ *{RIL_" \ 3347 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' 3348 */ 3349 switch(request) { 3350 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; 3351 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; 3352 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; 3353 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; 3354 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; 3355 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; 3356 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; 3357 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; 3358 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; 3359 case RIL_REQUEST_DIAL: return "DIAL"; 3360 case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; 3361 case RIL_REQUEST_HANGUP: return "HANGUP"; 3362 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; 3363 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; 3364 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; 3365 case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; 3366 case RIL_REQUEST_UDUB: return "UDUB"; 3367 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; 3368 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; 3369 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; 3370 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE"; 3371 case RIL_REQUEST_OPERATOR: return "OPERATOR"; 3372 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; 3373 case RIL_REQUEST_DTMF: return "DTMF"; 3374 case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; 3375 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; 3376 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; 3377 case RIL_REQUEST_SIM_IO: return "SIM_IO"; 3378 case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; 3379 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; 3380 case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; 3381 case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; 3382 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; 3383 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; 3384 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; 3385 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; 3386 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; 3387 case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; 3388 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; 3389 case RIL_REQUEST_ANSWER: return "ANSWER"; 3390 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; 3391 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; 3392 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; 3393 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; 3394 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; 3395 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; 3396 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; 3397 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS "; 3398 case RIL_REQUEST_DTMF_START: return "DTMF_START"; 3399 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; 3400 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; 3401 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; 3402 case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; 3403 case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; 3404 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; 3405 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; 3406 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; 3407 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; 3408 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; 3409 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; 3410 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; 3411 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION"; 3412 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM"; 3413 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM"; 3414 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; 3415 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; 3416 case RIL_REQUEST_STK_GET_PROFILE: return "REQUEST_STK_GET_PROFILE"; 3417 case RIL_REQUEST_STK_SET_PROFILE: return "REQUEST_STK_SET_PROFILE"; 3418 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "REQUEST_STK_SEND_ENVELOPE_COMMAND"; 3419 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "REQUEST_STK_SEND_TERMINAL_RESPONSE"; 3420 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; 3421 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "REQUEST_EXPLICIT_CALL_TRANSFER"; 3422 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "REQUEST_SET_PREFERRED_NETWORK_TYPE"; 3423 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "REQUEST_GET_PREFERRED_NETWORK_TYPE"; 3424 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "REQUEST_GET_NEIGHBORING_CELL_IDS"; 3425 case RIL_REQUEST_SET_LOCATION_UPDATES: return "REQUEST_SET_LOCATION_UPDATES"; 3426 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE"; 3427 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE"; 3428 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE"; 3429 case RIL_REQUEST_SET_TTY_MODE: return "RIL_REQUEST_SET_TTY_MODE"; 3430 case RIL_REQUEST_QUERY_TTY_MODE: return "RIL_REQUEST_QUERY_TTY_MODE"; 3431 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; 3432 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; 3433 case RIL_REQUEST_CDMA_FLASH: return "RIL_REQUEST_CDMA_FLASH"; 3434 case RIL_REQUEST_CDMA_BURST_DTMF: return "RIL_REQUEST_CDMA_BURST_DTMF"; 3435 case RIL_REQUEST_CDMA_SEND_SMS: return "RIL_REQUEST_CDMA_SEND_SMS"; 3436 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE"; 3437 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG"; 3438 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG"; 3439 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG"; 3440 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG"; 3441 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION"; 3442 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY"; 3443 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION"; 3444 case RIL_REQUEST_CDMA_SUBSCRIPTION: return "RIL_REQUEST_CDMA_SUBSCRIPTION"; 3445 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM"; 3446 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM"; 3447 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY"; 3448 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS"; 3449 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS"; 3450 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "REQUEST_EXIT_EMERGENCY_CALLBACK_MODE"; 3451 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS"; 3452 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING"; 3453 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE"; 3454 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION"; 3455 default: return "<unknown request>"; 3456 } 3457 } 3458 3459 static String 3460 responseToString(int request) 3461 { 3462 /* 3463 cat libs/telephony/ril_unsol_commands.h \ 3464 | egrep "^ *{RIL_" \ 3465 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' 3466 */ 3467 switch(request) { 3468 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; 3469 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; 3470 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED"; 3471 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; 3472 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; 3473 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; 3474 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; 3475 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST"; 3476 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; 3477 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; 3478 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; 3479 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return "UNSOL_SUPP_SVC_NOTIFICATION"; 3480 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; 3481 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; 3482 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; 3483 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; 3484 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FULL"; 3485 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; 3486 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; 3487 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; 3488 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_RESPONSE_CDMA_NEW_SMS"; 3489 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_RESPONSE_NEW_BROADCAST_SMS"; 3490 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; 3491 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; 3492 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; 3493 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; 3494 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; 3495 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; 3496 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; 3497 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONG"; 3498 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; 3499 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED"; 3500 case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; 3501 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE"; 3502 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED"; 3503 default: return "<unknown reponse>"; 3504 } 3505 } 3506 3507 private void riljLog(String msg) { 3508 Log.d(LOG_TAG, msg); 3509 } 3510 3511 private void riljLogv(String msg) { 3512 Log.v(LOG_TAG, msg); 3513 } 3514 3515 private void unsljLog(int response) { 3516 riljLog("[UNSL]< " + responseToString(response)); 3517 } 3518 3519 private void unsljLogMore(int response, String more) { 3520 riljLog("[UNSL]< " + responseToString(response) + " " + more); 3521 } 3522 3523 private void unsljLogRet(int response, Object ret) { 3524 riljLog("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 3525 } 3526 3527 private void unsljLogvRet(int response, Object ret) { 3528 riljLogv("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 3529 } 3530 3531 3532 // ***** Methods for CDMA support 3533 public void 3534 getDeviceIdentity(Message response) { 3535 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DEVICE_IDENTITY, response); 3536 3537 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3538 3539 send(rr); 3540 } 3541 3542 public void 3543 getCDMASubscription(Message response) { 3544 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SUBSCRIPTION, response); 3545 3546 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3547 3548 send(rr); 3549 } 3550 3551 @Override 3552 public void setPhoneType(int phoneType) { // Called by CDMAPhone and GSMPhone constructor 3553 if (RILJ_LOGD) riljLog("setPhoneType=" + phoneType + " old value=" + mPhoneType); 3554 mPhoneType = phoneType; 3555 } 3556 3557 /** 3558 * {@inheritDoc} 3559 */ 3560 public void queryCdmaRoamingPreference(Message response) { 3561 RILRequest rr = RILRequest.obtain( 3562 RILConstants.RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, response); 3563 3564 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3565 3566 send(rr); 3567 } 3568 3569 /** 3570 * {@inheritDoc} 3571 */ 3572 public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) { 3573 RILRequest rr = RILRequest.obtain( 3574 RILConstants.RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, response); 3575 3576 rr.mp.writeInt(1); 3577 rr.mp.writeInt(cdmaRoamingType); 3578 3579 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3580 + " : " + cdmaRoamingType); 3581 3582 send(rr); 3583 } 3584 3585 /** 3586 * {@inheritDoc} 3587 */ 3588 public void setCdmaSubscriptionSource(int cdmaSubscription , Message response) { 3589 RILRequest rr = RILRequest.obtain( 3590 RILConstants.RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, response); 3591 3592 rr.mp.writeInt(1); 3593 rr.mp.writeInt(cdmaSubscription); 3594 3595 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3596 + " : " + cdmaSubscription); 3597 3598 send(rr); 3599 } 3600 3601 /** 3602 * {@inheritDoc} 3603 */ 3604 @Override 3605 public void getCdmaSubscriptionSource(Message response) { 3606 RILRequest rr = RILRequest.obtain( 3607 RILConstants.RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, response); 3608 3609 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3610 3611 send(rr); 3612 } 3613 3614 /** 3615 * {@inheritDoc} 3616 */ 3617 public void queryTTYMode(Message response) { 3618 RILRequest rr = RILRequest.obtain( 3619 RILConstants.RIL_REQUEST_QUERY_TTY_MODE, response); 3620 3621 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3622 3623 send(rr); 3624 } 3625 3626 /** 3627 * {@inheritDoc} 3628 */ 3629 public void setTTYMode(int ttyMode, Message response) { 3630 RILRequest rr = RILRequest.obtain( 3631 RILConstants.RIL_REQUEST_SET_TTY_MODE, response); 3632 3633 rr.mp.writeInt(1); 3634 rr.mp.writeInt(ttyMode); 3635 3636 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3637 + " : " + ttyMode); 3638 3639 send(rr); 3640 } 3641 3642 /** 3643 * {@inheritDoc} 3644 */ 3645 public void 3646 sendCDMAFeatureCode(String FeatureCode, Message response) { 3647 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_FLASH, response); 3648 3649 rr.mp.writeString(FeatureCode); 3650 3651 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3652 + " : " + FeatureCode); 3653 3654 send(rr); 3655 } 3656 3657 public void getCdmaBroadcastConfig(Message response) { 3658 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, response); 3659 3660 send(rr); 3661 } 3662 3663 // TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig 3664 public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) { 3665 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response); 3666 3667 for(int i = 0; i < configValuesArray.length; i++) { 3668 rr.mp.writeInt(configValuesArray[i]); 3669 } 3670 3671 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3672 3673 send(rr); 3674 } 3675 3676 public void setCdmaBroadcastActivation(boolean activate, Message response) { 3677 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, response); 3678 3679 rr.mp.writeInt(1); 3680 rr.mp.writeInt(activate ? 0 :1); 3681 3682 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3683 3684 send(rr); 3685 } 3686 3687 /** 3688 * {@inheritDoc} 3689 */ 3690 public void exitEmergencyCallbackMode(Message response) { 3691 RILRequest rr = RILRequest.obtain(RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, response); 3692 3693 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3694 3695 send(rr); 3696 } 3697 3698 public void requestIsimAuthentication(String nonce, Message response) { 3699 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ISIM_AUTHENTICATION, response); 3700 3701 rr.mp.writeString(nonce); 3702 3703 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3704 3705 send(rr); 3706 } 3707 } 3708