2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.internal.telephony;
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;
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;
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.uicc.SpnOverride;
68 import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
69 import com.android.internal.telephony.cdma.CdmaInformationRecords;
70 import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
71 import com.android.internal.telephony.dataconnection.DcFailCause;
72 import com.android.internal.telephony.dataconnection.DataCallResponse;
73 import com.android.internal.telephony.dataconnection.DataProfile;
74 import com.android.internal.telephony.RadioCapability;
75 import com.android.internal.telephony.TelephonyDevController;
76 import com.android.internal.telephony.HardwareConfig;
78 import java.io.ByteArrayInputStream;
79 import java.io.DataInputStream;
80 import java.io.FileDescriptor;
81 import java.io.IOException;
82 import java.io.InputStream;
83 import java.io.PrintWriter;
84 import java.util.ArrayList;
85 import java.util.Collections;
86 import java.util.concurrent.atomic.AtomicBoolean;
87 import java.util.concurrent.atomic.AtomicInteger;
88 import java.util.Random;
94 static final String LOG_TAG = "RilRequest";
96 //***** Class Variables
97 static Random sRandom = new Random();
98 static AtomicInteger sNextSerial = new AtomicInteger(0);
99 private static Object sPoolSync = new Object();
100 private static RILRequest sPool = null;
101 private static int sPoolSize = 0;
102 private static final int MAX_POOL_SIZE = 4;
103 private Context mContext;
105 //***** Instance Variables
113 * Retrieves a new RILRequest instance from the pool.
115 * @param request RIL_REQUEST_*
116 * @param result sent when operation completes
117 * @return a RILRequest instance from the pool.
119 static RILRequest obtain(int request, Message result) {
120 RILRequest rr = null;
122 synchronized(sPoolSync) {
132 rr = new RILRequest();
135 rr.mSerial = sNextSerial.getAndIncrement();
137 rr.mRequest = request;
139 rr.mParcel = Parcel.obtain();
141 if (result != null && result.getTarget() == null) {
142 throw new NullPointerException("Message target must not be null");
145 // first elements in any RIL Parcel
146 rr.mParcel.writeInt(request);
147 rr.mParcel.writeInt(rr.mSerial);
153 * Returns a RILRequest instance to the pool.
155 * Note: This should only be called once per use.
158 synchronized (sPoolSync) {
159 if (sPoolSize < MAX_POOL_SIZE) {
168 private RILRequest() {
173 // use a random so that on recovery we probably don't mix old requests
175 sNextSerial.set(sRandom.nextInt());
180 //Cheesy way to do %04d
181 StringBuilder sb = new StringBuilder(8);
184 long adjustedSerial = (((long)mSerial) - Integer.MIN_VALUE)%10000;
186 sn = Long.toString(adjustedSerial);
190 for (int i = 0, s = sn.length() ; i < 4 - s; i++) {
196 return sb.toString();
200 onError(int error, Object ret) {
203 ex = CommandException.fromRilErrno(error);
205 if (RIL.RILJ_LOGD) Rlog.d(LOG_TAG, serialString() + "< "
206 + RIL.requestToString(mRequest)
207 + " error: " + ex + " ret=" + RIL.retToString(mRequest, ret));
209 if (mResult != null) {
210 AsyncResult.forMessage(mResult, ret, ex);
211 mResult.sendToTarget();
214 if (mParcel != null) {
223 * RIL implementation of the CommandsInterface.
227 public final class RIL extends BaseCommands implements CommandsInterface {
228 static final String RILJ_LOG_TAG = "RILJ";
229 static final boolean RILJ_LOGD = true;
230 static final boolean RILJ_LOGV = false; // STOPSHIP if true
233 * Wake lock timeout should be longer than the longest timeout in
236 private static final int DEFAULT_WAKE_LOCK_TIMEOUT = 60000;
238 //***** Instance Variables
241 HandlerThread mSenderThread;
243 Thread mReceiverThread;
244 RILReceiver mReceiver;
245 Display mDefaultDisplay;
246 int mDefaultDisplayState = Display.STATE_UNKNOWN;
248 final int mWakeLockTimeout;
249 // The number of wakelock requests currently active. Don't release the lock
253 SparseArray<RILRequest> mRequestList = new SparseArray<RILRequest>();
255 Object mLastNITZTimeInfo;
257 // When we are testing emergency calls
258 AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false);
260 private Integer mInstanceId;
264 static final int EVENT_SEND = 1;
265 static final int EVENT_WAKE_LOCK_TIMEOUT = 2;
269 // match with constant in ril.cpp
270 static final int RIL_MAX_COMMAND_BYTES = (8 * 1024);
271 static final int RESPONSE_SOLICITED = 0;
272 static final int RESPONSE_UNSOLICITED = 1;
274 static final String[] SOCKET_NAME_RIL = {"rild", "rild2", "rild3"};
276 static final int SOCKET_OPEN_RETRY_MILLIS = 4 * 1000;
278 // The number of the required config values for broadcast SMS stored in the C struct
279 // RIL_CDMA_BroadcastServiceInfo
280 private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3;
282 private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31;
284 private final DisplayManager.DisplayListener mDisplayListener =
285 new DisplayManager.DisplayListener() {
287 public void onDisplayAdded(int displayId) { }
290 public void onDisplayRemoved(int displayId) { }
293 public void onDisplayChanged(int displayId) {
294 if (displayId == Display.DEFAULT_DISPLAY) {
300 class RILSender extends Handler implements Runnable {
301 public RILSender(Looper looper) {
305 // Only allocated once
306 byte[] dataLength = new byte[4];
308 //***** Runnable implementation
316 //***** Handler implementation
317 @Override public void
318 handleMessage(Message msg) {
319 RILRequest rr = (RILRequest)(msg.obj);
320 RILRequest req = null;
330 rr.onError(RADIO_NOT_AVAILABLE, null);
336 synchronized (mRequestList) {
337 mRequestList.append(rr.mSerial, rr);
342 data = rr.mParcel.marshall();
343 rr.mParcel.recycle();
346 if (data.length > RIL_MAX_COMMAND_BYTES) {
347 throw new RuntimeException(
348 "Parcel larger than max bytes allowed! "
352 // parcel length in big endian
353 dataLength[0] = dataLength[1] = 0;
354 dataLength[2] = (byte)((data.length >> 8) & 0xff);
355 dataLength[3] = (byte)((data.length) & 0xff);
357 //Rlog.v(RILJ_LOG_TAG, "writing packet: " + data.length + " bytes");
359 s.getOutputStream().write(dataLength);
360 s.getOutputStream().write(data);
361 } catch (IOException ex) {
362 Rlog.e(RILJ_LOG_TAG, "IOException", ex);
363 req = findAndRemoveRequestFromList(rr.mSerial);
364 // make sure this request has not already been handled,
365 // eg, if RILReceiver cleared the list.
367 rr.onError(RADIO_NOT_AVAILABLE, null);
371 } catch (RuntimeException exc) {
372 Rlog.e(RILJ_LOG_TAG, "Uncaught exception ", exc);
373 req = findAndRemoveRequestFromList(rr.mSerial);
374 // make sure this request has not already been handled,
375 // eg, if RILReceiver cleared the list.
377 rr.onError(GENERIC_FAILURE, null);
385 case EVENT_WAKE_LOCK_TIMEOUT:
386 // Haven't heard back from the last request. Assume we're
387 // not getting a response and release the wake lock.
389 // The timer of WAKE_LOCK_TIMEOUT is reset with each
390 // new send request. So when WAKE_LOCK_TIMEOUT occurs
391 // all requests in mRequestList already waited at
392 // least DEFAULT_WAKE_LOCK_TIMEOUT but no response.
394 // Note: Keep mRequestList so that delayed response
395 // can still be handled when response finally comes.
397 synchronized (mRequestList) {
398 if (clearWakeLock()) {
400 int count = mRequestList.size();
401 Rlog.d(RILJ_LOG_TAG, "WAKE_LOCK_TIMEOUT " +
402 " mRequestList=" + count);
403 for (int i = 0; i < count; i++) {
404 rr = mRequestList.valueAt(i);
405 Rlog.d(RILJ_LOG_TAG, i + ": [" + rr.mSerial + "] "
406 + requestToString(rr.mRequest));
417 * Reads in a single RIL message off the wire. A RIL message consists
418 * of a 4-byte little-endian length and a subsequent series of bytes.
419 * The final message (length header omitted) is read into
420 * <code>buffer</code> and the length of the final message (less header)
421 * is returned. A return value of -1 indicates end-of-stream.
423 * @param is non-null; Stream to read from
424 * @param buffer Buffer to fill in. Must be as large as maximum
425 * message size, or an ArrayOutOfBounds exception will be thrown.
426 * @return Length of message less header, or -1 on end of stream.
427 * @throws IOException
429 private static int readRilMessage(InputStream is, byte[] buffer)
436 // First, read in the length of the message
440 countRead = is.read(buffer, offset, remaining);
442 if (countRead < 0 ) {
443 Rlog.e(RILJ_LOG_TAG, "Hit EOS reading message length");
448 remaining -= countRead;
449 } while (remaining > 0);
451 messageLength = ((buffer[0] & 0xff) << 24)
452 | ((buffer[1] & 0xff) << 16)
453 | ((buffer[2] & 0xff) << 8)
454 | (buffer[3] & 0xff);
456 // Then, re-use the buffer and read in the message itself
458 remaining = messageLength;
460 countRead = is.read(buffer, offset, remaining);
462 if (countRead < 0 ) {
463 Rlog.e(RILJ_LOG_TAG, "Hit EOS reading message. messageLength=" + messageLength
464 + " remaining=" + remaining);
469 remaining -= countRead;
470 } while (remaining > 0);
472 return messageLength;
475 class RILReceiver implements Runnable {
479 buffer = new byte[RIL_MAX_COMMAND_BYTES];
486 String rilSocket = "rild";
489 LocalSocket s = null;
490 LocalSocketAddress l;
492 if (mInstanceId == null || mInstanceId == 0 ) {
493 rilSocket = SOCKET_NAME_RIL[0];
495 rilSocket = SOCKET_NAME_RIL[mInstanceId];
499 s = new LocalSocket();
500 l = new LocalSocketAddress(rilSocket,
501 LocalSocketAddress.Namespace.RESERVED);
503 } catch (IOException ex){
508 } catch (IOException ex2) {
509 //ignore failure to close after failure to connect
512 // don't print an error message after the the first time
513 // or after the 8th time
515 if (retryCount == 8) {
516 Rlog.e (RILJ_LOG_TAG,
517 "Couldn't find '" + rilSocket
518 + "' socket after " + retryCount
519 + " times, continuing to retry silently");
520 } else if (retryCount >= 0 && retryCount < 8) {
521 Rlog.i (RILJ_LOG_TAG,
522 "Couldn't find '" + rilSocket
523 + "' socket; retrying after timeout");
527 Thread.sleep(SOCKET_OPEN_RETRY_MILLIS);
528 } catch (InterruptedException er) {
538 Rlog.i(RILJ_LOG_TAG, "(" + mInstanceId + ") Connected to '"
539 + rilSocket + "' socket");
543 InputStream is = mSocket.getInputStream();
548 length = readRilMessage(is, buffer);
551 // End-of-stream reached
556 p.unmarshall(buffer, 0, length);
557 p.setDataPosition(0);
559 //Rlog.v(RILJ_LOG_TAG, "Read packet: " + length + " bytes");
564 } catch (java.io.IOException ex) {
565 Rlog.i(RILJ_LOG_TAG, "'" + rilSocket + "' socket closed",
567 } catch (Throwable tr) {
568 Rlog.e(RILJ_LOG_TAG, "Uncaught exception read length=" + length +
569 "Exception:" + tr.toString());
572 Rlog.i(RILJ_LOG_TAG, "(" + mInstanceId + ") Disconnected from '" + rilSocket
575 setRadioState (RadioState.RADIO_UNAVAILABLE);
579 } catch (IOException ex) {
583 RILRequest.resetSerial();
585 // Clear request list on close
586 clearRequestList(RADIO_NOT_AVAILABLE, false);
587 }} catch (Throwable tr) {
588 Rlog.e(RILJ_LOG_TAG,"Uncaught exception", tr);
591 /* We're disconnected so we don't know the ril version */
592 notifyRegistrantsRilConnectionChanged(-1);
600 public RIL(Context context, int preferredNetworkType, int cdmaSubscription) {
601 this(context, preferredNetworkType, cdmaSubscription, null);
604 public RIL(Context context, int preferredNetworkType,
605 int cdmaSubscription, Integer instanceId) {
608 riljLog("RIL(context, preferredNetworkType=" + preferredNetworkType +
609 " cdmaSubscription=" + cdmaSubscription + ")");
613 mCdmaSubscription = cdmaSubscription;
614 mPreferredNetworkType = preferredNetworkType;
615 mPhoneType = RILConstants.NO_PHONE;
616 mInstanceId = instanceId;
618 PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
619 mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RILJ_LOG_TAG);
620 mWakeLock.setReferenceCounted(false);
621 mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT,
622 DEFAULT_WAKE_LOCK_TIMEOUT);
625 mSenderThread = new HandlerThread("RILSender" + mInstanceId);
626 mSenderThread.start();
628 Looper looper = mSenderThread.getLooper();
629 mSender = new RILSender(looper);
631 ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
632 Context.CONNECTIVITY_SERVICE);
633 if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false) {
634 riljLog("Not starting RILReceiver: wifi-only");
636 riljLog("Starting RILReceiver" + mInstanceId);
637 mReceiver = new RILReceiver();
638 mReceiverThread = new Thread(mReceiver, "RILReceiver" + mInstanceId);
639 mReceiverThread.start();
641 DisplayManager dm = (DisplayManager)context.getSystemService(
642 Context.DISPLAY_SERVICE);
643 mDefaultDisplay = dm.getDisplay(Display.DEFAULT_DISPLAY);
644 dm.registerDisplayListener(mDisplayListener, null);
647 TelephonyDevController tdc = TelephonyDevController.getInstance();
648 tdc.registerRIL(this);
651 //***** CommandsInterface implementation
654 public void getVoiceRadioTechnology(Message result) {
655 RILRequest rr = RILRequest.obtain(RIL_REQUEST_VOICE_RADIO_TECH, result);
657 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
663 public void getImsRegistrationState(Message result) {
664 RILRequest rr = RILRequest.obtain(RIL_REQUEST_IMS_REGISTRATION_STATE, result);
667 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
672 @Override public void
673 setOnNITZTime(Handler h, int what, Object obj) {
674 super.setOnNITZTime(h, what, obj);
676 // Send the last NITZ time if we have it
677 if (mLastNITZTimeInfo != null) {
680 new AsyncResult (null, mLastNITZTimeInfo, null));
686 getIccCardStatus(Message result) {
687 //Note: This RIL request has not been renamed to ICC,
688 // but this request is also valid for SIM and RUIM
689 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SIM_STATUS, result);
691 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
696 public void setUiccSubscription(int slotId, int appIndex, int subId,
697 int subStatus, Message result) {
698 //Note: This RIL request is also valid for SIM and RUIM (ICC card)
699 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_UICC_SUBSCRIPTION, result);
701 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
702 + " slot: " + slotId + " appIndex: " + appIndex
703 + " subId: " + subId + " subStatus: " + subStatus);
705 rr.mParcel.writeInt(slotId);
706 rr.mParcel.writeInt(appIndex);
707 rr.mParcel.writeInt(subId);
708 rr.mParcel.writeInt(subStatus);
713 // FIXME This API should take an AID and slot ID
714 public void setDataAllowed(boolean allowed, Message result) {
715 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ALLOW_DATA, result);
716 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
718 rr.mParcel.writeInt(1);
719 rr.mParcel.writeInt(allowed ? 1 : 0);
723 @Override public void
724 supplyIccPin(String pin, Message result) {
725 supplyIccPinForApp(pin, null, result);
728 @Override public void
729 supplyIccPinForApp(String pin, String aid, Message result) {
730 //Note: This RIL request has not been renamed to ICC,
731 // but this request is also valid for SIM and RUIM
732 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN, result);
734 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
736 rr.mParcel.writeInt(2);
737 rr.mParcel.writeString(pin);
738 rr.mParcel.writeString(aid);
743 @Override public void
744 supplyIccPuk(String puk, String newPin, Message result) {
745 supplyIccPukForApp(puk, newPin, null, result);
748 @Override public void
749 supplyIccPukForApp(String puk, String newPin, String aid, Message result) {
750 //Note: This RIL request has not been renamed to ICC,
751 // but this request is also valid for SIM and RUIM
752 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK, result);
754 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
756 rr.mParcel.writeInt(3);
757 rr.mParcel.writeString(puk);
758 rr.mParcel.writeString(newPin);
759 rr.mParcel.writeString(aid);
764 @Override public void
765 supplyIccPin2(String pin, Message result) {
766 supplyIccPin2ForApp(pin, null, result);
769 @Override public void
770 supplyIccPin2ForApp(String pin, String aid, Message result) {
771 //Note: This RIL request has not been renamed to ICC,
772 // but this request is also valid for SIM and RUIM
773 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN2, result);
775 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
777 rr.mParcel.writeInt(2);
778 rr.mParcel.writeString(pin);
779 rr.mParcel.writeString(aid);
784 @Override public void
785 supplyIccPuk2(String puk2, String newPin2, Message result) {
786 supplyIccPuk2ForApp(puk2, newPin2, null, result);
789 @Override public void
790 supplyIccPuk2ForApp(String puk, String newPin2, String aid, Message result) {
791 //Note: This RIL request has not been renamed to ICC,
792 // but this request is also valid for SIM and RUIM
793 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK2, result);
795 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
797 rr.mParcel.writeInt(3);
798 rr.mParcel.writeString(puk);
799 rr.mParcel.writeString(newPin2);
800 rr.mParcel.writeString(aid);
805 @Override public void
806 changeIccPin(String oldPin, String newPin, Message result) {
807 changeIccPinForApp(oldPin, newPin, null, result);
810 @Override public void
811 changeIccPinForApp(String oldPin, String newPin, String aid, Message result) {
812 //Note: This RIL request has not been renamed to ICC,
813 // but this request is also valid for SIM and RUIM
814 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN, result);
816 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
818 rr.mParcel.writeInt(3);
819 rr.mParcel.writeString(oldPin);
820 rr.mParcel.writeString(newPin);
821 rr.mParcel.writeString(aid);
826 @Override public void
827 changeIccPin2(String oldPin2, String newPin2, Message result) {
828 changeIccPin2ForApp(oldPin2, newPin2, null, result);
831 @Override public void
832 changeIccPin2ForApp(String oldPin2, String newPin2, String aid, Message result) {
833 //Note: This RIL request has not been renamed to ICC,
834 // but this request is also valid for SIM and RUIM
835 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN2, result);
837 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
839 rr.mParcel.writeInt(3);
840 rr.mParcel.writeString(oldPin2);
841 rr.mParcel.writeString(newPin2);
842 rr.mParcel.writeString(aid);
849 changeBarringPassword(String facility, String oldPwd, String newPwd, Message result) {
850 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_BARRING_PASSWORD, result);
852 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
854 rr.mParcel.writeInt(3);
855 rr.mParcel.writeString(facility);
856 rr.mParcel.writeString(oldPwd);
857 rr.mParcel.writeString(newPwd);
864 supplyNetworkDepersonalization(String netpin, Message result) {
865 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, result);
867 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
869 rr.mParcel.writeInt(1);
870 rr.mParcel.writeString(netpin);
877 getCurrentCalls (Message result) {
878 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CURRENT_CALLS, result);
880 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
886 @Deprecated public void
887 getPDPContextList(Message result) {
888 getDataCallList(result);
893 getDataCallList(Message result) {
894 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DATA_CALL_LIST, result);
896 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
903 dial (String address, int clirMode, Message result) {
904 dial(address, clirMode, null, result);
909 dial(String address, int clirMode, UUSInfo uusInfo, Message result) {
910 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result);
912 rr.mParcel.writeString(address);
913 rr.mParcel.writeInt(clirMode);
915 if (uusInfo == null) {
916 rr.mParcel.writeInt(0); // UUS information is absent
918 rr.mParcel.writeInt(1); // UUS information is present
919 rr.mParcel.writeInt(uusInfo.getType());
920 rr.mParcel.writeInt(uusInfo.getDcs());
921 rr.mParcel.writeByteArray(uusInfo.getUserData());
924 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
931 getIMSI(Message result) {
932 getIMSIForApp(null, result);
937 getIMSIForApp(String aid, Message result) {
938 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result);
940 rr.mParcel.writeInt(1);
941 rr.mParcel.writeString(aid);
943 if (RILJ_LOGD) riljLog(rr.serialString() +
944 "> getIMSI: " + requestToString(rr.mRequest)
952 getIMEI(Message result) {
953 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEI, result);
955 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
962 getIMEISV(Message result) {
963 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMEISV, result);
965 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
973 hangupConnection (int gsmIndex, Message result) {
974 if (RILJ_LOGD) riljLog("hangupConnection: gsmIndex=" + gsmIndex);
976 RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP, result);
978 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " +
981 rr.mParcel.writeInt(1);
982 rr.mParcel.writeInt(gsmIndex);
989 hangupWaitingOrBackground (Message result) {
990 RILRequest rr = RILRequest.obtain(RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND,
993 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1000 hangupForegroundResumeBackground (Message result) {
1002 = RILRequest.obtain(
1003 RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND,
1005 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1012 switchWaitingOrHoldingAndActive (Message result) {
1014 = RILRequest.obtain(
1015 RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE,
1017 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1024 conference (Message result) {
1026 = RILRequest.obtain(RIL_REQUEST_CONFERENCE, result);
1028 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1035 public void setPreferredVoicePrivacy(boolean enable, Message result) {
1036 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1039 rr.mParcel.writeInt(1);
1040 rr.mParcel.writeInt(enable ? 1:0);
1046 public void getPreferredVoicePrivacy(Message result) {
1047 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE,
1054 separateConnection (int gsmIndex, Message result) {
1056 = RILRequest.obtain(RIL_REQUEST_SEPARATE_CONNECTION, result);
1058 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1061 rr.mParcel.writeInt(1);
1062 rr.mParcel.writeInt(gsmIndex);
1069 acceptCall (Message result) {
1071 = RILRequest.obtain(RIL_REQUEST_ANSWER, result);
1073 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1080 rejectCall (Message result) {
1082 = RILRequest.obtain(RIL_REQUEST_UDUB, result);
1084 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1091 explicitCallTransfer (Message result) {
1093 = RILRequest.obtain(RIL_REQUEST_EXPLICIT_CALL_TRANSFER, result);
1095 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1102 getLastCallFailCause (Message result) {
1104 = RILRequest.obtain(RIL_REQUEST_LAST_CALL_FAIL_CAUSE, result);
1106 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1117 getLastPdpFailCause (Message result) {
1118 getLastDataCallFailCause (result);
1122 * The preferred new alternative to getLastPdpFailCause
1126 getLastDataCallFailCause (Message result) {
1128 = RILRequest.obtain(RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, result);
1130 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1137 setMute (boolean enableMute, Message response) {
1139 = RILRequest.obtain(RIL_REQUEST_SET_MUTE, response);
1141 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1142 + " " + enableMute);
1144 rr.mParcel.writeInt(1);
1145 rr.mParcel.writeInt(enableMute ? 1 : 0);
1152 getMute (Message response) {
1154 = RILRequest.obtain(RIL_REQUEST_GET_MUTE, response);
1156 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1163 getSignalStrength (Message result) {
1165 = RILRequest.obtain(RIL_REQUEST_SIGNAL_STRENGTH, result);
1167 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1174 getVoiceRegistrationState (Message result) {
1176 = RILRequest.obtain(RIL_REQUEST_VOICE_REGISTRATION_STATE, result);
1178 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1185 getDataRegistrationState (Message result) {
1187 = RILRequest.obtain(RIL_REQUEST_DATA_REGISTRATION_STATE, result);
1189 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1196 getOperator(Message result) {
1198 = RILRequest.obtain(RIL_REQUEST_OPERATOR, result);
1200 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1207 getHardwareConfig (Message result) {
1208 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_HARDWARE_CONFIG, result);
1210 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1217 sendDtmf(char c, Message result) {
1219 = RILRequest.obtain(RIL_REQUEST_DTMF, result);
1221 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1223 rr.mParcel.writeString(Character.toString(c));
1230 startDtmf(char c, Message result) {
1232 = RILRequest.obtain(RIL_REQUEST_DTMF_START, result);
1234 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1236 rr.mParcel.writeString(Character.toString(c));
1243 stopDtmf(Message result) {
1245 = RILRequest.obtain(RIL_REQUEST_DTMF_STOP, result);
1247 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1254 sendBurstDtmf(String dtmfString, int on, int off, Message result) {
1255 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BURST_DTMF, result);
1257 rr.mParcel.writeInt(3);
1258 rr.mParcel.writeString(dtmfString);
1259 rr.mParcel.writeString(Integer.toString(on));
1260 rr.mParcel.writeString(Integer.toString(off));
1262 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1263 + " : " + dtmfString);
1269 constructGsmSendSmsRilRequest (RILRequest rr, String smscPDU, String pdu) {
1270 rr.mParcel.writeInt(2);
1271 rr.mParcel.writeString(smscPDU);
1272 rr.mParcel.writeString(pdu);
1276 sendSMS (String smscPDU, String pdu, Message result) {
1278 = RILRequest.obtain(RIL_REQUEST_SEND_SMS, result);
1280 constructGsmSendSmsRilRequest(rr, smscPDU, pdu);
1282 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1289 sendSMSExpectMore (String smscPDU, String pdu, Message result) {
1291 = RILRequest.obtain(RIL_REQUEST_SEND_SMS_EXPECT_MORE, result);
1293 constructGsmSendSmsRilRequest(rr, smscPDU, pdu);
1295 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1301 constructCdmaSendSmsRilRequest(RILRequest rr, byte[] pdu) {
1302 int address_nbr_of_digits;
1303 int subaddr_nbr_of_digits;
1304 int bearerDataLength;
1305 ByteArrayInputStream bais = new ByteArrayInputStream(pdu);
1306 DataInputStream dis = new DataInputStream(bais);
1309 rr.mParcel.writeInt(dis.readInt()); //teleServiceId
1310 rr.mParcel.writeByte((byte) dis.readInt()); //servicePresent
1311 rr.mParcel.writeInt(dis.readInt()); //serviceCategory
1312 rr.mParcel.writeInt(dis.read()); //address_digit_mode
1313 rr.mParcel.writeInt(dis.read()); //address_nbr_mode
1314 rr.mParcel.writeInt(dis.read()); //address_ton
1315 rr.mParcel.writeInt(dis.read()); //address_nbr_plan
1316 address_nbr_of_digits = (byte) dis.read();
1317 rr.mParcel.writeByte((byte) address_nbr_of_digits);
1318 for(int i=0; i < address_nbr_of_digits; i++){
1319 rr.mParcel.writeByte(dis.readByte()); // address_orig_bytes[i]
1321 rr.mParcel.writeInt(dis.read()); //subaddressType
1322 rr.mParcel.writeByte((byte) dis.read()); //subaddr_odd
1323 subaddr_nbr_of_digits = (byte) dis.read();
1324 rr.mParcel.writeByte((byte) subaddr_nbr_of_digits);
1325 for(int i=0; i < subaddr_nbr_of_digits; i++){
1326 rr.mParcel.writeByte(dis.readByte()); //subaddr_orig_bytes[i]
1329 bearerDataLength = dis.read();
1330 rr.mParcel.writeInt(bearerDataLength);
1331 for(int i=0; i < bearerDataLength; i++){
1332 rr.mParcel.writeByte(dis.readByte()); //bearerData[i]
1334 }catch (IOException ex){
1335 if (RILJ_LOGD) riljLog("sendSmsCdma: conversion from input stream to object failed: "
1341 sendCdmaSms(byte[] pdu, Message result) {
1343 = RILRequest.obtain(RIL_REQUEST_CDMA_SEND_SMS, result);
1345 constructCdmaSendSmsRilRequest(rr, pdu);
1347 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1353 sendImsGsmSms (String smscPDU, String pdu, int retry, int messageRef,
1355 RILRequest rr = RILRequest.obtain(RIL_REQUEST_IMS_SEND_SMS, result);
1357 rr.mParcel.writeInt(RILConstants.GSM_PHONE);
1358 rr.mParcel.writeByte((byte)retry);
1359 rr.mParcel.writeInt(messageRef);
1361 constructGsmSendSmsRilRequest(rr, smscPDU, pdu);
1363 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1369 sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message result) {
1370 RILRequest rr = RILRequest.obtain(RIL_REQUEST_IMS_SEND_SMS, result);
1372 rr.mParcel.writeInt(RILConstants.CDMA_PHONE);
1373 rr.mParcel.writeByte((byte)retry);
1374 rr.mParcel.writeInt(messageRef);
1376 constructCdmaSendSmsRilRequest(rr, pdu);
1378 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1384 public void deleteSmsOnSim(int index, Message response) {
1385 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DELETE_SMS_ON_SIM,
1388 rr.mParcel.writeInt(1);
1389 rr.mParcel.writeInt(index);
1391 if (RILJ_LOGV) riljLog(rr.serialString() + "> "
1392 + requestToString(rr.mRequest)
1399 public void deleteSmsOnRuim(int index, Message response) {
1400 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM,
1403 rr.mParcel.writeInt(1);
1404 rr.mParcel.writeInt(index);
1406 if (RILJ_LOGV) riljLog(rr.serialString() + "> "
1407 + requestToString(rr.mRequest)
1414 public void writeSmsToSim(int status, String smsc, String pdu, Message response) {
1415 status = translateStatus(status);
1417 RILRequest rr = RILRequest.obtain(RIL_REQUEST_WRITE_SMS_TO_SIM,
1420 rr.mParcel.writeInt(status);
1421 rr.mParcel.writeString(pdu);
1422 rr.mParcel.writeString(smsc);
1424 if (RILJ_LOGV) riljLog(rr.serialString() + "> "
1425 + requestToString(rr.mRequest)
1432 public void writeSmsToRuim(int status, String pdu, Message response) {
1433 status = translateStatus(status);
1435 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM,
1438 rr.mParcel.writeInt(status);
1439 rr.mParcel.writeString(pdu);
1441 if (RILJ_LOGV) riljLog(rr.serialString() + "> "
1442 + requestToString(rr.mRequest)
1449 * Translates EF_SMS status bits to a status value compatible with
1450 * SMS AT commands. See TS 27.005 3.1.
1452 private int translateStatus(int status) {
1453 switch(status & 0x7) {
1454 case SmsManager.STATUS_ON_ICC_READ:
1456 case SmsManager.STATUS_ON_ICC_UNREAD:
1458 case SmsManager.STATUS_ON_ICC_SENT:
1460 case SmsManager.STATUS_ON_ICC_UNSENT:
1470 setupDataCall(String radioTechnology, String profile, String apn,
1471 String user, String password, String authType, String protocol,
1474 = RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result);
1476 rr.mParcel.writeInt(7);
1478 rr.mParcel.writeString(radioTechnology);
1479 rr.mParcel.writeString(profile);
1480 rr.mParcel.writeString(apn);
1481 rr.mParcel.writeString(user);
1482 rr.mParcel.writeString(password);
1483 rr.mParcel.writeString(authType);
1484 rr.mParcel.writeString(protocol);
1486 if (RILJ_LOGD) riljLog(rr.serialString() + "> "
1487 + requestToString(rr.mRequest) + " " + radioTechnology + " "
1488 + profile + " " + apn + " " + user + " "
1489 + password + " " + authType + " " + protocol);
1496 deactivateDataCall(int cid, int reason, Message result) {
1498 = RILRequest.obtain(RIL_REQUEST_DEACTIVATE_DATA_CALL, result);
1500 rr.mParcel.writeInt(2);
1501 rr.mParcel.writeString(Integer.toString(cid));
1502 rr.mParcel.writeString(Integer.toString(reason));
1504 if (RILJ_LOGD) riljLog(rr.serialString() + "> " +
1505 requestToString(rr.mRequest) + " " + cid + " " + reason);
1512 setRadioPower(boolean on, Message result) {
1513 RILRequest rr = RILRequest.obtain(RIL_REQUEST_RADIO_POWER, result);
1515 rr.mParcel.writeInt(1);
1516 rr.mParcel.writeInt(on ? 1 : 0);
1519 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1520 + (on ? " on" : " off"));
1527 public void requestShutdown(Message result) {
1528 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SHUTDOWN, result);
1531 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1538 setSuppServiceNotifications(boolean enable, Message result) {
1540 = RILRequest.obtain(RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, result);
1542 rr.mParcel.writeInt(1);
1543 rr.mParcel.writeInt(enable ? 1 : 0);
1545 if (RILJ_LOGD) riljLog(rr.serialString() + "> "
1546 + requestToString(rr.mRequest));
1553 acknowledgeLastIncomingGsmSms(boolean success, int cause, Message result) {
1555 = RILRequest.obtain(RIL_REQUEST_SMS_ACKNOWLEDGE, result);
1557 rr.mParcel.writeInt(2);
1558 rr.mParcel.writeInt(success ? 1 : 0);
1559 rr.mParcel.writeInt(cause);
1561 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1562 + " " + success + " " + cause);
1569 acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message result) {
1571 = RILRequest.obtain(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result);
1573 rr.mParcel.writeInt(success ? 0 : 1); //RIL_CDMA_SMS_ErrorClass
1574 // cause code according to X.S004-550E
1575 rr.mParcel.writeInt(cause);
1577 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1578 + " " + success + " " + cause);
1585 acknowledgeIncomingGsmSmsWithPdu(boolean success, String ackPdu, Message result) {
1587 = RILRequest.obtain(RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, result);
1589 rr.mParcel.writeInt(2);
1590 rr.mParcel.writeString(success ? "1" : "0");
1591 rr.mParcel.writeString(ackPdu);
1593 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1594 + ' ' + success + " [" + ackPdu + ']');
1601 iccIO (int command, int fileid, String path, int p1, int p2, int p3,
1602 String data, String pin2, Message result) {
1603 iccIOForApp(command, fileid, path, p1, p2, p3, data, pin2, null, result);
1607 iccIOForApp (int command, int fileid, String path, int p1, int p2, int p3,
1608 String data, String pin2, String aid, Message result) {
1609 //Note: This RIL request has not been renamed to ICC,
1610 // but this request is also valid for SIM and RUIM
1612 = RILRequest.obtain(RIL_REQUEST_SIM_IO, result);
1614 rr.mParcel.writeInt(command);
1615 rr.mParcel.writeInt(fileid);
1616 rr.mParcel.writeString(path);
1617 rr.mParcel.writeInt(p1);
1618 rr.mParcel.writeInt(p2);
1619 rr.mParcel.writeInt(p3);
1620 rr.mParcel.writeString(data);
1621 rr.mParcel.writeString(pin2);
1622 rr.mParcel.writeString(aid);
1624 if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: "
1625 + requestToString(rr.mRequest)
1626 + " 0x" + Integer.toHexString(command)
1627 + " 0x" + Integer.toHexString(fileid) + " "
1628 + " path: " + path + ","
1629 + p1 + "," + p2 + "," + p3
1637 getCLIR(Message result) {
1639 = RILRequest.obtain(RIL_REQUEST_GET_CLIR, result);
1641 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1648 setCLIR(int clirMode, Message result) {
1650 = RILRequest.obtain(RIL_REQUEST_SET_CLIR, result);
1653 rr.mParcel.writeInt(1);
1655 rr.mParcel.writeInt(clirMode);
1657 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1665 queryCallWaiting(int serviceClass, Message response) {
1667 = RILRequest.obtain(RIL_REQUEST_QUERY_CALL_WAITING, response);
1669 rr.mParcel.writeInt(1);
1670 rr.mParcel.writeInt(serviceClass);
1672 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1673 + " " + serviceClass);
1680 setCallWaiting(boolean enable, int serviceClass, Message response) {
1682 = RILRequest.obtain(RIL_REQUEST_SET_CALL_WAITING, response);
1684 rr.mParcel.writeInt(2);
1685 rr.mParcel.writeInt(enable ? 1 : 0);
1686 rr.mParcel.writeInt(serviceClass);
1688 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1689 + " " + enable + ", " + serviceClass);
1696 setNetworkSelectionModeAutomatic(Message response) {
1698 = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
1701 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1708 setNetworkSelectionModeManual(String operatorNumeric, Message response) {
1710 = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1713 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1714 + " " + operatorNumeric);
1716 rr.mParcel.writeString(operatorNumeric);
1723 getNetworkSelectionMode(Message response) {
1725 = RILRequest.obtain(RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE,
1728 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1735 getAvailableNetworks(Message response) {
1737 = RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,
1740 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1747 setCallForward(int action, int cfReason, int serviceClass,
1748 String number, int timeSeconds, Message response) {
1750 = RILRequest.obtain(RIL_REQUEST_SET_CALL_FORWARD, response);
1752 rr.mParcel.writeInt(action);
1753 rr.mParcel.writeInt(cfReason);
1754 rr.mParcel.writeInt(serviceClass);
1755 rr.mParcel.writeInt(PhoneNumberUtils.toaFromString(number));
1756 rr.mParcel.writeString(number);
1757 rr.mParcel.writeInt (timeSeconds);
1759 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1760 + " " + action + " " + cfReason + " " + serviceClass
1768 queryCallForwardStatus(int cfReason, int serviceClass,
1769 String number, Message response) {
1771 = RILRequest.obtain(RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, response);
1773 rr.mParcel.writeInt(2); // 2 is for query action, not in used anyway
1774 rr.mParcel.writeInt(cfReason);
1775 rr.mParcel.writeInt(serviceClass);
1776 rr.mParcel.writeInt(PhoneNumberUtils.toaFromString(number));
1777 rr.mParcel.writeString(number);
1778 rr.mParcel.writeInt (0);
1780 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1781 + " " + cfReason + " " + serviceClass);
1788 queryCLIP(Message response) {
1790 = RILRequest.obtain(RIL_REQUEST_QUERY_CLIP, response);
1792 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1800 getBasebandVersion (Message response) {
1802 = RILRequest.obtain(RIL_REQUEST_BASEBAND_VERSION, response);
1804 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1811 queryFacilityLock(String facility, String password, int serviceClass,
1813 queryFacilityLockForApp(facility, password, serviceClass, null, response);
1818 queryFacilityLockForApp(String facility, String password, int serviceClass, String appId,
1820 RILRequest rr = RILRequest.obtain(RIL_REQUEST_QUERY_FACILITY_LOCK, response);
1822 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1823 + " [" + facility + " " + serviceClass
1824 + " " + appId + "]");
1827 rr.mParcel.writeInt(4);
1829 rr.mParcel.writeString(facility);
1830 rr.mParcel.writeString(password);
1832 rr.mParcel.writeString(Integer.toString(serviceClass));
1833 rr.mParcel.writeString(appId);
1840 setFacilityLock (String facility, boolean lockState, String password,
1841 int serviceClass, Message response) {
1842 setFacilityLockForApp(facility, lockState, password, serviceClass, null, response);
1847 setFacilityLockForApp(String facility, boolean lockState, String password,
1848 int serviceClass, String appId, Message response) {
1851 = RILRequest.obtain(RIL_REQUEST_SET_FACILITY_LOCK, response);
1853 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1854 + " [" + facility + " " + lockState
1855 + " " + serviceClass + " " + appId + "]");
1858 rr.mParcel.writeInt(5);
1860 rr.mParcel.writeString(facility);
1861 lockString = (lockState)?"1":"0";
1862 rr.mParcel.writeString(lockString);
1863 rr.mParcel.writeString(password);
1864 rr.mParcel.writeString(Integer.toString(serviceClass));
1865 rr.mParcel.writeString(appId);
1873 sendUSSD (String ussdString, Message response) {
1875 = RILRequest.obtain(RIL_REQUEST_SEND_USSD, response);
1878 String logUssdString = "*******";
1879 if (RILJ_LOGV) logUssdString = ussdString;
1880 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1881 + " " + logUssdString);
1884 rr.mParcel.writeString(ussdString);
1889 // inherited javadoc suffices
1891 public void cancelPendingUssd (Message response) {
1893 = RILRequest.obtain(RIL_REQUEST_CANCEL_USSD, response);
1895 if (RILJ_LOGD) riljLog(rr.serialString()
1896 + "> " + requestToString(rr.mRequest));
1903 public void resetRadio(Message result) {
1905 = RILRequest.obtain(RIL_REQUEST_RESET_RADIO, result);
1907 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1913 public void invokeOemRilRequestRaw(byte[] data, Message response) {
1915 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_RAW, response);
1917 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1918 + "[" + IccUtils.bytesToHexString(data) + "]");
1920 rr.mParcel.writeByteArray(data);
1927 public void invokeOemRilRequestStrings(String[] strings, Message response) {
1929 = RILRequest.obtain(RIL_REQUEST_OEM_HOOK_STRINGS, response);
1931 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1933 rr.mParcel.writeStringArray(strings);
1939 * Assign a specified band for RF configuration.
1941 * @param bandMode one of BM_*_BAND
1942 * @param response is callback message
1945 public void setBandMode (int bandMode, Message response) {
1947 = RILRequest.obtain(RIL_REQUEST_SET_BAND_MODE, response);
1949 rr.mParcel.writeInt(1);
1950 rr.mParcel.writeInt(bandMode);
1952 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
1959 * Query the list of band mode supported by RF.
1961 * @param response is callback message
1962 * ((AsyncResult)response.obj).result is an int[] where int[0] is
1963 * the size of the array and the rest of each element representing
1964 * one available BM_*_BAND
1967 public void queryAvailableBandMode (Message response) {
1969 = RILRequest.obtain(RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE,
1972 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1981 public void sendTerminalResponse(String contents, Message response) {
1982 RILRequest rr = RILRequest.obtain(
1983 RILConstants.RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, response);
1985 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
1987 rr.mParcel.writeString(contents);
1995 public void sendEnvelope(String contents, Message response) {
1996 RILRequest rr = RILRequest.obtain(
1997 RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, response);
1999 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2001 rr.mParcel.writeString(contents);
2009 public void sendEnvelopeWithStatus(String contents, Message response) {
2010 RILRequest rr = RILRequest.obtain(
2011 RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, response);
2013 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
2014 + '[' + contents + ']');
2016 rr.mParcel.writeString(contents);
2024 public void handleCallSetupRequestFromSim(
2025 boolean accept, Message response) {
2027 RILRequest rr = RILRequest.obtain(
2028 RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
2031 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2033 int[] param = new int[1];
2034 param[0] = accept ? 1 : 0;
2035 rr.mParcel.writeIntArray(param);
2043 public void setPreferredNetworkType(int networkType , Message response) {
2044 RILRequest rr = RILRequest.obtain(
2045 RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response);
2047 rr.mParcel.writeInt(1);
2048 rr.mParcel.writeInt(networkType);
2050 mPreferredNetworkType = networkType;
2052 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
2053 + " : " + networkType);
2062 public void getPreferredNetworkType(Message response) {
2063 RILRequest rr = RILRequest.obtain(
2064 RILConstants.RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, response);
2066 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2075 public void getNeighboringCids(Message response) {
2076 RILRequest rr = RILRequest.obtain(
2077 RILConstants.RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, response);
2079 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2088 public void setLocationUpdates(boolean enable, Message response) {
2089 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_LOCATION_UPDATES, response);
2090 rr.mParcel.writeInt(1);
2091 rr.mParcel.writeInt(enable ? 1 : 0);
2093 if (RILJ_LOGD) riljLog(rr.serialString() + "> "
2094 + requestToString(rr.mRequest) + ": " + enable);
2103 public void getSmscAddress(Message result) {
2104 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SMSC_ADDRESS, result);
2106 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2115 public void setSmscAddress(String address, Message result) {
2116 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_SMSC_ADDRESS, result);
2118 rr.mParcel.writeString(address);
2120 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
2130 public void reportSmsMemoryStatus(boolean available, Message result) {
2131 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, result);
2132 rr.mParcel.writeInt(1);
2133 rr.mParcel.writeInt(available ? 1 : 0);
2135 if (RILJ_LOGD) riljLog(rr.serialString() + "> "
2136 + requestToString(rr.mRequest) + ": " + available);
2145 public void reportStkServiceIsRunning(Message result) {
2146 RILRequest rr = RILRequest.obtain(RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, result);
2148 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2157 public void getGsmBroadcastConfig(Message response) {
2158 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, response);
2160 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2169 public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) {
2170 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, response);
2172 int numOfConfig = config.length;
2173 rr.mParcel.writeInt(numOfConfig);
2175 for(int i = 0; i < numOfConfig; i++) {
2176 rr.mParcel.writeInt(config[i].getFromServiceId());
2177 rr.mParcel.writeInt(config[i].getToServiceId());
2178 rr.mParcel.writeInt(config[i].getFromCodeScheme());
2179 rr.mParcel.writeInt(config[i].getToCodeScheme());
2180 rr.mParcel.writeInt(config[i].isSelected() ? 1 : 0);
2184 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
2185 + " with " + numOfConfig + " configs : ");
2186 for (int i = 0; i < numOfConfig; i++) {
2187 riljLog(config[i].toString());
2198 public void setGsmBroadcastActivation(boolean activate, Message response) {
2199 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, response);
2201 rr.mParcel.writeInt(1);
2202 rr.mParcel.writeInt(activate ? 0 : 1);
2204 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
2209 //***** Private Methods
2211 // TODO(jeffbrown): Delete me.
2212 // The RIL should *not* be listening for screen state changes since they are
2213 // becoming increasingly ambiguous on our devices. The RIL_REQUEST_SCREEN_STATE
2214 // message should be deleted and replaced with more precise messages to control
2215 // behavior such as signal strength reporting or power managements based on
2216 // more robust signals.
2217 private void updateScreenState() {
2218 final int oldState = mDefaultDisplayState;
2219 mDefaultDisplayState = mDefaultDisplay.getState();
2220 if (mDefaultDisplayState != oldState) {
2221 if (oldState != Display.STATE_ON
2222 && mDefaultDisplayState == Display.STATE_ON) {
2223 sendScreenState(true);
2224 } else if ((oldState == Display.STATE_ON || oldState == Display.STATE_UNKNOWN)
2225 && mDefaultDisplayState != Display.STATE_ON) {
2226 sendScreenState(false);
2231 private void sendScreenState(boolean on) {
2232 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SCREEN_STATE, null);
2233 rr.mParcel.writeInt(1);
2234 rr.mParcel.writeInt(on ? 1 : 0);
2236 if (RILJ_LOGD) riljLog(rr.serialString()
2237 + "> " + requestToString(rr.mRequest) + ": " + on);
2244 onRadioAvailable() {
2245 // In case screen state was lost (due to process crash),
2246 // this ensures that the RIL knows the correct screen state.
2247 updateScreenState();
2250 private RadioState getRadioStateFromInt(int stateInt) {
2253 /* RIL_RadioState ril.h */
2255 case 0: state = RadioState.RADIO_OFF; break;
2256 case 1: state = RadioState.RADIO_UNAVAILABLE; break;
2257 case 10: state = RadioState.RADIO_ON; break;
2260 throw new RuntimeException(
2261 "Unrecognized RIL_RadioState: " + stateInt);
2266 private void switchToRadioState(RadioState newState) {
2267 setRadioState(newState);
2271 * Holds a PARTIAL_WAKE_LOCK whenever
2272 * a) There is outstanding RIL request sent to RIL deamon and no replied
2273 * b) There is a request pending to be sent out.
2275 * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
2281 synchronized (mWakeLock) {
2282 mWakeLock.acquire();
2285 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
2286 Message msg = mSender.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
2287 mSender.sendMessageDelayed(msg, mWakeLockTimeout);
2292 decrementWakeLock() {
2293 synchronized (mWakeLock) {
2294 if (mWakeLockCount > 1) {
2298 mWakeLock.release();
2299 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
2304 // true if we had the wakelock
2307 synchronized (mWakeLock) {
2308 if (mWakeLockCount == 0 && mWakeLock.isHeld() == false) return false;
2309 Rlog.d(RILJ_LOG_TAG, "NOTE: mWakeLockCount is " + mWakeLockCount + "at time of clearing");
2311 mWakeLock.release();
2312 mSender.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
2318 send(RILRequest rr) {
2321 if (mSocket == null) {
2322 rr.onError(RADIO_NOT_AVAILABLE, null);
2327 msg = mSender.obtainMessage(EVENT_SEND, rr);
2335 processResponse (Parcel p) {
2340 if (type == RESPONSE_UNSOLICITED) {
2341 processUnsolicited (p);
2342 } else if (type == RESPONSE_SOLICITED) {
2343 RILRequest rr = processSolicited (p);
2346 decrementWakeLock();
2352 * Release each request in mRequestList then clear the list
2353 * @param error is the RIL_Errno sent back
2354 * @param loggable true means to print all requests in mRequestList
2356 private void clearRequestList(int error, boolean loggable) {
2358 synchronized (mRequestList) {
2359 int count = mRequestList.size();
2360 if (RILJ_LOGD && loggable) {
2361 Rlog.d(RILJ_LOG_TAG, "clearRequestList " +
2362 " mWakeLockCount=" + mWakeLockCount +
2363 " mRequestList=" + count);
2366 for (int i = 0; i < count ; i++) {
2367 rr = mRequestList.valueAt(i);
2368 if (RILJ_LOGD && loggable) {
2369 Rlog.d(RILJ_LOG_TAG, i + ": [" + rr.mSerial + "] " +
2370 requestToString(rr.mRequest));
2372 rr.onError(error, null);
2374 decrementWakeLock();
2376 mRequestList.clear();
2380 private RILRequest findAndRemoveRequestFromList(int serial) {
2381 RILRequest rr = null;
2382 synchronized (mRequestList) {
2383 rr = mRequestList.get(serial);
2385 mRequestList.remove(serial);
2393 processSolicited (Parcel p) {
2395 boolean found = false;
2397 serial = p.readInt();
2398 error = p.readInt();
2402 rr = findAndRemoveRequestFromList(serial);
2405 Rlog.w(RILJ_LOG_TAG, "Unexpected solicited response! sn: "
2406 + serial + " error: " + error);
2412 if (error == 0 || p.dataAvail() > 0) {
2413 // either command succeeds or command fails but with data payload
2414 try {switch (rr.mRequest) {
2416 cat libs/telephony/ril_commands.h \
2417 | egrep "^ *{RIL_" \
2418 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: ret = \2(p); break;/'
2420 case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break;
2421 case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break;
2422 case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break;
2423 case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break;
2424 case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break;
2425 case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break;
2426 case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break;
2427 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break;
2428 case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break;
2429 case RIL_REQUEST_DIAL: ret = responseVoid(p); break;
2430 case RIL_REQUEST_GET_IMSI: ret = responseString(p); break;
2431 case RIL_REQUEST_HANGUP: ret = responseVoid(p); break;
2432 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break;
2433 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: {
2434 if (mTestingEmergencyCall.getAndSet(false)) {
2435 if (mEmergencyCallbackModeRegistrant != null) {
2436 riljLog("testing emergency call, notify ECM Registrants");
2437 mEmergencyCallbackModeRegistrant.notifyRegistrant();
2440 ret = responseVoid(p);
2443 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break;
2444 case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break;
2445 case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
2446 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break;
2447 case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
2448 case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break;
2449 case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break;
2450 case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break;
2451 case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break;
2452 case RIL_REQUEST_DTMF: ret = responseVoid(p); break;
2453 case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break;
2454 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break;
2455 case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break;
2456 case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break;
2457 case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break;
2458 case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break;
2459 case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break;
2460 case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break;
2461 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break;
2462 case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break;
2463 case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break;
2464 case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break;
2465 case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
2466 case RIL_REQUEST_GET_IMEI: ret = responseString(p); break;
2467 case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break;
2468 case RIL_REQUEST_ANSWER: ret = responseVoid(p); break;
2469 case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break;
2470 case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break;
2471 case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break;
2472 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break;
2473 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break;
2474 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break;
2475 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break;
2476 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break;
2477 case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break;
2478 case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break;
2479 case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break;
2480 case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break;
2481 case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break;
2482 case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break;
2483 case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break;
2484 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break;
2485 case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break;
2486 case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break;
2487 case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break;
2488 case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break;
2489 case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break;
2490 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break;
2491 case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break;
2492 case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break;
2493 case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break;
2494 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break;
2495 case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break;
2496 case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break;
2497 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break;
2498 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break;
2499 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break;
2500 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break;
2501 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break;
2502 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break;
2503 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseCellList(p); break;
2504 case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break;
2505 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break;
2506 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break;
2507 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break;
2508 case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break;
2509 case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break;
2510 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break;
2511 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break;
2512 case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break;
2513 case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break;
2514 case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break;
2515 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
2516 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break;
2517 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
2518 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
2519 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break;
2520 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
2521 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
2522 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break;
2523 case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break;
2524 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break;
2525 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break;
2526 case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break;
2527 case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break;
2528 case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
2529 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
2530 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break;
2531 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
2532 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break;
2533 case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break;
2534 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: ret = responseVoid(p); break;
2535 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: ret = responseICC_IO(p); break;
2536 case RIL_REQUEST_VOICE_RADIO_TECH: ret = responseInts(p); break;
2537 case RIL_REQUEST_GET_CELL_INFO_LIST: ret = responseCellInfoList(p); break;
2538 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: ret = responseVoid(p); break;
2539 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: ret = responseVoid(p); break;
2540 case RIL_REQUEST_SET_DATA_PROFILE: ret = responseVoid(p); break;
2541 case RIL_REQUEST_IMS_REGISTRATION_STATE: ret = responseInts(p); break;
2542 case RIL_REQUEST_IMS_SEND_SMS: ret = responseSMS(p); break;
2543 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: ret = responseICC_IO(p); break;
2544 case RIL_REQUEST_SIM_OPEN_CHANNEL: ret = responseInts(p); break;
2545 case RIL_REQUEST_SIM_CLOSE_CHANNEL: ret = responseVoid(p); break;
2546 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: ret = responseICC_IO(p); break;
2547 case RIL_REQUEST_NV_READ_ITEM: ret = responseString(p); break;
2548 case RIL_REQUEST_NV_WRITE_ITEM: ret = responseVoid(p); break;
2549 case RIL_REQUEST_NV_WRITE_CDMA_PRL: ret = responseVoid(p); break;
2550 case RIL_REQUEST_NV_RESET_CONFIG: ret = responseVoid(p); break;
2551 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: ret = responseVoid(p); break;
2552 case RIL_REQUEST_ALLOW_DATA: ret = responseVoid(p); break;
2553 case RIL_REQUEST_GET_HARDWARE_CONFIG: ret = responseHardwareConfig(p); break;
2554 case RIL_REQUEST_SIM_AUTHENTICATION: ret = responseICC_IOBase64(p); break;
2555 case RIL_REQUEST_SHUTDOWN: ret = responseVoid(p); break;
2556 case RIL_REQUEST_GET_RADIO_CAPABILITY: ret = responseRadioCapability(p); break;
2557 case RIL_REQUEST_SET_RADIO_CAPABILITY: ret = responseRadioCapability(p); break;
2559 throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
2561 }} catch (Throwable tr) {
2562 // Exceptions here usually mean invalid RIL responses
2564 Rlog.w(RILJ_LOG_TAG, rr.serialString() + "< "
2565 + requestToString(rr.mRequest)
2566 + " exception, possible invalid RIL response", tr);
2568 if (rr.mResult != null) {
2569 AsyncResult.forMessage(rr.mResult, null, tr);
2570 rr.mResult.sendToTarget();
2576 if (rr.mRequest == RIL_REQUEST_SHUTDOWN) {
2577 // Set RADIO_STATE to RADIO_UNAVAILABLE to continue shutdown process
2578 // regardless of error code to continue shutdown procedure.
2579 riljLog("Response to RIL_REQUEST_SHUTDOWN received. Error is " +
2580 error + " Setting Radio State to Unavailable regardless of error.");
2581 setRadioState(RadioState.RADIO_UNAVAILABLE);
2584 // Here and below fake RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, see b/7255789.
2585 // This is needed otherwise we don't automatically transition to the main lock
2586 // screen when the pin or puk is entered incorrectly.
2587 switch (rr.mRequest) {
2588 case RIL_REQUEST_ENTER_SIM_PUK:
2589 case RIL_REQUEST_ENTER_SIM_PUK2:
2590 if (mIccStatusChangedRegistrants != null) {
2592 riljLog("ON enter sim puk fakeSimStatusChanged: reg count="
2593 + mIccStatusChangedRegistrants.size());
2595 mIccStatusChangedRegistrants.notifyRegistrants();
2601 switch (rr.mRequest) {
2602 case RIL_REQUEST_ENTER_SIM_PIN:
2603 case RIL_REQUEST_ENTER_SIM_PIN2:
2604 case RIL_REQUEST_CHANGE_SIM_PIN:
2605 case RIL_REQUEST_CHANGE_SIM_PIN2:
2606 case RIL_REQUEST_SET_FACILITY_LOCK:
2607 if (mIccStatusChangedRegistrants != null) {
2609 riljLog("ON some errors fakeSimStatusChanged: reg count="
2610 + mIccStatusChangedRegistrants.size());
2612 mIccStatusChangedRegistrants.notifyRegistrants();
2617 rr.onError(error, ret);
2620 if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
2621 + " " + retToString(rr.mRequest, ret));
2623 if (rr.mResult != null) {
2624 AsyncResult.forMessage(rr.mResult, ret, null);
2625 rr.mResult.sendToTarget();
2632 retToString(int req, Object ret) {
2633 if (ret == null) return "";
2635 // Don't log these return values, for privacy's sake.
2636 case RIL_REQUEST_GET_IMSI:
2637 case RIL_REQUEST_GET_IMEI:
2638 case RIL_REQUEST_GET_IMEISV:
2639 case RIL_REQUEST_SIM_OPEN_CHANNEL:
2640 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL:
2643 // If not versbose logging just return and don't display IMSI and IMEI, IMEISV
2651 if (ret instanceof int[]){
2652 int[] intArray = (int[]) ret;
2653 length = intArray.length;
2654 sb = new StringBuilder("{");
2657 sb.append(intArray[i++]);
2658 while ( i < length) {
2659 sb.append(", ").append(intArray[i++]);
2664 } else if (ret instanceof String[]) {
2665 String[] strings = (String[]) ret;
2666 length = strings.length;
2667 sb = new StringBuilder("{");
2670 sb.append(strings[i++]);
2671 while ( i < length) {
2672 sb.append(", ").append(strings[i++]);
2677 }else if (req == RIL_REQUEST_GET_CURRENT_CALLS) {
2678 ArrayList<DriverCall> calls = (ArrayList<DriverCall>) ret;
2679 sb = new StringBuilder("{");
2680 for (DriverCall dc : calls) {
2681 sb.append("[").append(dc).append("] ");
2685 } else if (req == RIL_REQUEST_GET_NEIGHBORING_CELL_IDS) {
2686 ArrayList<NeighboringCellInfo> cells = (ArrayList<NeighboringCellInfo>) ret;
2687 sb = new StringBuilder("{");
2688 for (NeighboringCellInfo cell : cells) {
2689 sb.append("[").append(cell).append("] ");
2693 } else if (req == RIL_REQUEST_QUERY_CALL_FORWARD_STATUS) {
2694 CallForwardInfo[] cinfo = (CallForwardInfo[]) ret;
2695 length = cinfo.length;
2696 sb = new StringBuilder("{");
2697 for(int i = 0; i < length; i++) {
2698 sb.append("[").append(cinfo[i]).append("] ");
2702 } else if (req == RIL_REQUEST_GET_HARDWARE_CONFIG) {
2703 ArrayList<HardwareConfig> hwcfgs = (ArrayList<HardwareConfig>) ret;
2704 sb = new StringBuilder(" ");
2705 for (HardwareConfig hwcfg : hwcfgs) {
2706 sb.append("[").append(hwcfg).append("] ");
2716 processUnsolicited (Parcel p) {
2720 response = p.readInt();
2722 try {switch(response) {
2724 cat libs/telephony/ril_unsol_commands.h \
2725 | egrep "^ *{RIL_" \
2726 | sed -re 's/\{([^,]+),[^,]+,([^}]+).+/case \1: \2(rr, p); break;/'
2729 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break;
2730 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: ret = responseVoid(p); break;
2731 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: ret = responseVoid(p); break;
2732 case RIL_UNSOL_RESPONSE_NEW_SMS: ret = responseString(p); break;
2733 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: ret = responseString(p); break;
2734 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: ret = responseInts(p); break;
2735 case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break;
2736 case RIL_UNSOL_NITZ_TIME_RECEIVED: ret = responseString(p); break;
2737 case RIL_UNSOL_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
2738 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: ret = responseDataCallList(p);break;
2739 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: ret = responseSuppServiceNotification(p); break;
2740 case RIL_UNSOL_STK_SESSION_END: ret = responseVoid(p); break;
2741 case RIL_UNSOL_STK_PROACTIVE_COMMAND: ret = responseString(p); break;
2742 case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break;
2743 case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break;
2744 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
2745 case RIL_UNSOL_SIM_REFRESH: ret = responseSimRefresh(p); break;
2746 case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break;
2747 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break;
2748 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break;
2749 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break;
2750 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseRaw(p); break;
2751 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
2752 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
2753 case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break;
2754 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: ret = responseInts(p); break;
2755 case RIL_UNSOL_CDMA_INFO_REC: ret = responseCdmaInformationRecord(p); break;
2756 case RIL_UNSOL_OEM_HOOK_RAW: ret = responseRaw(p); break;
2757 case RIL_UNSOL_RINGBACK_TONE: ret = responseInts(p); break;
2758 case RIL_UNSOL_RESEND_INCALL_MUTE: ret = responseVoid(p); break;
2759 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: ret = responseInts(p); break;
2760 case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break;
2761 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
2762 case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break;
2763 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: ret = responseInts(p); break;
2764 case RIL_UNSOL_CELL_INFO_LIST: ret = responseCellInfoList(p); break;
2765 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: ret = responseVoid(p); break;
2766 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: ret = responseInts(p); break;
2767 case RIL_UNSOL_SRVCC_STATE_NOTIFY: ret = responseInts(p); break;
2768 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: ret = responseHardwareConfig(p); break;
2769 case RIL_UNSOL_RADIO_CAPABILITY:
2770 ret = responseRadioCapability(p); break;
2771 case RIL_UNSOL_ON_SS: ret = responseSsData(p); break;
2772 case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: ret = responseString(p); break;
2775 throw new RuntimeException("Unrecognized unsol response: " + response);
2777 }} catch (Throwable tr) {
2778 Rlog.e(RILJ_LOG_TAG, "Exception processing unsol response: " + response +
2779 "Exception:" + tr.toString());
2784 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
2785 /* has bonus radio state int */
2786 RadioState newState = getRadioStateFromInt(p.readInt());
2787 if (RILJ_LOGD) unsljLogMore(response, newState.toString());
2789 switchToRadioState(newState);
2791 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
2792 if (RILJ_LOGD) unsljLog(response);
2794 mImsNetworkStateChangedRegistrants
2795 .notifyRegistrants(new AsyncResult(null, null, null));
2797 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
2798 if (RILJ_LOGD) unsljLog(response);
2800 mCallStateRegistrants
2801 .notifyRegistrants(new AsyncResult(null, null, null));
2803 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
2804 if (RILJ_LOGD) unsljLog(response);
2806 mVoiceNetworkStateRegistrants
2807 .notifyRegistrants(new AsyncResult(null, null, null));
2809 case RIL_UNSOL_RESPONSE_NEW_SMS: {
2810 if (RILJ_LOGD) unsljLog(response);
2812 // FIXME this should move up a layer
2813 String a[] = new String[2];
2819 sms = SmsMessage.newFromCMT(a);
2820 if (mGsmSmsRegistrant != null) {
2822 .notifyRegistrant(new AsyncResult(null, sms, null));
2826 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
2827 if (RILJ_LOGD) unsljLogRet(response, ret);
2829 if (mSmsStatusRegistrant != null) {
2830 mSmsStatusRegistrant.notifyRegistrant(
2831 new AsyncResult(null, ret, null));
2834 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM:
2835 if (RILJ_LOGD) unsljLogRet(response, ret);
2837 int[] smsIndex = (int[])ret;
2839 if(smsIndex.length == 1) {
2840 if (mSmsOnSimRegistrant != null) {
2841 mSmsOnSimRegistrant.
2842 notifyRegistrant(new AsyncResult(null, smsIndex, null));
2845 if (RILJ_LOGD) riljLog(" NEW_SMS_ON_SIM ERROR with wrong length "
2849 case RIL_UNSOL_ON_USSD:
2850 String[] resp = (String[])ret;
2852 if (resp.length < 2) {
2853 resp = new String[2];
2854 resp[0] = ((String[])ret)[0];
2857 if (RILJ_LOGD) unsljLogMore(response, resp[0]);
2858 if (mUSSDRegistrant != null) {
2859 mUSSDRegistrant.notifyRegistrant(
2860 new AsyncResult (null, resp, null));
2863 case RIL_UNSOL_NITZ_TIME_RECEIVED:
2864 if (RILJ_LOGD) unsljLogRet(response, ret);
2866 // has bonus long containing milliseconds since boot that the NITZ
2867 // time was received
2868 long nitzReceiveTime = p.readLong();
2870 Object[] result = new Object[2];
2873 result[1] = Long.valueOf(nitzReceiveTime);
2875 boolean ignoreNitz = SystemProperties.getBoolean(
2876 TelephonyProperties.PROPERTY_IGNORE_NITZ, false);
2879 if (RILJ_LOGD) riljLog("ignoring UNSOL_NITZ_TIME_RECEIVED");
2881 if (mNITZTimeRegistrant != null) {
2884 .notifyRegistrant(new AsyncResult (null, result, null));
2886 // in case NITZ time registrant isn't registered yet, or a new registrant
2888 mLastNITZTimeInfo = result;
2892 case RIL_UNSOL_SIGNAL_STRENGTH:
2893 // Note this is set to "verbose" because it happens
2895 if (RILJ_LOGV) unsljLogvRet(response, ret);
2897 if (mSignalStrengthRegistrant != null) {
2898 mSignalStrengthRegistrant.notifyRegistrant(
2899 new AsyncResult (null, ret, null));
2902 case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
2903 if (RILJ_LOGD) unsljLogRet(response, ret);
2905 mDataNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, ret, null));
2908 case RIL_UNSOL_SUPP_SVC_NOTIFICATION:
2909 if (RILJ_LOGD) unsljLogRet(response, ret);
2911 if (mSsnRegistrant != null) {
2912 mSsnRegistrant.notifyRegistrant(
2913 new AsyncResult (null, ret, null));
2917 case RIL_UNSOL_STK_SESSION_END:
2918 if (RILJ_LOGD) unsljLog(response);
2920 if (mCatSessionEndRegistrant != null) {
2921 mCatSessionEndRegistrant.notifyRegistrant(
2922 new AsyncResult (null, ret, null));
2926 case RIL_UNSOL_STK_PROACTIVE_COMMAND:
2927 if (RILJ_LOGD) unsljLog(response);
2929 if (mCatProCmdRegistrant != null) {
2930 mCatProCmdRegistrant.notifyRegistrant(
2931 new AsyncResult (null, ret, null));
2935 case RIL_UNSOL_STK_EVENT_NOTIFY:
2936 if (RILJ_LOGD) unsljLog(response);
2938 if (mCatEventRegistrant != null) {
2939 mCatEventRegistrant.notifyRegistrant(
2940 new AsyncResult (null, ret, null));
2944 case RIL_UNSOL_STK_CALL_SETUP:
2945 if (RILJ_LOGD) unsljLogRet(response, ret);
2947 if (mCatCallSetUpRegistrant != null) {
2948 mCatCallSetUpRegistrant.notifyRegistrant(
2949 new AsyncResult (null, ret, null));
2953 case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
2954 if (RILJ_LOGD) unsljLog(response);
2956 if (mIccSmsFullRegistrant != null) {
2957 mIccSmsFullRegistrant.notifyRegistrant();
2961 case RIL_UNSOL_SIM_REFRESH:
2962 if (RILJ_LOGD) unsljLogRet(response, ret);
2964 if (mIccRefreshRegistrants != null) {
2965 mIccRefreshRegistrants.notifyRegistrants(
2966 new AsyncResult (null, ret, null));
2970 case RIL_UNSOL_CALL_RING:
2971 if (RILJ_LOGD) unsljLogRet(response, ret);
2973 if (mRingRegistrant != null) {
2974 mRingRegistrant.notifyRegistrant(
2975 new AsyncResult (null, ret, null));
2979 case RIL_UNSOL_RESTRICTED_STATE_CHANGED:
2980 if (RILJ_LOGD) unsljLogvRet(response, ret);
2981 if (mRestrictedStateRegistrant != null) {
2982 mRestrictedStateRegistrant.notifyRegistrant(
2983 new AsyncResult (null, ret, null));
2987 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
2988 if (RILJ_LOGD) unsljLog(response);
2990 if (mIccStatusChangedRegistrants != null) {
2991 mIccStatusChangedRegistrants.notifyRegistrants();
2995 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
2996 if (RILJ_LOGD) unsljLog(response);
2998 SmsMessage sms = (SmsMessage) ret;
3000 if (mCdmaSmsRegistrant != null) {
3002 .notifyRegistrant(new AsyncResult(null, sms, null));
3006 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
3007 if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret));
3009 if (mGsmBroadcastSmsRegistrant != null) {
3010 mGsmBroadcastSmsRegistrant
3011 .notifyRegistrant(new AsyncResult(null, ret, null));
3015 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL:
3016 if (RILJ_LOGD) unsljLog(response);
3018 if (mIccSmsFullRegistrant != null) {
3019 mIccSmsFullRegistrant.notifyRegistrant();
3023 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE:
3024 if (RILJ_LOGD) unsljLog(response);
3026 if (mEmergencyCallbackModeRegistrant != null) {
3027 mEmergencyCallbackModeRegistrant.notifyRegistrant();
3031 case RIL_UNSOL_CDMA_CALL_WAITING:
3032 if (RILJ_LOGD) unsljLogRet(response, ret);
3034 if (mCallWaitingInfoRegistrants != null) {
3035 mCallWaitingInfoRegistrants.notifyRegistrants(
3036 new AsyncResult (null, ret, null));
3040 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS:
3041 if (RILJ_LOGD) unsljLogRet(response, ret);
3043 if (mOtaProvisionRegistrants != null) {
3044 mOtaProvisionRegistrants.notifyRegistrants(
3045 new AsyncResult (null, ret, null));
3049 case RIL_UNSOL_CDMA_INFO_REC:
3050 ArrayList<CdmaInformationRecords> listInfoRecs;
3053 listInfoRecs = (ArrayList<CdmaInformationRecords>)ret;
3054 } catch (ClassCastException e) {
3055 Rlog.e(RILJ_LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
3059 for (CdmaInformationRecords rec : listInfoRecs) {
3060 if (RILJ_LOGD) unsljLogRet(response, rec);
3061 notifyRegistrantsCdmaInfoRec(rec);
3065 case RIL_UNSOL_OEM_HOOK_RAW:
3066 if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret));
3067 if (mUnsolOemHookRawRegistrant != null) {
3068 mUnsolOemHookRawRegistrant.notifyRegistrant(new AsyncResult(null, ret, null));
3072 case RIL_UNSOL_RINGBACK_TONE:
3073 if (RILJ_LOGD) unsljLogvRet(response, ret);
3074 if (mRingbackToneRegistrants != null) {
3075 boolean playtone = (((int[])ret)[0] == 1);
3076 mRingbackToneRegistrants.notifyRegistrants(
3077 new AsyncResult (null, playtone, null));
3081 case RIL_UNSOL_RESEND_INCALL_MUTE:
3082 if (RILJ_LOGD) unsljLogRet(response, ret);
3084 if (mResendIncallMuteRegistrants != null) {
3085 mResendIncallMuteRegistrants.notifyRegistrants(
3086 new AsyncResult (null, ret, null));
3090 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED:
3091 if (RILJ_LOGD) unsljLogRet(response, ret);
3093 if (mVoiceRadioTechChangedRegistrants != null) {
3094 mVoiceRadioTechChangedRegistrants.notifyRegistrants(
3095 new AsyncResult(null, ret, null));
3099 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
3100 if (RILJ_LOGD) unsljLogRet(response, ret);
3102 if (mCdmaSubscriptionChangedRegistrants != null) {
3103 mCdmaSubscriptionChangedRegistrants.notifyRegistrants(
3104 new AsyncResult (null, ret, null));
3108 case RIL_UNSOl_CDMA_PRL_CHANGED:
3109 if (RILJ_LOGD) unsljLogRet(response, ret);
3111 if (mCdmaPrlChangedRegistrants != null) {
3112 mCdmaPrlChangedRegistrants.notifyRegistrants(
3113 new AsyncResult (null, ret, null));
3117 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE:
3118 if (RILJ_LOGD) unsljLogRet(response, ret);
3120 if (mExitEmergencyCallbackModeRegistrants != null) {
3121 mExitEmergencyCallbackModeRegistrants.notifyRegistrants(
3122 new AsyncResult (null, null, null));
3126 case RIL_UNSOL_RIL_CONNECTED: {
3127 if (RILJ_LOGD) unsljLogRet(response, ret);
3129 getRadioCapability(mSupportedRafHandler.obtainMessage());
3131 // Initial conditions
3132 setRadioPower(false, null);
3133 setPreferredNetworkType(mPreferredNetworkType, null);
3134 setCdmaSubscriptionSource(mCdmaSubscription, null);
3135 setCellInfoListRate(Integer.MAX_VALUE, null);
3136 notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
3139 case RIL_UNSOL_CELL_INFO_LIST: {
3140 if (RILJ_LOGD) unsljLogRet(response, ret);
3142 if (mRilCellInfoListRegistrants != null) {
3143 mRilCellInfoListRegistrants.notifyRegistrants(
3144 new AsyncResult (null, ret, null));
3148 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: {
3149 if (RILJ_LOGD) unsljLogRet(response, ret);
3151 if (mSubscriptionStatusRegistrants != null) {
3152 mSubscriptionStatusRegistrants.notifyRegistrants(
3153 new AsyncResult (null, ret, null));
3157 case RIL_UNSOL_SRVCC_STATE_NOTIFY: {
3158 if (RILJ_LOGD) unsljLogRet(response, ret);
3160 if (mSrvccStateRegistrants != null) {
3161 mSrvccStateRegistrants
3162 .notifyRegistrants(new AsyncResult(null, ret, null));
3166 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED:
3167 if (RILJ_LOGD) unsljLogRet(response, ret);
3169 if (mHardwareConfigChangeRegistrants != null) {
3170 mHardwareConfigChangeRegistrants.notifyRegistrants(
3171 new AsyncResult (null, ret, null));
3174 case RIL_UNSOL_RADIO_CAPABILITY:
3175 if (RILJ_LOGD) unsljLogRet(response, ret);
3177 if (mPhoneRadioCapabilityChangedRegistrants != null) {
3178 mPhoneRadioCapabilityChangedRegistrants.notifyRegistrants(
3179 new AsyncResult(null, ret, null));
3182 case RIL_UNSOL_ON_SS:
3183 if (RILJ_LOGD) unsljLogRet(response, ret);
3185 if (mSsRegistrant != null) {
3186 mSsRegistrant.notifyRegistrant(
3187 new AsyncResult (null, ret, null));
3190 case RIL_UNSOL_STK_CC_ALPHA_NOTIFY:
3191 if (RILJ_LOGD) unsljLogRet(response, ret);
3193 if (mCatCcAlphaRegistrant != null) {
3194 mCatCcAlphaRegistrant.notifyRegistrant(
3195 new AsyncResult (null, ret, null));
3202 * Receives and stores the capabilities supported by the modem.
3204 private Handler mSupportedRafHandler = new Handler() {
3206 public void handleMessage(Message msg) {
3207 AsyncResult ar = (AsyncResult) msg.obj;
3208 RadioCapability rc = (RadioCapability) ar.result;
3209 if (ar.exception != null) {
3210 if (RILJ_LOGD) riljLog("Get supported radio access family fail");
3212 mSupportedRaf = rc.getRadioAccessFamily();
3213 if (RILJ_LOGD) riljLog("Supported radio access family=" + mSupportedRaf);
3219 * Notifiy all registrants that the ril has connected or disconnected.
3221 * @param rilVer is the version of the ril or -1 if disconnected.
3223 private void notifyRegistrantsRilConnectionChanged(int rilVer) {
3224 mRilVersion = rilVer;
3225 if (mRilConnectedRegistrants != null) {
3226 mRilConnectedRegistrants.notifyRegistrants(
3227 new AsyncResult (null, new Integer(rilVer), null));
3232 responseInts(Parcel p) {
3236 numInts = p.readInt();
3238 response = new int[numInts];
3240 for (int i = 0 ; i < numInts ; i++) {
3241 response[i] = p.readInt();
3249 responseVoid(Parcel p) {
3254 responseCallForward(Parcel p) {
3256 CallForwardInfo infos[];
3258 numInfos = p.readInt();
3260 infos = new CallForwardInfo[numInfos];
3262 for (int i = 0 ; i < numInfos ; i++) {
3263 infos[i] = new CallForwardInfo();
3265 infos[i].status = p.readInt();
3266 infos[i].reason = p.readInt();
3267 infos[i].serviceClass = p.readInt();
3268 infos[i].toa = p.readInt();
3269 infos[i].number = p.readString();
3270 infos[i].timeSeconds = p.readInt();
3277 responseSuppServiceNotification(Parcel p) {
3278 SuppServiceNotification notification = new SuppServiceNotification();
3280 notification.notificationType = p.readInt();
3281 notification.code = p.readInt();
3282 notification.index = p.readInt();
3283 notification.type = p.readInt();
3284 notification.number = p.readString();
3286 return notification;
3290 responseCdmaSms(Parcel p) {
3292 sms = SmsMessage.newFromParcel(p);
3298 responseString(Parcel p) {
3301 response = p.readString();
3307 responseStrings(Parcel p) {
3311 response = p.readStringArray();
3317 responseRaw(Parcel p) {
3321 response = p.createByteArray();
3327 responseSMS(Parcel p) {
3328 int messageRef, errorCode;
3331 messageRef = p.readInt();
3332 ackPDU = p.readString();
3333 errorCode = p.readInt();
3335 SmsResponse response = new SmsResponse(messageRef, ackPDU, errorCode);
3342 responseICC_IO(Parcel p) {
3349 String s = p.readString();
3351 if (RILJ_LOGV) riljLog("< iccIO: "
3352 + " 0x" + Integer.toHexString(sw1)
3353 + " 0x" + Integer.toHexString(sw2) + " "
3356 return new IccIoResult(sw1, sw2, s);
3360 responseICC_IOBase64(Parcel p) {
3367 String s = p.readString();
3369 if (RILJ_LOGV) riljLog("< iccIO: "
3370 + " 0x" + Integer.toHexString(sw1)
3371 + " 0x" + Integer.toHexString(sw2) + " "
3375 return new IccIoResult(sw1, sw2, android.util.Base64.decode(s, android.util.Base64.DEFAULT));
3379 responseIccCardStatus(Parcel p) {
3380 IccCardApplicationStatus appStatus;
3382 IccCardStatus cardStatus = new IccCardStatus();
3383 cardStatus.setCardState(p.readInt());
3384 cardStatus.setUniversalPinState(p.readInt());
3385 cardStatus.mGsmUmtsSubscriptionAppIndex = p.readInt();
3386 cardStatus.mCdmaSubscriptionAppIndex = p.readInt();
3387 cardStatus.mImsSubscriptionAppIndex = p.readInt();
3388 int numApplications = p.readInt();
3390 // limit to maximum allowed applications
3391 if (numApplications > IccCardStatus.CARD_MAX_APPS) {
3392 numApplications = IccCardStatus.CARD_MAX_APPS;
3394 cardStatus.mApplications = new IccCardApplicationStatus[numApplications];
3395 for (int i = 0 ; i < numApplications ; i++) {
3396 appStatus = new IccCardApplicationStatus();
3397 appStatus.app_type = appStatus.AppTypeFromRILInt(p.readInt());
3398 appStatus.app_state = appStatus.AppStateFromRILInt(p.readInt());
3399 appStatus.perso_substate = appStatus.PersoSubstateFromRILInt(p.readInt());
3400 appStatus.aid = p.readString();
3401 appStatus.app_label = p.readString();
3402 appStatus.pin1_replaced = p.readInt();
3403 appStatus.pin1 = appStatus.PinStateFromRILInt(p.readInt());
3404 appStatus.pin2 = appStatus.PinStateFromRILInt(p.readInt());
3405 cardStatus.mApplications[i] = appStatus;
3411 responseSimRefresh(Parcel p) {
3412 IccRefreshResponse response = new IccRefreshResponse();
3414 response.refreshResult = p.readInt();
3415 response.efId = p.readInt();
3416 response.aid = p.readString();
3421 responseCallList(Parcel p) {
3424 ArrayList<DriverCall> response;
3428 response = new ArrayList<DriverCall>(num);
3431 riljLog("responseCallList: num=" + num +
3432 " mEmergencyCallbackModeRegistrant=" + mEmergencyCallbackModeRegistrant +
3433 " mTestingEmergencyCall=" + mTestingEmergencyCall.get());
3435 for (int i = 0 ; i < num ; i++) {
3436 dc = new DriverCall();
3438 dc.state = DriverCall.stateFromCLCC(p.readInt());
3439 dc.index = p.readInt();
3440 dc.TOA = p.readInt();
3441 dc.isMpty = (0 != p.readInt());
3442 dc.isMT = (0 != p.readInt());
3443 dc.als = p.readInt();
3444 voiceSettings = p.readInt();
3445 dc.isVoice = (0 == voiceSettings) ? false : true;
3446 dc.isVoicePrivacy = (0 != p.readInt());
3447 dc.number = p.readString();
3448 int np = p.readInt();
3449 dc.numberPresentation = DriverCall.presentationFromCLIP(np);
3450 dc.name = p.readString();
3451 // according to ril.h, namePresentation should be handled as numberPresentation;
3452 dc.namePresentation = DriverCall.presentationFromCLIP(p.readInt());
3453 int uusInfoPresent = p.readInt();
3454 if (uusInfoPresent == 1) {
3455 dc.uusInfo = new UUSInfo();
3456 dc.uusInfo.setType(p.readInt());
3457 dc.uusInfo.setDcs(p.readInt());
3458 byte[] userData = p.createByteArray();
3459 dc.uusInfo.setUserData(userData);
3460 riljLogv(String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
3461 dc.uusInfo.getType(), dc.uusInfo.getDcs(),
3462 dc.uusInfo.getUserData().length));
3463 riljLogv("Incoming UUS : data (string)="
3464 + new String(dc.uusInfo.getUserData()));
3465 riljLogv("Incoming UUS : data (hex): "
3466 + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
3468 riljLogv("Incoming UUS : NOT present!");
3471 // Make sure there's a leading + on addresses with a TOA of 145
3472 dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
3476 if (dc.isVoicePrivacy) {
3477 mVoicePrivacyOnRegistrants.notifyRegistrants();
3478 riljLog("InCall VoicePrivacy is enabled");
3480 mVoicePrivacyOffRegistrants.notifyRegistrants();
3481 riljLog("InCall VoicePrivacy is disabled");
3485 Collections.sort(response);
3487 if ((num == 0) && mTestingEmergencyCall.getAndSet(false)) {
3488 if (mEmergencyCallbackModeRegistrant != null) {
3489 riljLog("responseCallList: call ended, testing emergency call," +
3490 " notify ECM Registrants");
3491 mEmergencyCallbackModeRegistrant.notifyRegistrant();
3498 private DataCallResponse getDataCallResponse(Parcel p, int version) {
3499 DataCallResponse dataCall = new DataCallResponse();
3501 dataCall.version = version;
3503 dataCall.cid = p.readInt();
3504 dataCall.active = p.readInt();
3505 dataCall.type = p.readString();
3506 String addresses = p.readString();
3507 if (!TextUtils.isEmpty(addresses)) {
3508 dataCall.addresses = addresses.split(" ");
3511 dataCall.status = p.readInt();
3512 dataCall.suggestedRetryTime = p.readInt();
3513 dataCall.cid = p.readInt();
3514 dataCall.active = p.readInt();
3515 dataCall.type = p.readString();
3516 dataCall.ifname = p.readString();
3517 if ((dataCall.status == DcFailCause.NONE.getErrorCode()) &&
3518 TextUtils.isEmpty(dataCall.ifname)) {
3519 throw new RuntimeException("getDataCallResponse, no ifname");
3521 String addresses = p.readString();
3522 if (!TextUtils.isEmpty(addresses)) {
3523 dataCall.addresses = addresses.split(" ");
3525 String dnses = p.readString();
3526 if (!TextUtils.isEmpty(dnses)) {
3527 dataCall.dnses = dnses.split(" ");
3529 String gateways = p.readString();
3530 if (!TextUtils.isEmpty(gateways)) {
3531 dataCall.gateways = gateways.split(" ");
3533 if (version >= 10) {
3534 String pcscf = p.readString();
3535 if (!TextUtils.isEmpty(pcscf)) {
3536 dataCall.pcscf = pcscf.split(" ");
3539 if (version >= 11) {
3540 dataCall.mtu = p.readInt();
3547 responseDataCallList(Parcel p) {
3548 ArrayList<DataCallResponse> response;
3550 int ver = p.readInt();
3551 int num = p.readInt();
3552 riljLog("responseDataCallList ver=" + ver + " num=" + num);
3554 response = new ArrayList<DataCallResponse>(num);
3555 for (int i = 0; i < num; i++) {
3556 response.add(getDataCallResponse(p, ver));
3563 responseSetupDataCall(Parcel p) {
3564 int ver = p.readInt();
3565 int num = p.readInt();
3566 if (RILJ_LOGV) riljLog("responseSetupDataCall ver=" + ver + " num=" + num);
3568 DataCallResponse dataCall;
3571 dataCall = new DataCallResponse();
3572 dataCall.version = ver;
3573 dataCall.cid = Integer.parseInt(p.readString());
3574 dataCall.ifname = p.readString();
3575 if (TextUtils.isEmpty(dataCall.ifname)) {
3576 throw new RuntimeException(
3577 "RIL_REQUEST_SETUP_DATA_CALL response, no ifname");
3579 String addresses = p.readString();
3580 if (!TextUtils.isEmpty(addresses)) {
3581 dataCall.addresses = addresses.split(" ");
3584 String dnses = p.readString();
3585 if (RILJ_LOGD) riljLog("responseSetupDataCall got dnses=" + dnses);
3586 if (!TextUtils.isEmpty(dnses)) {
3587 dataCall.dnses = dnses.split(" ");
3591 String gateways = p.readString();
3592 if (RILJ_LOGD) riljLog("responseSetupDataCall got gateways=" + gateways);
3593 if (!TextUtils.isEmpty(gateways)) {
3594 dataCall.gateways = gateways.split(" ");
3598 String pcscf = p.readString();
3599 if (RILJ_LOGD) riljLog("responseSetupDataCall got pcscf=" + pcscf);
3600 if (!TextUtils.isEmpty(pcscf)) {
3601 dataCall.pcscf = pcscf.split(" ");
3606 throw new RuntimeException(
3607 "RIL_REQUEST_SETUP_DATA_CALL response expecting 1 RIL_Data_Call_response_v5"
3610 dataCall = getDataCallResponse(p, ver);
3617 responseOperatorInfos(Parcel p) {
3618 String strings[] = (String [])responseStrings(p);
3619 ArrayList<OperatorInfo> ret;
3621 // FIXME: What is this really doing
3622 SpnOverride spnOverride = new SpnOverride();
3624 if (strings.length % 4 != 0) {
3625 throw new RuntimeException(
3626 "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
3627 + strings.length + " strings, expected multible of 4");
3630 ret = new ArrayList<OperatorInfo>(strings.length / 4);
3632 for (int i = 0 ; i < strings.length ; i += 4) {
3633 String strOperatorLong = null;
3634 if (spnOverride.containsCarrier(strings[i+2])) {
3635 strOperatorLong = spnOverride.getSpn(strings[i+2]);
3637 strOperatorLong = strings[i+0];
3651 responseCellList(Parcel p) {
3654 ArrayList<NeighboringCellInfo> response;
3655 NeighboringCellInfo cell;
3658 response = new ArrayList<NeighboringCellInfo>();
3660 // Determine the radio access type
3661 int[] subId = SubscriptionManager.getSubId(mInstanceId);
3663 ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)).
3664 getDataNetworkType(subId[0]);
3666 // Interpret the location based on radio access type
3667 if (radioType != NETWORK_TYPE_UNKNOWN) {
3668 for (int i = 0 ; i < num ; i++) {
3670 location = p.readString();
3671 cell = new NeighboringCellInfo(rssi, location, radioType);
3678 private Object responseGetPreferredNetworkType(Parcel p) {
3679 int [] response = (int[]) responseInts(p);
3681 if (response.length >= 1) {
3682 // Since this is the response for getPreferredNetworkType
3683 // we'll assume that it should be the value we want the
3684 // vendor ril to take if we reestablish a connection to it.
3685 mPreferredNetworkType = response[0];
3690 private Object responseGmsBroadcastConfig(Parcel p) {
3692 ArrayList<SmsBroadcastConfigInfo> response;
3693 SmsBroadcastConfigInfo info;
3696 response = new ArrayList<SmsBroadcastConfigInfo>(num);
3698 for (int i = 0; i < num; i++) {
3699 int fromId = p.readInt();
3700 int toId = p.readInt();
3701 int fromScheme = p.readInt();
3702 int toScheme = p.readInt();
3703 boolean selected = (p.readInt() == 1);
3705 info = new SmsBroadcastConfigInfo(fromId, toId, fromScheme,
3706 toScheme, selected);
3713 responseCdmaBroadcastConfig(Parcel p) {
3714 int numServiceCategories;
3717 numServiceCategories = p.readInt();
3719 if (numServiceCategories == 0) {
3720 // TODO: The logic of providing default values should
3721 // not be done by this transport layer. And needs to
3722 // be done by the vendor ril or application logic.
3724 numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
3725 response = new int[numInts];
3727 // Faking a default record for all possible records.
3728 response[0] = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES;
3730 // Loop over CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES set 'english' as
3731 // default language and selection status to false for all.
3732 for (int i = 1; i < numInts; i += CDMA_BSI_NO_OF_INTS_STRUCT ) {
3733 response[i + 0] = i / CDMA_BSI_NO_OF_INTS_STRUCT;
3734 response[i + 1] = 1;
3735 response[i + 2] = 0;
3739 numInts = (numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT) + 1;
3740 response = new int[numInts];
3742 response[0] = numServiceCategories;
3743 for (int i = 1 ; i < numInts; i++) {
3744 response[i] = p.readInt();
3752 responseSignalStrength(Parcel p) {
3753 // Assume this is gsm, but doesn't matter as ServiceStateTracker
3754 // sets the proper value.
3755 SignalStrength signalStrength = SignalStrength.makeSignalStrengthFromRilParcel(p);
3756 return signalStrength;
3759 private ArrayList<CdmaInformationRecords>
3760 responseCdmaInformationRecord(Parcel p) {
3761 int numberOfInfoRecs;
3762 ArrayList<CdmaInformationRecords> response;
3765 * Loop through all of the information records unmarshalling them
3766 * and converting them to Java Objects.
3768 numberOfInfoRecs = p.readInt();
3769 response = new ArrayList<CdmaInformationRecords>(numberOfInfoRecs);
3771 for (int i = 0; i < numberOfInfoRecs; i++) {
3772 CdmaInformationRecords InfoRec = new CdmaInformationRecords(p);
3773 response.add(InfoRec);
3780 responseCdmaCallWaiting(Parcel p) {
3781 CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification();
3783 notification.number = p.readString();
3784 notification.numberPresentation =
3785 CdmaCallWaitingNotification.presentationFromCLIP(p.readInt());
3786 notification.name = p.readString();
3787 notification.namePresentation = notification.numberPresentation;
3788 notification.isPresent = p.readInt();
3789 notification.signalType = p.readInt();
3790 notification.alertPitch = p.readInt();
3791 notification.signal = p.readInt();
3792 notification.numberType = p.readInt();
3793 notification.numberPlan = p.readInt();
3795 return notification;
3799 responseCallRing(Parcel p){
3800 char response[] = new char[4];
3802 response[0] = (char) p.readInt(); // isPresent
3803 response[1] = (char) p.readInt(); // signalType
3804 response[2] = (char) p.readInt(); // alertPitch
3805 response[3] = (char) p.readInt(); // signal
3811 notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) {
3812 int response = RIL_UNSOL_CDMA_INFO_REC;
3813 if (infoRec.record instanceof CdmaInformationRecords.CdmaDisplayInfoRec) {
3814 if (mDisplayInfoRegistrants != null) {
3815 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3816 mDisplayInfoRegistrants.notifyRegistrants(
3817 new AsyncResult (null, infoRec.record, null));
3819 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaSignalInfoRec) {
3820 if (mSignalInfoRegistrants != null) {
3821 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3822 mSignalInfoRegistrants.notifyRegistrants(
3823 new AsyncResult (null, infoRec.record, null));
3825 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaNumberInfoRec) {
3826 if (mNumberInfoRegistrants != null) {
3827 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3828 mNumberInfoRegistrants.notifyRegistrants(
3829 new AsyncResult (null, infoRec.record, null));
3831 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaRedirectingNumberInfoRec) {
3832 if (mRedirNumInfoRegistrants != null) {
3833 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3834 mRedirNumInfoRegistrants.notifyRegistrants(
3835 new AsyncResult (null, infoRec.record, null));
3837 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) {
3838 if (mLineControlInfoRegistrants != null) {
3839 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3840 mLineControlInfoRegistrants.notifyRegistrants(
3841 new AsyncResult (null, infoRec.record, null));
3843 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) {
3844 if (mT53ClirInfoRegistrants != null) {
3845 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3846 mT53ClirInfoRegistrants.notifyRegistrants(
3847 new AsyncResult (null, infoRec.record, null));
3849 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53AudioControlInfoRec) {
3850 if (mT53AudCntrlInfoRegistrants != null) {
3851 if (RILJ_LOGD) unsljLogRet(response, infoRec.record);
3852 mT53AudCntrlInfoRegistrants.notifyRegistrants(
3853 new AsyncResult (null, infoRec.record, null));
3858 private ArrayList<CellInfo> responseCellInfoList(Parcel p) {
3859 int numberOfInfoRecs;
3860 ArrayList<CellInfo> response;
3863 * Loop through all of the information records unmarshalling them
3864 * and converting them to Java Objects.
3866 numberOfInfoRecs = p.readInt();
3867 response = new ArrayList<CellInfo>(numberOfInfoRecs);
3869 for (int i = 0; i < numberOfInfoRecs; i++) {
3870 CellInfo InfoRec = CellInfo.CREATOR.createFromParcel(p);
3871 response.add(InfoRec);
3878 responseHardwareConfig(Parcel p) {
3880 ArrayList<HardwareConfig> response;
3884 response = new ArrayList<HardwareConfig>(num);
3887 riljLog("responseHardwareConfig: num=" + num);
3889 for (int i = 0 ; i < num ; i++) {
3890 int type = p.readInt();
3892 case HardwareConfig.DEV_HARDWARE_TYPE_MODEM: {
3893 hw = new HardwareConfig(type);
3894 hw.assignModem(p.readString(), p.readInt(), p.readInt(),
3895 p.readInt(), p.readInt(), p.readInt(), p.readInt());
3898 case HardwareConfig.DEV_HARDWARE_TYPE_SIM: {
3899 hw = new HardwareConfig(type);
3900 hw.assignSim(p.readString(), p.readInt(), p.readString());
3904 throw new RuntimeException(
3905 "RIL_REQUEST_GET_HARDWARE_CONFIG invalid hardward type:" + type);
3916 responseRadioCapability(Parcel p) {
3917 int version = p.readInt();
3918 int session = p.readInt();
3919 int phase = p.readInt();
3920 int rat = p.readInt();
3921 String logicModemUuid = p.readString();
3922 int status = p.readInt();
3924 riljLog("responseRadioCapability: version= " + version +
3925 ", session=" + session +
3926 ", phase=" + phase +
3928 ", logicModemUuid=" + logicModemUuid +
3929 ", status=" + status);
3930 RadioCapability rc = new RadioCapability(
3931 mInstanceId.intValue(), session, phase, rat, logicModemUuid, status);
3936 requestToString(int request) {
3938 cat libs/telephony/ril_commands.h \
3939 | egrep "^ *{RIL_" \
3940 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
3943 case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
3944 case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
3945 case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
3946 case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
3947 case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
3948 case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
3949 case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
3950 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
3951 case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
3952 case RIL_REQUEST_DIAL: return "DIAL";
3953 case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
3954 case RIL_REQUEST_HANGUP: return "HANGUP";
3955 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
3956 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
3957 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
3958 case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
3959 case RIL_REQUEST_UDUB: return "UDUB";
3960 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
3961 case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
3962 case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
3963 case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
3964 case RIL_REQUEST_OPERATOR: return "OPERATOR";
3965 case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
3966 case RIL_REQUEST_DTMF: return "DTMF";
3967 case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
3968 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
3969 case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
3970 case RIL_REQUEST_SIM_IO: return "SIM_IO";
3971 case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
3972 case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
3973 case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
3974 case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
3975 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
3976 case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
3977 case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
3978 case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
3979 case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
3980 case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
3981 case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
3982 case RIL_REQUEST_ANSWER: return "ANSWER";
3983 case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
3984 case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
3985 case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
3986 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
3987 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
3988 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
3989 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
3990 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
3991 case RIL_REQUEST_DTMF_START: return "DTMF_START";
3992 case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
3993 case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
3994 case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
3995 case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
3996 case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
3997 case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
3998 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
3999 case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
4000 case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
4001 case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
4002 case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
4003 case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
4004 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION";
4005 case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
4006 case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
4007 case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
4008 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
4009 case RIL_REQUEST_STK_GET_PROFILE: return "REQUEST_STK_GET_PROFILE";
4010 case RIL_REQUEST_STK_SET_PROFILE: return "REQUEST_STK_SET_PROFILE";
4011 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "REQUEST_STK_SEND_ENVELOPE_COMMAND";
4012 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "REQUEST_STK_SEND_TERMINAL_RESPONSE";
4013 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
4014 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "REQUEST_EXPLICIT_CALL_TRANSFER";
4015 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "REQUEST_SET_PREFERRED_NETWORK_TYPE";
4016 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "REQUEST_GET_PREFERRED_NETWORK_TYPE";
4017 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "REQUEST_GET_NEIGHBORING_CELL_IDS";
4018 case RIL_REQUEST_SET_LOCATION_UPDATES: return "REQUEST_SET_LOCATION_UPDATES";
4019 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
4020 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
4021 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
4022 case RIL_REQUEST_SET_TTY_MODE: return "RIL_REQUEST_SET_TTY_MODE";
4023 case RIL_REQUEST_QUERY_TTY_MODE: return "RIL_REQUEST_QUERY_TTY_MODE";
4024 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
4025 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
4026 case RIL_REQUEST_CDMA_FLASH: return "RIL_REQUEST_CDMA_FLASH";
4027 case RIL_REQUEST_CDMA_BURST_DTMF: return "RIL_REQUEST_CDMA_BURST_DTMF";
4028 case RIL_REQUEST_CDMA_SEND_SMS: return "RIL_REQUEST_CDMA_SEND_SMS";
4029 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
4030 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG";
4031 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG";
4032 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG";
4033 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG";
4034 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION";
4035 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
4036 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION";
4037 case RIL_REQUEST_CDMA_SUBSCRIPTION: return "RIL_REQUEST_CDMA_SUBSCRIPTION";
4038 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
4039 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
4040 case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
4041 case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
4042 case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
4043 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
4044 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
4045 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
4046 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
4047 case RIL_REQUEST_ISIM_AUTHENTICATION: return "RIL_REQUEST_ISIM_AUTHENTICATION";
4048 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
4049 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
4050 case RIL_REQUEST_VOICE_RADIO_TECH: return "RIL_REQUEST_VOICE_RADIO_TECH";
4051 case RIL_REQUEST_GET_CELL_INFO_LIST: return "RIL_REQUEST_GET_CELL_INFO_LIST";
4052 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return "RIL_REQUEST_SET_CELL_INFO_LIST_RATE";
4053 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
4054 case RIL_REQUEST_SET_DATA_PROFILE: return "RIL_REQUEST_SET_DATA_PROFILE";
4055 case RIL_REQUEST_IMS_REGISTRATION_STATE: return "RIL_REQUEST_IMS_REGISTRATION_STATE";
4056 case RIL_REQUEST_IMS_SEND_SMS: return "RIL_REQUEST_IMS_SEND_SMS";
4057 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC";
4058 case RIL_REQUEST_SIM_OPEN_CHANNEL: return "RIL_REQUEST_SIM_OPEN_CHANNEL";
4059 case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "RIL_REQUEST_SIM_CLOSE_CHANNEL";
4060 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL";
4061 case RIL_REQUEST_NV_READ_ITEM: return "RIL_REQUEST_NV_READ_ITEM";
4062 case RIL_REQUEST_NV_WRITE_ITEM: return "RIL_REQUEST_NV_WRITE_ITEM";
4063 case RIL_REQUEST_NV_WRITE_CDMA_PRL: return "RIL_REQUEST_NV_WRITE_CDMA_PRL";
4064 case RIL_REQUEST_NV_RESET_CONFIG: return "RIL_REQUEST_NV_RESET_CONFIG";
4065 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
4066 case RIL_REQUEST_ALLOW_DATA: return "RIL_REQUEST_ALLOW_DATA";
4067 case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
4068 case RIL_REQUEST_SIM_AUTHENTICATION: return "RIL_REQUEST_SIM_AUTHENTICATION";
4069 case RIL_REQUEST_SHUTDOWN: return "RIL_REQUEST_SHUTDOWN";
4070 case RIL_REQUEST_SET_RADIO_CAPABILITY:
4071 return "RIL_REQUEST_SET_RADIO_CAPABILITY";
4072 case RIL_REQUEST_GET_RADIO_CAPABILITY:
4073 return "RIL_REQUEST_GET_RADIO_CAPABILITY";
4074 default: return "<unknown request>";
4079 responseToString(int request)
4082 cat libs/telephony/ril_unsol_commands.h \
4083 | egrep "^ *{RIL_" \
4084 | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
4087 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
4088 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
4089 case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
4090 case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
4091 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
4092 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
4093 case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
4094 case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST";
4095 case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
4096 case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
4097 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
4098 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: return "UNSOL_SUPP_SVC_NOTIFICATION";
4099 case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
4100 case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
4101 case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
4102 case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
4103 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FULL";
4104 case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
4105 case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
4106 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
4107 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_RESPONSE_CDMA_NEW_SMS";
4108 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_RESPONSE_NEW_BROADCAST_SMS";
4109 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
4110 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
4111 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
4112 case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
4113 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
4114 case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
4115 case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
4116 case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
4117 case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
4118 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED";
4119 case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
4120 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
4121 case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
4122 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
4123 case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
4124 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
4125 return "UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED";
4126 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED:
4127 return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
4128 case RIL_UNSOL_SRVCC_STATE_NOTIFY:
4129 return "UNSOL_SRVCC_STATE_NOTIFY";
4130 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED";
4131 case RIL_UNSOL_RADIO_CAPABILITY:
4132 return "RIL_UNSOL_RADIO_CAPABILITY";
4133 case RIL_UNSOL_ON_SS: return "UNSOL_ON_SS";
4134 case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: return "UNSOL_STK_CC_ALPHA_NOTIFY";
4135 default: return "<unknown response>";
4139 private void riljLog(String msg) {
4140 Rlog.d(RILJ_LOG_TAG, msg
4141 + (mInstanceId != null ? (" [SUB" + mInstanceId + "]") : ""));
4144 private void riljLogv(String msg) {
4145 Rlog.v(RILJ_LOG_TAG, msg
4146 + (mInstanceId != null ? (" [SUB" + mInstanceId + "]") : ""));
4149 private void unsljLog(int response) {
4150 riljLog("[UNSL]< " + responseToString(response));
4153 private void unsljLogMore(int response, String more) {
4154 riljLog("[UNSL]< " + responseToString(response) + " " + more);
4157 private void unsljLogRet(int response, Object ret) {
4158 riljLog("[UNSL]< " + responseToString(response) + " " + retToString(response, ret));
4161 private void unsljLogvRet(int response, Object ret) {
4162 riljLogv("[UNSL]< " + responseToString(response) + " " + retToString(response, ret));
4166 responseSsData(Parcel p) {
4168 SsData ssData = new SsData();
4170 ssData.serviceType = ssData.ServiceTypeFromRILInt(p.readInt());
4171 ssData.requestType = ssData.RequestTypeFromRILInt(p.readInt());
4172 ssData.teleserviceType = ssData.TeleserviceTypeFromRILInt(p.readInt());
4173 ssData.serviceClass = p.readInt(); // This is service class sent in the SS request.
4174 ssData.result = p.readInt(); // This is the result of the SS request.
4177 if (ssData.serviceType.isTypeCF() &&
4178 ssData.requestType.isTypeInterrogation()) {
4179 ssData.cfInfo = new CallForwardInfo[num];
4181 for (int i = 0; i < num; i++) {
4182 ssData.cfInfo[i] = new CallForwardInfo();
4184 ssData.cfInfo[i].status = p.readInt();
4185 ssData.cfInfo[i].reason = p.readInt();
4186 ssData.cfInfo[i].serviceClass = p.readInt();
4187 ssData.cfInfo[i].toa = p.readInt();
4188 ssData.cfInfo[i].number = p.readString();
4189 ssData.cfInfo[i].timeSeconds = p.readInt();
4191 riljLog("[SS Data] CF Info " + i + " : " + ssData.cfInfo[i]);
4194 ssData.ssInfo = new int[num];
4195 for (int i = 0; i < num; i++) {
4196 ssData.ssInfo[i] = p.readInt();
4197 riljLog("[SS Data] SS Info " + i + " : " + ssData.ssInfo[i]);
4205 // ***** Methods for CDMA support
4208 getDeviceIdentity(Message response) {
4209 RILRequest rr = RILRequest.obtain(RIL_REQUEST_DEVICE_IDENTITY, response);
4211 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4218 getCDMASubscription(Message response) {
4219 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SUBSCRIPTION, response);
4221 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4227 public void setPhoneType(int phoneType) { // Called by CDMAPhone and GSMPhone constructor
4228 if (RILJ_LOGD) riljLog("setPhoneType=" + phoneType + " old value=" + mPhoneType);
4229 mPhoneType = phoneType;
4236 public void queryCdmaRoamingPreference(Message response) {
4237 RILRequest rr = RILRequest.obtain(
4238 RILConstants.RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, response);
4240 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4249 public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) {
4250 RILRequest rr = RILRequest.obtain(
4251 RILConstants.RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, response);
4253 rr.mParcel.writeInt(1);
4254 rr.mParcel.writeInt(cdmaRoamingType);
4256 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4257 + " : " + cdmaRoamingType);
4266 public void setCdmaSubscriptionSource(int cdmaSubscription , Message response) {
4267 RILRequest rr = RILRequest.obtain(
4268 RILConstants.RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, response);
4270 rr.mParcel.writeInt(1);
4271 rr.mParcel.writeInt(cdmaSubscription);
4273 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4274 + " : " + cdmaSubscription);
4283 public void getCdmaSubscriptionSource(Message response) {
4284 RILRequest rr = RILRequest.obtain(
4285 RILConstants.RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, response);
4287 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4296 public void queryTTYMode(Message response) {
4297 RILRequest rr = RILRequest.obtain(
4298 RILConstants.RIL_REQUEST_QUERY_TTY_MODE, response);
4300 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4309 public void setTTYMode(int ttyMode, Message response) {
4310 RILRequest rr = RILRequest.obtain(
4311 RILConstants.RIL_REQUEST_SET_TTY_MODE, response);
4313 rr.mParcel.writeInt(1);
4314 rr.mParcel.writeInt(ttyMode);
4316 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4327 sendCDMAFeatureCode(String FeatureCode, Message response) {
4328 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_FLASH, response);
4330 rr.mParcel.writeString(FeatureCode);
4332 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4333 + " : " + FeatureCode);
4339 public void getCdmaBroadcastConfig(Message response) {
4340 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, response);
4346 public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message response) {
4347 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response);
4349 // Convert to 1 service category per config (the way RIL takes is)
4350 ArrayList<CdmaSmsBroadcastConfigInfo> processedConfigs =
4351 new ArrayList<CdmaSmsBroadcastConfigInfo>();
4352 for (CdmaSmsBroadcastConfigInfo config : configs) {
4353 for (int i = config.getFromServiceCategory(); i <= config.getToServiceCategory(); i++) {
4354 processedConfigs.add(new CdmaSmsBroadcastConfigInfo(i,
4356 config.getLanguage(),
4357 config.isSelected()));
4361 CdmaSmsBroadcastConfigInfo[] rilConfigs = processedConfigs.toArray(configs);
4362 rr.mParcel.writeInt(rilConfigs.length);
4363 for(int i = 0; i < rilConfigs.length; i++) {
4364 rr.mParcel.writeInt(rilConfigs[i].getFromServiceCategory());
4365 rr.mParcel.writeInt(rilConfigs[i].getLanguage());
4366 rr.mParcel.writeInt(rilConfigs[i].isSelected() ? 1 : 0);
4370 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4371 + " with " + rilConfigs.length + " configs : ");
4372 for (int i = 0; i < rilConfigs.length; i++) {
4373 riljLog(rilConfigs[i].toString());
4381 public void setCdmaBroadcastActivation(boolean activate, Message response) {
4382 RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, response);
4384 rr.mParcel.writeInt(1);
4385 rr.mParcel.writeInt(activate ? 0 :1);
4387 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4396 public void exitEmergencyCallbackMode(Message response) {
4397 RILRequest rr = RILRequest.obtain(RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, response);
4399 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4405 public void requestIsimAuthentication(String nonce, Message response) {
4406 RILRequest rr = RILRequest.obtain(RIL_REQUEST_ISIM_AUTHENTICATION, response);
4408 rr.mParcel.writeString(nonce);
4410 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4416 public void requestIccSimAuthentication(int authContext, String data, String aid,
4418 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SIM_AUTHENTICATION, response);
4420 rr.mParcel.writeInt(authContext);
4421 rr.mParcel.writeString(data);
4422 rr.mParcel.writeString(aid);
4424 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4433 public void getCellInfoList(Message result) {
4434 RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CELL_INFO_LIST, result);
4436 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4445 public void setCellInfoListRate(int rateInMillis, Message response) {
4446 if (RILJ_LOGD) riljLog("setCellInfoListRate: " + rateInMillis);
4447 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, response);
4449 rr.mParcel.writeInt(1);
4450 rr.mParcel.writeInt(rateInMillis);
4452 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4457 public void setInitialAttachApn(String apn, String protocol, int authType, String username,
4458 String password, Message result) {
4459 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_INITIAL_ATTACH_APN, null);
4461 if (RILJ_LOGD) riljLog("Set RIL_REQUEST_SET_INITIAL_ATTACH_APN");
4463 rr.mParcel.writeString(apn);
4464 rr.mParcel.writeString(protocol);
4465 rr.mParcel.writeInt(authType);
4466 rr.mParcel.writeString(username);
4467 rr.mParcel.writeString(password);
4469 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4470 + ", apn:" + apn + ", protocol:" + protocol + ", authType:" + authType
4471 + ", username:" + username + ", password:" + password);
4476 public void setDataProfile(DataProfile[] dps, Message result) {
4477 if (RILJ_LOGD) riljLog("Set RIL_REQUEST_SET_DATA_PROFILE");
4479 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_DATA_PROFILE, null);
4480 DataProfile.toParcel(rr.mParcel, dps);
4483 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4484 + " with " + dps + " Data Profiles : ");
4485 for (int i = 0; i < dps.length; i++) {
4486 riljLog(dps[i].toString());
4494 * @see com.android.internal.telephony.BaseCommands#testingEmergencyCall()
4497 public void testingEmergencyCall() {
4498 if (RILJ_LOGD) riljLog("testingEmergencyCall");
4499 mTestingEmergencyCall.set(true);
4502 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
4503 pw.println("RIL: " + this);
4504 pw.println(" mSocket=" + mSocket);
4505 pw.println(" mSenderThread=" + mSenderThread);
4506 pw.println(" mSender=" + mSender);
4507 pw.println(" mReceiverThread=" + mReceiverThread);
4508 pw.println(" mReceiver=" + mReceiver);
4509 pw.println(" mWakeLock=" + mWakeLock);
4510 pw.println(" mWakeLockTimeout=" + mWakeLockTimeout);
4511 synchronized (mRequestList) {
4512 synchronized (mWakeLock) {
4513 pw.println(" mWakeLockCount=" + mWakeLockCount);
4515 int count = mRequestList.size();
4516 pw.println(" mRequestList count=" + count);
4517 for (int i = 0; i < count; i++) {
4518 RILRequest rr = mRequestList.valueAt(i);
4519 pw.println(" [" + rr.mSerial + "] " + requestToString(rr.mRequest));
4522 pw.println(" mLastNITZTimeInfo=" + mLastNITZTimeInfo);
4523 pw.println(" mTestingEmergencyCall=" + mTestingEmergencyCall.get());
4530 public void iccOpenLogicalChannel(String AID, Message response) {
4531 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SIM_OPEN_CHANNEL, response);
4532 rr.mParcel.writeString(AID);
4535 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4544 public void iccCloseLogicalChannel(int channel, Message response) {
4545 RILRequest rr = RILRequest.obtain(RIL_REQUEST_SIM_CLOSE_CHANNEL, response);
4546 rr.mParcel.writeInt(1);
4547 rr.mParcel.writeInt(channel);
4550 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4559 public void iccTransmitApduLogicalChannel(int channel, int cla, int instruction,
4560 int p1, int p2, int p3, String data, Message response) {
4562 throw new RuntimeException(
4563 "Invalid channel in iccTransmitApduLogicalChannel: " + channel);
4566 iccTransmitApduHelper(RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, channel, cla,
4567 instruction, p1, p2, p3, data, response);
4574 public void iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2,
4575 int p3, String data, Message response) {
4576 iccTransmitApduHelper(RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, 0, cla, instruction,
4577 p1, p2, p3, data, response);
4581 * Helper function for the iccTransmitApdu* commands above.
4583 private void iccTransmitApduHelper(int rilCommand, int channel, int cla,
4584 int instruction, int p1, int p2, int p3, String data, Message response) {
4585 RILRequest rr = RILRequest.obtain(rilCommand, response);
4586 rr.mParcel.writeInt(channel);
4587 rr.mParcel.writeInt(cla);
4588 rr.mParcel.writeInt(instruction);
4589 rr.mParcel.writeInt(p1);
4590 rr.mParcel.writeInt(p2);
4591 rr.mParcel.writeInt(p3);
4592 rr.mParcel.writeString(data);
4595 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
4601 public void nvReadItem(int itemID, Message response) {
4602 RILRequest rr = RILRequest.obtain(RIL_REQUEST_NV_READ_ITEM, response);
4604 rr.mParcel.writeInt(itemID);
4606 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4613 public void nvWriteItem(int itemID, String itemValue, Message response) {
4614 RILRequest rr = RILRequest.obtain(RIL_REQUEST_NV_WRITE_ITEM, response);
4616 rr.mParcel.writeInt(itemID);
4617 rr.mParcel.writeString(itemValue);
4619 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4620 + ' ' + itemID + ": " + itemValue);
4626 public void nvWriteCdmaPrl(byte[] preferredRoamingList, Message response) {
4627 RILRequest rr = RILRequest.obtain(RIL_REQUEST_NV_WRITE_CDMA_PRL, response);
4629 rr.mParcel.writeByteArray(preferredRoamingList);
4631 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4632 + " (" + preferredRoamingList.length + " bytes)");
4638 public void nvResetConfig(int resetType, Message response) {
4639 RILRequest rr = RILRequest.obtain(RIL_REQUEST_NV_RESET_CONFIG, response);
4641 rr.mParcel.writeInt(1);
4642 rr.mParcel.writeInt(resetType);
4644 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4651 public void setRadioCapability(RadioCapability rc, Message response) {
4652 RILRequest rr = RILRequest.obtain(
4653 RIL_REQUEST_SET_RADIO_CAPABILITY, response);
4655 rr.mParcel.writeInt(rc.getVersion());
4656 rr.mParcel.writeInt(rc.getSession());
4657 rr.mParcel.writeInt(rc.getPhase());
4658 rr.mParcel.writeInt(rc.getRadioAccessFamily());
4659 rr.mParcel.writeString(rc.getLogicalModemUuid());
4660 rr.mParcel.writeInt(rc.getStatus());
4663 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
4664 + " " + rc.toString());
4671 public void getRadioCapability(Message response) {
4672 RILRequest rr = RILRequest.obtain(
4673 RIL_REQUEST_GET_RADIO_CAPABILITY, response);
4675 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));