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