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