Guest User

Untitled

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