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