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