RIL.java revision 5b81adc82a53b3064f4baa3acfeabef31586588a
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.cdma.CdmaCallWaitingNotification; 55import com.android.internal.telephony.cdma.CdmaInformationRecords; 56import com.android.internal.telephony.IccRefreshResponse; 57 58import java.io.ByteArrayInputStream; 59import java.io.DataInputStream; 60import java.io.FileDescriptor; 61import java.io.IOException; 62import java.io.InputStream; 63import java.io.PrintWriter; 64import java.util.ArrayList; 65import java.util.Collections; 66import java.util.concurrent.atomic.AtomicBoolean; 67 68/** 69 * {@hide} 70 */ 71class RILRequest { 72 static final String LOG_TAG = "RILJ"; 73 74 //***** Class Variables 75 static int sNextSerial = 0; 76 static Object sSerialMonitor = new Object(); 77 private static Object sPoolSync = new Object(); 78 private static RILRequest sPool = null; 79 private static int sPoolSize = 0; 80 private static final int MAX_POOL_SIZE = 4; 81 82 //***** Instance Variables 83 int mSerial; 84 int mRequest; 85 Message mResult; 86 Parcel mp; 87 RILRequest mNext; 88 89 /** 90 * Retrieves a new RILRequest instance from the pool. 91 * 92 * @param request RIL_REQUEST_* 93 * @param result sent when operation completes 94 * @return a RILRequest instance from the pool. 95 */ 96 static RILRequest obtain(int request, Message result) { 97 RILRequest rr = null; 98 99 synchronized(sPoolSync) { 100 if (sPool != null) { 101 rr = sPool; 102 sPool = rr.mNext; 103 rr.mNext = null; 104 sPoolSize--; 105 } 106 } 107 108 if (rr == null) { 109 rr = new RILRequest(); 110 } 111 112 synchronized(sSerialMonitor) { 113 rr.mSerial = sNextSerial++; 114 } 115 rr.mRequest = request; 116 rr.mResult = result; 117 rr.mp = Parcel.obtain(); 118 119 if (result != null && result.getTarget() == null) { 120 throw new NullPointerException("Message target must not be null"); 121 } 122 123 // first elements in any RIL Parcel 124 rr.mp.writeInt(request); 125 rr.mp.writeInt(rr.mSerial); 126 127 return rr; 128 } 129 130 /** 131 * Returns a RILRequest instance to the pool. 132 * 133 * Note: This should only be called once per use. 134 */ 135 void release() { 136 synchronized (sPoolSync) { 137 if (sPoolSize < MAX_POOL_SIZE) { 138 this.mNext = sPool; 139 sPool = this; 140 sPoolSize++; 141 mResult = null; 142 } 143 } 144 } 145 146 private RILRequest() { 147 } 148 149 static void 150 resetSerial() { 151 synchronized(sSerialMonitor) { 152 sNextSerial = 0; 153 } 154 } 155 156 String 157 serialString() { 158 //Cheesy way to do %04d 159 StringBuilder sb = new StringBuilder(8); 160 String sn; 161 162 sn = Integer.toString(mSerial); 163 164 //sb.append("J["); 165 sb.append('['); 166 for (int i = 0, s = sn.length() ; i < 4 - s; i++) { 167 sb.append('0'); 168 } 169 170 sb.append(sn); 171 sb.append(']'); 172 return sb.toString(); 173 } 174 175 void 176 onError(int error, Object ret) { 177 CommandException ex; 178 179 ex = CommandException.fromRilErrno(error); 180 181 if (RIL.RILJ_LOGD) Log.d(LOG_TAG, serialString() + "< " 182 + RIL.requestToString(mRequest) 183 + " error: " + ex); 184 185 if (mResult != null) { 186 AsyncResult.forMessage(mResult, ret, ex); 187 mResult.sendToTarget(); 188 } 189 190 if (mp != null) { 191 mp.recycle(); 192 mp = null; 193 } 194 } 195} 196 197 198/** 199 * RIL implementation of the CommandsInterface. 200 * FIXME public only for testing 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 1663 // count strings 1664 rr.mp.writeInt(4); 1665 1666 rr.mp.writeString(facility); 1667 rr.mp.writeString(password); 1668 1669 rr.mp.writeString(Integer.toString(serviceClass)); 1670 rr.mp.writeString(appId); 1671 1672 send(rr); 1673 } 1674 1675 @Override 1676 public void 1677 setFacilityLock (String facility, boolean lockState, String password, 1678 int serviceClass, Message response) { 1679 setFacilityLockForApp(facility, lockState, password, serviceClass, null, response); 1680 } 1681 1682 @Override 1683 public void 1684 setFacilityLockForApp(String facility, boolean lockState, String password, 1685 int serviceClass, String appId, Message response) { 1686 String lockString; 1687 RILRequest rr 1688 = RILRequest.obtain(RIL_REQUEST_SET_FACILITY_LOCK, response); 1689 1690 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1691 1692 // count strings 1693 rr.mp.writeInt(5); 1694 1695 rr.mp.writeString(facility); 1696 lockString = (lockState)?"1":"0"; 1697 rr.mp.writeString(lockString); 1698 rr.mp.writeString(password); 1699 rr.mp.writeString(Integer.toString(serviceClass)); 1700 rr.mp.writeString(appId); 1701 1702 send(rr); 1703 1704 } 1705 1706 public void 1707 sendUSSD (String ussdString, Message response) { 1708 RILRequest rr 1709 = RILRequest.obtain(RIL_REQUEST_SEND_USSD, response); 1710 1711 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1712 + " " + ussdString); 1713 1714 rr.mp.writeString(ussdString); 1715 1716 send(rr); 1717 } 1718 1719 // inherited javadoc suffices 1720 public void cancelPendingUssd (Message response) { 1721 RILRequest rr 1722 = RILRequest.obtain(RIL_REQUEST_CANCEL_USSD, response); 1723 1724 if (RILJ_LOGD) riljLog(rr.serialString() 1725 + "> " + requestToString(rr.mRequest)); 1726 1727 send(rr); 1728 } 1729 1730 1731 public void resetRadio(Message result) { 1732 RILRequest rr 1733 = RILRequest.obtain(RIL_REQUEST_RESET_RADIO, result); 1734 1735 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1736 1737 send(rr); 1738 } 1739 1740 public void invokeOemRilRequestRaw(byte[] data, Message response) { 1741 RILRequest rr 1742 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_RAW, response); 1743 1744 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1745 + "[" + IccUtils.bytesToHexString(data) + "]"); 1746 1747 rr.mp.writeByteArray(data); 1748 1749 send(rr); 1750 1751 } 1752 1753 public void invokeOemRilRequestStrings(String[] strings, Message response) { 1754 RILRequest rr 1755 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_STRINGS, response); 1756 1757 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1758 1759 rr.mp.writeStringArray(strings); 1760 1761 send(rr); 1762 } 1763 1764 /** 1765 * Assign a specified band for RF configuration. 1766 * 1767 * @param bandMode one of BM_*_BAND 1768 * @param response is callback message 1769 */ 1770 public void setBandMode (int bandMode, Message response) { 1771 RILRequest rr 1772 = RILRequest.obtain(RIL_REQUEST_SET_BAND_MODE, response); 1773 1774 rr.mp.writeInt(1); 1775 rr.mp.writeInt(bandMode); 1776 1777 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1778 + " " + bandMode); 1779 1780 send(rr); 1781 } 1782 1783 /** 1784 * Query the list of band mode supported by RF. 1785 * 1786 * @param response is callback message 1787 * ((AsyncResult)response.obj).result is an int[] with every 1788 * element representing one avialable BM_*_BAND 1789 */ 1790 public void queryAvailableBandMode (Message response) { 1791 RILRequest rr 1792 = RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, 1793 response); 1794 1795 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1796 1797 send(rr); 1798 } 1799 1800 /** 1801 * {@inheritDoc} 1802 */ 1803 public void sendTerminalResponse(String contents, Message response) { 1804 RILRequest rr = RILRequest.obtain( 1805 RILConstants.RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, response); 1806 1807 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1808 1809 rr.mp.writeString(contents); 1810 send(rr); 1811 } 1812 1813 /** 1814 * {@inheritDoc} 1815 */ 1816 public void sendEnvelope(String contents, Message response) { 1817 RILRequest rr = RILRequest.obtain( 1818 RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, response); 1819 1820 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1821 1822 rr.mp.writeString(contents); 1823 send(rr); 1824 } 1825 1826 /** 1827 * {@inheritDoc} 1828 */ 1829 public void sendEnvelopeWithStatus(String contents, Message response) { 1830 RILRequest rr = RILRequest.obtain( 1831 RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, response); 1832 1833 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1834 + '[' + contents + ']'); 1835 1836 rr.mp.writeString(contents); 1837 send(rr); 1838 } 1839 1840 /** 1841 * {@inheritDoc} 1842 */ 1843 public void handleCallSetupRequestFromSim( 1844 boolean accept, Message response) { 1845 1846 RILRequest rr = RILRequest.obtain( 1847 RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, 1848 response); 1849 1850 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1851 1852 int[] param = new int[1]; 1853 param[0] = accept ? 1 : 0; 1854 rr.mp.writeIntArray(param); 1855 send(rr); 1856 } 1857 1858 /** 1859 * {@inheritDoc} 1860 */ 1861 @Override 1862 public void setCurrentPreferredNetworkType() { 1863 if (RILJ_LOGD) riljLog("setCurrentPreferredNetworkType: " + mSetPreferredNetworkType); 1864 setPreferredNetworkType(mSetPreferredNetworkType, null); 1865 } 1866 private int mSetPreferredNetworkType; 1867 1868 /** 1869 * {@inheritDoc} 1870 */ 1871 public void setPreferredNetworkType(int networkType , Message response) { 1872 RILRequest rr = RILRequest.obtain( 1873 RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response); 1874 1875 rr.mp.writeInt(1); 1876 rr.mp.writeInt(networkType); 1877 1878 mSetPreferredNetworkType = networkType; 1879 mPreferredNetworkType = networkType; 1880 1881 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1882 + " : " + networkType); 1883 1884 send(rr); 1885 } 1886 1887 /** 1888 * {@inheritDoc} 1889 */ 1890 public void getPreferredNetworkType(Message response) { 1891 RILRequest rr = RILRequest.obtain( 1892 RILConstants.RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, response); 1893 1894 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1895 1896 send(rr); 1897 } 1898 1899 /** 1900 * {@inheritDoc} 1901 */ 1902 public void getNeighboringCids(Message response) { 1903 RILRequest rr = RILRequest.obtain( 1904 RILConstants.RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, response); 1905 1906 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1907 1908 send(rr); 1909 } 1910 1911 /** 1912 * {@inheritDoc} 1913 */ 1914 public void setLocationUpdates(boolean enable, Message response) { 1915 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_LOCATION_UPDATES, response); 1916 rr.mp.writeInt(1); 1917 rr.mp.writeInt(enable ? 1 : 0); 1918 1919 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1920 + requestToString(rr.mRequest) + ": " + enable); 1921 1922 send(rr); 1923 } 1924 1925 /** 1926 * {@inheritDoc} 1927 */ 1928 public void getSmscAddress(Message result) { 1929 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SMSC_ADDRESS, result); 1930 1931 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1932 1933 send(rr); 1934 } 1935 1936 /** 1937 * {@inheritDoc} 1938 */ 1939 public void setSmscAddress(String address, Message result) { 1940 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_SMSC_ADDRESS, result); 1941 1942 rr.mp.writeString(address); 1943 1944 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1945 + " : " + address); 1946 1947 send(rr); 1948 } 1949 1950 /** 1951 * {@inheritDoc} 1952 */ 1953 public void reportSmsMemoryStatus(boolean available, Message result) { 1954 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, result); 1955 rr.mp.writeInt(1); 1956 rr.mp.writeInt(available ? 1 : 0); 1957 1958 if (RILJ_LOGD) riljLog(rr.serialString() + "> " 1959 + requestToString(rr.mRequest) + ": " + available); 1960 1961 send(rr); 1962 } 1963 1964 /** 1965 * {@inheritDoc} 1966 */ 1967 public void reportStkServiceIsRunning(Message result) { 1968 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, result); 1969 1970 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1971 1972 send(rr); 1973 } 1974 1975 /** 1976 * {@inheritDoc} 1977 */ 1978 public void getGsmBroadcastConfig(Message response) { 1979 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, response); 1980 1981 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1982 1983 send(rr); 1984 } 1985 1986 /** 1987 * {@inheritDoc} 1988 */ 1989 public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) { 1990 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, response); 1991 1992 int numOfConfig = config.length; 1993 rr.mp.writeInt(numOfConfig); 1994 1995 for(int i = 0; i < numOfConfig; i++) { 1996 rr.mp.writeInt(config[i].getFromServiceId()); 1997 rr.mp.writeInt(config[i].getToServiceId()); 1998 rr.mp.writeInt(config[i].getFromCodeScheme()); 1999 rr.mp.writeInt(config[i].getToCodeScheme()); 2000 rr.mp.writeInt(config[i].isSelected() ? 1 : 0); 2001 } 2002 2003 if (RILJ_LOGD) { 2004 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2005 + " with " + numOfConfig + " configs : "); 2006 for (int i = 0; i < numOfConfig; i++) { 2007 riljLog(config[i].toString()); 2008 } 2009 } 2010 2011 send(rr); 2012 } 2013 2014 /** 2015 * {@inheritDoc} 2016 */ 2017 public void setGsmBroadcastActivation(boolean activate, Message response) { 2018 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, response); 2019 2020 rr.mp.writeInt(1); 2021 rr.mp.writeInt(activate ? 0 : 1); 2022 2023 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2024 2025 send(rr); 2026 } 2027 2028 //***** Private Methods 2029 2030 private void sendScreenState(boolean on) { 2031 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SCREEN_STATE, null); 2032 rr.mp.writeInt(1); 2033 rr.mp.writeInt(on ? 1 : 0); 2034 2035 if (RILJ_LOGD) riljLog(rr.serialString() 2036 + "> " + requestToString(rr.mRequest) + ": " + on); 2037 2038 send(rr); 2039 } 2040 2041 protected void 2042 onRadioAvailable() { 2043 // In case screen state was lost (due to process crash), 2044 // this ensures that the RIL knows the correct screen state. 2045 2046 // TODO: Should query Power Manager and send the actual 2047 // screen state. Just send true for now. 2048 sendScreenState(true); 2049 } 2050 2051 private RadioState getRadioStateFromInt(int stateInt) { 2052 RadioState state; 2053 2054 /* RIL_RadioState ril.h */ 2055 switch(stateInt) { 2056 case 0: state = RadioState.RADIO_OFF; break; 2057 case 1: state = RadioState.RADIO_UNAVAILABLE; break; 2058 case 10: state = RadioState.RADIO_ON; break; 2059 2060 default: 2061 throw new RuntimeException( 2062 "Unrecognized RIL_RadioState: " + stateInt); 2063 } 2064 return state; 2065 } 2066 2067 private void switchToRadioState(RadioState newState) { 2068 setRadioState(newState); 2069 } 2070 2071 /** 2072 * Holds a PARTIAL_WAKE_LOCK whenever 2073 * a) There is outstanding RIL request sent to RIL deamon and no replied 2074 * b) There is a request pending to be sent out. 2075 * 2076 * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't 2077 * happen often. 2078 */ 2079 2080 private void 2081 acquireWakeLock() { 2082 synchronized (mWakeLock) { 2083 mWakeLock.acquire(); 2084 mRequestMessagesPending++; 2085 2086 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); 2087 Message msg = mSender.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT); 2088 mSender.sendMessageDelayed(msg, mWakeLockTimeout); 2089 } 2090 } 2091 2092 private void 2093 releaseWakeLockIfDone() { 2094 synchronized (mWakeLock) { 2095 if (mWakeLock.isHeld() && 2096 (mRequestMessagesPending == 0) && 2097 (mRequestMessagesWaiting == 0)) { 2098 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); 2099 mWakeLock.release(); 2100 } 2101 } 2102 } 2103 2104 private void 2105 send(RILRequest rr) { 2106 Message msg; 2107 2108 if (mSocket == null) { 2109 rr.onError(RADIO_NOT_AVAILABLE, null); 2110 rr.release(); 2111 return; 2112 } 2113 2114 msg = mSender.obtainMessage(EVENT_SEND, rr); 2115 2116 acquireWakeLock(); 2117 2118 msg.sendToTarget(); 2119 } 2120 2121 private void 2122 processResponse (Parcel p) { 2123 int type; 2124 2125 type = p.readInt(); 2126 2127 if (type == RESPONSE_UNSOLICITED) { 2128 processUnsolicited (p); 2129 } else if (type == RESPONSE_SOLICITED) { 2130 processSolicited (p); 2131 } 2132 2133 releaseWakeLockIfDone(); 2134 } 2135 2136 /** 2137 * Release each request in mReqeustsList then clear the list 2138 * @param error is the RIL_Errno sent back 2139 * @param loggable true means to print all requests in mRequestslist 2140 */ 2141 private void clearRequestsList(int error, boolean loggable) { 2142 RILRequest rr; 2143 synchronized (mRequestsList) { 2144 int count = mRequestsList.size(); 2145 if (RILJ_LOGD && loggable) { 2146 Log.d(LOG_TAG, "WAKE_LOCK_TIMEOUT " + 2147 " mReqPending=" + mRequestMessagesPending + 2148 " mRequestList=" + count); 2149 } 2150 2151 for (int i = 0; i < count ; i++) { 2152 rr = mRequestsList.get(i); 2153 if (RILJ_LOGD && loggable) { 2154 Log.d(LOG_TAG, i + ": [" + rr.mSerial + "] " + 2155 requestToString(rr.mRequest)); 2156 } 2157 rr.onError(error, null); 2158 rr.release(); 2159 } 2160 mRequestsList.clear(); 2161 mRequestMessagesWaiting = 0; 2162 } 2163 } 2164 2165 private RILRequest findAndRemoveRequestFromList(int serial) { 2166 synchronized (mRequestsList) { 2167 for (int i = 0, s = mRequestsList.size() ; i < s ; i++) { 2168 RILRequest rr = mRequestsList.get(i); 2169 2170 if (rr.mSerial == serial) { 2171 mRequestsList.remove(i); 2172 if (mRequestMessagesWaiting > 0) 2173 mRequestMessagesWaiting--; 2174 return rr; 2175 } 2176 } 2177 } 2178 2179 return null; 2180 } 2181 2182 private void 2183 processSolicited (Parcel p) { 2184 int serial, error; 2185 boolean found = false; 2186 2187 serial = p.readInt(); 2188 error = p.readInt(); 2189 2190 RILRequest rr; 2191 2192 rr = findAndRemoveRequestFromList(serial); 2193 2194 if (rr == null) { 2195 Log.w(LOG_TAG, "Unexpected solicited response! sn: " 2196 + serial + " error: " + error); 2197 return; 2198 } 2199 2200 Object ret = null; 2201 2202 if (error == 0 || p.dataAvail() > 0) { 2203 // either command succeeds or command fails but with data payload 2204 try {switch (rr.mRequest) { 2205 /* 2206 cat libs/telephony/ril_commands.h \ 2207 | egrep "^ *{RIL_" \ 2208 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: ret = \2(p); break;/' 2209 */ 2210 case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break; 2211 case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break; 2212 case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break; 2213 case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break; 2214 case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break; 2215 case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break; 2216 case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break; 2217 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break; 2218 case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break; 2219 case RIL_REQUEST_DIAL: ret = responseVoid(p); break; 2220 case RIL_REQUEST_GET_IMSI: ret = responseString(p); break; 2221 case RIL_REQUEST_HANGUP: ret = responseVoid(p); break; 2222 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break; 2223 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: { 2224 if (mTestingEmergencyCall.getAndSet(false)) { 2225 if (mEmergencyCallbackModeRegistrant != null) { 2226 riljLog("testing emergency call, notify ECM Registrants"); 2227 mEmergencyCallbackModeRegistrant.notifyRegistrant(); 2228 } 2229 } 2230 ret = responseVoid(p); 2231 break; 2232 } 2233 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break; 2234 case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break; 2235 case RIL_REQUEST_UDUB: ret = responseVoid(p); break; 2236 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break; 2237 case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; 2238 case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break; 2239 case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break; 2240 case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break; 2241 case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break; 2242 case RIL_REQUEST_DTMF: ret = responseVoid(p); break; 2243 case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break; 2244 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break; 2245 case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break; 2246 case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break; 2247 case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break; 2248 case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break; 2249 case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break; 2250 case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break; 2251 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break; 2252 case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break; 2253 case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break; 2254 case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break; 2255 case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; 2256 case RIL_REQUEST_GET_IMEI: ret = responseString(p); break; 2257 case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break; 2258 case RIL_REQUEST_ANSWER: ret = responseVoid(p); break; 2259 case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break; 2260 case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break; 2261 case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break; 2262 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break; 2263 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break; 2264 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break; 2265 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break; 2266 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break; 2267 case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break; 2268 case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break; 2269 case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break; 2270 case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break; 2271 case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break; 2272 case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break; 2273 case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break; 2274 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break; 2275 case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break; 2276 case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break; 2277 case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break; 2278 case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break; 2279 case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break; 2280 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break; 2281 case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break; 2282 case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break; 2283 case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break; 2284 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break; 2285 case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break; 2286 case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break; 2287 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break; 2288 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break; 2289 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break; 2290 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break; 2291 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break; 2292 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break; 2293 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseCellList(p); break; 2294 case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break; 2295 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break; 2296 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break; 2297 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break; 2298 case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break; 2299 case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break; 2300 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break; 2301 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break; 2302 case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break; 2303 case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break; 2304 case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break; 2305 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; 2306 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break; 2307 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; 2308 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break; 2309 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break; 2310 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; 2311 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break; 2312 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break; 2313 case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break; 2314 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break; 2315 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break; 2316 case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break; 2317 case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break; 2318 case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break; 2319 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2320 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break; 2321 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break; 2322 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break; 2323 case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break; 2324 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: ret = responseVoid(p); break; 2325 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: ret = responseICC_IO(p); break; 2326 case RIL_REQUEST_VOICE_RADIO_TECH: ret = responseInts(p); break; 2327 default: 2328 throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest); 2329 //break; 2330 }} catch (Throwable tr) { 2331 // Exceptions here usually mean invalid RIL responses 2332 2333 Log.w(LOG_TAG, rr.serialString() + "< " 2334 + requestToString(rr.mRequest) 2335 + " exception, possible invalid RIL response", tr); 2336 2337 if (rr.mResult != null) { 2338 AsyncResult.forMessage(rr.mResult, null, tr); 2339 rr.mResult.sendToTarget(); 2340 } 2341 rr.release(); 2342 return; 2343 } 2344 } 2345 2346 if (error != 0) { 2347 rr.onError(error, ret); 2348 rr.release(); 2349 return; 2350 } 2351 2352 if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) 2353 + " " + retToString(rr.mRequest, ret)); 2354 2355 if (rr.mResult != null) { 2356 AsyncResult.forMessage(rr.mResult, ret, null); 2357 rr.mResult.sendToTarget(); 2358 } 2359 2360 rr.release(); 2361 } 2362 2363 private String 2364 retToString(int req, Object ret) { 2365 if (ret == null) return ""; 2366 switch (req) { 2367 // Don't log these return values, for privacy's sake. 2368 case RIL_REQUEST_GET_IMSI: 2369 case RIL_REQUEST_GET_IMEI: 2370 case RIL_REQUEST_GET_IMEISV: 2371 if (!RILJ_LOGV) { 2372 // If not versbose logging just return and don't display IMSI and IMEI, IMEISV 2373 return ""; 2374 } 2375 } 2376 2377 StringBuilder sb; 2378 String s; 2379 int length; 2380 if (ret instanceof int[]){ 2381 int[] intArray = (int[]) ret; 2382 length = intArray.length; 2383 sb = new StringBuilder("{"); 2384 if (length > 0) { 2385 int i = 0; 2386 sb.append(intArray[i++]); 2387 while ( i < length) { 2388 sb.append(", ").append(intArray[i++]); 2389 } 2390 } 2391 sb.append("}"); 2392 s = sb.toString(); 2393 } else if (ret instanceof String[]) { 2394 String[] strings = (String[]) ret; 2395 length = strings.length; 2396 sb = new StringBuilder("{"); 2397 if (length > 0) { 2398 int i = 0; 2399 sb.append(strings[i++]); 2400 while ( i < length) { 2401 sb.append(", ").append(strings[i++]); 2402 } 2403 } 2404 sb.append("}"); 2405 s = sb.toString(); 2406 }else if (req == RIL_REQUEST_GET_CURRENT_CALLS) { 2407 ArrayList<DriverCall> calls = (ArrayList<DriverCall>) ret; 2408 sb = new StringBuilder(" "); 2409 for (DriverCall dc : calls) { 2410 sb.append("[").append(dc).append("] "); 2411 } 2412 s = sb.toString(); 2413 } else if (req == RIL_REQUEST_GET_NEIGHBORING_CELL_IDS) { 2414 ArrayList<NeighboringCellInfo> cells; 2415 cells = (ArrayList<NeighboringCellInfo>) ret; 2416 sb = new StringBuilder(" "); 2417 for (NeighboringCellInfo cell : cells) { 2418 sb.append(cell).append(" "); 2419 } 2420 s = sb.toString(); 2421 } else { 2422 s = ret.toString(); 2423 } 2424 return s; 2425 } 2426 2427 private void 2428 processUnsolicited (Parcel p) { 2429 int response; 2430 Object ret; 2431 2432 response = p.readInt(); 2433 2434 try {switch(response) { 2435/* 2436 cat libs/telephony/ril_unsol_commands.h \ 2437 | egrep "^ *{RIL_" \ 2438 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: \2(rr, p); break;/' 2439*/ 2440 2441 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break; 2442 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: ret = responseVoid(p); break; 2443 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: ret = responseVoid(p); break; 2444 case RIL_UNSOL_RESPONSE_NEW_SMS: ret = responseString(p); break; 2445 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: ret = responseString(p); break; 2446 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: ret = responseInts(p); break; 2447 case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break; 2448 case RIL_UNSOL_NITZ_TIME_RECEIVED: ret = responseString(p); break; 2449 case RIL_UNSOL_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; 2450 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: ret = responseDataCallList(p);break; 2451 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: ret = responseSuppServiceNotification(p); break; 2452 case RIL_UNSOL_STK_SESSION_END: ret = responseVoid(p); break; 2453 case RIL_UNSOL_STK_PROACTIVE_COMMAND: ret = responseString(p); break; 2454 case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break; 2455 case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break; 2456 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break; 2457 case RIL_UNSOL_SIM_REFRESH: ret = responseSimRefresh(p); break; 2458 case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break; 2459 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break; 2460 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break; 2461 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break; 2462 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseRaw(p); break; 2463 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break; 2464 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2465 case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break; 2466 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: ret = responseInts(p); break; 2467 case RIL_UNSOL_CDMA_INFO_REC: ret = responseCdmaInformationRecord(p); break; 2468 case RIL_UNSOL_OEM_HOOK_RAW: ret = responseRaw(p); break; 2469 case RIL_UNSOL_RINGBACK_TONE: ret = responseInts(p); break; 2470 case RIL_UNSOL_RESEND_INCALL_MUTE: ret = responseVoid(p); break; 2471 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: ret = responseInts(p); break; 2472 case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break; 2473 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; 2474 case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break; 2475 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: ret = responseInts(p); break; 2476 2477 default: 2478 throw new RuntimeException("Unrecognized unsol response: " + response); 2479 //break; (implied) 2480 }} catch (Throwable tr) { 2481 Log.e(LOG_TAG, "Exception processing unsol response: " + response + 2482 "Exception:" + tr.toString()); 2483 return; 2484 } 2485 2486 switch(response) { 2487 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: 2488 /* has bonus radio state int */ 2489 RadioState newState = getRadioStateFromInt(p.readInt()); 2490 if (RILJ_LOGD) unsljLogMore(response, newState.toString()); 2491 2492 switchToRadioState(newState); 2493 break; 2494 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: 2495 if (RILJ_LOGD) unsljLog(response); 2496 2497 mCallStateRegistrants 2498 .notifyRegistrants(new AsyncResult(null, null, null)); 2499 break; 2500 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: 2501 if (RILJ_LOGD) unsljLog(response); 2502 2503 mVoiceNetworkStateRegistrants 2504 .notifyRegistrants(new AsyncResult(null, null, null)); 2505 break; 2506 case RIL_UNSOL_RESPONSE_NEW_SMS: { 2507 if (RILJ_LOGD) unsljLog(response); 2508 2509 // FIXME this should move up a layer 2510 String a[] = new String[2]; 2511 2512 a[1] = (String)ret; 2513 2514 SmsMessage sms; 2515 2516 sms = SmsMessage.newFromCMT(a); 2517 if (mGsmSmsRegistrant != null) { 2518 mGsmSmsRegistrant 2519 .notifyRegistrant(new AsyncResult(null, sms, null)); 2520 } 2521 break; 2522 } 2523 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: 2524 if (RILJ_LOGD) unsljLogRet(response, ret); 2525 2526 if (mSmsStatusRegistrant != null) { 2527 mSmsStatusRegistrant.notifyRegistrant( 2528 new AsyncResult(null, ret, null)); 2529 } 2530 break; 2531 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: 2532 if (RILJ_LOGD) unsljLogRet(response, ret); 2533 2534 int[] smsIndex = (int[])ret; 2535 2536 if(smsIndex.length == 1) { 2537 if (mSmsOnSimRegistrant != null) { 2538 mSmsOnSimRegistrant. 2539 notifyRegistrant(new AsyncResult(null, smsIndex, null)); 2540 } 2541 } else { 2542 if (RILJ_LOGD) riljLog(" NEW_SMS_ON_SIM ERROR with wrong length " 2543 + smsIndex.length); 2544 } 2545 break; 2546 case RIL_UNSOL_ON_USSD: 2547 String[] resp = (String[])ret; 2548 2549 if (resp.length < 2) { 2550 resp = new String[2]; 2551 resp[0] = ((String[])ret)[0]; 2552 resp[1] = null; 2553 } 2554 if (RILJ_LOGD) unsljLogMore(response, resp[0]); 2555 if (mUSSDRegistrant != null) { 2556 mUSSDRegistrant.notifyRegistrant( 2557 new AsyncResult (null, resp, null)); 2558 } 2559 break; 2560 case RIL_UNSOL_NITZ_TIME_RECEIVED: 2561 if (RILJ_LOGD) unsljLogRet(response, ret); 2562 2563 // has bonus long containing milliseconds since boot that the NITZ 2564 // time was received 2565 long nitzReceiveTime = p.readLong(); 2566 2567 Object[] result = new Object[2]; 2568 2569 result[0] = ret; 2570 result[1] = Long.valueOf(nitzReceiveTime); 2571 2572 boolean ignoreNitz = SystemProperties.getBoolean( 2573 TelephonyProperties.PROPERTY_IGNORE_NITZ, false); 2574 2575 if (ignoreNitz) { 2576 if (RILJ_LOGD) riljLog("ignoring UNSOL_NITZ_TIME_RECEIVED"); 2577 } else { 2578 if (mNITZTimeRegistrant != null) { 2579 2580 mNITZTimeRegistrant 2581 .notifyRegistrant(new AsyncResult (null, result, null)); 2582 } else { 2583 // in case NITZ time registrant isnt registered yet 2584 mLastNITZTimeInfo = result; 2585 } 2586 } 2587 break; 2588 2589 case RIL_UNSOL_SIGNAL_STRENGTH: 2590 // Note this is set to "verbose" because it happens 2591 // frequently 2592 if (RILJ_LOGV) unsljLogvRet(response, ret); 2593 2594 if (mSignalStrengthRegistrant != null) { 2595 mSignalStrengthRegistrant.notifyRegistrant( 2596 new AsyncResult (null, ret, null)); 2597 } 2598 break; 2599 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: 2600 if (RILJ_LOGD) unsljLogRet(response, ret); 2601 2602 mDataNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, ret, null)); 2603 break; 2604 2605 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: 2606 if (RILJ_LOGD) unsljLogRet(response, ret); 2607 2608 if (mSsnRegistrant != null) { 2609 mSsnRegistrant.notifyRegistrant( 2610 new AsyncResult (null, ret, null)); 2611 } 2612 break; 2613 2614 case RIL_UNSOL_STK_SESSION_END: 2615 if (RILJ_LOGD) unsljLog(response); 2616 2617 if (mCatSessionEndRegistrant != null) { 2618 mCatSessionEndRegistrant.notifyRegistrant( 2619 new AsyncResult (null, ret, null)); 2620 } 2621 break; 2622 2623 case RIL_UNSOL_STK_PROACTIVE_COMMAND: 2624 if (RILJ_LOGD) unsljLogRet(response, ret); 2625 2626 if (mCatProCmdRegistrant != null) { 2627 mCatProCmdRegistrant.notifyRegistrant( 2628 new AsyncResult (null, ret, null)); 2629 } 2630 break; 2631 2632 case RIL_UNSOL_STK_EVENT_NOTIFY: 2633 if (RILJ_LOGD) unsljLogRet(response, ret); 2634 2635 if (mCatEventRegistrant != null) { 2636 mCatEventRegistrant.notifyRegistrant( 2637 new AsyncResult (null, ret, null)); 2638 } 2639 break; 2640 2641 case RIL_UNSOL_STK_CALL_SETUP: 2642 if (RILJ_LOGD) unsljLogRet(response, ret); 2643 2644 if (mCatCallSetUpRegistrant != null) { 2645 mCatCallSetUpRegistrant.notifyRegistrant( 2646 new AsyncResult (null, ret, null)); 2647 } 2648 break; 2649 2650 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: 2651 if (RILJ_LOGD) unsljLog(response); 2652 2653 if (mIccSmsFullRegistrant != null) { 2654 mIccSmsFullRegistrant.notifyRegistrant(); 2655 } 2656 break; 2657 2658 case RIL_UNSOL_SIM_REFRESH: 2659 if (RILJ_LOGD) unsljLogRet(response, ret); 2660 2661 if (mIccRefreshRegistrants != null) { 2662 mIccRefreshRegistrants.notifyRegistrants( 2663 new AsyncResult (null, ret, null)); 2664 } 2665 break; 2666 2667 case RIL_UNSOL_CALL_RING: 2668 if (RILJ_LOGD) unsljLogRet(response, ret); 2669 2670 if (mRingRegistrant != null) { 2671 mRingRegistrant.notifyRegistrant( 2672 new AsyncResult (null, ret, null)); 2673 } 2674 break; 2675 2676 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: 2677 if (RILJ_LOGD) unsljLogvRet(response, ret); 2678 if (mRestrictedStateRegistrant != null) { 2679 mRestrictedStateRegistrant.notifyRegistrant( 2680 new AsyncResult (null, ret, null)); 2681 } 2682 break; 2683 2684 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: 2685 if (RILJ_LOGD) unsljLog(response); 2686 2687 if (mIccStatusChangedRegistrants != null) { 2688 mIccStatusChangedRegistrants.notifyRegistrants(); 2689 } 2690 break; 2691 2692 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: 2693 if (RILJ_LOGD) unsljLog(response); 2694 2695 SmsMessage sms = (SmsMessage) ret; 2696 2697 if (mCdmaSmsRegistrant != null) { 2698 mCdmaSmsRegistrant 2699 .notifyRegistrant(new AsyncResult(null, sms, null)); 2700 } 2701 break; 2702 2703 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: 2704 if (RILJ_LOGD) unsljLog(response); 2705 2706 if (mGsmBroadcastSmsRegistrant != null) { 2707 mGsmBroadcastSmsRegistrant 2708 .notifyRegistrant(new AsyncResult(null, ret, null)); 2709 } 2710 break; 2711 2712 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: 2713 if (RILJ_LOGD) unsljLog(response); 2714 2715 if (mIccSmsFullRegistrant != null) { 2716 mIccSmsFullRegistrant.notifyRegistrant(); 2717 } 2718 break; 2719 2720 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: 2721 if (RILJ_LOGD) unsljLog(response); 2722 2723 if (mEmergencyCallbackModeRegistrant != null) { 2724 mEmergencyCallbackModeRegistrant.notifyRegistrant(); 2725 } 2726 break; 2727 2728 case RIL_UNSOL_CDMA_CALL_WAITING: 2729 if (RILJ_LOGD) unsljLogRet(response, ret); 2730 2731 if (mCallWaitingInfoRegistrants != null) { 2732 mCallWaitingInfoRegistrants.notifyRegistrants( 2733 new AsyncResult (null, ret, null)); 2734 } 2735 break; 2736 2737 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: 2738 if (RILJ_LOGD) unsljLogRet(response, ret); 2739 2740 if (mOtaProvisionRegistrants != null) { 2741 mOtaProvisionRegistrants.notifyRegistrants( 2742 new AsyncResult (null, ret, null)); 2743 } 2744 break; 2745 2746 case RIL_UNSOL_CDMA_INFO_REC: 2747 ArrayList<CdmaInformationRecords> listInfoRecs; 2748 2749 try { 2750 listInfoRecs = (ArrayList<CdmaInformationRecords>)ret; 2751 } catch (ClassCastException e) { 2752 Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e); 2753 break; 2754 } 2755 2756 for (CdmaInformationRecords rec : listInfoRecs) { 2757 if (RILJ_LOGD) unsljLogRet(response, rec); 2758 notifyRegistrantsCdmaInfoRec(rec); 2759 } 2760 break; 2761 2762 case RIL_UNSOL_OEM_HOOK_RAW: 2763 if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret)); 2764 if (mUnsolOemHookRawRegistrant != null) { 2765 mUnsolOemHookRawRegistrant.notifyRegistrant(new AsyncResult(null, ret, null)); 2766 } 2767 break; 2768 2769 case RIL_UNSOL_RINGBACK_TONE: 2770 if (RILJ_LOGD) unsljLogvRet(response, ret); 2771 if (mRingbackToneRegistrants != null) { 2772 boolean playtone = (((int[])ret)[0] == 1); 2773 mRingbackToneRegistrants.notifyRegistrants( 2774 new AsyncResult (null, playtone, null)); 2775 } 2776 break; 2777 2778 case RIL_UNSOL_RESEND_INCALL_MUTE: 2779 if (RILJ_LOGD) unsljLogRet(response, ret); 2780 2781 if (mResendIncallMuteRegistrants != null) { 2782 mResendIncallMuteRegistrants.notifyRegistrants( 2783 new AsyncResult (null, ret, null)); 2784 } 2785 break; 2786 2787 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: 2788 if (RILJ_LOGD) unsljLogRet(response, ret); 2789 2790 if (mVoiceRadioTechChangedRegistrants != null) { 2791 mVoiceRadioTechChangedRegistrants.notifyRegistrants( 2792 new AsyncResult(null, ret, null)); 2793 } 2794 break; 2795 2796 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: 2797 if (RILJ_LOGD) unsljLogRet(response, ret); 2798 2799 if (mCdmaSubscriptionChangedRegistrants != null) { 2800 mCdmaSubscriptionChangedRegistrants.notifyRegistrants( 2801 new AsyncResult (null, ret, null)); 2802 } 2803 break; 2804 2805 case RIL_UNSOl_CDMA_PRL_CHANGED: 2806 if (RILJ_LOGD) unsljLogRet(response, ret); 2807 2808 if (mCdmaPrlChangedRegistrants != null) { 2809 mCdmaPrlChangedRegistrants.notifyRegistrants( 2810 new AsyncResult (null, ret, null)); 2811 } 2812 break; 2813 2814 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: 2815 if (RILJ_LOGD) unsljLogRet(response, ret); 2816 2817 if (mExitEmergencyCallbackModeRegistrants != null) { 2818 mExitEmergencyCallbackModeRegistrants.notifyRegistrants( 2819 new AsyncResult (null, null, null)); 2820 } 2821 break; 2822 2823 case RIL_UNSOL_RIL_CONNECTED: { 2824 if (RILJ_LOGD) unsljLogRet(response, ret); 2825 2826 // Initial conditions 2827 setRadioPower(false, null); 2828 setPreferredNetworkType(mPreferredNetworkType, null); 2829 setCdmaSubscriptionSource(mCdmaSubscription, null); 2830 notifyRegistrantsRilConnectionChanged(((int[])ret)[0]); 2831 break; 2832 } 2833 } 2834 } 2835 2836 /** 2837 * Notifiy all registrants that the ril has connected or disconnected. 2838 * 2839 * @param rilVer is the version of the ril or -1 if disconnected. 2840 */ 2841 private void notifyRegistrantsRilConnectionChanged(int rilVer) { 2842 mRilVersion = rilVer; 2843 if (mRilConnectedRegistrants != null) { 2844 mRilConnectedRegistrants.notifyRegistrants( 2845 new AsyncResult (null, new Integer(rilVer), null)); 2846 } 2847 } 2848 2849 private Object 2850 responseInts(Parcel p) { 2851 int numInts; 2852 int response[]; 2853 2854 numInts = p.readInt(); 2855 2856 response = new int[numInts]; 2857 2858 for (int i = 0 ; i < numInts ; i++) { 2859 response[i] = p.readInt(); 2860 } 2861 2862 return response; 2863 } 2864 2865 2866 private Object 2867 responseVoid(Parcel p) { 2868 return null; 2869 } 2870 2871 private Object 2872 responseCallForward(Parcel p) { 2873 int numInfos; 2874 CallForwardInfo infos[]; 2875 2876 numInfos = p.readInt(); 2877 2878 infos = new CallForwardInfo[numInfos]; 2879 2880 for (int i = 0 ; i < numInfos ; i++) { 2881 infos[i] = new CallForwardInfo(); 2882 2883 infos[i].status = p.readInt(); 2884 infos[i].reason = p.readInt(); 2885 infos[i].serviceClass = p.readInt(); 2886 infos[i].toa = p.readInt(); 2887 infos[i].number = p.readString(); 2888 infos[i].timeSeconds = p.readInt(); 2889 } 2890 2891 return infos; 2892 } 2893 2894 private Object 2895 responseSuppServiceNotification(Parcel p) { 2896 SuppServiceNotification notification = new SuppServiceNotification(); 2897 2898 notification.notificationType = p.readInt(); 2899 notification.code = p.readInt(); 2900 notification.index = p.readInt(); 2901 notification.type = p.readInt(); 2902 notification.number = p.readString(); 2903 2904 return notification; 2905 } 2906 2907 private Object 2908 responseCdmaSms(Parcel p) { 2909 SmsMessage sms; 2910 sms = SmsMessage.newFromParcel(p); 2911 2912 return sms; 2913 } 2914 2915 private Object 2916 responseString(Parcel p) { 2917 String response; 2918 2919 response = p.readString(); 2920 2921 return response; 2922 } 2923 2924 private Object 2925 responseStrings(Parcel p) { 2926 int num; 2927 String response[]; 2928 2929 response = p.readStringArray(); 2930 2931 if (false) { 2932 num = p.readInt(); 2933 2934 response = new String[num]; 2935 for (int i = 0; i < num; i++) { 2936 response[i] = p.readString(); 2937 } 2938 } 2939 2940 return response; 2941 } 2942 2943 private Object 2944 responseRaw(Parcel p) { 2945 int num; 2946 byte response[]; 2947 2948 response = p.createByteArray(); 2949 2950 return response; 2951 } 2952 2953 private Object 2954 responseSMS(Parcel p) { 2955 int messageRef, errorCode; 2956 String ackPDU; 2957 2958 messageRef = p.readInt(); 2959 ackPDU = p.readString(); 2960 errorCode = p.readInt(); 2961 2962 SmsResponse response = new SmsResponse(messageRef, ackPDU, errorCode); 2963 2964 return response; 2965 } 2966 2967 2968 private Object 2969 responseICC_IO(Parcel p) { 2970 int sw1, sw2; 2971 byte data[] = null; 2972 Message ret; 2973 2974 sw1 = p.readInt(); 2975 sw2 = p.readInt(); 2976 2977 String s = p.readString(); 2978 2979 if (RILJ_LOGV) riljLog("< iccIO: " 2980 + " 0x" + Integer.toHexString(sw1) 2981 + " 0x" + Integer.toHexString(sw2) + " " 2982 + s); 2983 2984 return new IccIoResult(sw1, sw2, s); 2985 } 2986 2987 private Object 2988 responseIccCardStatus(Parcel p) { 2989 IccCardApplication ca; 2990 2991 IccCardStatus status = new IccCardStatus(); 2992 status.setCardState(p.readInt()); 2993 status.setUniversalPinState(p.readInt()); 2994 status.setGsmUmtsSubscriptionAppIndex(p.readInt()); 2995 status.setCdmaSubscriptionAppIndex(p.readInt()); 2996 status.setImsSubscriptionAppIndex(p.readInt()); 2997 int numApplications = p.readInt(); 2998 2999 // limit to maximum allowed applications 3000 if (numApplications > IccCardStatus.CARD_MAX_APPS) { 3001 numApplications = IccCardStatus.CARD_MAX_APPS; 3002 } 3003 status.setNumApplications(numApplications); 3004 3005 for (int i = 0 ; i < numApplications ; i++) { 3006 ca = new IccCardApplication(); 3007 ca.app_type = ca.AppTypeFromRILInt(p.readInt()); 3008 ca.app_state = ca.AppStateFromRILInt(p.readInt()); 3009 ca.perso_substate = ca.PersoSubstateFromRILInt(p.readInt()); 3010 ca.aid = p.readString(); 3011 ca.app_label = p.readString(); 3012 ca.pin1_replaced = p.readInt(); 3013 ca.pin1 = ca.PinStateFromRILInt(p.readInt()); 3014 ca.pin2 = ca.PinStateFromRILInt(p.readInt()); 3015 status.addApplication(ca); 3016 } 3017 return status; 3018 } 3019 3020 private Object 3021 responseSimRefresh(Parcel p) { 3022 IccRefreshResponse response = new IccRefreshResponse(); 3023 3024 response.refreshResult = p.readInt(); 3025 response.efId = p.readInt(); 3026 response.aid = p.readString(); 3027 return response; 3028 } 3029 3030 private Object 3031 responseCallList(Parcel p) { 3032 int num; 3033 int voiceSettings; 3034 ArrayList<DriverCall> response; 3035 DriverCall dc; 3036 3037 num = p.readInt(); 3038 response = new ArrayList<DriverCall>(num); 3039 3040 if (RILJ_LOGV) { 3041 riljLog("responseCallList: num=" + num + 3042 " mEmergencyCallbackModeRegistrant=" + mEmergencyCallbackModeRegistrant + 3043 " mTestingEmergencyCall=" + mTestingEmergencyCall.get()); 3044 } 3045 for (int i = 0 ; i < num ; i++) { 3046 dc = new DriverCall(); 3047 3048 dc.state = DriverCall.stateFromCLCC(p.readInt()); 3049 dc.index = p.readInt(); 3050 dc.TOA = p.readInt(); 3051 dc.isMpty = (0 != p.readInt()); 3052 dc.isMT = (0 != p.readInt()); 3053 dc.als = p.readInt(); 3054 voiceSettings = p.readInt(); 3055 dc.isVoice = (0 == voiceSettings) ? false : true; 3056 dc.isVoicePrivacy = (0 != p.readInt()); 3057 dc.number = p.readString(); 3058 int np = p.readInt(); 3059 dc.numberPresentation = DriverCall.presentationFromCLIP(np); 3060 dc.name = p.readString(); 3061 dc.namePresentation = p.readInt(); 3062 int uusInfoPresent = p.readInt(); 3063 if (uusInfoPresent == 1) { 3064 dc.uusInfo = new UUSInfo(); 3065 dc.uusInfo.setType(p.readInt()); 3066 dc.uusInfo.setDcs(p.readInt()); 3067 byte[] userData = p.createByteArray(); 3068 dc.uusInfo.setUserData(userData); 3069 riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d", 3070 dc.uusInfo.getType(), dc.uusInfo.getDcs(), 3071 dc.uusInfo.getUserData().length)); 3072 riljLogv("Incoming UUS : data (string)=" 3073 + new String(dc.uusInfo.getUserData())); 3074 riljLogv("Incoming UUS : data (hex): " 3075 + IccUtils.bytesToHexString(dc.uusInfo.getUserData())); 3076 } else { 3077 riljLogv("Incoming UUS : NOT present!"); 3078 } 3079 3080 // Make sure there's a leading + on addresses with a TOA of 145 3081 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA); 3082 3083 response.add(dc); 3084 3085 if (dc.isVoicePrivacy) { 3086 mVoicePrivacyOnRegistrants.notifyRegistrants(); 3087 riljLog("InCall VoicePrivacy is enabled"); 3088 } else { 3089 mVoicePrivacyOffRegistrants.notifyRegistrants(); 3090 riljLog("InCall VoicePrivacy is disabled"); 3091 } 3092 } 3093 3094 Collections.sort(response); 3095 3096 if ((num == 0) && mTestingEmergencyCall.getAndSet(false)) { 3097 if (mEmergencyCallbackModeRegistrant != null) { 3098 riljLog("responseCallList: call ended, testing emergency call," + 3099 " notify ECM Registrants"); 3100 mEmergencyCallbackModeRegistrant.notifyRegistrant(); 3101 } 3102 } 3103 3104 return response; 3105 } 3106 3107 private DataCallState getDataCallState(Parcel p, int version) { 3108 DataCallState dataCall = new DataCallState(); 3109 3110 dataCall.version = version; 3111 if (version < 5) { 3112 dataCall.cid = p.readInt(); 3113 dataCall.active = p.readInt(); 3114 dataCall.type = p.readString(); 3115 String addresses = p.readString(); 3116 if (!TextUtils.isEmpty(addresses)) { 3117 dataCall.addresses = addresses.split(" "); 3118 } 3119 } else { 3120 dataCall.status = p.readInt(); 3121 dataCall.suggestedRetryTime = p.readInt(); 3122 dataCall.cid = p.readInt(); 3123 dataCall.active = p.readInt(); 3124 dataCall.type = p.readString(); 3125 dataCall.ifname = p.readString(); 3126 if ((dataCall.status == DataConnection.FailCause.NONE.getErrorCode()) && 3127 TextUtils.isEmpty(dataCall.ifname)) { 3128 throw new RuntimeException("getDataCallState, no ifname"); 3129 } 3130 String addresses = p.readString(); 3131 if (!TextUtils.isEmpty(addresses)) { 3132 dataCall.addresses = addresses.split(" "); 3133 } 3134 String dnses = p.readString(); 3135 if (!TextUtils.isEmpty(dnses)) { 3136 dataCall.dnses = dnses.split(" "); 3137 } 3138 String gateways = p.readString(); 3139 if (!TextUtils.isEmpty(gateways)) { 3140 dataCall.gateways = gateways.split(" "); 3141 } 3142 } 3143 return dataCall; 3144 } 3145 3146 private Object 3147 responseDataCallList(Parcel p) { 3148 ArrayList<DataCallState> response; 3149 3150 int ver = p.readInt(); 3151 int num = p.readInt(); 3152 riljLog("responseDataCallList ver=" + ver + " num=" + num); 3153 3154 response = new ArrayList<DataCallState>(num); 3155 for (int i = 0; i < num; i++) { 3156 response.add(getDataCallState(p, ver)); 3157 } 3158 3159 return response; 3160 } 3161 3162 private Object 3163 responseSetupDataCall(Parcel p) { 3164 int ver = p.readInt(); 3165 int num = p.readInt(); 3166 if (RILJ_LOGV) riljLog("responseSetupDataCall ver=" + ver + " num=" + num); 3167 3168 DataCallState dataCall; 3169 3170 if (ver < 5) { 3171 dataCall = new DataCallState(); 3172 dataCall.version = ver; 3173 dataCall.cid = Integer.parseInt(p.readString()); 3174 dataCall.ifname = p.readString(); 3175 if (TextUtils.isEmpty(dataCall.ifname)) { 3176 throw new RuntimeException( 3177 "RIL_REQUEST_SETUP_DATA_CALL response, no ifname"); 3178 } 3179 String addresses = p.readString(); 3180 if (!TextUtils.isEmpty(addresses)) { 3181 dataCall.addresses = addresses.split(" "); 3182 } 3183 if (num >= 4) { 3184 String dnses = p.readString(); 3185 if (RILJ_LOGD) riljLog("responseSetupDataCall got dnses=" + dnses); 3186 if (!TextUtils.isEmpty(dnses)) { 3187 dataCall.dnses = dnses.split(" "); 3188 } 3189 } 3190 if (num >= 5) { 3191 String gateways = p.readString(); 3192 if (RILJ_LOGD) riljLog("responseSetupDataCall got gateways=" + gateways); 3193 if (!TextUtils.isEmpty(gateways)) { 3194 dataCall.gateways = gateways.split(" "); 3195 } 3196 } 3197 } else { 3198 if (num != 1) { 3199 throw new RuntimeException( 3200 "RIL_REQUEST_SETUP_DATA_CALL response expecting 1 RIL_Data_Call_response_v5" 3201 + " got " + num); 3202 } 3203 dataCall = getDataCallState(p, ver); 3204 } 3205 3206 return dataCall; 3207 } 3208 3209 private Object 3210 responseOperatorInfos(Parcel p) { 3211 String strings[] = (String [])responseStrings(p); 3212 ArrayList<OperatorInfo> ret; 3213 3214 if (strings.length % 4 != 0) { 3215 throw new RuntimeException( 3216 "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got " 3217 + strings.length + " strings, expected multible of 4"); 3218 } 3219 3220 ret = new ArrayList<OperatorInfo>(strings.length / 4); 3221 3222 for (int i = 0 ; i < strings.length ; i += 4) { 3223 ret.add ( 3224 new OperatorInfo( 3225 strings[i+0], 3226 strings[i+1], 3227 strings[i+2], 3228 strings[i+3])); 3229 } 3230 3231 return ret; 3232 } 3233 3234 private Object 3235 responseCellList(Parcel p) { 3236 int num, rssi; 3237 String location; 3238 ArrayList<NeighboringCellInfo> response; 3239 NeighboringCellInfo cell; 3240 3241 num = p.readInt(); 3242 response = new ArrayList<NeighboringCellInfo>(); 3243 3244 // Determine the radio access type 3245 String radioString = SystemProperties.get( 3246 TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, "unknown"); 3247 int radioType; 3248 if (radioString.equals("GPRS")) { 3249 radioType = NETWORK_TYPE_GPRS; 3250 } else if (radioString.equals("EDGE")) { 3251 radioType = NETWORK_TYPE_EDGE; 3252 } else if (radioString.equals("UMTS")) { 3253 radioType = NETWORK_TYPE_UMTS; 3254 } else if (radioString.equals("HSDPA")) { 3255 radioType = NETWORK_TYPE_HSDPA; 3256 } else if (radioString.equals("HSUPA")) { 3257 radioType = NETWORK_TYPE_HSUPA; 3258 } else if (radioString.equals("HSPA")) { 3259 radioType = NETWORK_TYPE_HSPA; 3260 } else { 3261 radioType = NETWORK_TYPE_UNKNOWN; 3262 } 3263 3264 // Interpret the location based on radio access type 3265 if (radioType != NETWORK_TYPE_UNKNOWN) { 3266 for (int i = 0 ; i < num ; i++) { 3267 rssi = p.readInt(); 3268 location = p.readString(); 3269 cell = new NeighboringCellInfo(rssi, location, radioType); 3270 response.add(cell); 3271 } 3272 } 3273 return response; 3274 } 3275 3276 private Object responseGetPreferredNetworkType(Parcel p) { 3277 int [] response = (int[]) responseInts(p); 3278 3279 if (response.length >= 1) { 3280 // Since this is the response for getPreferredNetworkType 3281 // we'll assume that it should be the value we want the 3282 // vendor ril to take if we reestablish a connection to it. 3283 mPreferredNetworkType = response[0]; 3284 } 3285 return response; 3286 } 3287 3288 private Object responseGmsBroadcastConfig(Parcel p) { 3289 int num; 3290 ArrayList<SmsBroadcastConfigInfo> response; 3291 SmsBroadcastConfigInfo info; 3292 3293 num = p.readInt(); 3294 response = new ArrayList<SmsBroadcastConfigInfo>(num); 3295 3296 for (int i = 0; i < num; i++) { 3297 int fromId = p.readInt(); 3298 int toId = p.readInt(); 3299 int fromScheme = p.readInt(); 3300 int toScheme = p.readInt(); 3301 boolean selected = (p.readInt() == 1); 3302 3303 info = new SmsBroadcastConfigInfo(fromId, toId, fromScheme, 3304 toScheme, selected); 3305 response.add(info); 3306 } 3307 return response; 3308 } 3309 3310 private Object 3311 responseCdmaBroadcastConfig(Parcel p) { 3312 int numServiceCategories; 3313 int response[]; 3314 3315 numServiceCategories = p.readInt(); 3316 3317 if (numServiceCategories == 0) { 3318 // TODO: The logic of providing default values should 3319 // not be done by this transport layer. And needs to 3320 // be done by the vendor ril or application logic. 3321 int numInts; 3322 numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES * CDMA_BSI_NO_OF_INTS_STRUCT + 1; 3323 response = new int[numInts]; 3324 3325 // Faking a default record for all possible records. 3326 response[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES; 3327 3328 // Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as 3329 // default language and selection status to false for all. 3330 for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT ) { 3331 response[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT; 3332 response[i + 1] = 1; 3333 response[i + 2] = 0; 3334 } 3335 } else { 3336 int numInts; 3337 numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1; 3338 response = new int[numInts]; 3339 3340 response[0] = numServiceCategories; 3341 for (int i = 1 ; i < numInts; i++) { 3342 response[i] = p.readInt(); 3343 } 3344 } 3345 3346 return response; 3347 } 3348 3349 private Object 3350 responseSignalStrength(Parcel p) { 3351 SignalStrength signalStrength = new SignalStrength(p); 3352 return signalStrength; 3353 } 3354 3355 private ArrayList<CdmaInformationRecords> 3356 responseCdmaInformationRecord(Parcel p) { 3357 int numberOfInfoRecs; 3358 ArrayList<CdmaInformationRecords> response; 3359 3360 /** 3361 * Loop through all of the information records unmarshalling them 3362 * and converting them to Java Objects. 3363 */ 3364 numberOfInfoRecs = p.readInt(); 3365 response = new ArrayList<CdmaInformationRecords>(numberOfInfoRecs); 3366 3367 for (int i = 0; i < numberOfInfoRecs; i++) { 3368 CdmaInformationRecords InfoRec = new CdmaInformationRecords(p); 3369 response.add(InfoRec); 3370 } 3371 3372 return response; 3373 } 3374 3375 private Object 3376 responseCdmaCallWaiting(Parcel p) { 3377 CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification(); 3378 3379 notification.number = p.readString(); 3380 notification.numberPresentation = notification.presentationFromCLIP(p.readInt()); 3381 notification.name = p.readString(); 3382 notification.namePresentation = notification.numberPresentation; 3383 notification.isPresent = p.readInt(); 3384 notification.signalType = p.readInt(); 3385 notification.alertPitch = p.readInt(); 3386 notification.signal = p.readInt(); 3387 notification.numberType = p.readInt(); 3388 notification.numberPlan = p.readInt(); 3389 3390 return notification; 3391 } 3392 3393 private Object 3394 responseCallRing(Parcel p){ 3395 char response[] = new char[4]; 3396 3397 response[0] = (char) p.readInt(); // isPresent 3398 response[1] = (char) p.readInt(); // signalType 3399 response[2] = (char) p.readInt(); // alertPitch 3400 response[3] = (char) p.readInt(); // signal 3401 3402 return response; 3403 } 3404 3405 private void 3406 notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) { 3407 int response = RIL_UNSOL_CDMA_INFO_REC; 3408 if (infoRec.record instanceof CdmaInformationRecords.CdmaDisplayInfoRec) { 3409 if (mDisplayInfoRegistrants != null) { 3410 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3411 mDisplayInfoRegistrants.notifyRegistrants( 3412 new AsyncResult (null, infoRec.record, null)); 3413 } 3414 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaSignalInfoRec) { 3415 if (mSignalInfoRegistrants != null) { 3416 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3417 mSignalInfoRegistrants.notifyRegistrants( 3418 new AsyncResult (null, infoRec.record, null)); 3419 } 3420 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaNumberInfoRec) { 3421 if (mNumberInfoRegistrants != null) { 3422 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3423 mNumberInfoRegistrants.notifyRegistrants( 3424 new AsyncResult (null, infoRec.record, null)); 3425 } 3426 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaRedirectingNumberInfoRec) { 3427 if (mRedirNumInfoRegistrants != null) { 3428 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3429 mRedirNumInfoRegistrants.notifyRegistrants( 3430 new AsyncResult (null, infoRec.record, null)); 3431 } 3432 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) { 3433 if (mLineControlInfoRegistrants != null) { 3434 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3435 mLineControlInfoRegistrants.notifyRegistrants( 3436 new AsyncResult (null, infoRec.record, null)); 3437 } 3438 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) { 3439 if (mT53ClirInfoRegistrants != null) { 3440 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3441 mT53ClirInfoRegistrants.notifyRegistrants( 3442 new AsyncResult (null, infoRec.record, null)); 3443 } 3444 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53AudioControlInfoRec) { 3445 if (mT53AudCntrlInfoRegistrants != null) { 3446 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 3447 mT53AudCntrlInfoRegistrants.notifyRegistrants( 3448 new AsyncResult (null, infoRec.record, null)); 3449 } 3450 } 3451 } 3452 3453 static String 3454 requestToString(int request) { 3455/* 3456 cat libs/telephony/ril_commands.h \ 3457 | egrep "^ *{RIL_" \ 3458 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' 3459*/ 3460 switch(request) { 3461 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; 3462 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; 3463 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; 3464 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; 3465 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; 3466 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; 3467 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; 3468 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; 3469 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; 3470 case RIL_REQUEST_DIAL: return "DIAL"; 3471 case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; 3472 case RIL_REQUEST_HANGUP: return "HANGUP"; 3473 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; 3474 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; 3475 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; 3476 case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; 3477 case RIL_REQUEST_UDUB: return "UDUB"; 3478 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; 3479 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; 3480 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; 3481 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE"; 3482 case RIL_REQUEST_OPERATOR: return "OPERATOR"; 3483 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; 3484 case RIL_REQUEST_DTMF: return "DTMF"; 3485 case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; 3486 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; 3487 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; 3488 case RIL_REQUEST_SIM_IO: return "SIM_IO"; 3489 case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; 3490 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; 3491 case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; 3492 case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; 3493 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; 3494 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; 3495 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; 3496 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; 3497 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; 3498 case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; 3499 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; 3500 case RIL_REQUEST_ANSWER: return "ANSWER"; 3501 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; 3502 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; 3503 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; 3504 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; 3505 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; 3506 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; 3507 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; 3508 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS "; 3509 case RIL_REQUEST_DTMF_START: return "DTMF_START"; 3510 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; 3511 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; 3512 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; 3513 case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; 3514 case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; 3515 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; 3516 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; 3517 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; 3518 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; 3519 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; 3520 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; 3521 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; 3522 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION"; 3523 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM"; 3524 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM"; 3525 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; 3526 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; 3527 case RIL_REQUEST_STK_GET_PROFILE: return "REQUEST_STK_GET_PROFILE"; 3528 case RIL_REQUEST_STK_SET_PROFILE: return "REQUEST_STK_SET_PROFILE"; 3529 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "REQUEST_STK_SEND_ENVELOPE_COMMAND"; 3530 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "REQUEST_STK_SEND_TERMINAL_RESPONSE"; 3531 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; 3532 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "REQUEST_EXPLICIT_CALL_TRANSFER"; 3533 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "REQUEST_SET_PREFERRED_NETWORK_TYPE"; 3534 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "REQUEST_GET_PREFERRED_NETWORK_TYPE"; 3535 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "REQUEST_GET_NEIGHBORING_CELL_IDS"; 3536 case RIL_REQUEST_SET_LOCATION_UPDATES: return "REQUEST_SET_LOCATION_UPDATES"; 3537 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE"; 3538 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE"; 3539 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE"; 3540 case RIL_REQUEST_SET_TTY_MODE: return "RIL_REQUEST_SET_TTY_MODE"; 3541 case RIL_REQUEST_QUERY_TTY_MODE: return "RIL_REQUEST_QUERY_TTY_MODE"; 3542 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; 3543 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; 3544 case RIL_REQUEST_CDMA_FLASH: return "RIL_REQUEST_CDMA_FLASH"; 3545 case RIL_REQUEST_CDMA_BURST_DTMF: return "RIL_REQUEST_CDMA_BURST_DTMF"; 3546 case RIL_REQUEST_CDMA_SEND_SMS: return "RIL_REQUEST_CDMA_SEND_SMS"; 3547 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE"; 3548 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG"; 3549 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG"; 3550 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG"; 3551 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG"; 3552 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION"; 3553 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY"; 3554 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION"; 3555 case RIL_REQUEST_CDMA_SUBSCRIPTION: return "RIL_REQUEST_CDMA_SUBSCRIPTION"; 3556 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM"; 3557 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM"; 3558 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY"; 3559 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS"; 3560 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS"; 3561 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "REQUEST_EXIT_EMERGENCY_CALLBACK_MODE"; 3562 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS"; 3563 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING"; 3564 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE"; 3565 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION"; 3566 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; 3567 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS"; 3568 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH"; 3569 default: return "<unknown request>"; 3570 } 3571 } 3572 3573 static String 3574 responseToString(int request) 3575 { 3576/* 3577 cat libs/telephony/ril_unsol_commands.h \ 3578 | egrep "^ *{RIL_" \ 3579 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' 3580*/ 3581 switch(request) { 3582 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; 3583 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; 3584 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED"; 3585 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS"; 3586 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; 3587 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; 3588 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD"; 3589 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST"; 3590 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED"; 3591 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH"; 3592 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED"; 3593 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return "UNSOL_SUPP_SVC_NOTIFICATION"; 3594 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END"; 3595 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND"; 3596 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY"; 3597 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP"; 3598 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FULL"; 3599 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH"; 3600 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING"; 3601 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; 3602 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_RESPONSE_CDMA_NEW_SMS"; 3603 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_RESPONSE_NEW_BROADCAST_SMS"; 3604 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; 3605 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED"; 3606 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; 3607 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING"; 3608 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; 3609 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; 3610 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; 3611 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONG"; 3612 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; 3613 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED"; 3614 case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; 3615 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE"; 3616 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED"; 3617 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED"; 3618 default: return "<unknown reponse>"; 3619 } 3620 } 3621 3622 private void riljLog(String msg) { 3623 Log.d(LOG_TAG, msg); 3624 } 3625 3626 private void riljLogv(String msg) { 3627 Log.v(LOG_TAG, msg); 3628 } 3629 3630 private void unsljLog(int response) { 3631 riljLog("[UNSL]< " + responseToString(response)); 3632 } 3633 3634 private void unsljLogMore(int response, String more) { 3635 riljLog("[UNSL]< " + responseToString(response) + " " + more); 3636 } 3637 3638 private void unsljLogRet(int response, Object ret) { 3639 riljLog("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 3640 } 3641 3642 private void unsljLogvRet(int response, Object ret) { 3643 riljLogv("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 3644 } 3645 3646 3647 // ***** Methods for CDMA support 3648 public void 3649 getDeviceIdentity(Message response) { 3650 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DEVICE_IDENTITY, response); 3651 3652 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3653 3654 send(rr); 3655 } 3656 3657 public void 3658 getCDMASubscription(Message response) { 3659 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SUBSCRIPTION, response); 3660 3661 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3662 3663 send(rr); 3664 } 3665 3666 @Override 3667 public void setPhoneType(int phoneType) { // Called by CDMAPhone and GSMPhone constructor 3668 if (RILJ_LOGD) riljLog("setPhoneType=" + phoneType + " old value=" + mPhoneType); 3669 mPhoneType = phoneType; 3670 } 3671 3672 /** 3673 * {@inheritDoc} 3674 */ 3675 public void queryCdmaRoamingPreference(Message response) { 3676 RILRequest rr = RILRequest.obtain( 3677 RILConstants.RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, response); 3678 3679 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3680 3681 send(rr); 3682 } 3683 3684 /** 3685 * {@inheritDoc} 3686 */ 3687 public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) { 3688 RILRequest rr = RILRequest.obtain( 3689 RILConstants.RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, response); 3690 3691 rr.mp.writeInt(1); 3692 rr.mp.writeInt(cdmaRoamingType); 3693 3694 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3695 + " : " + cdmaRoamingType); 3696 3697 send(rr); 3698 } 3699 3700 /** 3701 * {@inheritDoc} 3702 */ 3703 public void setCdmaSubscriptionSource(int cdmaSubscription , Message response) { 3704 RILRequest rr = RILRequest.obtain( 3705 RILConstants.RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, response); 3706 3707 rr.mp.writeInt(1); 3708 rr.mp.writeInt(cdmaSubscription); 3709 3710 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3711 + " : " + cdmaSubscription); 3712 3713 send(rr); 3714 } 3715 3716 /** 3717 * {@inheritDoc} 3718 */ 3719 @Override 3720 public void getCdmaSubscriptionSource(Message response) { 3721 RILRequest rr = RILRequest.obtain( 3722 RILConstants.RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, response); 3723 3724 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3725 3726 send(rr); 3727 } 3728 3729 /** 3730 * {@inheritDoc} 3731 */ 3732 public void queryTTYMode(Message response) { 3733 RILRequest rr = RILRequest.obtain( 3734 RILConstants.RIL_REQUEST_QUERY_TTY_MODE, response); 3735 3736 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3737 3738 send(rr); 3739 } 3740 3741 /** 3742 * {@inheritDoc} 3743 */ 3744 public void setTTYMode(int ttyMode, Message response) { 3745 RILRequest rr = RILRequest.obtain( 3746 RILConstants.RIL_REQUEST_SET_TTY_MODE, response); 3747 3748 rr.mp.writeInt(1); 3749 rr.mp.writeInt(ttyMode); 3750 3751 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3752 + " : " + ttyMode); 3753 3754 send(rr); 3755 } 3756 3757 /** 3758 * {@inheritDoc} 3759 */ 3760 public void 3761 sendCDMAFeatureCode(String FeatureCode, Message response) { 3762 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_FLASH, response); 3763 3764 rr.mp.writeString(FeatureCode); 3765 3766 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3767 + " : " + FeatureCode); 3768 3769 send(rr); 3770 } 3771 3772 public void getCdmaBroadcastConfig(Message response) { 3773 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, response); 3774 3775 send(rr); 3776 } 3777 3778 // TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig 3779 public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) { 3780 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response); 3781 3782 for(int i = 0; i < configValuesArray.length; i++) { 3783 rr.mp.writeInt(configValuesArray[i]); 3784 } 3785 3786 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3787 3788 send(rr); 3789 } 3790 3791 public void setCdmaBroadcastActivation(boolean activate, Message response) { 3792 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, response); 3793 3794 rr.mp.writeInt(1); 3795 rr.mp.writeInt(activate ? 0 :1); 3796 3797 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3798 3799 send(rr); 3800 } 3801 3802 /** 3803 * {@inheritDoc} 3804 */ 3805 public void exitEmergencyCallbackMode(Message response) { 3806 RILRequest rr = RILRequest.obtain(RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, response); 3807 3808 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3809 3810 send(rr); 3811 } 3812 3813 public void requestIsimAuthentication(String nonce, Message response) { 3814 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ISIM_AUTHENTICATION, response); 3815 3816 rr.mp.writeString(nonce); 3817 3818 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3819 3820 send(rr); 3821 } 3822 3823 /* (non-Javadoc) 3824 * @see com.android.internal.telephony.BaseCommands#testingEmergencyCall() 3825 */ 3826 @Override 3827 public void testingEmergencyCall() { 3828 if (RILJ_LOGD) riljLog("testingEmergencyCall"); 3829 mTestingEmergencyCall.set(true); 3830 } 3831 3832 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 3833 pw.println("RIL:"); 3834 pw.println(" mSocket=" + mSocket); 3835 pw.println(" mSenderThread=" + mSenderThread); 3836 pw.println(" mSender=" + mSender); 3837 pw.println(" mReceiverThread=" + mReceiverThread); 3838 pw.println(" mReceiver=" + mReceiver); 3839 pw.println(" mWakeLock=" + mWakeLock); 3840 pw.println(" mWakeLockTimeout=" + mWakeLockTimeout); 3841 synchronized (mRequestsList) { 3842 pw.println(" mRequestMessagesPending=" + mRequestMessagesPending); 3843 pw.println(" mRequestMessagesWaiting=" + mRequestMessagesWaiting); 3844 int count = mRequestsList.size(); 3845 pw.println(" mRequestList count=" + count); 3846 for (int i = 0; i < count; i++) { 3847 RILRequest rr = mRequestsList.get(i); 3848 pw.println(" [" + rr.mSerial + "] " + requestToString(rr.mRequest)); 3849 } 3850 } 3851 pw.println(" mLastNITZTimeInfo=" + mLastNITZTimeInfo); 3852 pw.println(" mTestingEmergencyCall=" + mTestingEmergencyCall.get()); 3853 } 3854} 3855