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