Advertisement
Guest User

Untitled

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