1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony; 18 19 import static com.android.internal.telephony.RILConstants.*; 20 import static com.android.internal.util.Preconditions.checkNotNull; 21 22 import android.annotation.UnsupportedAppUsage; 23 import android.content.Context; 24 import android.hardware.radio.V1_0.Carrier; 25 import android.hardware.radio.V1_0.CarrierRestrictions; 26 import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo; 27 import android.hardware.radio.V1_0.CdmaSmsAck; 28 import android.hardware.radio.V1_0.CdmaSmsMessage; 29 import android.hardware.radio.V1_0.CdmaSmsWriteArgs; 30 import android.hardware.radio.V1_0.DataProfileId; 31 import android.hardware.radio.V1_0.Dial; 32 import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo; 33 import android.hardware.radio.V1_0.GsmSmsMessage; 34 import android.hardware.radio.V1_0.HardwareConfigModem; 35 import android.hardware.radio.V1_0.IRadio; 36 import android.hardware.radio.V1_0.IccIo; 37 import android.hardware.radio.V1_0.ImsSmsMessage; 38 import android.hardware.radio.V1_0.IndicationFilter; 39 import android.hardware.radio.V1_0.LceDataInfo; 40 import android.hardware.radio.V1_0.MvnoType; 41 import android.hardware.radio.V1_0.NvWriteItem; 42 import android.hardware.radio.V1_0.RadioError; 43 import android.hardware.radio.V1_0.RadioIndicationType; 44 import android.hardware.radio.V1_0.RadioResponseInfo; 45 import android.hardware.radio.V1_0.RadioResponseType; 46 import android.hardware.radio.V1_0.ResetNvType; 47 import android.hardware.radio.V1_0.SelectUiccSub; 48 import android.hardware.radio.V1_0.SimApdu; 49 import android.hardware.radio.V1_0.SmsWriteArgs; 50 import android.hardware.radio.V1_0.UusInfo; 51 import android.hardware.radio.V1_2.AccessNetwork; 52 import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; 53 import android.hardware.radio.V1_4.SimLockMultiSimPolicy; 54 import android.hardware.radio.deprecated.V1_0.IOemHook; 55 import android.net.ConnectivityManager; 56 import android.net.KeepalivePacketData; 57 import android.net.LinkAddress; 58 import android.net.LinkProperties; 59 import android.net.NetworkUtils; 60 import android.os.AsyncResult; 61 import android.os.Build; 62 import android.os.Handler; 63 import android.os.HwBinder; 64 import android.os.Message; 65 import android.os.PowerManager; 66 import android.os.PowerManager.WakeLock; 67 import android.os.RemoteException; 68 import android.os.SystemClock; 69 import android.os.SystemProperties; 70 import android.os.WorkSource; 71 import android.provider.Settings; 72 import android.service.carrier.CarrierIdentifier; 73 import android.telephony.AccessNetworkConstants.AccessNetworkType; 74 import android.telephony.CarrierRestrictionRules; 75 import android.telephony.CellInfo; 76 import android.telephony.ClientRequestStats; 77 import android.telephony.ImsiEncryptionInfo; 78 import android.telephony.ModemActivityInfo; 79 import android.telephony.NeighboringCellInfo; 80 import android.telephony.NetworkScanRequest; 81 import android.telephony.PhoneNumberUtils; 82 import android.telephony.RadioAccessFamily; 83 import android.telephony.RadioAccessSpecifier; 84 import android.telephony.Rlog; 85 import android.telephony.ServiceState; 86 import android.telephony.SmsManager; 87 import android.telephony.TelephonyHistogram; 88 import android.telephony.TelephonyManager; 89 import android.telephony.TelephonyManager.PrefNetworkMode; 90 import android.telephony.data.ApnSetting; 91 import android.telephony.data.DataCallResponse; 92 import android.telephony.data.DataProfile; 93 import android.telephony.data.DataService; 94 import android.telephony.emergency.EmergencyNumber; 95 import android.text.TextUtils; 96 import android.util.Log; 97 import android.util.SparseArray; 98 99 import com.android.internal.annotations.VisibleForTesting; 100 import com.android.internal.telephony.cat.ComprehensionTlv; 101 import com.android.internal.telephony.cat.ComprehensionTlvTag; 102 import com.android.internal.telephony.cdma.CdmaInformationRecords; 103 import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo; 104 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; 105 import com.android.internal.telephony.metrics.TelephonyMetrics; 106 import com.android.internal.telephony.nano.TelephonyProto.SmsSession; 107 import com.android.internal.telephony.uicc.IccUtils; 108 109 import java.io.ByteArrayInputStream; 110 import java.io.DataInputStream; 111 import java.io.FileDescriptor; 112 import java.io.IOException; 113 import java.io.PrintWriter; 114 import java.net.Inet4Address; 115 import java.net.Inet6Address; 116 import java.net.InetAddress; 117 import java.util.ArrayList; 118 import java.util.Arrays; 119 import java.util.HashSet; 120 import java.util.List; 121 import java.util.NoSuchElementException; 122 import java.util.Set; 123 import java.util.concurrent.atomic.AtomicBoolean; 124 import java.util.concurrent.atomic.AtomicLong; 125 126 /** 127 * RIL implementation of the CommandsInterface. 128 * 129 * {@hide} 130 */ 131 public class RIL extends BaseCommands implements CommandsInterface { 132 static final String RILJ_LOG_TAG = "RILJ"; 133 static final String RILJ_WAKELOCK_TAG = "*telephony-radio*"; 134 // Have a separate wakelock instance for Ack 135 static final String RILJ_ACK_WAKELOCK_NAME = "RILJ_ACK_WL"; 136 static final boolean RILJ_LOGD = true; 137 static final boolean RILJ_LOGV = false; // STOPSHIP if true 138 static final int RIL_HISTOGRAM_BUCKET_COUNT = 5; 139 140 /** 141 * Wake lock timeout should be longer than the longest timeout in 142 * the vendor ril. 143 */ 144 private static final int DEFAULT_WAKE_LOCK_TIMEOUT_MS = 60000; 145 146 // Wake lock default timeout associated with ack 147 private static final int DEFAULT_ACK_WAKE_LOCK_TIMEOUT_MS = 200; 148 149 private static final int DEFAULT_BLOCKING_MESSAGE_RESPONSE_TIMEOUT_MS = 2000; 150 151 // Variables used to differentiate ack messages from request while calling clearWakeLock() 152 public static final int INVALID_WAKELOCK = -1; 153 public static final int FOR_WAKELOCK = 0; 154 public static final int FOR_ACK_WAKELOCK = 1; 155 private final ClientWakelockTracker mClientWakelockTracker = new ClientWakelockTracker(); 156 157 /** @hide */ 158 public static final HalVersion RADIO_HAL_VERSION_UNKNOWN = HalVersion.UNKNOWN; 159 160 /** @hide */ 161 public static final HalVersion RADIO_HAL_VERSION_1_0 = new HalVersion(1, 0); 162 163 /** @hide */ 164 public static final HalVersion RADIO_HAL_VERSION_1_1 = new HalVersion(1, 1); 165 166 /** @hide */ 167 public static final HalVersion RADIO_HAL_VERSION_1_2 = new HalVersion(1, 2); 168 169 /** @hide */ 170 public static final HalVersion RADIO_HAL_VERSION_1_3 = new HalVersion(1, 3); 171 172 /** @hide */ 173 public static final HalVersion RADIO_HAL_VERSION_1_4 = new HalVersion(1, 4); 174 175 // IRadio version 176 private HalVersion mRadioVersion = RADIO_HAL_VERSION_UNKNOWN; 177 178 //***** Instance Variables 179 180 @UnsupportedAppUsage 181 final WakeLock mWakeLock; // Wake lock associated with request/response 182 final WakeLock mAckWakeLock; // Wake lock associated with ack sent 183 final int mWakeLockTimeout; // Timeout associated with request/response 184 final int mAckWakeLockTimeout; // Timeout associated with ack sent 185 // The number of wakelock requests currently active. Don't release the lock 186 // until dec'd to 0 187 int mWakeLockCount; 188 189 // Variables used to identify releasing of WL on wakelock timeouts 190 volatile int mWlSequenceNum = 0; 191 volatile int mAckWlSequenceNum = 0; 192 193 @UnsupportedAppUsage 194 SparseArray<RILRequest> mRequestList = new SparseArray<RILRequest>(); 195 static SparseArray<TelephonyHistogram> mRilTimeHistograms = new 196 SparseArray<TelephonyHistogram>(); 197 198 Object[] mLastNITZTimeInfo; 199 200 // When we are testing emergency calls 201 @UnsupportedAppUsage 202 AtomicBoolean mTestingEmergencyCall = new AtomicBoolean(false); 203 204 final Integer mPhoneId; 205 206 /** 207 * A set that records if radio service is disabled in hal for 208 * a specific phone id slot to avoid further getService request. 209 */ 210 Set<Integer> mDisabledRadioServices = new HashSet(); 211 212 /** 213 * A set that records if oem hook service is disabled in hal for 214 * a specific phone id slot to avoid further getService request. 215 */ 216 Set<Integer> mDisabledOemHookServices = new HashSet(); 217 218 /* default work source which will blame phone process */ 219 private WorkSource mRILDefaultWorkSource; 220 221 /* Worksource containing all applications causing wakelock to be held */ 222 private WorkSource mActiveWakelockWorkSource; 223 224 /** Telephony metrics instance for logging metrics event */ 225 private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance(); 226 /** Radio bug detector instance */ 227 private RadioBugDetector mRadioBugDetector = null; 228 229 boolean mIsMobileNetworkSupported; 230 RadioResponse mRadioResponse; 231 RadioIndication mRadioIndication; 232 volatile IRadio mRadioProxy = null; 233 OemHookResponse mOemHookResponse; 234 OemHookIndication mOemHookIndication; 235 volatile IOemHook mOemHookProxy = null; 236 final AtomicLong mRadioProxyCookie = new AtomicLong(0); 237 final RadioProxyDeathRecipient mRadioProxyDeathRecipient; 238 final RilHandler mRilHandler; 239 240 //***** Events 241 static final int EVENT_WAKE_LOCK_TIMEOUT = 2; 242 static final int EVENT_ACK_WAKE_LOCK_TIMEOUT = 4; 243 static final int EVENT_BLOCKING_RESPONSE_TIMEOUT = 5; 244 static final int EVENT_RADIO_PROXY_DEAD = 6; 245 246 //***** Constants 247 248 static final String[] HIDL_SERVICE_NAME = {"slot1", "slot2", "slot3"}; 249 250 static final int IRADIO_GET_SERVICE_DELAY_MILLIS = 4 * 1000; 251 252 static final String EMPTY_ALPHA_LONG = ""; 253 static final String EMPTY_ALPHA_SHORT = ""; 254 getTelephonyRILTimingHistograms()255 public static List<TelephonyHistogram> getTelephonyRILTimingHistograms() { 256 List<TelephonyHistogram> list; 257 synchronized (mRilTimeHistograms) { 258 list = new ArrayList<>(mRilTimeHistograms.size()); 259 for (int i = 0; i < mRilTimeHistograms.size(); i++) { 260 TelephonyHistogram entry = new TelephonyHistogram(mRilTimeHistograms.valueAt(i)); 261 list.add(entry); 262 } 263 } 264 return list; 265 } 266 267 /** The handler used to handle the internal event of RIL. */ 268 @VisibleForTesting 269 public class RilHandler extends Handler { 270 271 //***** Handler implementation 272 @Override handleMessage(Message msg)273 public void handleMessage(Message msg) { 274 RILRequest rr; 275 276 switch (msg.what) { 277 case EVENT_WAKE_LOCK_TIMEOUT: 278 // Haven't heard back from the last request. Assume we're 279 // not getting a response and release the wake lock. 280 281 // The timer of WAKE_LOCK_TIMEOUT is reset with each 282 // new send request. So when WAKE_LOCK_TIMEOUT occurs 283 // all requests in mRequestList already waited at 284 // least DEFAULT_WAKE_LOCK_TIMEOUT_MS but no response. 285 // 286 // Note: Keep mRequestList so that delayed response 287 // can still be handled when response finally comes. 288 289 synchronized (mRequestList) { 290 if (msg.arg1 == mWlSequenceNum && clearWakeLock(FOR_WAKELOCK)) { 291 if (mRadioBugDetector != null) { 292 mRadioBugDetector.processWakelockTimeout(); 293 } 294 if (RILJ_LOGD) { 295 int count = mRequestList.size(); 296 Rlog.d(RILJ_LOG_TAG, "WAKE_LOCK_TIMEOUT " + 297 " mRequestList=" + count); 298 for (int i = 0; i < count; i++) { 299 rr = mRequestList.valueAt(i); 300 Rlog.d(RILJ_LOG_TAG, i + ": [" + rr.mSerial + "] " 301 + requestToString(rr.mRequest)); 302 } 303 } 304 } 305 } 306 break; 307 308 case EVENT_ACK_WAKE_LOCK_TIMEOUT: 309 if (msg.arg1 == mAckWlSequenceNum && clearWakeLock(FOR_ACK_WAKELOCK)) { 310 if (RILJ_LOGV) { 311 Rlog.d(RILJ_LOG_TAG, "ACK_WAKE_LOCK_TIMEOUT"); 312 } 313 } 314 break; 315 316 case EVENT_BLOCKING_RESPONSE_TIMEOUT: 317 int serial = msg.arg1; 318 rr = findAndRemoveRequestFromList(serial); 319 // If the request has already been processed, do nothing 320 if(rr == null) { 321 break; 322 } 323 324 //build a response if expected 325 if (rr.mResult != null) { 326 Object timeoutResponse = getResponseForTimedOutRILRequest(rr); 327 AsyncResult.forMessage( rr.mResult, timeoutResponse, null); 328 rr.mResult.sendToTarget(); 329 mMetrics.writeOnRilTimeoutResponse(mPhoneId, rr.mSerial, rr.mRequest); 330 } 331 332 decrementWakeLock(rr); 333 rr.release(); 334 break; 335 336 case EVENT_RADIO_PROXY_DEAD: 337 riljLog("handleMessage: EVENT_RADIO_PROXY_DEAD cookie = " + msg.obj + 338 " mRadioProxyCookie = " + mRadioProxyCookie.get()); 339 if ((long) msg.obj == mRadioProxyCookie.get()) { 340 resetProxyAndRequestList(); 341 } 342 break; 343 } 344 } 345 } 346 347 /** Return RadioBugDetector instance for testing. */ 348 @VisibleForTesting getRadioBugDetector()349 public RadioBugDetector getRadioBugDetector() { 350 if (mRadioBugDetector == null) { 351 mRadioBugDetector = new RadioBugDetector(mContext, mPhoneId); 352 } 353 return mRadioBugDetector; 354 } 355 356 /** 357 * In order to prevent calls to Telephony from waiting indefinitely 358 * low-latency blocking calls will eventually time out. In the event of 359 * a timeout, this function generates a response that is returned to the 360 * higher layers to unblock the call. This is in lieu of a meaningful 361 * response. 362 * @param rr The RIL Request that has timed out. 363 * @return A default object, such as the one generated by a normal response 364 * that is returned to the higher layers. 365 **/ 366 @UnsupportedAppUsage getResponseForTimedOutRILRequest(RILRequest rr)367 private static Object getResponseForTimedOutRILRequest(RILRequest rr) { 368 if (rr == null ) return null; 369 370 Object timeoutResponse = null; 371 switch(rr.mRequest) { 372 case RIL_REQUEST_GET_ACTIVITY_INFO: 373 timeoutResponse = new ModemActivityInfo( 374 0, 0, 0, new int [ModemActivityInfo.TX_POWER_LEVELS], 0, 0); 375 break; 376 }; 377 return timeoutResponse; 378 } 379 380 final class RadioProxyDeathRecipient implements HwBinder.DeathRecipient { 381 @Override serviceDied(long cookie)382 public void serviceDied(long cookie) { 383 // Deal with service going away 384 riljLog("serviceDied"); 385 mRilHandler.sendMessage(mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD, cookie)); 386 } 387 } 388 resetProxyAndRequestList()389 private void resetProxyAndRequestList() { 390 mRadioProxy = null; 391 mOemHookProxy = null; 392 393 // increment the cookie so that death notification can be ignored 394 mRadioProxyCookie.incrementAndGet(); 395 396 setRadioState(TelephonyManager.RADIO_POWER_UNAVAILABLE, true /* forceNotifyRegistrants */); 397 398 RILRequest.resetSerial(); 399 // Clear request list on close 400 clearRequestList(RADIO_NOT_AVAILABLE, false); 401 402 getRadioProxy(null); 403 getOemHookProxy(null); 404 } 405 406 /** Returns a {@link IRadio} instance or null if the service is not available. */ 407 @VisibleForTesting getRadioProxy(Message result)408 public synchronized IRadio getRadioProxy(Message result) { 409 if (!mIsMobileNetworkSupported) { 410 if (RILJ_LOGV) riljLog("getRadioProxy: Not calling getService(): wifi-only"); 411 if (result != null) { 412 AsyncResult.forMessage(result, null, 413 CommandException.fromRilErrno(RADIO_NOT_AVAILABLE)); 414 result.sendToTarget(); 415 } 416 return null; 417 } 418 419 if (mRadioProxy != null) { 420 return mRadioProxy; 421 } 422 423 try { 424 if (mDisabledRadioServices.contains(mPhoneId)) { 425 riljLoge("getRadioProxy: mRadioProxy for " + HIDL_SERVICE_NAME[mPhoneId] 426 + " is disabled"); 427 } else { 428 try { 429 mRadioProxy = android.hardware.radio.V1_4.IRadio.getService( 430 HIDL_SERVICE_NAME[mPhoneId], true); 431 mRadioVersion = RADIO_HAL_VERSION_1_4; 432 } catch (NoSuchElementException e) { 433 } 434 435 if (mRadioProxy == null) { 436 try { 437 mRadioProxy = android.hardware.radio.V1_3.IRadio.getService( 438 HIDL_SERVICE_NAME[mPhoneId], true); 439 mRadioVersion = RADIO_HAL_VERSION_1_3; 440 } catch (NoSuchElementException e) { 441 } 442 } 443 444 if (mRadioProxy == null) { 445 try { 446 mRadioProxy = android.hardware.radio.V1_2.IRadio.getService( 447 HIDL_SERVICE_NAME[mPhoneId], true); 448 mRadioVersion = RADIO_HAL_VERSION_1_2; 449 } catch (NoSuchElementException e) { 450 } 451 } 452 453 if (mRadioProxy == null) { 454 try { 455 mRadioProxy = android.hardware.radio.V1_1.IRadio.getService( 456 HIDL_SERVICE_NAME[mPhoneId], true); 457 mRadioVersion = RADIO_HAL_VERSION_1_1; 458 } catch (NoSuchElementException e) { 459 } 460 } 461 462 if (mRadioProxy == null) { 463 try { 464 mRadioProxy = android.hardware.radio.V1_0.IRadio.getService( 465 HIDL_SERVICE_NAME[mPhoneId], true); 466 mRadioVersion = RADIO_HAL_VERSION_1_0; 467 } catch (NoSuchElementException e) { 468 } 469 } 470 471 if (mRadioProxy != null) { 472 mRadioProxy.linkToDeath(mRadioProxyDeathRecipient, 473 mRadioProxyCookie.incrementAndGet()); 474 mRadioProxy.setResponseFunctions(mRadioResponse, mRadioIndication); 475 } else { 476 mDisabledRadioServices.add(mPhoneId); 477 riljLoge("getRadioProxy: mRadioProxy for " 478 + HIDL_SERVICE_NAME[mPhoneId] + " is disabled"); 479 } 480 } 481 } catch (RemoteException e) { 482 mRadioProxy = null; 483 riljLoge("RadioProxy getService/setResponseFunctions: " + e); 484 } 485 486 if (mRadioProxy == null) { 487 // getService() is a blocking call, so this should never happen 488 riljLoge("getRadioProxy: mRadioProxy == null"); 489 if (result != null) { 490 AsyncResult.forMessage(result, null, 491 CommandException.fromRilErrno(RADIO_NOT_AVAILABLE)); 492 result.sendToTarget(); 493 } 494 } 495 496 return mRadioProxy; 497 } 498 499 /** Returns an {@link IOemHook} instance or null if the service is not available. */ 500 @VisibleForTesting getOemHookProxy(Message result)501 public synchronized IOemHook getOemHookProxy(Message result) { 502 if (!mIsMobileNetworkSupported) { 503 if (RILJ_LOGV) riljLog("getOemHookProxy: Not calling getService(): wifi-only"); 504 if (result != null) { 505 AsyncResult.forMessage(result, null, 506 CommandException.fromRilErrno(RADIO_NOT_AVAILABLE)); 507 result.sendToTarget(); 508 } 509 return null; 510 } 511 512 if (mOemHookProxy != null) { 513 return mOemHookProxy; 514 } 515 516 try { 517 if (mDisabledOemHookServices.contains(mPhoneId)) { 518 riljLoge("getOemHookProxy: mOemHookProxy for " + HIDL_SERVICE_NAME[mPhoneId] 519 + " is disabled"); 520 } else { 521 mOemHookProxy = IOemHook.getService(HIDL_SERVICE_NAME[mPhoneId], true); 522 if (mOemHookProxy != null) { 523 // not calling linkToDeath() as ril service runs in the same process and death 524 // notification for that should be sufficient 525 mOemHookProxy.setResponseFunctions(mOemHookResponse, mOemHookIndication); 526 } else { 527 mDisabledOemHookServices.add(mPhoneId); 528 riljLoge("getOemHookProxy: mOemHookProxy for " + HIDL_SERVICE_NAME[mPhoneId] 529 + " is disabled"); 530 } 531 } 532 } catch (NoSuchElementException e) { 533 mOemHookProxy = null; 534 riljLoge("IOemHook service is not on the device HAL: " + e); 535 } catch (RemoteException e) { 536 mOemHookProxy = null; 537 riljLoge("OemHookProxy getService/setResponseFunctions: " + e); 538 } 539 540 if (mOemHookProxy == null) { 541 if (result != null) { 542 AsyncResult.forMessage(result, null, 543 CommandException.fromRilErrno(RADIO_NOT_AVAILABLE)); 544 result.sendToTarget(); 545 } 546 } 547 548 return mOemHookProxy; 549 } 550 551 //***** Constructors 552 553 @UnsupportedAppUsage RIL(Context context, int preferredNetworkType, int cdmaSubscription)554 public RIL(Context context, int preferredNetworkType, int cdmaSubscription) { 555 this(context, preferredNetworkType, cdmaSubscription, null); 556 } 557 558 @UnsupportedAppUsage RIL(Context context, int preferredNetworkType, int cdmaSubscription, Integer instanceId)559 public RIL(Context context, int preferredNetworkType, 560 int cdmaSubscription, Integer instanceId) { 561 super(context); 562 if (RILJ_LOGD) { 563 riljLog("RIL: init preferredNetworkType=" + preferredNetworkType 564 + " cdmaSubscription=" + cdmaSubscription + ")"); 565 } 566 567 mContext = context; 568 mCdmaSubscription = cdmaSubscription; 569 mPreferredNetworkType = preferredNetworkType; 570 mPhoneType = RILConstants.NO_PHONE; 571 mPhoneId = instanceId == null ? 0 : instanceId; 572 if (isRadioBugDetectionEnabled()) { 573 mRadioBugDetector = new RadioBugDetector(context, mPhoneId); 574 } 575 576 ConnectivityManager cm = (ConnectivityManager)context.getSystemService( 577 Context.CONNECTIVITY_SERVICE); 578 mIsMobileNetworkSupported = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE); 579 580 mRadioResponse = new RadioResponse(this); 581 mRadioIndication = new RadioIndication(this); 582 mOemHookResponse = new OemHookResponse(this); 583 mOemHookIndication = new OemHookIndication(this); 584 mRilHandler = new RilHandler(); 585 mRadioProxyDeathRecipient = new RadioProxyDeathRecipient(); 586 587 PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); 588 mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RILJ_WAKELOCK_TAG); 589 mWakeLock.setReferenceCounted(false); 590 mAckWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RILJ_ACK_WAKELOCK_NAME); 591 mAckWakeLock.setReferenceCounted(false); 592 mWakeLockTimeout = SystemProperties.getInt(TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT, 593 DEFAULT_WAKE_LOCK_TIMEOUT_MS); 594 mAckWakeLockTimeout = SystemProperties.getInt( 595 TelephonyProperties.PROPERTY_WAKE_LOCK_TIMEOUT, DEFAULT_ACK_WAKE_LOCK_TIMEOUT_MS); 596 mWakeLockCount = 0; 597 mRILDefaultWorkSource = new WorkSource(context.getApplicationInfo().uid, 598 context.getPackageName()); 599 mActiveWakelockWorkSource = new WorkSource(); 600 601 TelephonyDevController tdc = TelephonyDevController.getInstance(); 602 tdc.registerRIL(this); 603 604 // set radio callback; needed to set RadioIndication callback (should be done after 605 // wakelock stuff is initialized above as callbacks are received on separate binder threads) 606 getRadioProxy(null); 607 getOemHookProxy(null); 608 609 if (RILJ_LOGD) { 610 riljLog("Radio HAL version: " + mRadioVersion); 611 } 612 } 613 isRadioBugDetectionEnabled()614 private boolean isRadioBugDetectionEnabled() { 615 return Settings.Global.getInt( 616 mContext.getContentResolver(), 617 Settings.Global.ENABLE_RADIO_BUG_DETECTION, 618 0) != 0; 619 } 620 621 @Override setOnNITZTime(Handler h, int what, Object obj)622 public void setOnNITZTime(Handler h, int what, Object obj) { 623 super.setOnNITZTime(h, what, obj); 624 625 // Send the last NITZ time if we have it 626 if (mLastNITZTimeInfo != null) { 627 mNITZTimeRegistrant 628 .notifyRegistrant( 629 new AsyncResult (null, mLastNITZTimeInfo, null)); 630 } 631 } 632 addRequest(RILRequest rr)633 private void addRequest(RILRequest rr) { 634 acquireWakeLock(rr, FOR_WAKELOCK); 635 synchronized (mRequestList) { 636 rr.mStartTimeMs = SystemClock.elapsedRealtime(); 637 mRequestList.append(rr.mSerial, rr); 638 } 639 } 640 obtainRequest(int request, Message result, WorkSource workSource)641 private RILRequest obtainRequest(int request, Message result, WorkSource workSource) { 642 RILRequest rr = RILRequest.obtain(request, result, workSource); 643 addRequest(rr); 644 return rr; 645 } 646 handleRadioProxyExceptionForRR(RILRequest rr, String caller, Exception e)647 private void handleRadioProxyExceptionForRR(RILRequest rr, String caller, Exception e) { 648 riljLoge(caller + ": " + e); 649 resetProxyAndRequestList(); 650 } 651 convertNullToEmptyString(String string)652 private static String convertNullToEmptyString(String string) { 653 return string != null ? string : ""; 654 } 655 656 @Override getIccCardStatus(Message result)657 public void getIccCardStatus(Message result) { 658 IRadio radioProxy = getRadioProxy(result); 659 if (radioProxy != null) { 660 RILRequest rr = obtainRequest(RIL_REQUEST_GET_SIM_STATUS, result, 661 mRILDefaultWorkSource); 662 663 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 664 665 try { 666 radioProxy.getIccCardStatus(rr.mSerial); 667 } catch (RemoteException | RuntimeException e) { 668 handleRadioProxyExceptionForRR(rr, "getIccCardStatus", e); 669 } 670 } 671 } 672 673 @Override getIccSlotsStatus(Message result)674 public void getIccSlotsStatus(Message result) { 675 if (result != null) { 676 AsyncResult.forMessage(result, null, 677 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 678 result.sendToTarget(); 679 } 680 } 681 682 @Override setLogicalToPhysicalSlotMapping(int[] physicalSlots, Message result)683 public void setLogicalToPhysicalSlotMapping(int[] physicalSlots, Message result) { 684 if (result != null) { 685 AsyncResult.forMessage(result, null, 686 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 687 result.sendToTarget(); 688 } 689 } 690 691 @Override supplyIccPin(String pin, Message result)692 public void supplyIccPin(String pin, Message result) { 693 supplyIccPinForApp(pin, null, result); 694 } 695 696 @Override supplyIccPinForApp(String pin, String aid, Message result)697 public void supplyIccPinForApp(String pin, String aid, Message result) { 698 IRadio radioProxy = getRadioProxy(result); 699 if (radioProxy != null) { 700 RILRequest rr = obtainRequest(RIL_REQUEST_ENTER_SIM_PIN, result, 701 mRILDefaultWorkSource); 702 703 if (RILJ_LOGD) { 704 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 705 + " aid = " + aid); 706 } 707 708 try { 709 radioProxy.supplyIccPinForApp(rr.mSerial, 710 convertNullToEmptyString(pin), 711 convertNullToEmptyString(aid)); 712 } catch (RemoteException | RuntimeException e) { 713 handleRadioProxyExceptionForRR(rr, "supplyIccPinForApp", e); 714 } 715 } 716 } 717 718 @Override supplyIccPuk(String puk, String newPin, Message result)719 public void supplyIccPuk(String puk, String newPin, Message result) { 720 supplyIccPukForApp(puk, newPin, null, result); 721 } 722 723 @Override supplyIccPukForApp(String puk, String newPin, String aid, Message result)724 public void supplyIccPukForApp(String puk, String newPin, String aid, Message result) { 725 IRadio radioProxy = getRadioProxy(result); 726 if (radioProxy != null) { 727 RILRequest rr = obtainRequest(RIL_REQUEST_ENTER_SIM_PUK, result, 728 mRILDefaultWorkSource); 729 730 if (RILJ_LOGD) { 731 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 732 + " aid = " + aid); 733 } 734 735 try { 736 radioProxy.supplyIccPukForApp(rr.mSerial, 737 convertNullToEmptyString(puk), 738 convertNullToEmptyString(newPin), 739 convertNullToEmptyString(aid)); 740 } catch (RemoteException | RuntimeException e) { 741 handleRadioProxyExceptionForRR(rr, "supplyIccPukForApp", e); 742 } 743 } 744 } 745 746 @Override supplyIccPin2(String pin, Message result)747 public void supplyIccPin2(String pin, Message result) { 748 supplyIccPin2ForApp(pin, null, result); 749 } 750 751 @Override supplyIccPin2ForApp(String pin, String aid, Message result)752 public void supplyIccPin2ForApp(String pin, String aid, Message result) { 753 IRadio radioProxy = getRadioProxy(result); 754 if (radioProxy != null) { 755 RILRequest rr = obtainRequest(RIL_REQUEST_ENTER_SIM_PIN2, result, 756 mRILDefaultWorkSource); 757 758 if (RILJ_LOGD) { 759 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 760 + " aid = " + aid); 761 } 762 763 try { 764 radioProxy.supplyIccPin2ForApp(rr.mSerial, 765 convertNullToEmptyString(pin), 766 convertNullToEmptyString(aid)); 767 } catch (RemoteException | RuntimeException e) { 768 handleRadioProxyExceptionForRR(rr, "supplyIccPin2ForApp", e); 769 } 770 } 771 } 772 773 @Override supplyIccPuk2(String puk2, String newPin2, Message result)774 public void supplyIccPuk2(String puk2, String newPin2, Message result) { 775 supplyIccPuk2ForApp(puk2, newPin2, null, result); 776 } 777 778 @Override supplyIccPuk2ForApp(String puk, String newPin2, String aid, Message result)779 public void supplyIccPuk2ForApp(String puk, String newPin2, String aid, Message result) { 780 IRadio radioProxy = getRadioProxy(result); 781 if (radioProxy != null) { 782 RILRequest rr = obtainRequest(RIL_REQUEST_ENTER_SIM_PUK2, result, 783 mRILDefaultWorkSource); 784 785 if (RILJ_LOGD) { 786 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 787 + " aid = " + aid); 788 } 789 790 try { 791 radioProxy.supplyIccPuk2ForApp(rr.mSerial, 792 convertNullToEmptyString(puk), 793 convertNullToEmptyString(newPin2), 794 convertNullToEmptyString(aid)); 795 } catch (RemoteException | RuntimeException e) { 796 handleRadioProxyExceptionForRR(rr, "supplyIccPuk2ForApp", e); 797 } 798 } 799 } 800 801 @Override changeIccPin(String oldPin, String newPin, Message result)802 public void changeIccPin(String oldPin, String newPin, Message result) { 803 changeIccPinForApp(oldPin, newPin, null, result); 804 } 805 806 @Override changeIccPinForApp(String oldPin, String newPin, String aid, Message result)807 public void changeIccPinForApp(String oldPin, String newPin, String aid, Message result) { 808 IRadio radioProxy = getRadioProxy(result); 809 if (radioProxy != null) { 810 RILRequest rr = obtainRequest(RIL_REQUEST_CHANGE_SIM_PIN, result, 811 mRILDefaultWorkSource); 812 813 if (RILJ_LOGD) { 814 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " oldPin = " 815 + oldPin + " newPin = " + newPin + " aid = " + aid); 816 } 817 818 try { 819 radioProxy.changeIccPinForApp(rr.mSerial, 820 convertNullToEmptyString(oldPin), 821 convertNullToEmptyString(newPin), 822 convertNullToEmptyString(aid)); 823 } catch (RemoteException | RuntimeException e) { 824 handleRadioProxyExceptionForRR(rr, "changeIccPinForApp", e); 825 } 826 } 827 } 828 829 @Override changeIccPin2(String oldPin2, String newPin2, Message result)830 public void changeIccPin2(String oldPin2, String newPin2, Message result) { 831 changeIccPin2ForApp(oldPin2, newPin2, null, result); 832 } 833 834 @Override changeIccPin2ForApp(String oldPin2, String newPin2, String aid, Message result)835 public void changeIccPin2ForApp(String oldPin2, String newPin2, String aid, Message result) { 836 IRadio radioProxy = getRadioProxy(result); 837 if (radioProxy != null) { 838 RILRequest rr = obtainRequest(RIL_REQUEST_CHANGE_SIM_PIN2, result, 839 mRILDefaultWorkSource); 840 841 if (RILJ_LOGD) { 842 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " oldPin = " 843 + oldPin2 + " newPin = " + newPin2 + " aid = " + aid); 844 } 845 846 try { 847 radioProxy.changeIccPin2ForApp(rr.mSerial, 848 convertNullToEmptyString(oldPin2), 849 convertNullToEmptyString(newPin2), 850 convertNullToEmptyString(aid)); 851 } catch (RemoteException | RuntimeException e) { 852 handleRadioProxyExceptionForRR(rr, "changeIccPin2ForApp", e); 853 } 854 } 855 } 856 857 @Override supplyNetworkDepersonalization(String netpin, Message result)858 public void supplyNetworkDepersonalization(String netpin, Message result) { 859 IRadio radioProxy = getRadioProxy(result); 860 if (radioProxy != null) { 861 RILRequest rr = obtainRequest(RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, result, 862 mRILDefaultWorkSource); 863 864 if (RILJ_LOGD) { 865 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " netpin = " 866 + netpin); 867 } 868 869 try { 870 radioProxy.supplyNetworkDepersonalization(rr.mSerial, 871 convertNullToEmptyString(netpin)); 872 } catch (RemoteException | RuntimeException e) { 873 handleRadioProxyExceptionForRR(rr, "supplyNetworkDepersonalization", e); 874 } 875 } 876 } 877 878 @Override getCurrentCalls(Message result)879 public void getCurrentCalls(Message result) { 880 IRadio radioProxy = getRadioProxy(result); 881 if (radioProxy != null) { 882 RILRequest rr = obtainRequest(RIL_REQUEST_GET_CURRENT_CALLS, result, 883 mRILDefaultWorkSource); 884 885 if (RILJ_LOGD) { 886 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 887 } 888 889 try { 890 radioProxy.getCurrentCalls(rr.mSerial); 891 } catch (RemoteException | RuntimeException e) { 892 handleRadioProxyExceptionForRR(rr, "getCurrentCalls", e); 893 } 894 } 895 } 896 897 @Override dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo, boolean hasKnownUserIntentEmergency, int clirMode, Message result)898 public void dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo, 899 boolean hasKnownUserIntentEmergency, int clirMode, Message result) { 900 dial(address, isEmergencyCall, emergencyNumberInfo, hasKnownUserIntentEmergency, 901 clirMode, null, result); 902 } 903 904 @Override enableModem(boolean enable, Message result)905 public void enableModem(boolean enable, Message result) { 906 IRadio radioProxy = getRadioProxy(result); 907 if (mRadioVersion.less(RADIO_HAL_VERSION_1_3)) { 908 if (RILJ_LOGV) riljLog("enableModem: not supported."); 909 if (result != null) { 910 AsyncResult.forMessage(result, null, 911 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 912 result.sendToTarget(); 913 } 914 return; 915 } 916 917 android.hardware.radio.V1_3.IRadio radioProxy13 = 918 (android.hardware.radio.V1_3.IRadio) radioProxy; 919 if (radioProxy13 != null) { 920 RILRequest rr = obtainRequest(RIL_REQUEST_ENABLE_MODEM, result, 921 mRILDefaultWorkSource); 922 923 if (RILJ_LOGD) { 924 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " enable = " 925 + enable); 926 } 927 928 try { 929 radioProxy13.enableModem(rr.mSerial, enable); 930 } catch (RemoteException | RuntimeException e) { 931 handleRadioProxyExceptionForRR(rr, "enableModem", e); 932 } 933 } 934 } 935 936 @Override getModemStatus(Message result)937 public void getModemStatus(Message result) { 938 IRadio radioProxy = getRadioProxy(result); 939 if (mRadioVersion.less(RADIO_HAL_VERSION_1_3)) { 940 if (RILJ_LOGV) riljLog("getModemStatus: not supported."); 941 if (result != null) { 942 AsyncResult.forMessage(result, null, 943 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 944 result.sendToTarget(); 945 } 946 return; 947 } 948 949 android.hardware.radio.V1_3.IRadio radioProxy13 = 950 (android.hardware.radio.V1_3.IRadio) radioProxy; 951 if (radioProxy13 != null) { 952 RILRequest rr = obtainRequest(RIL_REQUEST_GET_MODEM_STATUS, result, 953 mRILDefaultWorkSource); 954 955 if (RILJ_LOGD) { 956 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 957 } 958 959 try { 960 radioProxy13.getModemStackStatus(rr.mSerial); 961 } catch (RemoteException | RuntimeException e) { 962 handleRadioProxyExceptionForRR(rr, "getModemStatus", e); 963 } 964 } 965 } 966 967 @Override dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo, boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, Message result)968 public void dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo, 969 boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, 970 Message result) { 971 if (isEmergencyCall && mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4) 972 && emergencyNumberInfo != null) { 973 emergencyDial(address, emergencyNumberInfo, hasKnownUserIntentEmergency, clirMode, 974 uusInfo, result); 975 return; 976 } 977 IRadio radioProxy = getRadioProxy(result); 978 if (radioProxy != null) { 979 RILRequest rr = obtainRequest(RIL_REQUEST_DIAL, result, 980 mRILDefaultWorkSource); 981 982 Dial dialInfo = new Dial(); 983 dialInfo.address = convertNullToEmptyString(address); 984 dialInfo.clir = clirMode; 985 if (uusInfo != null) { 986 UusInfo info = new UusInfo(); 987 info.uusType = uusInfo.getType(); 988 info.uusDcs = uusInfo.getDcs(); 989 info.uusData = new String(uusInfo.getUserData()); 990 dialInfo.uusInfo.add(info); 991 } 992 993 if (RILJ_LOGD) { 994 // Do not log function arg for privacy 995 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 996 } 997 998 try { 999 radioProxy.dial(rr.mSerial, dialInfo); 1000 } catch (RemoteException | RuntimeException e) { 1001 handleRadioProxyExceptionForRR(rr, "dial", e); 1002 } 1003 } 1004 } 1005 emergencyDial(String address, EmergencyNumber emergencyNumberInfo, boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, Message result)1006 private void emergencyDial(String address, EmergencyNumber emergencyNumberInfo, 1007 boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, 1008 Message result) { 1009 IRadio radioProxy = getRadioProxy(result); 1010 // IRadio V1.4 1011 android.hardware.radio.V1_4.IRadio radioProxy14 = 1012 (android.hardware.radio.V1_4.IRadio) radioProxy; 1013 if (radioProxy != null) { 1014 RILRequest rr = obtainRequest(RIL_REQUEST_EMERGENCY_DIAL, result, 1015 mRILDefaultWorkSource); 1016 Dial dialInfo = new Dial(); 1017 dialInfo.address = convertNullToEmptyString(address); 1018 dialInfo.clir = clirMode; 1019 if (uusInfo != null) { 1020 UusInfo info = new UusInfo(); 1021 info.uusType = uusInfo.getType(); 1022 info.uusDcs = uusInfo.getDcs(); 1023 info.uusData = new String(uusInfo.getUserData()); 1024 dialInfo.uusInfo.add(info); 1025 } 1026 1027 if (RILJ_LOGD) { 1028 // Do not log function arg for privacy 1029 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1030 } 1031 1032 try { 1033 radioProxy14.emergencyDial(rr.mSerial, dialInfo, 1034 emergencyNumberInfo.getEmergencyServiceCategoryBitmaskInternalDial(), 1035 emergencyNumberInfo.getEmergencyUrns() != null 1036 ? new ArrayList(emergencyNumberInfo.getEmergencyUrns()) 1037 : new ArrayList<>(), 1038 emergencyNumberInfo.getEmergencyCallRouting(), 1039 hasKnownUserIntentEmergency, 1040 emergencyNumberInfo.getEmergencyNumberSourceBitmask() 1041 == EmergencyNumber.EMERGENCY_NUMBER_SOURCE_TEST); 1042 } catch (RemoteException | RuntimeException e) { 1043 handleRadioProxyExceptionForRR(rr, "emergencyDial", e); 1044 } 1045 } 1046 } 1047 1048 @Override getIMSI(Message result)1049 public void getIMSI(Message result) { 1050 getIMSIForApp(null, result); 1051 } 1052 1053 @Override getIMSIForApp(String aid, Message result)1054 public void getIMSIForApp(String aid, Message result) { 1055 IRadio radioProxy = getRadioProxy(result); 1056 if (radioProxy != null) { 1057 RILRequest rr = obtainRequest(RIL_REQUEST_GET_IMSI, result, 1058 mRILDefaultWorkSource); 1059 1060 if (RILJ_LOGD) { 1061 riljLog(rr.serialString() 1062 + "> " + requestToString(rr.mRequest) + " aid = " + aid); 1063 } 1064 try { 1065 radioProxy.getImsiForApp(rr.mSerial, convertNullToEmptyString(aid)); 1066 } catch (RemoteException | RuntimeException e) { 1067 handleRadioProxyExceptionForRR(rr, "getIMSIForApp", e); 1068 } 1069 } 1070 } 1071 1072 @Override hangupConnection(int gsmIndex, Message result)1073 public void hangupConnection(int gsmIndex, Message result) { 1074 IRadio radioProxy = getRadioProxy(result); 1075 if (radioProxy != null) { 1076 RILRequest rr = obtainRequest(RIL_REQUEST_HANGUP, result, 1077 mRILDefaultWorkSource); 1078 1079 if (RILJ_LOGD) { 1080 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " gsmIndex = " 1081 + gsmIndex); 1082 } 1083 1084 try { 1085 radioProxy.hangup(rr.mSerial, gsmIndex); 1086 } catch (RemoteException | RuntimeException e) { 1087 handleRadioProxyExceptionForRR(rr, "hangupConnection", e); 1088 } 1089 } 1090 } 1091 1092 @UnsupportedAppUsage 1093 @Override hangupWaitingOrBackground(Message result)1094 public void hangupWaitingOrBackground(Message result) { 1095 IRadio radioProxy = getRadioProxy(result); 1096 if (radioProxy != null) { 1097 RILRequest rr = obtainRequest(RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND, result, 1098 mRILDefaultWorkSource); 1099 1100 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1101 1102 try { 1103 radioProxy.hangupWaitingOrBackground(rr.mSerial); 1104 } catch (RemoteException | RuntimeException e) { 1105 handleRadioProxyExceptionForRR(rr, "hangupWaitingOrBackground", e); 1106 } 1107 } 1108 } 1109 1110 @UnsupportedAppUsage 1111 @Override hangupForegroundResumeBackground(Message result)1112 public void hangupForegroundResumeBackground(Message result) { 1113 IRadio radioProxy = getRadioProxy(result); 1114 if (radioProxy != null) { 1115 RILRequest rr = obtainRequest(RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND, result, 1116 mRILDefaultWorkSource); 1117 1118 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1119 1120 try { 1121 radioProxy.hangupForegroundResumeBackground(rr.mSerial); 1122 } catch (RemoteException | RuntimeException e) { 1123 handleRadioProxyExceptionForRR(rr, "hangupForegroundResumeBackground", e); 1124 } 1125 } 1126 } 1127 1128 @Override switchWaitingOrHoldingAndActive(Message result)1129 public void switchWaitingOrHoldingAndActive(Message result) { 1130 IRadio radioProxy = getRadioProxy(result); 1131 if (radioProxy != null) { 1132 RILRequest rr = obtainRequest(RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, result, 1133 mRILDefaultWorkSource); 1134 1135 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1136 1137 try { 1138 radioProxy.switchWaitingOrHoldingAndActive(rr.mSerial); 1139 } catch (RemoteException | RuntimeException e) { 1140 handleRadioProxyExceptionForRR(rr, "switchWaitingOrHoldingAndActive", e); 1141 } 1142 } 1143 } 1144 1145 @Override conference(Message result)1146 public void conference(Message result) { 1147 IRadio radioProxy = getRadioProxy(result); 1148 if (radioProxy != null) { 1149 RILRequest rr = obtainRequest(RIL_REQUEST_CONFERENCE, result, 1150 mRILDefaultWorkSource); 1151 1152 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1153 1154 try { 1155 radioProxy.conference(rr.mSerial); 1156 } catch (RemoteException | RuntimeException e) { 1157 handleRadioProxyExceptionForRR(rr, "conference", e); 1158 } 1159 } 1160 } 1161 1162 @Override rejectCall(Message result)1163 public void rejectCall(Message result) { 1164 IRadio radioProxy = getRadioProxy(result); 1165 if (radioProxy != null) { 1166 RILRequest rr = obtainRequest(RIL_REQUEST_UDUB, result, 1167 mRILDefaultWorkSource); 1168 1169 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1170 1171 try { 1172 radioProxy.rejectCall(rr.mSerial); 1173 } catch (RemoteException | RuntimeException e) { 1174 handleRadioProxyExceptionForRR(rr, "rejectCall", e); 1175 } 1176 } 1177 } 1178 1179 @Override getLastCallFailCause(Message result)1180 public void getLastCallFailCause(Message result) { 1181 IRadio radioProxy = getRadioProxy(result); 1182 if (radioProxy != null) { 1183 RILRequest rr = obtainRequest(RIL_REQUEST_LAST_CALL_FAIL_CAUSE, result, 1184 mRILDefaultWorkSource); 1185 1186 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1187 1188 try { 1189 radioProxy.getLastCallFailCause(rr.mSerial); 1190 } catch (RemoteException | RuntimeException e) { 1191 handleRadioProxyExceptionForRR(rr, "getLastCallFailCause", e); 1192 } 1193 } 1194 } 1195 1196 @Override getSignalStrength(Message result)1197 public void getSignalStrength(Message result) { 1198 IRadio radioProxy = getRadioProxy(result); 1199 if (radioProxy != null) { 1200 RILRequest rr = obtainRequest(RIL_REQUEST_SIGNAL_STRENGTH, result, 1201 mRILDefaultWorkSource); 1202 1203 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1204 1205 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 1206 android.hardware.radio.V1_4.IRadio radioProxy14 = 1207 (android.hardware.radio.V1_4.IRadio) radioProxy; 1208 try { 1209 radioProxy14.getSignalStrength_1_4(rr.mSerial); 1210 } catch (RemoteException | RuntimeException e) { 1211 handleRadioProxyExceptionForRR(rr, "getSignalStrength_1_4", e); 1212 } 1213 } else { 1214 try { 1215 radioProxy.getSignalStrength(rr.mSerial); 1216 } catch (RemoteException | RuntimeException e) { 1217 handleRadioProxyExceptionForRR(rr, "getSignalStrength", e); 1218 } 1219 } 1220 } 1221 } 1222 1223 @Override getVoiceRegistrationState(Message result)1224 public void getVoiceRegistrationState(Message result) { 1225 IRadio radioProxy = getRadioProxy(result); 1226 if (radioProxy != null) { 1227 RILRequest rr = obtainRequest(RIL_REQUEST_VOICE_REGISTRATION_STATE, result, 1228 mRILDefaultWorkSource); 1229 1230 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1231 1232 try { 1233 radioProxy.getVoiceRegistrationState(rr.mSerial); 1234 } catch (RemoteException | RuntimeException e) { 1235 handleRadioProxyExceptionForRR(rr, "getVoiceRegistrationState", e); 1236 } 1237 } 1238 } 1239 1240 @Override getDataRegistrationState(Message result)1241 public void getDataRegistrationState(Message result) { 1242 IRadio radioProxy = getRadioProxy(result); 1243 if (radioProxy != null) { 1244 RILRequest rr = obtainRequest(RIL_REQUEST_DATA_REGISTRATION_STATE, result, 1245 mRILDefaultWorkSource); 1246 1247 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1248 1249 try { 1250 radioProxy.getDataRegistrationState(rr.mSerial); 1251 } catch (RemoteException | RuntimeException e) { 1252 handleRadioProxyExceptionForRR(rr, "getDataRegistrationState", e); 1253 } 1254 } 1255 } 1256 1257 @Override getOperator(Message result)1258 public void getOperator(Message result) { 1259 IRadio radioProxy = getRadioProxy(result); 1260 if (radioProxy != null) { 1261 RILRequest rr = obtainRequest(RIL_REQUEST_OPERATOR, result, 1262 mRILDefaultWorkSource); 1263 1264 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1265 1266 try { 1267 radioProxy.getOperator(rr.mSerial); 1268 } catch (RemoteException | RuntimeException e) { 1269 handleRadioProxyExceptionForRR(rr, "getOperator", e); 1270 } 1271 } 1272 } 1273 1274 @UnsupportedAppUsage 1275 @Override setRadioPower(boolean on, Message result)1276 public void setRadioPower(boolean on, Message result) { 1277 IRadio radioProxy = getRadioProxy(result); 1278 if (radioProxy != null) { 1279 RILRequest rr = obtainRequest(RIL_REQUEST_RADIO_POWER, result, 1280 mRILDefaultWorkSource); 1281 1282 if (RILJ_LOGD) { 1283 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1284 + " on = " + on); 1285 } 1286 1287 try { 1288 radioProxy.setRadioPower(rr.mSerial, on); 1289 } catch (RemoteException | RuntimeException e) { 1290 handleRadioProxyExceptionForRR(rr, "setRadioPower", e); 1291 } 1292 } 1293 } 1294 1295 @Override sendDtmf(char c, Message result)1296 public void sendDtmf(char c, Message result) { 1297 IRadio radioProxy = getRadioProxy(result); 1298 if (radioProxy != null) { 1299 RILRequest rr = obtainRequest(RIL_REQUEST_DTMF, result, 1300 mRILDefaultWorkSource); 1301 1302 if (RILJ_LOGD) { 1303 // Do not log function arg for privacy 1304 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1305 } 1306 1307 try { 1308 radioProxy.sendDtmf(rr.mSerial, c + ""); 1309 } catch (RemoteException | RuntimeException e) { 1310 handleRadioProxyExceptionForRR(rr, "sendDtmf", e); 1311 } 1312 } 1313 } 1314 constructGsmSendSmsRilRequest(String smscPdu, String pdu)1315 private GsmSmsMessage constructGsmSendSmsRilRequest(String smscPdu, String pdu) { 1316 GsmSmsMessage msg = new GsmSmsMessage(); 1317 msg.smscPdu = smscPdu == null ? "" : smscPdu; 1318 msg.pdu = pdu == null ? "" : pdu; 1319 return msg; 1320 } 1321 1322 @Override sendSMS(String smscPdu, String pdu, Message result)1323 public void sendSMS(String smscPdu, String pdu, Message result) { 1324 IRadio radioProxy = getRadioProxy(result); 1325 if (radioProxy != null) { 1326 RILRequest rr = obtainRequest(RIL_REQUEST_SEND_SMS, result, 1327 mRILDefaultWorkSource); 1328 1329 // Do not log function args for privacy 1330 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1331 1332 GsmSmsMessage msg = constructGsmSendSmsRilRequest(smscPdu, pdu); 1333 1334 try { 1335 radioProxy.sendSms(rr.mSerial, msg); 1336 mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_GSM, 1337 SmsSession.Event.Format.SMS_FORMAT_3GPP); 1338 } catch (RemoteException | RuntimeException e) { 1339 handleRadioProxyExceptionForRR(rr, "sendSMS", e); 1340 } 1341 } 1342 } 1343 1344 @Override sendSMSExpectMore(String smscPdu, String pdu, Message result)1345 public void sendSMSExpectMore(String smscPdu, String pdu, Message result) { 1346 IRadio radioProxy = getRadioProxy(result); 1347 if (radioProxy != null) { 1348 RILRequest rr = obtainRequest(RIL_REQUEST_SEND_SMS_EXPECT_MORE, result, 1349 mRILDefaultWorkSource); 1350 1351 // Do not log function arg for privacy 1352 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1353 1354 GsmSmsMessage msg = constructGsmSendSmsRilRequest(smscPdu, pdu); 1355 1356 try { 1357 radioProxy.sendSMSExpectMore(rr.mSerial, msg); 1358 mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_GSM, 1359 SmsSession.Event.Format.SMS_FORMAT_3GPP); 1360 } catch (RemoteException | RuntimeException e) { 1361 handleRadioProxyExceptionForRR(rr, "sendSMSExpectMore", e); 1362 } 1363 } 1364 } 1365 1366 /** 1367 * Convert MVNO type string into MvnoType defined in types.hal. 1368 * @param mvnoType MVNO type 1369 * @return MVNO type in integer 1370 */ convertToHalMvnoType(String mvnoType)1371 private static int convertToHalMvnoType(String mvnoType) { 1372 switch (mvnoType) { 1373 case "imsi" : return MvnoType.IMSI; 1374 case "gid" : return MvnoType.GID; 1375 case "spn" : return MvnoType.SPN; 1376 default: return MvnoType.NONE; 1377 } 1378 } 1379 1380 /** 1381 * Convert to DataProfileInfo defined in radio/1.0/types.hal 1382 * @param dp Data profile 1383 * @return A converted data profile 1384 */ convertToHalDataProfile10( DataProfile dp)1385 private static android.hardware.radio.V1_0.DataProfileInfo convertToHalDataProfile10( 1386 DataProfile dp) { 1387 android.hardware.radio.V1_0.DataProfileInfo dpi = 1388 new android.hardware.radio.V1_0.DataProfileInfo(); 1389 1390 dpi.profileId = dp.getProfileId(); 1391 dpi.apn = dp.getApn(); 1392 dpi.protocol = ApnSetting.getProtocolStringFromInt(dp.getProtocolType()); 1393 dpi.roamingProtocol = ApnSetting.getProtocolStringFromInt(dp.getRoamingProtocolType()); 1394 dpi.authType = dp.getAuthType(); 1395 dpi.user = dp.getUserName(); 1396 dpi.password = dp.getPassword(); 1397 dpi.type = dp.getType(); 1398 dpi.maxConnsTime = dp.getMaxConnectionsTime(); 1399 dpi.maxConns = dp.getMaxConnections(); 1400 dpi.waitTime = dp.getWaitTime(); 1401 dpi.enabled = dp.isEnabled(); 1402 dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmask(); 1403 // Shift by 1 bit due to the discrepancy between 1404 // android.hardware.radio.V1_0.RadioAccessFamily and the bitmask version of 1405 // ServiceState.RIL_RADIO_TECHNOLOGY_XXXX. 1406 dpi.bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( 1407 dp.getBearerBitmask()) << 1; 1408 dpi.mtu = dp.getMtu(); 1409 dpi.mvnoType = MvnoType.NONE; 1410 dpi.mvnoMatchData = ""; 1411 1412 return dpi; 1413 } 1414 1415 /** 1416 * Convert to DataProfileInfo defined in radio/1.4/types.hal 1417 * @param dp Data profile 1418 * @return A converted data profile 1419 */ convertToHalDataProfile14( DataProfile dp)1420 private static android.hardware.radio.V1_4.DataProfileInfo convertToHalDataProfile14( 1421 DataProfile dp) { 1422 android.hardware.radio.V1_4.DataProfileInfo dpi = 1423 new android.hardware.radio.V1_4.DataProfileInfo(); 1424 1425 dpi.apn = dp.getApn(); 1426 dpi.protocol = dp.getProtocolType(); 1427 dpi.roamingProtocol = dp.getRoamingProtocolType(); 1428 dpi.authType = dp.getAuthType(); 1429 dpi.user = dp.getUserName(); 1430 dpi.password = dp.getPassword(); 1431 dpi.type = dp.getType(); 1432 dpi.maxConnsTime = dp.getMaxConnectionsTime(); 1433 dpi.maxConns = dp.getMaxConnections(); 1434 dpi.waitTime = dp.getWaitTime(); 1435 dpi.enabled = dp.isEnabled(); 1436 dpi.supportedApnTypesBitmap = dp.getSupportedApnTypesBitmask(); 1437 // Shift by 1 bit due to the discrepancy between 1438 // android.hardware.radio.V1_0.RadioAccessFamily and the bitmask version of 1439 // ServiceState.RIL_RADIO_TECHNOLOGY_XXXX. 1440 dpi.bearerBitmap = ServiceState.convertNetworkTypeBitmaskToBearerBitmask( 1441 dp.getBearerBitmask()) << 1; 1442 dpi.mtu = dp.getMtu(); 1443 dpi.persistent = dp.isPersistent(); 1444 dpi.preferred = dp.isPreferred(); 1445 1446 // profile id is only meaningful when it's persistent on the modem. 1447 dpi.profileId = (dpi.persistent) ? dp.getProfileId() : DataProfileId.INVALID; 1448 1449 return dpi; 1450 } 1451 1452 /** 1453 * Convert NV reset type into ResetNvType defined in types.hal. 1454 * @param resetType NV reset type. 1455 * @return Converted reset type in integer or -1 if param is invalid. 1456 */ convertToHalResetNvType(int resetType)1457 private static int convertToHalResetNvType(int resetType) { 1458 /** 1459 * resetType values 1460 * 1 - reload all NV items 1461 * 2 - erase NV reset (SCRTN) 1462 * 3 - factory reset (RTN) 1463 */ 1464 switch (resetType) { 1465 case 1: return ResetNvType.RELOAD; 1466 case 2: return ResetNvType.ERASE; 1467 case 3: return ResetNvType.FACTORY_RESET; 1468 } 1469 return -1; 1470 } 1471 1472 @Override setupDataCall(int accessNetworkType, DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, int reason, LinkProperties linkProperties, Message result)1473 public void setupDataCall(int accessNetworkType, DataProfile dataProfile, boolean isRoaming, 1474 boolean allowRoaming, int reason, LinkProperties linkProperties, 1475 Message result) { 1476 1477 IRadio radioProxy = getRadioProxy(result); 1478 1479 if (radioProxy != null) { 1480 1481 RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result, 1482 mRILDefaultWorkSource); 1483 1484 ArrayList<String> addresses = new ArrayList<>(); 1485 ArrayList<String> dnses = new ArrayList<>(); 1486 if (linkProperties != null) { 1487 for (InetAddress address : linkProperties.getAddresses()) { 1488 addresses.add(address.getHostAddress()); 1489 } 1490 for (InetAddress dns : linkProperties.getDnsServers()) { 1491 dnses.add(dns.getHostAddress()); 1492 } 1493 } 1494 1495 try { 1496 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 1497 // IRadio V1.4 1498 android.hardware.radio.V1_4.IRadio radioProxy14 = 1499 (android.hardware.radio.V1_4.IRadio) radioProxy; 1500 1501 // Convert to HAL data profile 1502 android.hardware.radio.V1_4.DataProfileInfo dpi = 1503 convertToHalDataProfile14(dataProfile); 1504 1505 if (RILJ_LOGD) { 1506 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1507 + ",accessNetworkType=" 1508 + AccessNetworkType.toString(accessNetworkType) + ",isRoaming=" 1509 + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile 1510 + ",addresses=" + addresses + ",dnses=" + dnses); 1511 } 1512 1513 radioProxy14.setupDataCall_1_4(rr.mSerial, accessNetworkType, dpi, allowRoaming, 1514 reason, addresses, dnses); 1515 } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 1516 // IRadio V1.2 and IRadio V1.3 1517 android.hardware.radio.V1_2.IRadio radioProxy12 = 1518 (android.hardware.radio.V1_2.IRadio) radioProxy; 1519 1520 // Convert to HAL data profile 1521 android.hardware.radio.V1_0.DataProfileInfo dpi = 1522 convertToHalDataProfile10(dataProfile); 1523 1524 if (RILJ_LOGD) { 1525 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1526 + ",accessNetworkType=" 1527 + AccessNetworkType.toString(accessNetworkType) + ",isRoaming=" 1528 + isRoaming + ",allowRoaming=" + allowRoaming + "," 1529 + dataProfile + ",addresses=" + addresses + ",dnses=" + dnses); 1530 } 1531 1532 radioProxy12.setupDataCall_1_2(rr.mSerial, accessNetworkType, dpi, 1533 dataProfile.isPersistent(), allowRoaming, isRoaming, reason, 1534 addresses, dnses); 1535 } else { 1536 // IRadio V1.0 and IRadio V1.1 1537 1538 // Convert to HAL data profile 1539 android.hardware.radio.V1_0.DataProfileInfo dpi = 1540 convertToHalDataProfile10(dataProfile); 1541 1542 // Getting data RAT here is just a workaround to support the older 1.0 1543 // vendor RIL. The new data service interface passes access network type 1544 // instead of RAT for setup data request. It is impossible to convert access 1545 // network type back to RAT here, so we directly get the data RAT from 1546 // phone. 1547 int dataRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; 1548 Phone phone = PhoneFactory.getPhone(mPhoneId); 1549 if (phone != null) { 1550 ServiceState ss = phone.getServiceState(); 1551 if (ss != null) { 1552 dataRat = ss.getRilDataRadioTechnology(); 1553 } 1554 } 1555 if (RILJ_LOGD) { 1556 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1557 + ",dataRat=" + dataRat + ",isRoaming=" + isRoaming 1558 + ",allowRoaming=" + allowRoaming + "," + dataProfile); 1559 } 1560 1561 radioProxy.setupDataCall(rr.mSerial, dataRat, dpi, 1562 dataProfile.isPersistent(), allowRoaming, isRoaming); 1563 } 1564 } catch (RemoteException | RuntimeException e) { 1565 handleRadioProxyExceptionForRR(rr, "setupDataCall", e); 1566 } 1567 } 1568 } 1569 1570 @Override iccIO(int command, int fileId, String path, int p1, int p2, int p3, String data, String pin2, Message result)1571 public void iccIO(int command, int fileId, String path, int p1, int p2, int p3, 1572 String data, String pin2, Message result) { 1573 iccIOForApp(command, fileId, path, p1, p2, p3, data, pin2, null, result); 1574 } 1575 1576 @Override iccIOForApp(int command, int fileId, String path, int p1, int p2, int p3, String data, String pin2, String aid, Message result)1577 public void iccIOForApp(int command, int fileId, String path, int p1, int p2, int p3, 1578 String data, String pin2, String aid, Message result) { 1579 IRadio radioProxy = getRadioProxy(result); 1580 if (radioProxy != null) { 1581 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_IO, result, 1582 mRILDefaultWorkSource); 1583 1584 if (RILJ_LOGD) { 1585 if (Build.IS_DEBUGGABLE) { 1586 riljLog(rr.serialString() + "> iccIO: " 1587 + requestToString(rr.mRequest) + " command = 0x" 1588 + Integer.toHexString(command) + " fileId = 0x" 1589 + Integer.toHexString(fileId) + " path = " + path + " p1 = " 1590 + p1 + " p2 = " + p2 + " p3 = " + " data = " + data 1591 + " aid = " + aid); 1592 } else { 1593 riljLog(rr.serialString() + "> iccIO: " + requestToString(rr.mRequest)); 1594 } 1595 } 1596 1597 IccIo iccIo = new IccIo(); 1598 iccIo.command = command; 1599 iccIo.fileId = fileId; 1600 iccIo.path = convertNullToEmptyString(path); 1601 iccIo.p1 = p1; 1602 iccIo.p2 = p2; 1603 iccIo.p3 = p3; 1604 iccIo.data = convertNullToEmptyString(data); 1605 iccIo.pin2 = convertNullToEmptyString(pin2); 1606 iccIo.aid = convertNullToEmptyString(aid); 1607 1608 try { 1609 radioProxy.iccIOForApp(rr.mSerial, iccIo); 1610 } catch (RemoteException | RuntimeException e) { 1611 handleRadioProxyExceptionForRR(rr, "iccIOForApp", e); 1612 } 1613 } 1614 } 1615 1616 @Override sendUSSD(String ussd, Message result)1617 public void sendUSSD(String ussd, Message result) { 1618 IRadio radioProxy = getRadioProxy(result); 1619 if (radioProxy != null) { 1620 RILRequest rr = obtainRequest(RIL_REQUEST_SEND_USSD, result, 1621 mRILDefaultWorkSource); 1622 1623 if (RILJ_LOGD) { 1624 String logUssd = "*******"; 1625 if (RILJ_LOGV) logUssd = ussd; 1626 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1627 + " ussd = " + logUssd); 1628 } 1629 1630 try { 1631 radioProxy.sendUssd(rr.mSerial, convertNullToEmptyString(ussd)); 1632 } catch (RemoteException | RuntimeException e) { 1633 handleRadioProxyExceptionForRR(rr, "sendUSSD", e); 1634 } 1635 } 1636 } 1637 1638 @Override cancelPendingUssd(Message result)1639 public void cancelPendingUssd(Message result) { 1640 IRadio radioProxy = getRadioProxy(result); 1641 if (radioProxy != null) { 1642 RILRequest rr = obtainRequest(RIL_REQUEST_CANCEL_USSD, result, 1643 mRILDefaultWorkSource); 1644 1645 if (RILJ_LOGD) { 1646 riljLog(rr.serialString() 1647 + "> " + requestToString(rr.mRequest)); 1648 } 1649 1650 try { 1651 radioProxy.cancelPendingUssd(rr.mSerial); 1652 } catch (RemoteException | RuntimeException e) { 1653 handleRadioProxyExceptionForRR(rr, "cancelPendingUssd", e); 1654 } 1655 } 1656 } 1657 1658 @Override getCLIR(Message result)1659 public void getCLIR(Message result) { 1660 IRadio radioProxy = getRadioProxy(result); 1661 if (radioProxy != null) { 1662 RILRequest rr = obtainRequest(RIL_REQUEST_GET_CLIR, result, 1663 mRILDefaultWorkSource); 1664 1665 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1666 1667 try { 1668 radioProxy.getClir(rr.mSerial); 1669 } catch (RemoteException | RuntimeException e) { 1670 handleRadioProxyExceptionForRR(rr, "getCLIR", e); 1671 } 1672 } 1673 } 1674 1675 @Override setCLIR(int clirMode, Message result)1676 public void setCLIR(int clirMode, Message result) { 1677 IRadio radioProxy = getRadioProxy(result); 1678 if (radioProxy != null) { 1679 RILRequest rr = obtainRequest(RIL_REQUEST_SET_CLIR, result, mRILDefaultWorkSource); 1680 1681 if (RILJ_LOGD) { 1682 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1683 + " clirMode = " + clirMode); 1684 } 1685 1686 try { 1687 radioProxy.setClir(rr.mSerial, clirMode); 1688 } catch (RemoteException | RuntimeException e) { 1689 handleRadioProxyExceptionForRR(rr, "setCLIR", e); 1690 } 1691 } 1692 } 1693 1694 @Override queryCallForwardStatus(int cfReason, int serviceClass, String number, Message result)1695 public void queryCallForwardStatus(int cfReason, int serviceClass, 1696 String number, Message result) { 1697 IRadio radioProxy = getRadioProxy(result); 1698 if (radioProxy != null) { 1699 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, result, 1700 mRILDefaultWorkSource); 1701 1702 if (RILJ_LOGD) { 1703 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1704 + " cfreason = " + cfReason + " serviceClass = " + serviceClass); 1705 } 1706 1707 android.hardware.radio.V1_0.CallForwardInfo cfInfo = 1708 new android.hardware.radio.V1_0.CallForwardInfo(); 1709 cfInfo.reason = cfReason; 1710 cfInfo.serviceClass = serviceClass; 1711 cfInfo.toa = PhoneNumberUtils.toaFromString(number); 1712 cfInfo.number = convertNullToEmptyString(number); 1713 cfInfo.timeSeconds = 0; 1714 1715 try { 1716 radioProxy.getCallForwardStatus(rr.mSerial, cfInfo); 1717 } catch (RemoteException | RuntimeException e) { 1718 handleRadioProxyExceptionForRR(rr, "queryCallForwardStatus", e); 1719 } 1720 } 1721 } 1722 1723 @Override setCallForward(int action, int cfReason, int serviceClass, String number, int timeSeconds, Message result)1724 public void setCallForward(int action, int cfReason, int serviceClass, 1725 String number, int timeSeconds, Message result) { 1726 IRadio radioProxy = getRadioProxy(result); 1727 if (radioProxy != null) { 1728 RILRequest rr = obtainRequest(RIL_REQUEST_SET_CALL_FORWARD, result, 1729 mRILDefaultWorkSource); 1730 1731 if (RILJ_LOGD) { 1732 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1733 + " action = " + action + " cfReason = " + cfReason + " serviceClass = " 1734 + serviceClass + " timeSeconds = " + timeSeconds); 1735 } 1736 1737 android.hardware.radio.V1_0.CallForwardInfo cfInfo = 1738 new android.hardware.radio.V1_0.CallForwardInfo(); 1739 cfInfo.status = action; 1740 cfInfo.reason = cfReason; 1741 cfInfo.serviceClass = serviceClass; 1742 cfInfo.toa = PhoneNumberUtils.toaFromString(number); 1743 cfInfo.number = convertNullToEmptyString(number); 1744 cfInfo.timeSeconds = timeSeconds; 1745 1746 try { 1747 radioProxy.setCallForward(rr.mSerial, cfInfo); 1748 } catch (RemoteException | RuntimeException e) { 1749 handleRadioProxyExceptionForRR(rr, "setCallForward", e); 1750 1751 } 1752 } 1753 } 1754 1755 @Override queryCallWaiting(int serviceClass, Message result)1756 public void queryCallWaiting(int serviceClass, Message result) { 1757 IRadio radioProxy = getRadioProxy(result); 1758 if (radioProxy != null) { 1759 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_CALL_WAITING, result, 1760 mRILDefaultWorkSource); 1761 1762 if (RILJ_LOGD) { 1763 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1764 + " serviceClass = " + serviceClass); 1765 } 1766 1767 try { 1768 radioProxy.getCallWaiting(rr.mSerial, serviceClass); 1769 } catch (RemoteException | RuntimeException e) { 1770 handleRadioProxyExceptionForRR(rr, "queryCallWaiting", e); 1771 } 1772 } 1773 } 1774 1775 @Override setCallWaiting(boolean enable, int serviceClass, Message result)1776 public void setCallWaiting(boolean enable, int serviceClass, Message result) { 1777 IRadio radioProxy = getRadioProxy(result); 1778 if (radioProxy != null) { 1779 RILRequest rr = obtainRequest(RIL_REQUEST_SET_CALL_WAITING, result, 1780 mRILDefaultWorkSource); 1781 1782 if (RILJ_LOGD) { 1783 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1784 + " enable = " + enable + " serviceClass = " + serviceClass); 1785 } 1786 1787 try { 1788 radioProxy.setCallWaiting(rr.mSerial, enable, serviceClass); 1789 } catch (RemoteException | RuntimeException e) { 1790 handleRadioProxyExceptionForRR(rr, "setCallWaiting", e); 1791 } 1792 } 1793 } 1794 1795 @Override acknowledgeLastIncomingGsmSms(boolean success, int cause, Message result)1796 public void acknowledgeLastIncomingGsmSms(boolean success, int cause, Message result) { 1797 IRadio radioProxy = getRadioProxy(result); 1798 if (radioProxy != null) { 1799 RILRequest rr = obtainRequest(RIL_REQUEST_SMS_ACKNOWLEDGE, result, 1800 mRILDefaultWorkSource); 1801 1802 if (RILJ_LOGD) { 1803 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1804 + " success = " + success + " cause = " + cause); 1805 } 1806 1807 try { 1808 radioProxy.acknowledgeLastIncomingGsmSms(rr.mSerial, success, cause); 1809 } catch (RemoteException | RuntimeException e) { 1810 handleRadioProxyExceptionForRR(rr, "acknowledgeLastIncomingGsmSms", e); 1811 } 1812 } 1813 } 1814 1815 @Override acceptCall(Message result)1816 public void acceptCall(Message result) { 1817 IRadio radioProxy = getRadioProxy(result); 1818 if (radioProxy != null) { 1819 RILRequest rr = obtainRequest(RIL_REQUEST_ANSWER, result, 1820 mRILDefaultWorkSource); 1821 1822 if (RILJ_LOGD) { 1823 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1824 } 1825 1826 try { 1827 radioProxy.acceptCall(rr.mSerial); 1828 mMetrics.writeRilAnswer(mPhoneId, rr.mSerial); 1829 } catch (RemoteException | RuntimeException e) { 1830 handleRadioProxyExceptionForRR(rr, "acceptCall", e); 1831 } 1832 } 1833 } 1834 1835 @Override deactivateDataCall(int cid, int reason, Message result)1836 public void deactivateDataCall(int cid, int reason, Message result) { 1837 IRadio radioProxy = getRadioProxy(result); 1838 if (radioProxy != null) { 1839 RILRequest rr = obtainRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, result, 1840 mRILDefaultWorkSource); 1841 1842 if (RILJ_LOGD) { 1843 riljLog(rr.serialString() + "> " 1844 + requestToString(rr.mRequest) + " cid = " + cid + " reason = " + reason); 1845 } 1846 1847 try { 1848 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 1849 android.hardware.radio.V1_2.IRadio radioProxy12 = 1850 (android.hardware.radio.V1_2.IRadio) radioProxy; 1851 1852 radioProxy12.deactivateDataCall_1_2(rr.mSerial, cid, reason); 1853 } else { 1854 radioProxy.deactivateDataCall(rr.mSerial, cid, 1855 (reason == DataService.REQUEST_REASON_SHUTDOWN)); 1856 } 1857 mMetrics.writeRilDeactivateDataCall(mPhoneId, rr.mSerial, cid, reason); 1858 } catch (RemoteException | RuntimeException e) { 1859 handleRadioProxyExceptionForRR(rr, "deactivateDataCall", e); 1860 } 1861 } 1862 } 1863 1864 @Override queryFacilityLock(String facility, String password, int serviceClass, Message result)1865 public void queryFacilityLock(String facility, String password, int serviceClass, 1866 Message result) { 1867 queryFacilityLockForApp(facility, password, serviceClass, null, result); 1868 } 1869 1870 @Override queryFacilityLockForApp(String facility, String password, int serviceClass, String appId, Message result)1871 public void queryFacilityLockForApp(String facility, String password, int serviceClass, 1872 String appId, Message result) { 1873 IRadio radioProxy = getRadioProxy(result); 1874 if (radioProxy != null) { 1875 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_FACILITY_LOCK, result, 1876 mRILDefaultWorkSource); 1877 1878 if (RILJ_LOGD) { 1879 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1880 + " facility = " + facility + " serviceClass = " + serviceClass 1881 + " appId = " + appId); 1882 } 1883 1884 try { 1885 radioProxy.getFacilityLockForApp(rr.mSerial, 1886 convertNullToEmptyString(facility), 1887 convertNullToEmptyString(password), 1888 serviceClass, 1889 convertNullToEmptyString(appId)); 1890 } catch (RemoteException | RuntimeException e) { 1891 handleRadioProxyExceptionForRR(rr, "getFacilityLockForApp", e); 1892 } 1893 } 1894 } 1895 1896 @Override setFacilityLock(String facility, boolean lockState, String password, int serviceClass, Message result)1897 public void setFacilityLock(String facility, boolean lockState, String password, 1898 int serviceClass, Message result) { 1899 setFacilityLockForApp(facility, lockState, password, serviceClass, null, result); 1900 } 1901 1902 @Override setFacilityLockForApp(String facility, boolean lockState, String password, int serviceClass, String appId, Message result)1903 public void setFacilityLockForApp(String facility, boolean lockState, String password, 1904 int serviceClass, String appId, Message result) { 1905 IRadio radioProxy = getRadioProxy(result); 1906 if (radioProxy != null) { 1907 RILRequest rr = obtainRequest(RIL_REQUEST_SET_FACILITY_LOCK, result, 1908 mRILDefaultWorkSource); 1909 1910 if (RILJ_LOGD) { 1911 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1912 + " facility = " + facility + " lockstate = " + lockState 1913 + " serviceClass = " + serviceClass + " appId = " + appId); 1914 } 1915 1916 try { 1917 radioProxy.setFacilityLockForApp(rr.mSerial, 1918 convertNullToEmptyString(facility), 1919 lockState, 1920 convertNullToEmptyString(password), 1921 serviceClass, 1922 convertNullToEmptyString(appId)); 1923 } catch (RemoteException | RuntimeException e) { 1924 handleRadioProxyExceptionForRR(rr, "setFacilityLockForApp", e); 1925 } 1926 } 1927 } 1928 1929 @Override changeBarringPassword(String facility, String oldPwd, String newPwd, Message result)1930 public void changeBarringPassword(String facility, String oldPwd, String newPwd, 1931 Message result) { 1932 IRadio radioProxy = getRadioProxy(result); 1933 if (radioProxy != null) { 1934 RILRequest rr = obtainRequest(RIL_REQUEST_CHANGE_BARRING_PASSWORD, result, 1935 mRILDefaultWorkSource); 1936 1937 // Do not log all function args for privacy 1938 if (RILJ_LOGD) { 1939 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1940 + "facility = " + facility); 1941 } 1942 1943 try { 1944 radioProxy.setBarringPassword(rr.mSerial, 1945 convertNullToEmptyString(facility), 1946 convertNullToEmptyString(oldPwd), 1947 convertNullToEmptyString(newPwd)); 1948 } catch (RemoteException | RuntimeException e) { 1949 handleRadioProxyExceptionForRR(rr, "changeBarringPassword", e); 1950 } 1951 } 1952 } 1953 1954 @Override getNetworkSelectionMode(Message result)1955 public void getNetworkSelectionMode(Message result) { 1956 IRadio radioProxy = getRadioProxy(result); 1957 if (radioProxy != null) { 1958 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, result, 1959 mRILDefaultWorkSource); 1960 1961 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1962 1963 try { 1964 radioProxy.getNetworkSelectionMode(rr.mSerial); 1965 } catch (RemoteException | RuntimeException e) { 1966 handleRadioProxyExceptionForRR(rr, "getNetworkSelectionMode", e); 1967 } 1968 } 1969 } 1970 1971 @Override setNetworkSelectionModeAutomatic(Message result)1972 public void setNetworkSelectionModeAutomatic(Message result) { 1973 IRadio radioProxy = getRadioProxy(result); 1974 if (radioProxy != null) { 1975 RILRequest rr = obtainRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, result, 1976 mRILDefaultWorkSource); 1977 1978 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 1979 1980 try { 1981 radioProxy.setNetworkSelectionModeAutomatic(rr.mSerial); 1982 } catch (RemoteException | RuntimeException e) { 1983 handleRadioProxyExceptionForRR(rr, "setNetworkSelectionModeAutomatic", e); 1984 } 1985 } 1986 } 1987 1988 @Override setNetworkSelectionModeManual(String operatorNumeric, Message result)1989 public void setNetworkSelectionModeManual(String operatorNumeric, Message result) { 1990 IRadio radioProxy = getRadioProxy(result); 1991 if (radioProxy != null) { 1992 RILRequest rr = obtainRequest(RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, result, 1993 mRILDefaultWorkSource); 1994 1995 if (RILJ_LOGD) { 1996 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 1997 + " operatorNumeric = " + operatorNumeric); 1998 } 1999 2000 try { 2001 radioProxy.setNetworkSelectionModeManual(rr.mSerial, 2002 convertNullToEmptyString(operatorNumeric)); 2003 } catch (RemoteException | RuntimeException e) { 2004 handleRadioProxyExceptionForRR(rr, "setNetworkSelectionModeManual", e); 2005 } 2006 } 2007 } 2008 2009 @Override getAvailableNetworks(Message result)2010 public void getAvailableNetworks(Message result) { 2011 IRadio radioProxy = getRadioProxy(result); 2012 if (radioProxy != null) { 2013 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_AVAILABLE_NETWORKS, result, 2014 mRILDefaultWorkSource); 2015 2016 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2017 2018 try { 2019 radioProxy.getAvailableNetworks(rr.mSerial); 2020 } catch (RemoteException | RuntimeException e) { 2021 handleRadioProxyExceptionForRR(rr, "getAvailableNetworks", e); 2022 } 2023 } 2024 } 2025 convertRadioAccessSpecifierToRadioHAL( RadioAccessSpecifier ras)2026 private android.hardware.radio.V1_1.RadioAccessSpecifier convertRadioAccessSpecifierToRadioHAL( 2027 RadioAccessSpecifier ras) { 2028 android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat = 2029 new android.hardware.radio.V1_1.RadioAccessSpecifier(); 2030 rasInHalFormat.radioAccessNetwork = ras.getRadioAccessNetwork(); 2031 List<Integer> bands = null; 2032 switch (ras.getRadioAccessNetwork()) { 2033 case AccessNetworkType.GERAN: 2034 bands = rasInHalFormat.geranBands; 2035 break; 2036 case AccessNetworkType.UTRAN: 2037 bands = rasInHalFormat.utranBands; 2038 break; 2039 case AccessNetworkType.EUTRAN: 2040 bands = rasInHalFormat.eutranBands; 2041 break; 2042 default: 2043 Log.wtf(RILJ_LOG_TAG, "radioAccessNetwork " + ras.getRadioAccessNetwork() 2044 + " not supported!"); 2045 return null; 2046 } 2047 2048 if (ras.getBands() != null) { 2049 for (int band : ras.getBands()) { 2050 bands.add(band); 2051 } 2052 } 2053 if (ras.getChannels() != null) { 2054 for (int channel : ras.getChannels()) { 2055 rasInHalFormat.channels.add(channel); 2056 } 2057 } 2058 2059 return rasInHalFormat; 2060 } 2061 2062 @Override startNetworkScan(NetworkScanRequest nsr, Message result)2063 public void startNetworkScan(NetworkScanRequest nsr, Message result) { 2064 IRadio radioProxy = getRadioProxy(result); 2065 if (radioProxy != null) { 2066 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 2067 2068 android.hardware.radio.V1_2.NetworkScanRequest request = 2069 new android.hardware.radio.V1_2.NetworkScanRequest(); 2070 request.type = nsr.getScanType(); 2071 request.interval = nsr.getSearchPeriodicity(); 2072 request.maxSearchTime = nsr.getMaxSearchTime(); 2073 request.incrementalResultsPeriodicity = nsr.getIncrementalResultsPeriodicity(); 2074 request.incrementalResults = nsr.getIncrementalResults(); 2075 2076 for (RadioAccessSpecifier ras : nsr.getSpecifiers()) { 2077 2078 android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat = 2079 convertRadioAccessSpecifierToRadioHAL(ras); 2080 if (rasInHalFormat == null) { 2081 return; 2082 } 2083 2084 request.specifiers.add(rasInHalFormat); 2085 } 2086 2087 request.mccMncs.addAll(nsr.getPlmns()); 2088 RILRequest rr = obtainRequest(RIL_REQUEST_START_NETWORK_SCAN, result, 2089 mRILDefaultWorkSource); 2090 2091 if (RILJ_LOGD) { 2092 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2093 } 2094 2095 try { 2096 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 2097 android.hardware.radio.V1_4.IRadio radioProxy14 = 2098 (android.hardware.radio.V1_4.IRadio) radioProxy; 2099 radioProxy14.startNetworkScan_1_4(rr.mSerial, request); 2100 } else { 2101 android.hardware.radio.V1_2.IRadio radioProxy12 = 2102 (android.hardware.radio.V1_2.IRadio) radioProxy; 2103 radioProxy12.startNetworkScan_1_2(rr.mSerial, request); 2104 } 2105 } catch (RemoteException | RuntimeException e) { 2106 handleRadioProxyExceptionForRR(rr, "startNetworkScan", e); 2107 } 2108 } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_1)) { 2109 android.hardware.radio.V1_1.IRadio radioProxy11 = 2110 (android.hardware.radio.V1_1.IRadio) radioProxy; 2111 2112 android.hardware.radio.V1_1.NetworkScanRequest request = 2113 new android.hardware.radio.V1_1.NetworkScanRequest(); 2114 request.type = nsr.getScanType(); 2115 request.interval = nsr.getSearchPeriodicity(); 2116 for (RadioAccessSpecifier ras : nsr.getSpecifiers()) { 2117 android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat = 2118 convertRadioAccessSpecifierToRadioHAL(ras); 2119 if (rasInHalFormat == null) { 2120 return; 2121 } 2122 2123 request.specifiers.add(rasInHalFormat); 2124 } 2125 2126 RILRequest rr = obtainRequest(RIL_REQUEST_START_NETWORK_SCAN, result, 2127 mRILDefaultWorkSource); 2128 2129 if (RILJ_LOGD) { 2130 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2131 } 2132 2133 try { 2134 radioProxy11.startNetworkScan(rr.mSerial, request); 2135 } catch (RemoteException | RuntimeException e) { 2136 handleRadioProxyExceptionForRR(rr, "startNetworkScan", e); 2137 } 2138 } else if (result != null) { 2139 AsyncResult.forMessage(result, null, 2140 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 2141 result.sendToTarget(); 2142 } 2143 } 2144 } 2145 2146 @Override stopNetworkScan(Message result)2147 public void stopNetworkScan(Message result) { 2148 IRadio radioProxy = getRadioProxy(result); 2149 if (radioProxy != null) { 2150 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_1)) { 2151 android.hardware.radio.V1_1.IRadio radioProxy11 = 2152 (android.hardware.radio.V1_1.IRadio) radioProxy; 2153 2154 RILRequest rr = obtainRequest(RIL_REQUEST_STOP_NETWORK_SCAN, result, 2155 mRILDefaultWorkSource); 2156 2157 if (RILJ_LOGD) { 2158 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2159 } 2160 2161 try { 2162 radioProxy11.stopNetworkScan(rr.mSerial); 2163 } catch (RemoteException | RuntimeException e) { 2164 handleRadioProxyExceptionForRR(rr, "stopNetworkScan", e); 2165 } 2166 } else if (result != null) { 2167 AsyncResult.forMessage(result, null, 2168 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 2169 result.sendToTarget(); 2170 } 2171 } 2172 } 2173 2174 @Override startDtmf(char c, Message result)2175 public void startDtmf(char c, Message result) { 2176 IRadio radioProxy = getRadioProxy(result); 2177 if (radioProxy != null) { 2178 RILRequest rr = obtainRequest(RIL_REQUEST_DTMF_START, result, 2179 mRILDefaultWorkSource); 2180 2181 // Do not log function arg for privacy 2182 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2183 2184 try { 2185 radioProxy.startDtmf(rr.mSerial, c + ""); 2186 } catch (RemoteException | RuntimeException e) { 2187 handleRadioProxyExceptionForRR(rr, "startDtmf", e); 2188 } 2189 } 2190 } 2191 2192 @Override stopDtmf(Message result)2193 public void stopDtmf(Message result) { 2194 IRadio radioProxy = getRadioProxy(result); 2195 if (radioProxy != null) { 2196 RILRequest rr = obtainRequest(RIL_REQUEST_DTMF_STOP, result, 2197 mRILDefaultWorkSource); 2198 2199 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2200 2201 try { 2202 radioProxy.stopDtmf(rr.mSerial); 2203 } catch (RemoteException | RuntimeException e) { 2204 handleRadioProxyExceptionForRR(rr, "stopDtmf", e); 2205 } 2206 } 2207 } 2208 2209 @Override separateConnection(int gsmIndex, Message result)2210 public void separateConnection(int gsmIndex, Message result) { 2211 IRadio radioProxy = getRadioProxy(result); 2212 if (radioProxy != null) { 2213 RILRequest rr = obtainRequest(RIL_REQUEST_SEPARATE_CONNECTION, result, 2214 mRILDefaultWorkSource); 2215 2216 if (RILJ_LOGD) { 2217 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2218 + " gsmIndex = " + gsmIndex); 2219 } 2220 2221 try { 2222 radioProxy.separateConnection(rr.mSerial, gsmIndex); 2223 } catch (RemoteException | RuntimeException e) { 2224 handleRadioProxyExceptionForRR(rr, "separateConnection", e); 2225 } 2226 } 2227 } 2228 2229 @Override getBasebandVersion(Message result)2230 public void getBasebandVersion(Message result) { 2231 IRadio radioProxy = getRadioProxy(result); 2232 if (radioProxy != null) { 2233 RILRequest rr = obtainRequest(RIL_REQUEST_BASEBAND_VERSION, result, 2234 mRILDefaultWorkSource); 2235 2236 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2237 2238 try { 2239 radioProxy.getBasebandVersion(rr.mSerial); 2240 } catch (RemoteException | RuntimeException e) { 2241 handleRadioProxyExceptionForRR(rr, "getBasebandVersion", e); 2242 } 2243 } 2244 } 2245 2246 @Override setMute(boolean enableMute, Message result)2247 public void setMute(boolean enableMute, Message result) { 2248 IRadio radioProxy = getRadioProxy(result); 2249 if (radioProxy != null) { 2250 RILRequest rr = obtainRequest(RIL_REQUEST_SET_MUTE, result, 2251 mRILDefaultWorkSource); 2252 2253 if (RILJ_LOGD) { 2254 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2255 + " enableMute = " + enableMute); 2256 } 2257 2258 try { 2259 radioProxy.setMute(rr.mSerial, enableMute); 2260 } catch (RemoteException | RuntimeException e) { 2261 handleRadioProxyExceptionForRR(rr, "setMute", e); 2262 } 2263 } 2264 } 2265 2266 @Override getMute(Message result)2267 public void getMute(Message result) { 2268 IRadio radioProxy = getRadioProxy(result); 2269 if (radioProxy != null) { 2270 RILRequest rr = obtainRequest(RIL_REQUEST_GET_MUTE, result, 2271 mRILDefaultWorkSource); 2272 2273 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2274 2275 try { 2276 radioProxy.getMute(rr.mSerial); 2277 } catch (RemoteException | RuntimeException e) { 2278 handleRadioProxyExceptionForRR(rr, "getMute", e); 2279 } 2280 } 2281 } 2282 2283 @Override queryCLIP(Message result)2284 public void queryCLIP(Message result) { 2285 IRadio radioProxy = getRadioProxy(result); 2286 if (radioProxy != null) { 2287 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_CLIP, result, 2288 mRILDefaultWorkSource); 2289 2290 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2291 2292 try { 2293 radioProxy.getClip(rr.mSerial); 2294 } catch (RemoteException | RuntimeException e) { 2295 handleRadioProxyExceptionForRR(rr, "queryCLIP", e); 2296 } 2297 } 2298 } 2299 2300 /** 2301 * @deprecated 2302 */ 2303 @Override 2304 @Deprecated getPDPContextList(Message result)2305 public void getPDPContextList(Message result) { 2306 getDataCallList(result); 2307 } 2308 2309 @Override getDataCallList(Message result)2310 public void getDataCallList(Message result) { 2311 IRadio radioProxy = getRadioProxy(result); 2312 if (radioProxy != null) { 2313 RILRequest rr = obtainRequest(RIL_REQUEST_DATA_CALL_LIST, result, 2314 mRILDefaultWorkSource); 2315 2316 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2317 2318 try { 2319 radioProxy.getDataCallList(rr.mSerial); 2320 } catch (RemoteException | RuntimeException e) { 2321 handleRadioProxyExceptionForRR(rr, "getDataCallList", e); 2322 } 2323 } 2324 } 2325 2326 @UnsupportedAppUsage 2327 @Override invokeOemRilRequestRaw(byte[] data, Message response)2328 public void invokeOemRilRequestRaw(byte[] data, Message response) { 2329 IOemHook oemHookProxy = getOemHookProxy(response); 2330 if (oemHookProxy != null) { 2331 RILRequest rr = obtainRequest(RIL_REQUEST_OEM_HOOK_RAW, response, 2332 mRILDefaultWorkSource); 2333 2334 if (RILJ_LOGD) { 2335 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2336 + "[" + IccUtils.bytesToHexString(data) + "]"); 2337 } 2338 2339 try { 2340 oemHookProxy.sendRequestRaw(rr.mSerial, primitiveArrayToArrayList(data)); 2341 } catch (RemoteException | RuntimeException e) { 2342 handleRadioProxyExceptionForRR(rr, "invokeOemRilRequestRaw", e); 2343 } 2344 } else { 2345 // OEM Hook service is disabled for P and later devices. 2346 // Deprecated OEM Hook APIs will perform dummy before being removed. 2347 if (RILJ_LOGD) riljLog("Radio Oem Hook Service is disabled for P and later devices. "); 2348 } 2349 } 2350 2351 @Override invokeOemRilRequestStrings(String[] strings, Message result)2352 public void invokeOemRilRequestStrings(String[] strings, Message result) { 2353 IOemHook oemHookProxy = getOemHookProxy(result); 2354 if (oemHookProxy != null) { 2355 RILRequest rr = obtainRequest(RIL_REQUEST_OEM_HOOK_STRINGS, result, 2356 mRILDefaultWorkSource); 2357 2358 String logStr = ""; 2359 for (int i = 0; i < strings.length; i++) { 2360 logStr = logStr + strings[i] + " "; 2361 } 2362 if (RILJ_LOGD) { 2363 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " strings = " 2364 + logStr); 2365 } 2366 2367 try { 2368 oemHookProxy.sendRequestStrings(rr.mSerial, 2369 new ArrayList<String>(Arrays.asList(strings))); 2370 } catch (RemoteException | RuntimeException e) { 2371 handleRadioProxyExceptionForRR(rr, "invokeOemRilRequestStrings", e); 2372 } 2373 } else { 2374 // OEM Hook service is disabled for P and later devices. 2375 // Deprecated OEM Hook APIs will perform dummy before being removed. 2376 if (RILJ_LOGD) riljLog("Radio Oem Hook Service is disabled for P and later devices. "); 2377 } 2378 } 2379 2380 @Override setSuppServiceNotifications(boolean enable, Message result)2381 public void setSuppServiceNotifications(boolean enable, Message result) { 2382 IRadio radioProxy = getRadioProxy(result); 2383 if (radioProxy != null) { 2384 RILRequest rr = obtainRequest(RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, result, 2385 mRILDefaultWorkSource); 2386 2387 if (RILJ_LOGD) { 2388 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " enable = " 2389 + enable); 2390 } 2391 2392 try { 2393 radioProxy.setSuppServiceNotifications(rr.mSerial, enable); 2394 } catch (RemoteException | RuntimeException e) { 2395 handleRadioProxyExceptionForRR(rr, "setSuppServiceNotifications", e); 2396 } 2397 } 2398 } 2399 2400 @Override writeSmsToSim(int status, String smsc, String pdu, Message result)2401 public void writeSmsToSim(int status, String smsc, String pdu, Message result) { 2402 status = translateStatus(status); 2403 IRadio radioProxy = getRadioProxy(result); 2404 if (radioProxy != null) { 2405 RILRequest rr = obtainRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, result, 2406 mRILDefaultWorkSource); 2407 2408 if (RILJ_LOGV) { 2409 riljLog(rr.serialString() + "> " 2410 + requestToString(rr.mRequest) 2411 + " " + status); 2412 } 2413 2414 SmsWriteArgs args = new SmsWriteArgs(); 2415 args.status = status; 2416 args.smsc = convertNullToEmptyString(smsc); 2417 args.pdu = convertNullToEmptyString(pdu); 2418 2419 try { 2420 radioProxy.writeSmsToSim(rr.mSerial, args); 2421 } catch (RemoteException | RuntimeException e) { 2422 handleRadioProxyExceptionForRR(rr, "writeSmsToSim", e); 2423 } 2424 } 2425 } 2426 2427 @Override deleteSmsOnSim(int index, Message result)2428 public void deleteSmsOnSim(int index, Message result) { 2429 IRadio radioProxy = getRadioProxy(result); 2430 if (radioProxy != null) { 2431 RILRequest rr = obtainRequest(RIL_REQUEST_DELETE_SMS_ON_SIM, result, 2432 mRILDefaultWorkSource); 2433 2434 if (RILJ_LOGV) { 2435 riljLog(rr.serialString() + "> " 2436 + requestToString(rr.mRequest) + " index = " + index); 2437 } 2438 2439 try { 2440 radioProxy.deleteSmsOnSim(rr.mSerial, index); 2441 } catch (RemoteException | RuntimeException e) { 2442 handleRadioProxyExceptionForRR(rr, "deleteSmsOnSim", e); 2443 } 2444 } 2445 } 2446 2447 @Override setBandMode(int bandMode, Message result)2448 public void setBandMode(int bandMode, Message result) { 2449 IRadio radioProxy = getRadioProxy(result); 2450 if (radioProxy != null) { 2451 RILRequest rr = obtainRequest(RIL_REQUEST_SET_BAND_MODE, result, 2452 mRILDefaultWorkSource); 2453 2454 if (RILJ_LOGD) { 2455 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2456 + " bandMode = " + bandMode); 2457 } 2458 2459 try { 2460 radioProxy.setBandMode(rr.mSerial, bandMode); 2461 } catch (RemoteException | RuntimeException e) { 2462 handleRadioProxyExceptionForRR(rr, "setBandMode", e); 2463 } 2464 } 2465 } 2466 2467 @Override queryAvailableBandMode(Message result)2468 public void queryAvailableBandMode(Message result) { 2469 IRadio radioProxy = getRadioProxy(result); 2470 if (radioProxy != null) { 2471 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, result, 2472 mRILDefaultWorkSource); 2473 2474 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2475 2476 try { 2477 radioProxy.getAvailableBandModes(rr.mSerial); 2478 } catch (RemoteException | RuntimeException e) { 2479 handleRadioProxyExceptionForRR(rr, "queryAvailableBandMode", e); 2480 } 2481 } 2482 } 2483 2484 @Override sendEnvelope(String contents, Message result)2485 public void sendEnvelope(String contents, Message result) { 2486 IRadio radioProxy = getRadioProxy(result); 2487 if (radioProxy != null) { 2488 RILRequest rr = obtainRequest(RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, result, 2489 mRILDefaultWorkSource); 2490 2491 if (RILJ_LOGD) { 2492 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " contents = " 2493 + contents); 2494 } 2495 2496 try { 2497 radioProxy.sendEnvelope(rr.mSerial, convertNullToEmptyString(contents)); 2498 } catch (RemoteException | RuntimeException e) { 2499 handleRadioProxyExceptionForRR(rr, "sendEnvelope", e); 2500 } 2501 } 2502 } 2503 2504 @Override sendTerminalResponse(String contents, Message result)2505 public void sendTerminalResponse(String contents, Message result) { 2506 IRadio radioProxy = getRadioProxy(result); 2507 if (radioProxy != null) { 2508 RILRequest rr = obtainRequest(RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, result, 2509 mRILDefaultWorkSource); 2510 2511 if (RILJ_LOGD) { 2512 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " contents = " 2513 + (Build.IS_DEBUGGABLE ? contents : censoredTerminalResponse(contents))); 2514 } 2515 2516 try { 2517 radioProxy.sendTerminalResponseToSim(rr.mSerial, 2518 convertNullToEmptyString(contents)); 2519 } catch (RemoteException | RuntimeException e) { 2520 handleRadioProxyExceptionForRR(rr, "sendTerminalResponse", e); 2521 } 2522 } 2523 } 2524 censoredTerminalResponse(String terminalResponse)2525 private String censoredTerminalResponse(String terminalResponse) { 2526 try { 2527 byte[] bytes = IccUtils.hexStringToBytes(terminalResponse); 2528 if (bytes != null) { 2529 List<ComprehensionTlv> ctlvs = ComprehensionTlv.decodeMany(bytes, 0); 2530 int from = 0; 2531 for (ComprehensionTlv ctlv : ctlvs) { 2532 // Find text strings which might be personal information input by user, 2533 // then replace it with "********". 2534 if (ComprehensionTlvTag.TEXT_STRING.value() == ctlv.getTag()) { 2535 byte[] target = Arrays.copyOfRange(ctlv.getRawValue(), from, 2536 ctlv.getValueIndex() + ctlv.getLength()); 2537 terminalResponse = terminalResponse.toLowerCase().replace( 2538 IccUtils.bytesToHexString(target).toLowerCase(), "********"); 2539 } 2540 // The text string tag and the length field should also be hidden. 2541 from = ctlv.getValueIndex() + ctlv.getLength(); 2542 } 2543 } 2544 } catch (Exception e) { 2545 Rlog.e(RILJ_LOG_TAG, "Could not censor the terminal response: " + e); 2546 terminalResponse = null; 2547 } 2548 2549 return terminalResponse; 2550 } 2551 2552 @Override sendEnvelopeWithStatus(String contents, Message result)2553 public void sendEnvelopeWithStatus(String contents, Message result) { 2554 IRadio radioProxy = getRadioProxy(result); 2555 if (radioProxy != null) { 2556 RILRequest rr = obtainRequest(RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, result, 2557 mRILDefaultWorkSource); 2558 2559 if (RILJ_LOGD) { 2560 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " contents = " 2561 + contents); 2562 } 2563 2564 try { 2565 radioProxy.sendEnvelopeWithStatus(rr.mSerial, convertNullToEmptyString(contents)); 2566 } catch (RemoteException | RuntimeException e) { 2567 handleRadioProxyExceptionForRR(rr, "sendEnvelopeWithStatus", e); 2568 } 2569 } 2570 } 2571 2572 @Override explicitCallTransfer(Message result)2573 public void explicitCallTransfer(Message result) { 2574 IRadio radioProxy = getRadioProxy(result); 2575 if (radioProxy != null) { 2576 RILRequest rr = obtainRequest(RIL_REQUEST_EXPLICIT_CALL_TRANSFER, result, 2577 mRILDefaultWorkSource); 2578 2579 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2580 2581 try { 2582 radioProxy.explicitCallTransfer(rr.mSerial); 2583 } catch (RemoteException | RuntimeException e) { 2584 handleRadioProxyExceptionForRR(rr, "explicitCallTransfer", e); 2585 } 2586 } 2587 } 2588 2589 @Override setPreferredNetworkType(@refNetworkMode int networkType , Message result)2590 public void setPreferredNetworkType(@PrefNetworkMode int networkType , Message result) { 2591 IRadio radioProxy = getRadioProxy(result); 2592 if (radioProxy != null) { 2593 RILRequest rr = obtainRequest(RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, result, 2594 mRILDefaultWorkSource); 2595 2596 if (RILJ_LOGD) { 2597 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2598 + " networkType = " + networkType); 2599 } 2600 mPreferredNetworkType = networkType; 2601 mMetrics.writeSetPreferredNetworkType(mPhoneId, networkType); 2602 2603 if (mRadioVersion.lessOrEqual(RADIO_HAL_VERSION_1_3)) { 2604 try { 2605 radioProxy.setPreferredNetworkType(rr.mSerial, networkType); 2606 } catch (RemoteException | RuntimeException e) { 2607 handleRadioProxyExceptionForRR(rr, "setPreferredNetworkType", e); 2608 } 2609 } else if (mRadioVersion.equals(RADIO_HAL_VERSION_1_4)) { 2610 android.hardware.radio.V1_4.IRadio radioProxy14 = 2611 (android.hardware.radio.V1_4.IRadio) radioProxy; 2612 try { 2613 radioProxy14.setPreferredNetworkTypeBitmap( 2614 rr.mSerial, convertToHalRadioAccessFamily( 2615 RadioAccessFamily.getRafFromNetworkType(networkType))); 2616 } catch (RemoteException | RuntimeException e) { 2617 handleRadioProxyExceptionForRR(rr, "setPreferredNetworkTypeBitmap", e); 2618 } 2619 } 2620 } 2621 } 2622 2623 /** 2624 * convert RAF from {@link android.hardware.radio.V1_0.RadioAccessFamily} to 2625 * {@link TelephonyManager.NetworkTypeBitMask}, the bitmask represented by 2626 * {@link TelephonyManager.NetworkType}. 2627 * 2628 * @param raf {@link android.hardware.radio.V1_0.RadioAccessFamily} 2629 * @return {@link TelephonyManager.NetworkTypeBitMask} 2630 */ 2631 @TelephonyManager.NetworkTypeBitMask convertToNetworkTypeBitMask(int raf)2632 public static int convertToNetworkTypeBitMask(int raf) { 2633 int networkTypeRaf = 0; 2634 2635 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.GSM) != 0) { 2636 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_GSM; 2637 } 2638 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.GPRS) != 0) { 2639 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_GPRS; 2640 } 2641 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.EDGE) != 0) { 2642 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_EDGE; 2643 } 2644 // convert both IS95A/IS95B to CDMA as network mode doesn't support CDMA 2645 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.IS95A) != 0) { 2646 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_CDMA; 2647 } 2648 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.IS95B) != 0) { 2649 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_CDMA; 2650 } 2651 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.ONE_X_RTT) != 0) { 2652 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_1xRTT; 2653 } 2654 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.EVDO_0) != 0) { 2655 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_0; 2656 } 2657 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.EVDO_A) != 0) { 2658 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_A; 2659 } 2660 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.EVDO_B) != 0) { 2661 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_B; 2662 } 2663 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.EHRPD) != 0) { 2664 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_EHRPD; 2665 } 2666 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.HSUPA) != 0) { 2667 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_HSUPA; 2668 } 2669 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.HSDPA) != 0) { 2670 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_HSDPA; 2671 } 2672 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.HSPA) != 0) { 2673 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_HSPA; 2674 } 2675 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.HSPAP) != 0) { 2676 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_HSPAP; 2677 } 2678 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.UMTS) != 0) { 2679 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_UMTS; 2680 } 2681 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.TD_SCDMA) != 0) { 2682 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_TD_SCDMA; 2683 } 2684 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.LTE) != 0) { 2685 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_LTE; 2686 } 2687 if ((raf & android.hardware.radio.V1_0.RadioAccessFamily.LTE_CA) != 0) { 2688 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_LTE_CA; 2689 } 2690 if ((raf & android.hardware.radio.V1_4.RadioAccessFamily.NR) != 0) { 2691 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_NR; 2692 } 2693 // TODO: need hal definition 2694 if ((raf & (1 << ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN)) != 0) { 2695 networkTypeRaf |= TelephonyManager.NETWORK_TYPE_BITMASK_IWLAN; 2696 } 2697 return (networkTypeRaf == 0) ? TelephonyManager.NETWORK_TYPE_UNKNOWN : networkTypeRaf; 2698 } 2699 2700 // convert to android.hardware.radio.V1_0.RadioAccessFamily convertToHalRadioAccessFamily( @elephonyManager.NetworkTypeBitMask int networkTypeBitmask)2701 private static int convertToHalRadioAccessFamily( 2702 @TelephonyManager.NetworkTypeBitMask int networkTypeBitmask) { 2703 int raf = 0; 2704 2705 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_GSM) != 0) { 2706 raf |= android.hardware.radio.V1_0.RadioAccessFamily.GSM; 2707 } 2708 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_GPRS) != 0) { 2709 raf |= android.hardware.radio.V1_0.RadioAccessFamily.GPRS; 2710 } 2711 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_EDGE) != 0) { 2712 raf |= android.hardware.radio.V1_0.RadioAccessFamily.EDGE; 2713 } 2714 // convert CDMA to IS95A, consistent with ServiceState.networkTypeToRilRadioTechnology 2715 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_CDMA) != 0) { 2716 raf |= android.hardware.radio.V1_0.RadioAccessFamily.IS95A; 2717 } 2718 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_1xRTT) != 0) { 2719 raf |= android.hardware.radio.V1_0.RadioAccessFamily.ONE_X_RTT; 2720 } 2721 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_0) != 0) { 2722 raf |= android.hardware.radio.V1_0.RadioAccessFamily.EVDO_0; 2723 } 2724 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_A) != 0) { 2725 raf |= android.hardware.radio.V1_0.RadioAccessFamily.EVDO_A; 2726 } 2727 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_EVDO_B) != 0) { 2728 raf |= android.hardware.radio.V1_0.RadioAccessFamily.EVDO_B; 2729 } 2730 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_EHRPD) != 0) { 2731 raf |= android.hardware.radio.V1_0.RadioAccessFamily.EHRPD; 2732 } 2733 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_HSUPA) != 0) { 2734 raf |= android.hardware.radio.V1_0.RadioAccessFamily.HSUPA; 2735 } 2736 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_HSDPA) != 0) { 2737 raf |= android.hardware.radio.V1_0.RadioAccessFamily.HSDPA; 2738 } 2739 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_HSPA) != 0) { 2740 raf |= android.hardware.radio.V1_0.RadioAccessFamily.HSPA; 2741 } 2742 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_HSPAP) != 0) { 2743 raf |= android.hardware.radio.V1_0.RadioAccessFamily.HSPAP; 2744 } 2745 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_UMTS) != 0) { 2746 raf |= android.hardware.radio.V1_0.RadioAccessFamily.UMTS; 2747 } 2748 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_TD_SCDMA) != 0) { 2749 raf |= android.hardware.radio.V1_0.RadioAccessFamily.TD_SCDMA; 2750 } 2751 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_LTE) != 0) { 2752 raf |= android.hardware.radio.V1_0.RadioAccessFamily.LTE; 2753 } 2754 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_LTE_CA) != 0) { 2755 raf |= android.hardware.radio.V1_0.RadioAccessFamily.LTE_CA; 2756 } 2757 if ((networkTypeBitmask & TelephonyManager.NETWORK_TYPE_BITMASK_NR) != 0) { 2758 raf |= android.hardware.radio.V1_4.RadioAccessFamily.NR; 2759 } 2760 // TODO: need hal definition for IWLAN 2761 return (raf == 0) ? android.hardware.radio.V1_4.RadioAccessFamily.UNKNOWN : raf; 2762 } 2763 2764 @Override getPreferredNetworkType(Message result)2765 public void getPreferredNetworkType(Message result) { 2766 IRadio radioProxy = getRadioProxy(result); 2767 if (radioProxy != null) { 2768 RILRequest rr = obtainRequest(RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, result, 2769 mRILDefaultWorkSource); 2770 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2771 if (mRadioVersion.lessOrEqual(RADIO_HAL_VERSION_1_3)) { 2772 try { 2773 radioProxy.getPreferredNetworkType(rr.mSerial); 2774 } catch (RemoteException | RuntimeException e) { 2775 handleRadioProxyExceptionForRR(rr, "getPreferredNetworkType", e); 2776 } 2777 } else if (mRadioVersion.equals(RADIO_HAL_VERSION_1_4)) { 2778 android.hardware.radio.V1_4.IRadio radioProxy14 = 2779 (android.hardware.radio.V1_4.IRadio) radioProxy; 2780 try { 2781 radioProxy14.getPreferredNetworkTypeBitmap(rr.mSerial); 2782 } catch (RemoteException | RuntimeException e) { 2783 handleRadioProxyExceptionForRR(rr, "getPreferredNetworkTypeBitmap", e); 2784 } 2785 } 2786 } 2787 } 2788 2789 @Override setLocationUpdates(boolean enable, Message result)2790 public void setLocationUpdates(boolean enable, Message result) { 2791 IRadio radioProxy = getRadioProxy(result); 2792 if (radioProxy != null) { 2793 RILRequest rr = obtainRequest(RIL_REQUEST_SET_LOCATION_UPDATES, result, 2794 mRILDefaultWorkSource); 2795 2796 if (RILJ_LOGD) { 2797 riljLog(rr.serialString() + "> " 2798 + requestToString(rr.mRequest) + " enable = " + enable); 2799 } 2800 2801 try { 2802 radioProxy.setLocationUpdates(rr.mSerial, enable); 2803 } catch (RemoteException | RuntimeException e) { 2804 handleRadioProxyExceptionForRR(rr, "setLocationUpdates", e); 2805 } 2806 } 2807 } 2808 2809 @Override setCdmaSubscriptionSource(int cdmaSubscription , Message result)2810 public void setCdmaSubscriptionSource(int cdmaSubscription , Message result) { 2811 IRadio radioProxy = getRadioProxy(result); 2812 if (radioProxy != null) { 2813 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, result, 2814 mRILDefaultWorkSource); 2815 2816 if (RILJ_LOGD) { 2817 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2818 + " cdmaSubscription = " + cdmaSubscription); 2819 } 2820 2821 try { 2822 radioProxy.setCdmaSubscriptionSource(rr.mSerial, cdmaSubscription); 2823 } catch (RemoteException | RuntimeException e) { 2824 handleRadioProxyExceptionForRR(rr, "setCdmaSubscriptionSource", e); 2825 } 2826 } 2827 } 2828 2829 @Override queryCdmaRoamingPreference(Message result)2830 public void queryCdmaRoamingPreference(Message result) { 2831 IRadio radioProxy = getRadioProxy(result); 2832 if (radioProxy != null) { 2833 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, result, 2834 mRILDefaultWorkSource); 2835 2836 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2837 2838 try { 2839 radioProxy.getCdmaRoamingPreference(rr.mSerial); 2840 } catch (RemoteException | RuntimeException e) { 2841 handleRadioProxyExceptionForRR(rr, "queryCdmaRoamingPreference", e); 2842 } 2843 } 2844 } 2845 2846 @Override setCdmaRoamingPreference(int cdmaRoamingType, Message result)2847 public void setCdmaRoamingPreference(int cdmaRoamingType, Message result) { 2848 IRadio radioProxy = getRadioProxy(result); 2849 if (radioProxy != null) { 2850 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, result, 2851 mRILDefaultWorkSource); 2852 2853 if (RILJ_LOGD) { 2854 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2855 + " cdmaRoamingType = " + cdmaRoamingType); 2856 } 2857 2858 try { 2859 radioProxy.setCdmaRoamingPreference(rr.mSerial, cdmaRoamingType); 2860 } catch (RemoteException | RuntimeException e) { 2861 handleRadioProxyExceptionForRR(rr, "setCdmaRoamingPreference", e); 2862 } 2863 } 2864 } 2865 2866 @Override queryTTYMode(Message result)2867 public void queryTTYMode(Message result) { 2868 IRadio radioProxy = getRadioProxy(result); 2869 if (radioProxy != null) { 2870 RILRequest rr = obtainRequest(RIL_REQUEST_QUERY_TTY_MODE, result, 2871 mRILDefaultWorkSource); 2872 2873 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2874 2875 try { 2876 radioProxy.getTTYMode(rr.mSerial); 2877 } catch (RemoteException | RuntimeException e) { 2878 handleRadioProxyExceptionForRR(rr, "queryTTYMode", e); 2879 } 2880 } 2881 } 2882 2883 @Override setTTYMode(int ttyMode, Message result)2884 public void setTTYMode(int ttyMode, Message result) { 2885 IRadio radioProxy = getRadioProxy(result); 2886 if (radioProxy != null) { 2887 RILRequest rr = obtainRequest(RIL_REQUEST_SET_TTY_MODE, result, 2888 mRILDefaultWorkSource); 2889 2890 if (RILJ_LOGD) { 2891 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2892 + " ttyMode = " + ttyMode); 2893 } 2894 2895 try { 2896 radioProxy.setTTYMode(rr.mSerial, ttyMode); 2897 } catch (RemoteException | RuntimeException e) { 2898 handleRadioProxyExceptionForRR(rr, "setTTYMode", e); 2899 } 2900 } 2901 } 2902 2903 @Override setPreferredVoicePrivacy(boolean enable, Message result)2904 public void setPreferredVoicePrivacy(boolean enable, Message result) { 2905 IRadio radioProxy = getRadioProxy(result); 2906 if (radioProxy != null) { 2907 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, result, 2908 mRILDefaultWorkSource); 2909 2910 if (RILJ_LOGD) { 2911 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2912 + " enable = " + enable); 2913 } 2914 2915 try { 2916 radioProxy.setPreferredVoicePrivacy(rr.mSerial, enable); 2917 } catch (RemoteException | RuntimeException e) { 2918 handleRadioProxyExceptionForRR(rr, "setPreferredVoicePrivacy", e); 2919 } 2920 } 2921 } 2922 2923 @Override getPreferredVoicePrivacy(Message result)2924 public void getPreferredVoicePrivacy(Message result) { 2925 IRadio radioProxy = getRadioProxy(result); 2926 if (radioProxy != null) { 2927 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, 2928 result, mRILDefaultWorkSource); 2929 2930 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 2931 2932 try { 2933 radioProxy.getPreferredVoicePrivacy(rr.mSerial); 2934 } catch (RemoteException | RuntimeException e) { 2935 handleRadioProxyExceptionForRR(rr, "getPreferredVoicePrivacy", e); 2936 } 2937 } 2938 } 2939 2940 @Override sendCDMAFeatureCode(String featureCode, Message result)2941 public void sendCDMAFeatureCode(String featureCode, Message result) { 2942 IRadio radioProxy = getRadioProxy(result); 2943 if (radioProxy != null) { 2944 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_FLASH, result, 2945 mRILDefaultWorkSource); 2946 2947 if (RILJ_LOGD) { 2948 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2949 + " featureCode = " + featureCode); 2950 } 2951 2952 try { 2953 radioProxy.sendCDMAFeatureCode(rr.mSerial, convertNullToEmptyString(featureCode)); 2954 } catch (RemoteException | RuntimeException e) { 2955 handleRadioProxyExceptionForRR(rr, "sendCDMAFeatureCode", e); 2956 } 2957 } 2958 } 2959 2960 @Override sendBurstDtmf(String dtmfString, int on, int off, Message result)2961 public void sendBurstDtmf(String dtmfString, int on, int off, Message result) { 2962 IRadio radioProxy = getRadioProxy(result); 2963 if (radioProxy != null) { 2964 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_BURST_DTMF, result, 2965 mRILDefaultWorkSource); 2966 2967 if (RILJ_LOGD) { 2968 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 2969 + " dtmfString = " + dtmfString + " on = " + on + " off = " + off); 2970 } 2971 2972 try { 2973 radioProxy.sendBurstDtmf(rr.mSerial, convertNullToEmptyString(dtmfString), on, off); 2974 } catch (RemoteException | RuntimeException e) { 2975 handleRadioProxyExceptionForRR(rr, "sendBurstDtmf", e); 2976 } 2977 } 2978 } 2979 constructCdmaSendSmsRilRequest(CdmaSmsMessage msg, byte[] pdu)2980 private void constructCdmaSendSmsRilRequest(CdmaSmsMessage msg, byte[] pdu) { 2981 int addrNbrOfDigits; 2982 int subaddrNbrOfDigits; 2983 int bearerDataLength; 2984 ByteArrayInputStream bais = new ByteArrayInputStream(pdu); 2985 DataInputStream dis = new DataInputStream(bais); 2986 2987 try { 2988 msg.teleserviceId = dis.readInt(); // teleServiceId 2989 msg.isServicePresent = (byte) dis.readInt() == 1 ? true : false; // servicePresent 2990 msg.serviceCategory = dis.readInt(); // serviceCategory 2991 msg.address.digitMode = dis.read(); // address digit mode 2992 msg.address.numberMode = dis.read(); // address number mode 2993 msg.address.numberType = dis.read(); // address number type 2994 msg.address.numberPlan = dis.read(); // address number plan 2995 addrNbrOfDigits = (byte) dis.read(); 2996 for (int i = 0; i < addrNbrOfDigits; i++) { 2997 msg.address.digits.add(dis.readByte()); // address_orig_bytes[i] 2998 } 2999 msg.subAddress.subaddressType = dis.read(); //subaddressType 3000 msg.subAddress.odd = (byte) dis.read() == 1 ? true : false; //subaddr odd 3001 subaddrNbrOfDigits = (byte) dis.read(); 3002 for (int i = 0; i < subaddrNbrOfDigits; i++) { 3003 msg.subAddress.digits.add(dis.readByte()); //subaddr_orig_bytes[i] 3004 } 3005 3006 bearerDataLength = dis.read(); 3007 for (int i = 0; i < bearerDataLength; i++) { 3008 msg.bearerData.add(dis.readByte()); //bearerData[i] 3009 } 3010 } catch (IOException ex) { 3011 if (RILJ_LOGD) { 3012 riljLog("sendSmsCdma: conversion from input stream to object failed: " 3013 + ex); 3014 } 3015 } 3016 } 3017 3018 @Override sendCdmaSms(byte[] pdu, Message result)3019 public void sendCdmaSms(byte[] pdu, Message result) { 3020 IRadio radioProxy = getRadioProxy(result); 3021 if (radioProxy != null) { 3022 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SEND_SMS, result, 3023 mRILDefaultWorkSource); 3024 3025 // Do not log function arg for privacy 3026 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3027 3028 CdmaSmsMessage msg = new CdmaSmsMessage(); 3029 constructCdmaSendSmsRilRequest(msg, pdu); 3030 3031 try { 3032 radioProxy.sendCdmaSms(rr.mSerial, msg); 3033 mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_CDMA, 3034 SmsSession.Event.Format.SMS_FORMAT_3GPP2); 3035 } catch (RemoteException | RuntimeException e) { 3036 handleRadioProxyExceptionForRR(rr, "sendCdmaSms", e); 3037 } 3038 } 3039 } 3040 3041 @Override acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message result)3042 public void acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message result) { 3043 IRadio radioProxy = getRadioProxy(result); 3044 if (radioProxy != null) { 3045 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result, 3046 mRILDefaultWorkSource); 3047 3048 if (RILJ_LOGD) { 3049 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3050 + " success = " + success + " cause = " + cause); 3051 } 3052 3053 CdmaSmsAck msg = new CdmaSmsAck(); 3054 msg.errorClass = success ? 0 : 1; 3055 msg.smsCauseCode = cause; 3056 3057 try { 3058 radioProxy.acknowledgeLastIncomingCdmaSms(rr.mSerial, msg); 3059 } catch (RemoteException | RuntimeException e) { 3060 handleRadioProxyExceptionForRR(rr, "acknowledgeLastIncomingCdmaSms", e); 3061 } 3062 } 3063 } 3064 3065 @Override getGsmBroadcastConfig(Message result)3066 public void getGsmBroadcastConfig(Message result) { 3067 IRadio radioProxy = getRadioProxy(result); 3068 if (radioProxy != null) { 3069 RILRequest rr = obtainRequest(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, result, 3070 mRILDefaultWorkSource); 3071 3072 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3073 3074 try { 3075 radioProxy.getGsmBroadcastConfig(rr.mSerial); 3076 } catch (RemoteException | RuntimeException e) { 3077 handleRadioProxyExceptionForRR(rr, "getGsmBroadcastConfig", e); 3078 } 3079 } 3080 } 3081 3082 @Override setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message result)3083 public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message result) { 3084 IRadio radioProxy = getRadioProxy(result); 3085 if (radioProxy != null) { 3086 RILRequest rr = obtainRequest(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, result, 3087 mRILDefaultWorkSource); 3088 3089 if (RILJ_LOGD) { 3090 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3091 + " with " + config.length + " configs : "); 3092 for (int i = 0; i < config.length; i++) { 3093 riljLog(config[i].toString()); 3094 } 3095 } 3096 3097 ArrayList<GsmBroadcastSmsConfigInfo> configs = new ArrayList<>(); 3098 3099 int numOfConfig = config.length; 3100 GsmBroadcastSmsConfigInfo info; 3101 3102 for (int i = 0; i < numOfConfig; i++) { 3103 info = new GsmBroadcastSmsConfigInfo(); 3104 info.fromServiceId = config[i].getFromServiceId(); 3105 info.toServiceId = config[i].getToServiceId(); 3106 info.fromCodeScheme = config[i].getFromCodeScheme(); 3107 info.toCodeScheme = config[i].getToCodeScheme(); 3108 info.selected = config[i].isSelected(); 3109 configs.add(info); 3110 } 3111 3112 try { 3113 radioProxy.setGsmBroadcastConfig(rr.mSerial, configs); 3114 } catch (RemoteException | RuntimeException e) { 3115 handleRadioProxyExceptionForRR(rr, "setGsmBroadcastConfig", e); 3116 } 3117 } 3118 } 3119 3120 @Override setGsmBroadcastActivation(boolean activate, Message result)3121 public void setGsmBroadcastActivation(boolean activate, Message result) { 3122 IRadio radioProxy = getRadioProxy(result); 3123 if (radioProxy != null) { 3124 RILRequest rr = obtainRequest(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, result, 3125 mRILDefaultWorkSource); 3126 3127 if (RILJ_LOGD) { 3128 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3129 + " activate = " + activate); 3130 } 3131 3132 try { 3133 radioProxy.setGsmBroadcastActivation(rr.mSerial, activate); 3134 } catch (RemoteException | RuntimeException e) { 3135 handleRadioProxyExceptionForRR(rr, "setGsmBroadcastActivation", e); 3136 } 3137 } 3138 } 3139 3140 @Override getCdmaBroadcastConfig(Message result)3141 public void getCdmaBroadcastConfig(Message result) { 3142 IRadio radioProxy = getRadioProxy(result); 3143 if (radioProxy != null) { 3144 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, result, 3145 mRILDefaultWorkSource); 3146 3147 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3148 3149 try { 3150 radioProxy.getCdmaBroadcastConfig(rr.mSerial); 3151 } catch (RemoteException | RuntimeException e) { 3152 handleRadioProxyExceptionForRR(rr, "getCdmaBroadcastConfig", e); 3153 } 3154 } 3155 } 3156 3157 @Override setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message result)3158 public void setCdmaBroadcastConfig(CdmaSmsBroadcastConfigInfo[] configs, Message result) { 3159 IRadio radioProxy = getRadioProxy(result); 3160 if (radioProxy != null) { 3161 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, result, 3162 mRILDefaultWorkSource); 3163 3164 ArrayList<CdmaBroadcastSmsConfigInfo> halConfigs = new ArrayList<>(); 3165 3166 for (CdmaSmsBroadcastConfigInfo config: configs) { 3167 for (int i = config.getFromServiceCategory(); 3168 i <= config.getToServiceCategory(); 3169 i++) { 3170 CdmaBroadcastSmsConfigInfo info = new CdmaBroadcastSmsConfigInfo(); 3171 info.serviceCategory = i; 3172 info.language = config.getLanguage(); 3173 info.selected = config.isSelected(); 3174 halConfigs.add(info); 3175 } 3176 } 3177 3178 if (RILJ_LOGD) { 3179 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3180 + " with " + halConfigs.size() + " configs : "); 3181 for (CdmaBroadcastSmsConfigInfo config : halConfigs) { 3182 riljLog(config.toString()); 3183 } 3184 } 3185 3186 try { 3187 radioProxy.setCdmaBroadcastConfig(rr.mSerial, halConfigs); 3188 } catch (RemoteException | RuntimeException e) { 3189 handleRadioProxyExceptionForRR(rr, "setCdmaBroadcastConfig", e); 3190 } 3191 } 3192 } 3193 3194 @Override setCdmaBroadcastActivation(boolean activate, Message result)3195 public void setCdmaBroadcastActivation(boolean activate, Message result) { 3196 IRadio radioProxy = getRadioProxy(result); 3197 if (radioProxy != null) { 3198 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, result, 3199 mRILDefaultWorkSource); 3200 3201 if (RILJ_LOGD) { 3202 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3203 + " activate = " + activate); 3204 } 3205 3206 try { 3207 radioProxy.setCdmaBroadcastActivation(rr.mSerial, activate); 3208 } catch (RemoteException | RuntimeException e) { 3209 handleRadioProxyExceptionForRR(rr, "setCdmaBroadcastActivation", e); 3210 } 3211 } 3212 } 3213 3214 @Override getCDMASubscription(Message result)3215 public void getCDMASubscription(Message result) { 3216 IRadio radioProxy = getRadioProxy(result); 3217 if (radioProxy != null) { 3218 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SUBSCRIPTION, result, 3219 mRILDefaultWorkSource); 3220 3221 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3222 3223 try { 3224 radioProxy.getCDMASubscription(rr.mSerial); 3225 } catch (RemoteException | RuntimeException e) { 3226 handleRadioProxyExceptionForRR(rr, "getCDMASubscription", e); 3227 } 3228 } 3229 } 3230 3231 @Override writeSmsToRuim(int status, String pdu, Message result)3232 public void writeSmsToRuim(int status, String pdu, Message result) { 3233 status = translateStatus(status); 3234 IRadio radioProxy = getRadioProxy(result); 3235 if (radioProxy != null) { 3236 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, result, 3237 mRILDefaultWorkSource); 3238 3239 if (RILJ_LOGV) { 3240 riljLog(rr.serialString() + "> " 3241 + requestToString(rr.mRequest) 3242 + " status = " + status); 3243 } 3244 3245 CdmaSmsWriteArgs args = new CdmaSmsWriteArgs(); 3246 args.status = status; 3247 constructCdmaSendSmsRilRequest(args.message, pdu.getBytes()); 3248 3249 try { 3250 radioProxy.writeSmsToRuim(rr.mSerial, args); 3251 } catch (RemoteException | RuntimeException e) { 3252 handleRadioProxyExceptionForRR(rr, "writeSmsToRuim", e); 3253 } 3254 } 3255 } 3256 3257 @Override deleteSmsOnRuim(int index, Message result)3258 public void deleteSmsOnRuim(int index, Message result) { 3259 IRadio radioProxy = getRadioProxy(result); 3260 if (radioProxy != null) { 3261 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, result, 3262 mRILDefaultWorkSource); 3263 3264 if (RILJ_LOGV) { 3265 riljLog(rr.serialString() + "> " 3266 + requestToString(rr.mRequest) 3267 + " index = " + index); 3268 } 3269 3270 try { 3271 radioProxy.deleteSmsOnRuim(rr.mSerial, index); 3272 } catch (RemoteException | RuntimeException e) { 3273 handleRadioProxyExceptionForRR(rr, "deleteSmsOnRuim", e); 3274 } 3275 } 3276 } 3277 3278 @Override getDeviceIdentity(Message result)3279 public void getDeviceIdentity(Message result) { 3280 IRadio radioProxy = getRadioProxy(result); 3281 if (radioProxy != null) { 3282 RILRequest rr = obtainRequest(RIL_REQUEST_DEVICE_IDENTITY, result, 3283 mRILDefaultWorkSource); 3284 3285 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3286 3287 try { 3288 radioProxy.getDeviceIdentity(rr.mSerial); 3289 } catch (RemoteException | RuntimeException e) { 3290 handleRadioProxyExceptionForRR(rr, "getDeviceIdentity", e); 3291 } 3292 } 3293 } 3294 3295 @Override exitEmergencyCallbackMode(Message result)3296 public void exitEmergencyCallbackMode(Message result) { 3297 IRadio radioProxy = getRadioProxy(result); 3298 if (radioProxy != null) { 3299 RILRequest rr = obtainRequest(RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, result, 3300 mRILDefaultWorkSource); 3301 3302 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3303 3304 try { 3305 radioProxy.exitEmergencyCallbackMode(rr.mSerial); 3306 } catch (RemoteException | RuntimeException e) { 3307 handleRadioProxyExceptionForRR(rr, "exitEmergencyCallbackMode", e); 3308 } 3309 } 3310 } 3311 3312 @Override getSmscAddress(Message result)3313 public void getSmscAddress(Message result) { 3314 IRadio radioProxy = getRadioProxy(result); 3315 if (radioProxy != null) { 3316 RILRequest rr = obtainRequest(RIL_REQUEST_GET_SMSC_ADDRESS, result, 3317 mRILDefaultWorkSource); 3318 3319 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3320 3321 try { 3322 radioProxy.getSmscAddress(rr.mSerial); 3323 } catch (RemoteException | RuntimeException e) { 3324 handleRadioProxyExceptionForRR(rr, "getSmscAddress", e); 3325 } 3326 } 3327 } 3328 3329 @Override setSmscAddress(String address, Message result)3330 public void setSmscAddress(String address, Message result) { 3331 IRadio radioProxy = getRadioProxy(result); 3332 if (radioProxy != null) { 3333 RILRequest rr = obtainRequest(RIL_REQUEST_SET_SMSC_ADDRESS, result, 3334 mRILDefaultWorkSource); 3335 3336 if (RILJ_LOGD) { 3337 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3338 + " address = " + address); 3339 } 3340 3341 try { 3342 radioProxy.setSmscAddress(rr.mSerial, convertNullToEmptyString(address)); 3343 } catch (RemoteException | RuntimeException e) { 3344 handleRadioProxyExceptionForRR(rr, "setSmscAddress", e); 3345 } 3346 } 3347 } 3348 3349 @Override reportSmsMemoryStatus(boolean available, Message result)3350 public void reportSmsMemoryStatus(boolean available, Message result) { 3351 IRadio radioProxy = getRadioProxy(result); 3352 if (radioProxy != null) { 3353 RILRequest rr = obtainRequest(RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, result, 3354 mRILDefaultWorkSource); 3355 3356 if (RILJ_LOGD) { 3357 riljLog(rr.serialString() + "> " 3358 + requestToString(rr.mRequest) + " available = " + available); 3359 } 3360 3361 try { 3362 radioProxy.reportSmsMemoryStatus(rr.mSerial, available); 3363 } catch (RemoteException | RuntimeException e) { 3364 handleRadioProxyExceptionForRR(rr, "reportSmsMemoryStatus", e); 3365 } 3366 } 3367 } 3368 3369 @Override reportStkServiceIsRunning(Message result)3370 public void reportStkServiceIsRunning(Message result) { 3371 IRadio radioProxy = getRadioProxy(result); 3372 if (radioProxy != null) { 3373 RILRequest rr = obtainRequest(RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, result, 3374 mRILDefaultWorkSource); 3375 3376 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3377 3378 try { 3379 radioProxy.reportStkServiceIsRunning(rr.mSerial); 3380 } catch (RemoteException | RuntimeException e) { 3381 handleRadioProxyExceptionForRR(rr, "reportStkServiceIsRunning", e); 3382 } 3383 } 3384 } 3385 3386 @Override getCdmaSubscriptionSource(Message result)3387 public void getCdmaSubscriptionSource(Message result) { 3388 IRadio radioProxy = getRadioProxy(result); 3389 if (radioProxy != null) { 3390 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, result, 3391 mRILDefaultWorkSource); 3392 3393 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3394 3395 try { 3396 radioProxy.getCdmaSubscriptionSource(rr.mSerial); 3397 } catch (RemoteException | RuntimeException e) { 3398 handleRadioProxyExceptionForRR(rr, "getCdmaSubscriptionSource", e); 3399 } 3400 } 3401 } 3402 3403 @Override acknowledgeIncomingGsmSmsWithPdu(boolean success, String ackPdu, Message result)3404 public void acknowledgeIncomingGsmSmsWithPdu(boolean success, String ackPdu, Message result) { 3405 IRadio radioProxy = getRadioProxy(result); 3406 if (radioProxy != null) { 3407 RILRequest rr = obtainRequest(RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, result, 3408 mRILDefaultWorkSource); 3409 3410 if (RILJ_LOGD) { 3411 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3412 + " success = " + success); 3413 } 3414 3415 try { 3416 radioProxy.acknowledgeIncomingGsmSmsWithPdu(rr.mSerial, success, 3417 convertNullToEmptyString(ackPdu)); 3418 } catch (RemoteException | RuntimeException e) { 3419 handleRadioProxyExceptionForRR(rr, "acknowledgeIncomingGsmSmsWithPdu", e); 3420 } 3421 } 3422 } 3423 3424 @Override getVoiceRadioTechnology(Message result)3425 public void getVoiceRadioTechnology(Message result) { 3426 IRadio radioProxy = getRadioProxy(result); 3427 if (radioProxy != null) { 3428 RILRequest rr = obtainRequest(RIL_REQUEST_VOICE_RADIO_TECH, result, 3429 mRILDefaultWorkSource); 3430 3431 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3432 3433 try { 3434 radioProxy.getVoiceRadioTechnology(rr.mSerial); 3435 } catch (RemoteException | RuntimeException e) { 3436 handleRadioProxyExceptionForRR(rr, "getVoiceRadioTechnology", e); 3437 } 3438 } 3439 } 3440 3441 @Override getCellInfoList(Message result, WorkSource workSource)3442 public void getCellInfoList(Message result, WorkSource workSource) { 3443 workSource = getDeafultWorkSourceIfInvalid(workSource); 3444 IRadio radioProxy = getRadioProxy(result); 3445 if (radioProxy != null) { 3446 RILRequest rr = obtainRequest(RIL_REQUEST_GET_CELL_INFO_LIST, result, 3447 workSource); 3448 3449 if (RILJ_LOGD) { 3450 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3451 } 3452 3453 try { 3454 radioProxy.getCellInfoList(rr.mSerial); 3455 } catch (RemoteException | RuntimeException e) { 3456 handleRadioProxyExceptionForRR(rr, "getCellInfoList", e); 3457 } 3458 } 3459 } 3460 3461 @Override setCellInfoListRate(int rateInMillis, Message result, WorkSource workSource)3462 public void setCellInfoListRate(int rateInMillis, Message result, WorkSource workSource) { 3463 workSource = getDeafultWorkSourceIfInvalid(workSource); 3464 IRadio radioProxy = getRadioProxy(result); 3465 if (radioProxy != null) { 3466 RILRequest rr = obtainRequest(RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, result, 3467 workSource); 3468 3469 if (RILJ_LOGD) { 3470 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3471 + " rateInMillis = " + rateInMillis); 3472 } 3473 3474 try { 3475 radioProxy.setCellInfoListRate(rr.mSerial, rateInMillis); 3476 } catch (RemoteException | RuntimeException e) { 3477 handleRadioProxyExceptionForRR(rr, "setCellInfoListRate", e); 3478 } 3479 } 3480 } 3481 3482 @Override setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, Message result)3483 public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming, Message result) { 3484 3485 IRadio radioProxy = getRadioProxy(result); 3486 if (radioProxy != null) { 3487 RILRequest rr = obtainRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, result, 3488 mRILDefaultWorkSource); 3489 3490 if (RILJ_LOGD) { 3491 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + dataProfile); 3492 } 3493 3494 try { 3495 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 3496 // v1.4 3497 android.hardware.radio.V1_4.IRadio radioProxy14 = 3498 (android.hardware.radio.V1_4.IRadio) radioProxy; 3499 radioProxy14.setInitialAttachApn_1_4(rr.mSerial, 3500 convertToHalDataProfile14(dataProfile)); 3501 } else { 3502 // v1.3, v1.2, v1.1, and v1.0 3503 radioProxy.setInitialAttachApn(rr.mSerial, 3504 convertToHalDataProfile10(dataProfile), dataProfile.isPersistent(), 3505 isRoaming); 3506 } 3507 } catch (RemoteException | RuntimeException e) { 3508 handleRadioProxyExceptionForRR(rr, "setInitialAttachApn", e); 3509 } 3510 } 3511 } 3512 3513 @Override getImsRegistrationState(Message result)3514 public void getImsRegistrationState(Message result) { 3515 IRadio radioProxy = getRadioProxy(result); 3516 if (radioProxy != null) { 3517 RILRequest rr = obtainRequest(RIL_REQUEST_IMS_REGISTRATION_STATE, result, 3518 mRILDefaultWorkSource); 3519 3520 if (RILJ_LOGD) { 3521 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3522 } 3523 3524 try { 3525 radioProxy.getImsRegistrationState(rr.mSerial); 3526 } catch (RemoteException | RuntimeException e) { 3527 handleRadioProxyExceptionForRR(rr, "getImsRegistrationState", e); 3528 } 3529 } 3530 } 3531 3532 @Override sendImsGsmSms(String smscPdu, String pdu, int retry, int messageRef, Message result)3533 public void sendImsGsmSms(String smscPdu, String pdu, int retry, int messageRef, 3534 Message result) { 3535 IRadio radioProxy = getRadioProxy(result); 3536 if (radioProxy != null) { 3537 RILRequest rr = obtainRequest(RIL_REQUEST_IMS_SEND_SMS, result, 3538 mRILDefaultWorkSource); 3539 3540 // Do not log function args for privacy 3541 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3542 3543 ImsSmsMessage msg = new ImsSmsMessage(); 3544 msg.tech = RILConstants.GSM_PHONE; 3545 msg.retry = (byte) retry >= 1 ? true : false; 3546 msg.messageRef = messageRef; 3547 3548 GsmSmsMessage gsmMsg = constructGsmSendSmsRilRequest(smscPdu, pdu); 3549 msg.gsmMessage.add(gsmMsg); 3550 try { 3551 radioProxy.sendImsSms(rr.mSerial, msg); 3552 mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_IMS, 3553 SmsSession.Event.Format.SMS_FORMAT_3GPP); 3554 } catch (RemoteException | RuntimeException e) { 3555 handleRadioProxyExceptionForRR(rr, "sendImsGsmSms", e); 3556 } 3557 } 3558 } 3559 3560 @Override sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message result)3561 public void sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message result) { 3562 IRadio radioProxy = getRadioProxy(result); 3563 if (radioProxy != null) { 3564 RILRequest rr = obtainRequest(RIL_REQUEST_IMS_SEND_SMS, result, 3565 mRILDefaultWorkSource); 3566 3567 // Do not log function args for privacy 3568 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3569 3570 ImsSmsMessage msg = new ImsSmsMessage(); 3571 msg.tech = RILConstants.CDMA_PHONE; 3572 msg.retry = (byte) retry >= 1 ? true : false; 3573 msg.messageRef = messageRef; 3574 3575 CdmaSmsMessage cdmaMsg = new CdmaSmsMessage(); 3576 constructCdmaSendSmsRilRequest(cdmaMsg, pdu); 3577 msg.cdmaMessage.add(cdmaMsg); 3578 3579 try { 3580 radioProxy.sendImsSms(rr.mSerial, msg); 3581 mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_IMS, 3582 SmsSession.Event.Format.SMS_FORMAT_3GPP2); 3583 } catch (RemoteException | RuntimeException e) { 3584 handleRadioProxyExceptionForRR(rr, "sendImsCdmaSms", e); 3585 } 3586 } 3587 } 3588 createSimApdu(int channel, int cla, int instruction, int p1, int p2, int p3, String data)3589 private SimApdu createSimApdu(int channel, int cla, int instruction, int p1, int p2, int p3, 3590 String data) { 3591 SimApdu msg = new SimApdu(); 3592 msg.sessionId = channel; 3593 msg.cla = cla; 3594 msg.instruction = instruction; 3595 msg.p1 = p1; 3596 msg.p2 = p2; 3597 msg.p3 = p3; 3598 msg.data = convertNullToEmptyString(data); 3599 return msg; 3600 } 3601 3602 @Override iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, int p3, String data, Message result)3603 public void iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, 3604 int p3, String data, Message result) { 3605 IRadio radioProxy = getRadioProxy(result); 3606 if (radioProxy != null) { 3607 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, result, 3608 mRILDefaultWorkSource); 3609 3610 if (RILJ_LOGD) { 3611 if (Build.IS_DEBUGGABLE) { 3612 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3613 + String.format(" cla = 0x%02X ins = 0x%02X", cla, instruction) 3614 + String.format(" p1 = 0x%02X p2 = 0x%02X p3 = 0x%02X", p1, p2, p3) 3615 + " data = " + data); 3616 } else { 3617 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3618 } 3619 } 3620 3621 SimApdu msg = createSimApdu(0, cla, instruction, p1, p2, p3, data); 3622 try { 3623 radioProxy.iccTransmitApduBasicChannel(rr.mSerial, msg); 3624 } catch (RemoteException | RuntimeException e) { 3625 handleRadioProxyExceptionForRR(rr, "iccTransmitApduBasicChannel", e); 3626 } 3627 } 3628 } 3629 3630 @Override iccOpenLogicalChannel(String aid, int p2, Message result)3631 public void iccOpenLogicalChannel(String aid, int p2, Message result) { 3632 IRadio radioProxy = getRadioProxy(result); 3633 if (radioProxy != null) { 3634 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_OPEN_CHANNEL, result, 3635 mRILDefaultWorkSource); 3636 3637 if (RILJ_LOGD) { 3638 if (Build.IS_DEBUGGABLE) { 3639 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " aid = " + aid 3640 + " p2 = " + p2); 3641 } else { 3642 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3643 } 3644 } 3645 3646 try { 3647 radioProxy.iccOpenLogicalChannel(rr.mSerial, convertNullToEmptyString(aid), p2); 3648 } catch (RemoteException | RuntimeException e) { 3649 handleRadioProxyExceptionForRR(rr, "iccOpenLogicalChannel", e); 3650 } 3651 } 3652 } 3653 3654 @Override iccCloseLogicalChannel(int channel, Message result)3655 public void iccCloseLogicalChannel(int channel, Message result) { 3656 IRadio radioProxy = getRadioProxy(result); 3657 if (radioProxy != null) { 3658 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_CLOSE_CHANNEL, result, 3659 mRILDefaultWorkSource); 3660 3661 if (RILJ_LOGD) { 3662 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " channel = " 3663 + channel); 3664 } 3665 3666 try { 3667 radioProxy.iccCloseLogicalChannel(rr.mSerial, channel); 3668 } catch (RemoteException | RuntimeException e) { 3669 handleRadioProxyExceptionForRR(rr, "iccCloseLogicalChannel", e); 3670 } 3671 } 3672 } 3673 3674 @Override iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data, Message result)3675 public void iccTransmitApduLogicalChannel(int channel, int cla, int instruction, 3676 int p1, int p2, int p3, String data, 3677 Message result) { 3678 if (channel <= 0) { 3679 throw new RuntimeException( 3680 "Invalid channel in iccTransmitApduLogicalChannel: " + channel); 3681 } 3682 3683 IRadio radioProxy = getRadioProxy(result); 3684 if (radioProxy != null) { 3685 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, result, 3686 mRILDefaultWorkSource); 3687 3688 if (RILJ_LOGD) { 3689 if (Build.IS_DEBUGGABLE) { 3690 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3691 + String.format(" channel = %d", channel) 3692 + String.format(" cla = 0x%02X ins = 0x%02X", cla, instruction) 3693 + String.format(" p1 = 0x%02X p2 = 0x%02X p3 = 0x%02X", p1, p2, p3) 3694 + " data = " + data); 3695 } else { 3696 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3697 } 3698 } 3699 3700 SimApdu msg = createSimApdu(channel, cla, instruction, p1, p2, p3, data); 3701 3702 try { 3703 radioProxy.iccTransmitApduLogicalChannel(rr.mSerial, msg); 3704 } catch (RemoteException | RuntimeException e) { 3705 handleRadioProxyExceptionForRR(rr, "iccTransmitApduLogicalChannel", e); 3706 } 3707 } 3708 } 3709 3710 @Override nvReadItem(int itemID, Message result, WorkSource workSource)3711 public void nvReadItem(int itemID, Message result, WorkSource workSource) { 3712 workSource = getDeafultWorkSourceIfInvalid(workSource); 3713 IRadio radioProxy = getRadioProxy(result); 3714 if (radioProxy != null) { 3715 RILRequest rr = obtainRequest(RIL_REQUEST_NV_READ_ITEM, result, 3716 workSource); 3717 3718 if (RILJ_LOGD) { 3719 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3720 + " itemId = " + itemID); 3721 } 3722 3723 try { 3724 radioProxy.nvReadItem(rr.mSerial, itemID); 3725 } catch (RemoteException | RuntimeException e) { 3726 handleRadioProxyExceptionForRR(rr, "nvReadItem", e); 3727 } 3728 } 3729 } 3730 3731 @Override nvWriteItem(int itemId, String itemValue, Message result, WorkSource workSource)3732 public void nvWriteItem(int itemId, String itemValue, Message result, WorkSource workSource) { 3733 workSource = getDeafultWorkSourceIfInvalid(workSource); 3734 IRadio radioProxy = getRadioProxy(result); 3735 if (radioProxy != null) { 3736 RILRequest rr = obtainRequest(RIL_REQUEST_NV_WRITE_ITEM, result, 3737 workSource); 3738 3739 if (RILJ_LOGD) { 3740 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3741 + " itemId = " + itemId + " itemValue = " + itemValue); 3742 } 3743 3744 NvWriteItem item = new NvWriteItem(); 3745 item.itemId = itemId; 3746 item.value = convertNullToEmptyString(itemValue); 3747 3748 try { 3749 radioProxy.nvWriteItem(rr.mSerial, item); 3750 } catch (RemoteException | RuntimeException e) { 3751 handleRadioProxyExceptionForRR(rr, "nvWriteItem", e); 3752 } 3753 } 3754 } 3755 3756 @Override nvWriteCdmaPrl(byte[] preferredRoamingList, Message result)3757 public void nvWriteCdmaPrl(byte[] preferredRoamingList, Message result) { 3758 IRadio radioProxy = getRadioProxy(result); 3759 if (radioProxy != null) { 3760 RILRequest rr = obtainRequest(RIL_REQUEST_NV_WRITE_CDMA_PRL, result, 3761 mRILDefaultWorkSource); 3762 3763 if (RILJ_LOGD) { 3764 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3765 + " PreferredRoamingList = 0x" 3766 + IccUtils.bytesToHexString(preferredRoamingList)); 3767 } 3768 3769 ArrayList<Byte> arrList = new ArrayList<>(); 3770 for (int i = 0; i < preferredRoamingList.length; i++) { 3771 arrList.add(preferredRoamingList[i]); 3772 } 3773 3774 try { 3775 radioProxy.nvWriteCdmaPrl(rr.mSerial, arrList); 3776 } catch (RemoteException | RuntimeException e) { 3777 handleRadioProxyExceptionForRR(rr, "nvWriteCdmaPrl", e); 3778 } 3779 } 3780 } 3781 3782 @Override nvResetConfig(int resetType, Message result)3783 public void nvResetConfig(int resetType, Message result) { 3784 IRadio radioProxy = getRadioProxy(result); 3785 if (radioProxy != null) { 3786 RILRequest rr = obtainRequest(RIL_REQUEST_NV_RESET_CONFIG, result, 3787 mRILDefaultWorkSource); 3788 3789 if (RILJ_LOGD) { 3790 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3791 + " resetType = " + resetType); 3792 } 3793 3794 try { 3795 radioProxy.nvResetConfig(rr.mSerial, convertToHalResetNvType(resetType)); 3796 } catch (RemoteException | RuntimeException e) { 3797 handleRadioProxyExceptionForRR(rr, "nvResetConfig", e); 3798 } 3799 } 3800 } 3801 3802 @Override setUiccSubscription(int slotId, int appIndex, int subId, int subStatus, Message result)3803 public void setUiccSubscription(int slotId, int appIndex, int subId, 3804 int subStatus, Message result) { 3805 IRadio radioProxy = getRadioProxy(result); 3806 if (radioProxy != null) { 3807 RILRequest rr = obtainRequest(RIL_REQUEST_SET_UICC_SUBSCRIPTION, result, 3808 mRILDefaultWorkSource); 3809 3810 if (RILJ_LOGD) { 3811 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3812 + " slot = " + slotId + " appIndex = " + appIndex 3813 + " subId = " + subId + " subStatus = " + subStatus); 3814 } 3815 3816 SelectUiccSub info = new SelectUiccSub(); 3817 info.slot = slotId; 3818 info.appIndex = appIndex; 3819 info.subType = subId; 3820 info.actStatus = subStatus; 3821 3822 try { 3823 radioProxy.setUiccSubscription(rr.mSerial, info); 3824 } catch (RemoteException | RuntimeException e) { 3825 handleRadioProxyExceptionForRR(rr, "setUiccSubscription", e); 3826 } 3827 } 3828 } 3829 3830 @Override setDataAllowed(boolean allowed, Message result)3831 public void setDataAllowed(boolean allowed, Message result) { 3832 IRadio radioProxy = getRadioProxy(result); 3833 if (radioProxy != null) { 3834 RILRequest rr = obtainRequest(RIL_REQUEST_ALLOW_DATA, result, 3835 mRILDefaultWorkSource); 3836 3837 if (RILJ_LOGD) { 3838 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3839 + " allowed = " + allowed); 3840 } 3841 3842 try { 3843 radioProxy.setDataAllowed(rr.mSerial, allowed); 3844 } catch (RemoteException | RuntimeException e) { 3845 handleRadioProxyExceptionForRR(rr, "setDataAllowed", e); 3846 } 3847 } 3848 } 3849 3850 @Override getHardwareConfig(Message result)3851 public void getHardwareConfig(Message result) { 3852 IRadio radioProxy = getRadioProxy(result); 3853 if (radioProxy != null) { 3854 RILRequest rr = obtainRequest(RIL_REQUEST_GET_HARDWARE_CONFIG, result, 3855 mRILDefaultWorkSource); 3856 3857 // Do not log function args for privacy 3858 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3859 3860 try { 3861 radioProxy.getHardwareConfig(rr.mSerial); 3862 } catch (RemoteException | RuntimeException e) { 3863 handleRadioProxyExceptionForRR(rr, "getHardwareConfig", e); 3864 } 3865 } 3866 } 3867 3868 @Override requestIccSimAuthentication(int authContext, String data, String aid, Message result)3869 public void requestIccSimAuthentication(int authContext, String data, String aid, 3870 Message result) { 3871 IRadio radioProxy = getRadioProxy(result); 3872 if (radioProxy != null) { 3873 RILRequest rr = obtainRequest(RIL_REQUEST_SIM_AUTHENTICATION, result, 3874 mRILDefaultWorkSource); 3875 3876 // Do not log function args for privacy 3877 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3878 3879 try { 3880 radioProxy.requestIccSimAuthentication(rr.mSerial, 3881 authContext, 3882 convertNullToEmptyString(data), 3883 convertNullToEmptyString(aid)); 3884 } catch (RemoteException | RuntimeException e) { 3885 handleRadioProxyExceptionForRR(rr, "requestIccSimAuthentication", e); 3886 } 3887 } 3888 } 3889 3890 @Override setDataProfile(DataProfile[] dps, boolean isRoaming, Message result)3891 public void setDataProfile(DataProfile[] dps, boolean isRoaming, Message result) { 3892 3893 IRadio radioProxy = getRadioProxy(result); 3894 if (radioProxy != null) { 3895 3896 RILRequest rr = null; 3897 try { 3898 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 3899 // V1.4 3900 android.hardware.radio.V1_4.IRadio radioProxy14 = 3901 (android.hardware.radio.V1_4.IRadio) radioProxy; 3902 3903 rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, 3904 mRILDefaultWorkSource); 3905 3906 ArrayList<android.hardware.radio.V1_4.DataProfileInfo> dpis = new ArrayList<>(); 3907 for (DataProfile dp : dps) { 3908 dpis.add(convertToHalDataProfile14(dp)); 3909 } 3910 3911 if (RILJ_LOGD) { 3912 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3913 + " with data profiles : "); 3914 for (DataProfile profile : dps) { 3915 riljLog(profile.toString()); 3916 } 3917 } 3918 3919 radioProxy14.setDataProfile_1_4(rr.mSerial, dpis); 3920 } else { 3921 // V1.0, 1.1, 1,2 and 1.3 3922 ArrayList<android.hardware.radio.V1_0.DataProfileInfo> dpis = new ArrayList<>(); 3923 for (DataProfile dp : dps) { 3924 // For v1.0 to v1.2, we only send data profiles that has the persistent 3925 // (a.k.a modem cognitive) bit set to true. 3926 if (dp.isPersistent()) { 3927 dpis.add(convertToHalDataProfile10(dp)); 3928 } 3929 } 3930 3931 if (!dpis.isEmpty()) { 3932 rr = obtainRequest(RIL_REQUEST_SET_DATA_PROFILE, result, 3933 mRILDefaultWorkSource); 3934 3935 if (RILJ_LOGD) { 3936 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3937 + " with data profiles : "); 3938 for (DataProfile profile : dps) { 3939 riljLog(profile.toString()); 3940 } 3941 } 3942 3943 radioProxy.setDataProfile(rr.mSerial, dpis, isRoaming); 3944 } 3945 } 3946 } catch (RemoteException | RuntimeException e) { 3947 handleRadioProxyExceptionForRR(rr, "setDataProfile", e); 3948 } 3949 } 3950 } 3951 3952 @Override requestShutdown(Message result)3953 public void requestShutdown(Message result) { 3954 IRadio radioProxy = getRadioProxy(result); 3955 if (radioProxy != null) { 3956 RILRequest rr = obtainRequest(RIL_REQUEST_SHUTDOWN, result, 3957 mRILDefaultWorkSource); 3958 3959 if (RILJ_LOGD) { 3960 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3961 } 3962 3963 try { 3964 radioProxy.requestShutdown(rr.mSerial); 3965 } catch (RemoteException | RuntimeException e) { 3966 handleRadioProxyExceptionForRR(rr, "requestShutdown", e); 3967 } 3968 } 3969 } 3970 3971 @Override getRadioCapability(Message response)3972 public void getRadioCapability(Message response) { 3973 IRadio radioProxy = getRadioProxy(response); 3974 if (radioProxy != null) { 3975 RILRequest rr = obtainRequest(RIL_REQUEST_GET_RADIO_CAPABILITY, response, 3976 mRILDefaultWorkSource); 3977 3978 if (RILJ_LOGD) { 3979 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 3980 } 3981 3982 try { 3983 radioProxy.getRadioCapability(rr.mSerial); 3984 } catch (RemoteException | RuntimeException e) { 3985 handleRadioProxyExceptionForRR(rr, "getRadioCapability", e); 3986 } 3987 } 3988 } 3989 3990 @Override setRadioCapability(RadioCapability rc, Message response)3991 public void setRadioCapability(RadioCapability rc, Message response) { 3992 IRadio radioProxy = getRadioProxy(response); 3993 if (radioProxy != null) { 3994 RILRequest rr = obtainRequest(RIL_REQUEST_SET_RADIO_CAPABILITY, response, 3995 mRILDefaultWorkSource); 3996 3997 if (RILJ_LOGD) { 3998 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 3999 + " RadioCapability = " + rc.toString()); 4000 } 4001 4002 android.hardware.radio.V1_0.RadioCapability halRc = 4003 new android.hardware.radio.V1_0.RadioCapability(); 4004 4005 halRc.session = rc.getSession(); 4006 halRc.phase = rc.getPhase(); 4007 halRc.raf = rc.getRadioAccessFamily(); 4008 halRc.logicalModemUuid = convertNullToEmptyString(rc.getLogicalModemUuid()); 4009 halRc.status = rc.getStatus(); 4010 4011 try { 4012 radioProxy.setRadioCapability(rr.mSerial, halRc); 4013 } catch (Exception e) { 4014 handleRadioProxyExceptionForRR(rr, "setRadioCapability", e); 4015 } 4016 } 4017 } 4018 4019 @Override startLceService(int reportIntervalMs, boolean pullMode, Message result)4020 public void startLceService(int reportIntervalMs, boolean pullMode, Message result) { 4021 IRadio radioProxy = getRadioProxy(result); 4022 4023 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 4024 // We have a 1.2 or later radio, so the LCE 1.0 LCE service control path is unused. 4025 // Instead the LCE functionality is always-on and provides unsolicited indications. 4026 return; 4027 } 4028 4029 if (radioProxy != null) { 4030 RILRequest rr = obtainRequest(RIL_REQUEST_START_LCE, result, 4031 mRILDefaultWorkSource); 4032 4033 if (RILJ_LOGD) { 4034 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) 4035 + " reportIntervalMs = " + reportIntervalMs + " pullMode = " + pullMode); 4036 } 4037 4038 try { 4039 radioProxy.startLceService(rr.mSerial, reportIntervalMs, pullMode); 4040 } catch (RemoteException | RuntimeException e) { 4041 handleRadioProxyExceptionForRR(rr, "startLceService", e); 4042 } 4043 } 4044 } 4045 4046 @Override stopLceService(Message result)4047 public void stopLceService(Message result) { 4048 IRadio radioProxy = getRadioProxy(result); 4049 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 4050 // We have a 1.2 or later radio, so the LCE 1.0 LCE service control is unused. 4051 // Instead the LCE functionality is always-on and provides unsolicited indications. 4052 return; 4053 } 4054 4055 if (radioProxy != null) { 4056 RILRequest rr = obtainRequest(RIL_REQUEST_STOP_LCE, result, 4057 mRILDefaultWorkSource); 4058 4059 if (RILJ_LOGD) { 4060 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4061 } 4062 4063 try { 4064 radioProxy.stopLceService(rr.mSerial); 4065 } catch (RemoteException | RuntimeException e) { 4066 handleRadioProxyExceptionForRR(rr, "stopLceService", e); 4067 } 4068 } 4069 } 4070 4071 /** 4072 * This will only be called if the LCE service is started in PULL mode, which is 4073 * only enabled when using Radio HAL versions 1.1 and earlier. 4074 * 4075 * It is still possible for vendors to override this behavior and use the 1.1 version 4076 * of LCE; however, this is strongly discouraged and this functionality will be removed 4077 * when HAL 1.x support is dropped. 4078 * 4079 * @deprecated HAL 1.2 and later use an always-on LCE that relies on indications. 4080 */ 4081 @Deprecated 4082 @Override pullLceData(Message response)4083 public void pullLceData(Message response) { 4084 IRadio radioProxy = getRadioProxy(response); 4085 if (radioProxy != null) { 4086 RILRequest rr = obtainRequest(RIL_REQUEST_PULL_LCEDATA, response, 4087 mRILDefaultWorkSource); 4088 4089 if (RILJ_LOGD) { 4090 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4091 } 4092 4093 try { 4094 radioProxy.pullLceData(rr.mSerial); 4095 } catch (RemoteException | RuntimeException e) { 4096 handleRadioProxyExceptionForRR(rr, "pullLceData", e); 4097 } 4098 } 4099 } 4100 4101 @Override getModemActivityInfo(Message result, WorkSource workSource)4102 public void getModemActivityInfo(Message result, WorkSource workSource) { 4103 workSource = getDeafultWorkSourceIfInvalid(workSource); 4104 IRadio radioProxy = getRadioProxy(result); 4105 if (radioProxy != null) { 4106 RILRequest rr = obtainRequest(RIL_REQUEST_GET_ACTIVITY_INFO, result, 4107 workSource); 4108 4109 if (RILJ_LOGD) { 4110 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4111 } 4112 4113 try { 4114 radioProxy.getModemActivityInfo(rr.mSerial); 4115 4116 Message msg = mRilHandler.obtainMessage(EVENT_BLOCKING_RESPONSE_TIMEOUT); 4117 msg.obj = null; 4118 msg.arg1 = rr.mSerial; 4119 mRilHandler.sendMessageDelayed(msg, DEFAULT_BLOCKING_MESSAGE_RESPONSE_TIMEOUT_MS); 4120 } catch (RemoteException | RuntimeException e) { 4121 handleRadioProxyExceptionForRR(rr, "getModemActivityInfo", e); 4122 } 4123 } 4124 4125 4126 } 4127 4128 /** 4129 * Convert a list of CarrierIdentifier into a list of Carrier defined in 1.0/types.hal. 4130 * @param carriers List of CarrierIdentifier 4131 * @return List of converted objects 4132 */ 4133 @VisibleForTesting createCarrierRestrictionList( List<CarrierIdentifier> carriers)4134 public static ArrayList<Carrier> createCarrierRestrictionList( 4135 List<CarrierIdentifier> carriers) { 4136 ArrayList<Carrier> result = new ArrayList<>(); 4137 for (CarrierIdentifier ci : carriers) { 4138 Carrier c = new Carrier(); 4139 c.mcc = convertNullToEmptyString(ci.getMcc()); 4140 c.mnc = convertNullToEmptyString(ci.getMnc()); 4141 int matchType = CarrierIdentifier.MatchType.ALL; 4142 String matchData = null; 4143 if (!TextUtils.isEmpty(ci.getSpn())) { 4144 matchType = CarrierIdentifier.MatchType.SPN; 4145 matchData = ci.getSpn(); 4146 } else if (!TextUtils.isEmpty(ci.getImsi())) { 4147 matchType = CarrierIdentifier.MatchType.IMSI_PREFIX; 4148 matchData = ci.getImsi(); 4149 } else if (!TextUtils.isEmpty(ci.getGid1())) { 4150 matchType = CarrierIdentifier.MatchType.GID1; 4151 matchData = ci.getGid1(); 4152 } else if (!TextUtils.isEmpty(ci.getGid2())) { 4153 matchType = CarrierIdentifier.MatchType.GID2; 4154 matchData = ci.getGid2(); 4155 } 4156 c.matchType = matchType; 4157 c.matchData = convertNullToEmptyString(matchData); 4158 result.add(c); 4159 } 4160 return result; 4161 } 4162 4163 @Override setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource)4164 public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, 4165 Message result, WorkSource workSource) { 4166 riljLog("RIL.java - setAllowedCarriers"); 4167 4168 checkNotNull(carrierRestrictionRules, "Carrier restriction cannot be null."); 4169 workSource = getDeafultWorkSourceIfInvalid(workSource); 4170 4171 IRadio radioProxy = getRadioProxy(result); 4172 if (radioProxy == null) { 4173 return; 4174 } 4175 4176 RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource); 4177 4178 if (RILJ_LOGD) { 4179 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " params: " 4180 + carrierRestrictionRules); 4181 } 4182 4183 // Extract multisim policy 4184 int policy = SimLockMultiSimPolicy.NO_MULTISIM_POLICY; 4185 switch (carrierRestrictionRules.getMultiSimPolicy()) { 4186 case CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT: 4187 policy = SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT; 4188 break; 4189 } 4190 4191 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 4192 riljLog("RIL.java - Using IRadio 1.4 or greater"); 4193 4194 android.hardware.radio.V1_4.IRadio radioProxy14 = 4195 (android.hardware.radio.V1_4.IRadio) radioProxy; 4196 4197 // Prepare structure with allowed list, excluded list and priority 4198 CarrierRestrictionsWithPriority carrierRestrictions = 4199 new CarrierRestrictionsWithPriority(); 4200 carrierRestrictions.allowedCarriers = 4201 createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); 4202 carrierRestrictions.excludedCarriers = 4203 createCarrierRestrictionList(carrierRestrictionRules.getExcludedCarriers()); 4204 carrierRestrictions.allowedCarriersPrioritized = 4205 (carrierRestrictionRules.getDefaultCarrierRestriction() 4206 == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED); 4207 4208 try { 4209 radioProxy14.setAllowedCarriers_1_4(rr.mSerial, carrierRestrictions, policy); 4210 } catch (RemoteException | RuntimeException e) { 4211 handleRadioProxyExceptionForRR(rr, "setAllowedCarriers_1_4", e); 4212 } 4213 } else { 4214 boolean isAllCarriersAllowed = carrierRestrictionRules.isAllCarriersAllowed(); 4215 4216 boolean supported = (isAllCarriersAllowed 4217 || (carrierRestrictionRules.getExcludedCarriers().isEmpty() 4218 && (carrierRestrictionRules.getDefaultCarrierRestriction() 4219 == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED))); 4220 supported = supported && (policy == SimLockMultiSimPolicy.NO_MULTISIM_POLICY); 4221 4222 if (!supported) { 4223 // Feature is not supported by IRadio interface 4224 riljLoge("setAllowedCarriers does not support excluded list on IRadio version" 4225 + " less than 1.4"); 4226 if (result != null) { 4227 AsyncResult.forMessage(result, null, 4228 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 4229 result.sendToTarget(); 4230 } 4231 return; 4232 } 4233 riljLog("RIL.java - Using IRadio 1.3 or lower"); 4234 4235 // Prepare structure with allowed list 4236 CarrierRestrictions carrierRestrictions = new CarrierRestrictions(); 4237 carrierRestrictions.allowedCarriers = 4238 createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); 4239 4240 try { 4241 radioProxy.setAllowedCarriers(rr.mSerial, isAllCarriersAllowed, 4242 carrierRestrictions); 4243 } catch (RemoteException | RuntimeException e) { 4244 handleRadioProxyExceptionForRR(rr, "setAllowedCarriers", e); 4245 } 4246 } 4247 } 4248 4249 @Override getAllowedCarriers(Message result, WorkSource workSource)4250 public void getAllowedCarriers(Message result, WorkSource workSource) { 4251 workSource = getDeafultWorkSourceIfInvalid(workSource); 4252 4253 IRadio radioProxy = getRadioProxy(result); 4254 if (radioProxy == null) { 4255 return; 4256 } 4257 4258 RILRequest rr = obtainRequest(RIL_REQUEST_GET_ALLOWED_CARRIERS, result, 4259 workSource); 4260 4261 if (RILJ_LOGD) { 4262 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4263 } 4264 4265 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { 4266 riljLog("RIL.java - Using IRadio 1.4 or greater"); 4267 4268 android.hardware.radio.V1_4.IRadio radioProxy14 = 4269 (android.hardware.radio.V1_4.IRadio) radioProxy; 4270 4271 try { 4272 radioProxy14.getAllowedCarriers_1_4(rr.mSerial); 4273 } catch (RemoteException | RuntimeException e) { 4274 handleRadioProxyExceptionForRR(rr, "getAllowedCarriers_1_4", e); 4275 } 4276 } else { 4277 riljLog("RIL.java - Using IRadio 1.3 or lower"); 4278 4279 try { 4280 radioProxy.getAllowedCarriers(rr.mSerial); 4281 } catch (RemoteException | RuntimeException e) { 4282 handleRadioProxyExceptionForRR(rr, "getAllowedCarriers", e); 4283 } 4284 } 4285 } 4286 4287 @Override sendDeviceState(int stateType, boolean state, Message result)4288 public void sendDeviceState(int stateType, boolean state, 4289 Message result) { 4290 IRadio radioProxy = getRadioProxy(result); 4291 if (radioProxy != null) { 4292 RILRequest rr = obtainRequest(RIL_REQUEST_SEND_DEVICE_STATE, result, 4293 mRILDefaultWorkSource); 4294 4295 if (RILJ_LOGD) { 4296 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " 4297 + stateType + ":" + state); 4298 } 4299 4300 try { 4301 radioProxy.sendDeviceState(rr.mSerial, stateType, state); 4302 } catch (RemoteException | RuntimeException e) { 4303 handleRadioProxyExceptionForRR(rr, "sendDeviceState", e); 4304 } 4305 } 4306 } 4307 4308 @Override setUnsolResponseFilter(int filter, Message result)4309 public void setUnsolResponseFilter(int filter, Message result) { 4310 IRadio radioProxy = getRadioProxy(result); 4311 if (radioProxy != null) { 4312 RILRequest rr = obtainRequest(RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, result, 4313 mRILDefaultWorkSource); 4314 4315 if (RILJ_LOGD) { 4316 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + filter); 4317 } 4318 4319 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { 4320 try { 4321 android.hardware.radio.V1_2.IRadio radioProxy12 = 4322 (android.hardware.radio.V1_2.IRadio) radioProxy; 4323 4324 radioProxy12.setIndicationFilter_1_2(rr.mSerial, filter); 4325 } catch (RemoteException | RuntimeException e) { 4326 handleRadioProxyExceptionForRR(rr, "setIndicationFilter_1_2", e); 4327 } 4328 } else { 4329 try { 4330 int filter10 = filter & IndicationFilter.ALL; 4331 radioProxy.setIndicationFilter(rr.mSerial, filter10); 4332 } catch (RemoteException | RuntimeException e) { 4333 handleRadioProxyExceptionForRR(rr, "setIndicationFilter", e); 4334 } 4335 } 4336 } 4337 } 4338 4339 @Override setSignalStrengthReportingCriteria(int hysteresisMs, int hysteresisDb, int[] thresholdsDbm, int ran, Message result)4340 public void setSignalStrengthReportingCriteria(int hysteresisMs, int hysteresisDb, 4341 int[] thresholdsDbm, int ran, Message result) { 4342 IRadio radioProxy = getRadioProxy(result); 4343 if (radioProxy != null) { 4344 if (mRadioVersion.less(RADIO_HAL_VERSION_1_2)) { 4345 riljLoge("setSignalStrengthReportingCriteria ignored on IRadio version less " 4346 + "than 1.2"); 4347 return; 4348 } 4349 4350 RILRequest rr = obtainRequest(RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA, 4351 result, mRILDefaultWorkSource); 4352 4353 if (RILJ_LOGD) { 4354 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4355 } 4356 4357 try { 4358 android.hardware.radio.V1_2.IRadio radioProxy12 = 4359 (android.hardware.radio.V1_2.IRadio) radioProxy; 4360 radioProxy12.setSignalStrengthReportingCriteria(rr.mSerial, hysteresisMs, 4361 hysteresisDb, primitiveArrayToArrayList(thresholdsDbm), 4362 convertRanToHalRan(ran)); 4363 } catch (RemoteException | RuntimeException e) { 4364 handleRadioProxyExceptionForRR(rr, "setSignalStrengthReportingCriteria", e); 4365 } 4366 } 4367 } 4368 4369 @Override setLinkCapacityReportingCriteria(int hysteresisMs, int hysteresisDlKbps, int hysteresisUlKbps, int[] thresholdsDlKbps, int[] thresholdsUlKbps, int ran, Message result)4370 public void setLinkCapacityReportingCriteria(int hysteresisMs, int hysteresisDlKbps, 4371 int hysteresisUlKbps, int[] thresholdsDlKbps, int[] thresholdsUlKbps, int ran, 4372 Message result) { 4373 IRadio radioProxy = getRadioProxy(result); 4374 if (radioProxy != null) { 4375 if (mRadioVersion.less(RADIO_HAL_VERSION_1_2)) { 4376 riljLoge("setLinkCapacityReportingCriteria ignored on IRadio version less " 4377 + "than 1.2"); 4378 return; 4379 } 4380 4381 RILRequest rr = obtainRequest(RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA, 4382 result, mRILDefaultWorkSource); 4383 4384 if (RILJ_LOGD) { 4385 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4386 } 4387 4388 try { 4389 android.hardware.radio.V1_2.IRadio radioProxy12 = 4390 (android.hardware.radio.V1_2.IRadio) radioProxy; 4391 radioProxy12.setLinkCapacityReportingCriteria(rr.mSerial, hysteresisMs, 4392 hysteresisDlKbps, hysteresisUlKbps, 4393 primitiveArrayToArrayList(thresholdsDlKbps), 4394 primitiveArrayToArrayList(thresholdsUlKbps), convertRanToHalRan(ran)); 4395 } catch (RemoteException | RuntimeException e) { 4396 handleRadioProxyExceptionForRR(rr, "setLinkCapacityReportingCriteria", e); 4397 } 4398 } 4399 } 4400 convertRanToHalRan(int radioAccessNetwork)4401 private static int convertRanToHalRan(int radioAccessNetwork) { 4402 switch (radioAccessNetwork) { 4403 case AccessNetworkType.GERAN: 4404 return AccessNetwork.GERAN; 4405 case AccessNetworkType.UTRAN: 4406 return AccessNetwork.UTRAN; 4407 case AccessNetworkType.EUTRAN: 4408 return AccessNetwork.EUTRAN; 4409 case AccessNetworkType.CDMA2000: 4410 return AccessNetwork.CDMA2000; 4411 case AccessNetworkType.IWLAN: 4412 return AccessNetwork.IWLAN; 4413 case AccessNetworkType.UNKNOWN: 4414 default: 4415 return 0; 4416 } 4417 } 4418 4419 @Override setSimCardPower(int state, Message result, WorkSource workSource)4420 public void setSimCardPower(int state, Message result, WorkSource workSource) { 4421 workSource = getDeafultWorkSourceIfInvalid(workSource); 4422 IRadio radioProxy = getRadioProxy(result); 4423 if (radioProxy != null) { 4424 RILRequest rr = obtainRequest(RIL_REQUEST_SET_SIM_CARD_POWER, result, 4425 workSource); 4426 4427 if (RILJ_LOGD) { 4428 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + state); 4429 } 4430 4431 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_1)) { 4432 try { 4433 android.hardware.radio.V1_1.IRadio radioProxy11 = 4434 (android.hardware.radio.V1_1.IRadio) radioProxy; 4435 radioProxy11.setSimCardPower_1_1(rr.mSerial, state); 4436 } catch (RemoteException | RuntimeException e) { 4437 handleRadioProxyExceptionForRR(rr, "setSimCardPower", e); 4438 } 4439 } else { 4440 try { 4441 switch (state) { 4442 case TelephonyManager.CARD_POWER_DOWN: { 4443 radioProxy.setSimCardPower(rr.mSerial, false); 4444 break; 4445 } 4446 case TelephonyManager.CARD_POWER_UP: { 4447 radioProxy.setSimCardPower(rr.mSerial, true); 4448 break; 4449 } 4450 default: { 4451 if (result != null) { 4452 AsyncResult.forMessage(result, null, 4453 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 4454 result.sendToTarget(); 4455 } 4456 } 4457 } 4458 } catch (RemoteException | RuntimeException e) { 4459 handleRadioProxyExceptionForRR(rr, "setSimCardPower", e); 4460 } 4461 } 4462 } 4463 } 4464 4465 @Override setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo, Message result)4466 public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo, 4467 Message result) { 4468 checkNotNull(imsiEncryptionInfo, "ImsiEncryptionInfo cannot be null."); 4469 IRadio radioProxy = getRadioProxy(result); 4470 if (radioProxy != null) { 4471 if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_1)) { 4472 android.hardware.radio.V1_1.IRadio radioProxy11 = 4473 (android.hardware.radio.V1_1.IRadio ) radioProxy; 4474 4475 RILRequest rr = obtainRequest(RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION, result, 4476 mRILDefaultWorkSource); 4477 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4478 4479 try { 4480 android.hardware.radio.V1_1.ImsiEncryptionInfo halImsiInfo = 4481 new android.hardware.radio.V1_1.ImsiEncryptionInfo(); 4482 halImsiInfo.mnc = imsiEncryptionInfo.getMnc(); 4483 halImsiInfo.mcc = imsiEncryptionInfo.getMcc(); 4484 halImsiInfo.keyIdentifier = imsiEncryptionInfo.getKeyIdentifier(); 4485 if (imsiEncryptionInfo.getExpirationTime() != null) { 4486 halImsiInfo.expirationTime = 4487 imsiEncryptionInfo.getExpirationTime().getTime(); 4488 } 4489 for (byte b : imsiEncryptionInfo.getPublicKey().getEncoded()) { 4490 halImsiInfo.carrierKey.add(new Byte(b)); 4491 } 4492 4493 radioProxy11.setCarrierInfoForImsiEncryption( 4494 rr.mSerial, halImsiInfo); 4495 } catch (RemoteException | RuntimeException e) { 4496 handleRadioProxyExceptionForRR(rr, "setCarrierInfoForImsiEncryption", e); 4497 } 4498 } else if (result != null) { 4499 AsyncResult.forMessage(result, null, 4500 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 4501 result.sendToTarget(); 4502 } 4503 } 4504 } 4505 4506 @Override startNattKeepalive( int contextId, KeepalivePacketData packetData, int intervalMillis, Message result)4507 public void startNattKeepalive( 4508 int contextId, KeepalivePacketData packetData, int intervalMillis, Message result) { 4509 checkNotNull(packetData, "KeepaliveRequest cannot be null."); 4510 IRadio radioProxy = getRadioProxy(result); 4511 if (radioProxy == null) { 4512 riljLoge("Radio Proxy object is null!"); 4513 return; 4514 } 4515 4516 if (mRadioVersion.less(RADIO_HAL_VERSION_1_1)) { 4517 if (result != null) { 4518 AsyncResult.forMessage(result, null, 4519 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 4520 result.sendToTarget(); 4521 } 4522 return; 4523 } 4524 4525 android.hardware.radio.V1_1.IRadio radioProxy11 = 4526 (android.hardware.radio.V1_1.IRadio) radioProxy; 4527 4528 RILRequest rr = obtainRequest( 4529 RIL_REQUEST_START_KEEPALIVE, result, mRILDefaultWorkSource); 4530 4531 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4532 4533 try { 4534 android.hardware.radio.V1_1.KeepaliveRequest req = 4535 new android.hardware.radio.V1_1.KeepaliveRequest(); 4536 4537 req.cid = contextId; 4538 4539 if (packetData.dstAddress instanceof Inet4Address) { 4540 req.type = android.hardware.radio.V1_1.KeepaliveType.NATT_IPV4; 4541 } else if (packetData.dstAddress instanceof Inet6Address) { 4542 req.type = android.hardware.radio.V1_1.KeepaliveType.NATT_IPV6; 4543 } else { 4544 AsyncResult.forMessage(result, null, 4545 CommandException.fromRilErrno(INVALID_ARGUMENTS)); 4546 result.sendToTarget(); 4547 return; 4548 } 4549 4550 appendPrimitiveArrayToArrayList( 4551 packetData.srcAddress.getAddress(), req.sourceAddress); 4552 req.sourcePort = packetData.srcPort; 4553 appendPrimitiveArrayToArrayList( 4554 packetData.dstAddress.getAddress(), req.destinationAddress); 4555 req.destinationPort = packetData.dstPort; 4556 req.maxKeepaliveIntervalMillis = intervalMillis; 4557 4558 radioProxy11.startKeepalive(rr.mSerial, req); 4559 } catch (RemoteException | RuntimeException e) { 4560 handleRadioProxyExceptionForRR(rr, "startNattKeepalive", e); 4561 } 4562 } 4563 4564 @Override stopNattKeepalive(int sessionHandle, Message result)4565 public void stopNattKeepalive(int sessionHandle, Message result) { 4566 IRadio radioProxy = getRadioProxy(result); 4567 if (radioProxy == null) { 4568 Rlog.e(RIL.RILJ_LOG_TAG, "Radio Proxy object is null!"); 4569 return; 4570 } 4571 4572 if (mRadioVersion.less(RADIO_HAL_VERSION_1_1)) { 4573 if (result != null) { 4574 AsyncResult.forMessage(result, null, 4575 CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); 4576 result.sendToTarget(); 4577 } 4578 return; 4579 } 4580 4581 android.hardware.radio.V1_1.IRadio radioProxy11 = 4582 (android.hardware.radio.V1_1.IRadio) radioProxy; 4583 4584 RILRequest rr = obtainRequest( 4585 RIL_REQUEST_STOP_KEEPALIVE, result, mRILDefaultWorkSource); 4586 4587 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4588 4589 try { 4590 radioProxy11.stopKeepalive(rr.mSerial, sessionHandle); 4591 } catch (RemoteException | RuntimeException e) { 4592 handleRadioProxyExceptionForRR(rr, "stopNattKeepalive", e); 4593 } 4594 } 4595 4596 @Override getIMEI(Message result)4597 public void getIMEI(Message result) { 4598 throw new RuntimeException("getIMEI not expected to be called"); 4599 } 4600 4601 @Override getIMEISV(Message result)4602 public void getIMEISV(Message result) { 4603 throw new RuntimeException("getIMEISV not expected to be called"); 4604 } 4605 4606 /** 4607 * @deprecated 4608 */ 4609 @Deprecated 4610 @Override getLastPdpFailCause(Message result)4611 public void getLastPdpFailCause(Message result) { 4612 throw new RuntimeException("getLastPdpFailCause not expected to be called"); 4613 } 4614 4615 /** 4616 * The preferred new alternative to getLastPdpFailCause 4617 */ 4618 @Override getLastDataCallFailCause(Message result)4619 public void getLastDataCallFailCause(Message result) { 4620 throw new RuntimeException("getLastDataCallFailCause not expected to be called"); 4621 } 4622 4623 /** 4624 * Translates EF_SMS status bits to a status value compatible with 4625 * SMS AT commands. See TS 27.005 3.1. 4626 */ translateStatus(int status)4627 private int translateStatus(int status) { 4628 switch(status & 0x7) { 4629 case SmsManager.STATUS_ON_ICC_READ: 4630 return 1; 4631 case SmsManager.STATUS_ON_ICC_UNREAD: 4632 return 0; 4633 case SmsManager.STATUS_ON_ICC_SENT: 4634 return 3; 4635 case SmsManager.STATUS_ON_ICC_UNSENT: 4636 return 2; 4637 } 4638 4639 // Default to READ. 4640 return 1; 4641 } 4642 4643 @Override resetRadio(Message result)4644 public void resetRadio(Message result) { 4645 throw new RuntimeException("resetRadio not expected to be called"); 4646 } 4647 4648 /** 4649 * {@inheritDoc} 4650 */ 4651 @Override handleCallSetupRequestFromSim(boolean accept, Message result)4652 public void handleCallSetupRequestFromSim(boolean accept, Message result) { 4653 IRadio radioProxy = getRadioProxy(result); 4654 if (radioProxy != null) { 4655 RILRequest rr = obtainRequest(RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, 4656 result, mRILDefaultWorkSource); 4657 4658 if (RILJ_LOGD) { 4659 riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); 4660 } 4661 4662 try { 4663 radioProxy.handleStkCallSetupRequestFromSim(rr.mSerial, accept); 4664 } catch (RemoteException | RuntimeException e) { 4665 handleRadioProxyExceptionForRR(rr, "getAllowedCarriers", e); 4666 } 4667 } 4668 } 4669 4670 //***** Private Methods 4671 4672 /** 4673 * This is a helper function to be called when a RadioIndication callback is called. 4674 * It takes care of acquiring wakelock and sending ack if needed. 4675 * @param indicationType RadioIndicationType received 4676 */ processIndication(int indicationType)4677 void processIndication(int indicationType) { 4678 if (indicationType == RadioIndicationType.UNSOLICITED_ACK_EXP) { 4679 sendAck(); 4680 if (RILJ_LOGD) riljLog("Unsol response received; Sending ack to ril.cpp"); 4681 } else { 4682 // ack is not expected to be sent back. Nothing is required to be done here. 4683 } 4684 } 4685 processRequestAck(int serial)4686 void processRequestAck(int serial) { 4687 RILRequest rr; 4688 synchronized (mRequestList) { 4689 rr = mRequestList.get(serial); 4690 } 4691 if (rr == null) { 4692 Rlog.w(RIL.RILJ_LOG_TAG, "processRequestAck: Unexpected solicited ack response! " 4693 + "serial: " + serial); 4694 } else { 4695 decrementWakeLock(rr); 4696 if (RIL.RILJ_LOGD) { 4697 riljLog(rr.serialString() + " Ack < " + RIL.requestToString(rr.mRequest)); 4698 } 4699 } 4700 } 4701 4702 /** 4703 * This is a helper function to be called when a RadioResponse callback is called. 4704 * It takes care of acks, wakelocks, and finds and returns RILRequest corresponding to the 4705 * response if one is found. 4706 * @param responseInfo RadioResponseInfo received in response callback 4707 * @return RILRequest corresponding to the response 4708 */ 4709 @VisibleForTesting processResponse(RadioResponseInfo responseInfo)4710 public RILRequest processResponse(RadioResponseInfo responseInfo) { 4711 int serial = responseInfo.serial; 4712 int error = responseInfo.error; 4713 int type = responseInfo.type; 4714 4715 RILRequest rr = null; 4716 4717 if (type == RadioResponseType.SOLICITED_ACK) { 4718 synchronized (mRequestList) { 4719 rr = mRequestList.get(serial); 4720 } 4721 if (rr == null) { 4722 Rlog.w(RILJ_LOG_TAG, "Unexpected solicited ack response! sn: " + serial); 4723 } else { 4724 decrementWakeLock(rr); 4725 if (mRadioBugDetector != null) { 4726 mRadioBugDetector.detectRadioBug(rr.mRequest, error); 4727 } 4728 if (RILJ_LOGD) { 4729 riljLog(rr.serialString() + " Ack < " + requestToString(rr.mRequest)); 4730 } 4731 } 4732 return rr; 4733 } 4734 4735 rr = findAndRemoveRequestFromList(serial); 4736 if (rr == null) { 4737 Rlog.e(RIL.RILJ_LOG_TAG, "processResponse: Unexpected response! serial: " + serial 4738 + " error: " + error); 4739 return null; 4740 } 4741 4742 // Time logging for RIL command and storing it in TelephonyHistogram. 4743 addToRilHistogram(rr); 4744 if (mRadioBugDetector != null) { 4745 mRadioBugDetector.detectRadioBug(rr.mRequest, error); 4746 } 4747 if (type == RadioResponseType.SOLICITED_ACK_EXP) { 4748 sendAck(); 4749 if (RIL.RILJ_LOGD) { 4750 riljLog("Response received for " + rr.serialString() + " " 4751 + RIL.requestToString(rr.mRequest) + " Sending ack to ril.cpp"); 4752 } 4753 } else { 4754 // ack sent for SOLICITED_ACK_EXP above; nothing to do for SOLICITED response 4755 } 4756 4757 // Here and below fake RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, see b/7255789. 4758 // This is needed otherwise we don't automatically transition to the main lock 4759 // screen when the pin or puk is entered incorrectly. 4760 switch (rr.mRequest) { 4761 case RIL_REQUEST_ENTER_SIM_PUK: 4762 case RIL_REQUEST_ENTER_SIM_PUK2: 4763 if (mIccStatusChangedRegistrants != null) { 4764 if (RILJ_LOGD) { 4765 riljLog("ON enter sim puk fakeSimStatusChanged: reg count=" 4766 + mIccStatusChangedRegistrants.size()); 4767 } 4768 mIccStatusChangedRegistrants.notifyRegistrants(); 4769 } 4770 break; 4771 case RIL_REQUEST_SHUTDOWN: 4772 setRadioState(TelephonyManager.RADIO_POWER_UNAVAILABLE, 4773 false /* forceNotifyRegistrants */); 4774 break; 4775 } 4776 4777 if (error != RadioError.NONE) { 4778 switch (rr.mRequest) { 4779 case RIL_REQUEST_ENTER_SIM_PIN: 4780 case RIL_REQUEST_ENTER_SIM_PIN2: 4781 case RIL_REQUEST_CHANGE_SIM_PIN: 4782 case RIL_REQUEST_CHANGE_SIM_PIN2: 4783 case RIL_REQUEST_SET_FACILITY_LOCK: 4784 if (mIccStatusChangedRegistrants != null) { 4785 if (RILJ_LOGD) { 4786 riljLog("ON some errors fakeSimStatusChanged: reg count=" 4787 + mIccStatusChangedRegistrants.size()); 4788 } 4789 mIccStatusChangedRegistrants.notifyRegistrants(); 4790 } 4791 break; 4792 4793 } 4794 } else { 4795 switch (rr.mRequest) { 4796 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: 4797 if (mTestingEmergencyCall.getAndSet(false)) { 4798 if (mEmergencyCallbackModeRegistrant != null) { 4799 riljLog("testing emergency call, notify ECM Registrants"); 4800 mEmergencyCallbackModeRegistrant.notifyRegistrant(); 4801 } 4802 } 4803 } 4804 } 4805 return rr; 4806 } 4807 4808 /** 4809 * This is a helper function to be called at the end of all RadioResponse callbacks. 4810 * It takes care of sending error response, logging, decrementing wakelock if needed, and 4811 * releases the request from memory pool. 4812 * @param rr RILRequest for which response callback was called 4813 * @param responseInfo RadioResponseInfo received in the callback 4814 * @param ret object to be returned to request sender 4815 */ 4816 @VisibleForTesting processResponseDone(RILRequest rr, RadioResponseInfo responseInfo, Object ret)4817 public void processResponseDone(RILRequest rr, RadioResponseInfo responseInfo, Object ret) { 4818 if (responseInfo.error == 0) { 4819 if (RILJ_LOGD) { 4820 riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) 4821 + " " + retToString(rr.mRequest, ret)); 4822 } 4823 } else { 4824 if (RILJ_LOGD) { 4825 riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) 4826 + " error " + responseInfo.error); 4827 } 4828 rr.onError(responseInfo.error, ret); 4829 } 4830 mMetrics.writeOnRilSolicitedResponse(mPhoneId, rr.mSerial, responseInfo.error, 4831 rr.mRequest, ret); 4832 if (rr != null) { 4833 if (responseInfo.type == RadioResponseType.SOLICITED) { 4834 decrementWakeLock(rr); 4835 } 4836 rr.release(); 4837 } 4838 } 4839 4840 /** 4841 * Function to send ack and acquire related wakelock 4842 */ sendAck()4843 private void sendAck() { 4844 // TODO: Remove rr and clean up acquireWakelock for response and ack 4845 RILRequest rr = RILRequest.obtain(RIL_RESPONSE_ACKNOWLEDGEMENT, null, 4846 mRILDefaultWorkSource); 4847 acquireWakeLock(rr, RIL.FOR_ACK_WAKELOCK); 4848 IRadio radioProxy = getRadioProxy(null); 4849 if (radioProxy != null) { 4850 try { 4851 radioProxy.responseAcknowledgement(); 4852 } catch (RemoteException | RuntimeException e) { 4853 handleRadioProxyExceptionForRR(rr, "sendAck", e); 4854 riljLoge("sendAck: " + e); 4855 } 4856 } else { 4857 Rlog.e(RILJ_LOG_TAG, "Error trying to send ack, radioProxy = null"); 4858 } 4859 rr.release(); 4860 } 4861 getDeafultWorkSourceIfInvalid(WorkSource workSource)4862 private WorkSource getDeafultWorkSourceIfInvalid(WorkSource workSource) { 4863 if (workSource == null) { 4864 workSource = mRILDefaultWorkSource; 4865 } 4866 4867 return workSource; 4868 } 4869 4870 4871 /** 4872 * Holds a PARTIAL_WAKE_LOCK whenever 4873 * a) There is outstanding RIL request sent to RIL deamon and no replied 4874 * b) There is a request pending to be sent out. 4875 * 4876 * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't 4877 * happen often. 4878 */ 4879 @UnsupportedAppUsage acquireWakeLock(RILRequest rr, int wakeLockType)4880 private void acquireWakeLock(RILRequest rr, int wakeLockType) { 4881 synchronized (rr) { 4882 if (rr.mWakeLockType != INVALID_WAKELOCK) { 4883 Rlog.d(RILJ_LOG_TAG, "Failed to aquire wakelock for " + rr.serialString()); 4884 return; 4885 } 4886 4887 switch(wakeLockType) { 4888 case FOR_WAKELOCK: 4889 synchronized (mWakeLock) { 4890 mWakeLock.acquire(); 4891 mWakeLockCount++; 4892 mWlSequenceNum++; 4893 4894 String clientId = rr.getWorkSourceClientId(); 4895 if (!mClientWakelockTracker.isClientActive(clientId)) { 4896 mActiveWakelockWorkSource.add(rr.mWorkSource); 4897 mWakeLock.setWorkSource(mActiveWakelockWorkSource); 4898 } 4899 4900 mClientWakelockTracker.startTracking(rr.mClientId, 4901 rr.mRequest, rr.mSerial, mWakeLockCount); 4902 4903 Message msg = mRilHandler.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT); 4904 msg.arg1 = mWlSequenceNum; 4905 mRilHandler.sendMessageDelayed(msg, mWakeLockTimeout); 4906 } 4907 break; 4908 case FOR_ACK_WAKELOCK: 4909 synchronized (mAckWakeLock) { 4910 mAckWakeLock.acquire(); 4911 mAckWlSequenceNum++; 4912 4913 Message msg = mRilHandler.obtainMessage(EVENT_ACK_WAKE_LOCK_TIMEOUT); 4914 msg.arg1 = mAckWlSequenceNum; 4915 mRilHandler.sendMessageDelayed(msg, mAckWakeLockTimeout); 4916 } 4917 break; 4918 default: //WTF 4919 Rlog.w(RILJ_LOG_TAG, "Acquiring Invalid Wakelock type " + wakeLockType); 4920 return; 4921 } 4922 rr.mWakeLockType = wakeLockType; 4923 } 4924 } 4925 4926 /** Returns the wake lock of the given type. */ 4927 @VisibleForTesting getWakeLock(int wakeLockType)4928 public WakeLock getWakeLock(int wakeLockType) { 4929 return wakeLockType == FOR_WAKELOCK ? mWakeLock : mAckWakeLock; 4930 } 4931 4932 /** Returns the {@link RilHandler} instance. */ 4933 @VisibleForTesting getRilHandler()4934 public RilHandler getRilHandler() { 4935 return mRilHandler; 4936 } 4937 4938 /** Returns the Ril request list. */ 4939 @VisibleForTesting getRilRequestList()4940 public SparseArray<RILRequest> getRilRequestList() { 4941 return mRequestList; 4942 } 4943 4944 @UnsupportedAppUsage decrementWakeLock(RILRequest rr)4945 private void decrementWakeLock(RILRequest rr) { 4946 synchronized (rr) { 4947 switch(rr.mWakeLockType) { 4948 case FOR_WAKELOCK: 4949 synchronized (mWakeLock) { 4950 mClientWakelockTracker.stopTracking(rr.mClientId, 4951 rr.mRequest, rr.mSerial, 4952 (mWakeLockCount > 1) ? mWakeLockCount - 1 : 0); 4953 String clientId = rr.getWorkSourceClientId(); 4954 if (!mClientWakelockTracker.isClientActive(clientId)) { 4955 mActiveWakelockWorkSource.remove(rr.mWorkSource); 4956 mWakeLock.setWorkSource(mActiveWakelockWorkSource); 4957 } 4958 4959 if (mWakeLockCount > 1) { 4960 mWakeLockCount--; 4961 } else { 4962 mWakeLockCount = 0; 4963 mWakeLock.release(); 4964 } 4965 } 4966 break; 4967 case FOR_ACK_WAKELOCK: 4968 //We do not decrement the ACK wakelock 4969 break; 4970 case INVALID_WAKELOCK: 4971 break; 4972 default: 4973 Rlog.w(RILJ_LOG_TAG, "Decrementing Invalid Wakelock type " + rr.mWakeLockType); 4974 } 4975 rr.mWakeLockType = INVALID_WAKELOCK; 4976 } 4977 } 4978 4979 @UnsupportedAppUsage clearWakeLock(int wakeLockType)4980 private boolean clearWakeLock(int wakeLockType) { 4981 if (wakeLockType == FOR_WAKELOCK) { 4982 synchronized (mWakeLock) { 4983 if (mWakeLockCount == 0 && !mWakeLock.isHeld()) return false; 4984 Rlog.d(RILJ_LOG_TAG, "NOTE: mWakeLockCount is " + mWakeLockCount 4985 + "at time of clearing"); 4986 mWakeLockCount = 0; 4987 mWakeLock.release(); 4988 mClientWakelockTracker.stopTrackingAll(); 4989 mActiveWakelockWorkSource = new WorkSource(); 4990 return true; 4991 } 4992 } else { 4993 synchronized (mAckWakeLock) { 4994 if (!mAckWakeLock.isHeld()) return false; 4995 mAckWakeLock.release(); 4996 return true; 4997 } 4998 } 4999 } 5000 5001 /** 5002 * Release each request in mRequestList then clear the list 5003 * @param error is the RIL_Errno sent back 5004 * @param loggable true means to print all requests in mRequestList 5005 */ 5006 @UnsupportedAppUsage clearRequestList(int error, boolean loggable)5007 private void clearRequestList(int error, boolean loggable) { 5008 RILRequest rr; 5009 synchronized (mRequestList) { 5010 int count = mRequestList.size(); 5011 if (RILJ_LOGD && loggable) { 5012 Rlog.d(RILJ_LOG_TAG, "clearRequestList " + " mWakeLockCount=" 5013 + mWakeLockCount + " mRequestList=" + count); 5014 } 5015 5016 for (int i = 0; i < count; i++) { 5017 rr = mRequestList.valueAt(i); 5018 if (RILJ_LOGD && loggable) { 5019 Rlog.d(RILJ_LOG_TAG, i + ": [" + rr.mSerial + "] " 5020 + requestToString(rr.mRequest)); 5021 } 5022 rr.onError(error, null); 5023 decrementWakeLock(rr); 5024 rr.release(); 5025 } 5026 mRequestList.clear(); 5027 } 5028 } 5029 5030 @UnsupportedAppUsage findAndRemoveRequestFromList(int serial)5031 private RILRequest findAndRemoveRequestFromList(int serial) { 5032 RILRequest rr = null; 5033 synchronized (mRequestList) { 5034 rr = mRequestList.get(serial); 5035 if (rr != null) { 5036 mRequestList.remove(serial); 5037 } 5038 } 5039 5040 return rr; 5041 } 5042 addToRilHistogram(RILRequest rr)5043 private void addToRilHistogram(RILRequest rr) { 5044 long endTime = SystemClock.elapsedRealtime(); 5045 int totalTime = (int) (endTime - rr.mStartTimeMs); 5046 5047 synchronized (mRilTimeHistograms) { 5048 TelephonyHistogram entry = mRilTimeHistograms.get(rr.mRequest); 5049 if (entry == null) { 5050 // We would have total #RIL_HISTOGRAM_BUCKET_COUNT range buckets for RIL commands 5051 entry = new TelephonyHistogram(TelephonyHistogram.TELEPHONY_CATEGORY_RIL, 5052 rr.mRequest, RIL_HISTOGRAM_BUCKET_COUNT); 5053 mRilTimeHistograms.put(rr.mRequest, entry); 5054 } 5055 entry.addTimeTaken(totalTime); 5056 } 5057 } 5058 5059 @UnsupportedAppUsage makeStaticRadioCapability()5060 RadioCapability makeStaticRadioCapability() { 5061 // default to UNKNOWN so we fail fast. 5062 int raf = RadioAccessFamily.RAF_UNKNOWN; 5063 5064 String rafString = mContext.getResources().getString( 5065 com.android.internal.R.string.config_radio_access_family); 5066 if (!TextUtils.isEmpty(rafString)) { 5067 raf = RadioAccessFamily.rafTypeFromString(rafString); 5068 } 5069 RadioCapability rc = new RadioCapability(mPhoneId.intValue(), 0, 0, raf, 5070 "", RadioCapability.RC_STATUS_SUCCESS); 5071 if (RILJ_LOGD) riljLog("Faking RIL_REQUEST_GET_RADIO_CAPABILITY response using " + raf); 5072 return rc; 5073 } 5074 5075 @UnsupportedAppUsage retToString(int req, Object ret)5076 static String retToString(int req, Object ret) { 5077 if (ret == null) return ""; 5078 switch (req) { 5079 // Don't log these return values, for privacy's sake. 5080 case RIL_REQUEST_GET_IMSI: 5081 case RIL_REQUEST_GET_IMEI: 5082 case RIL_REQUEST_GET_IMEISV: 5083 case RIL_REQUEST_SIM_OPEN_CHANNEL: 5084 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: 5085 5086 if (!RILJ_LOGV) { 5087 // If not versbose logging just return and don't display IMSI and IMEI, IMEISV 5088 return ""; 5089 } 5090 } 5091 5092 StringBuilder sb; 5093 String s; 5094 int length; 5095 if (ret instanceof int[]) { 5096 int[] intArray = (int[]) ret; 5097 length = intArray.length; 5098 sb = new StringBuilder("{"); 5099 if (length > 0) { 5100 int i = 0; 5101 sb.append(intArray[i++]); 5102 while (i < length) { 5103 sb.append(", ").append(intArray[i++]); 5104 } 5105 } 5106 sb.append("}"); 5107 s = sb.toString(); 5108 } else if (ret instanceof String[]) { 5109 String[] strings = (String[]) ret; 5110 length = strings.length; 5111 sb = new StringBuilder("{"); 5112 if (length > 0) { 5113 int i = 0; 5114 // position 0 is IMEI in RIL_REQUEST_DEVICE_IDENTITY 5115 if (req == RIL_REQUEST_DEVICE_IDENTITY) { 5116 sb.append(Rlog.pii(RILJ_LOG_TAG, strings[i++])); 5117 } else { 5118 sb.append(strings[i++]); 5119 } 5120 while (i < length) { 5121 sb.append(", ").append(strings[i++]); 5122 } 5123 } 5124 sb.append("}"); 5125 s = sb.toString(); 5126 } else if (req == RIL_REQUEST_GET_CURRENT_CALLS) { 5127 ArrayList<DriverCall> calls = (ArrayList<DriverCall>) ret; 5128 sb = new StringBuilder("{"); 5129 for (DriverCall dc : calls) { 5130 sb.append("[").append(dc).append("] "); 5131 } 5132 sb.append("}"); 5133 s = sb.toString(); 5134 } else if (req == RIL_REQUEST_GET_NEIGHBORING_CELL_IDS) { 5135 ArrayList<NeighboringCellInfo> cells = (ArrayList<NeighboringCellInfo>) ret; 5136 sb = new StringBuilder("{"); 5137 for (NeighboringCellInfo cell : cells) { 5138 sb.append("[").append(cell).append("] "); 5139 } 5140 sb.append("}"); 5141 s = sb.toString(); 5142 } else if (req == RIL_REQUEST_QUERY_CALL_FORWARD_STATUS) { 5143 CallForwardInfo[] cinfo = (CallForwardInfo[]) ret; 5144 length = cinfo.length; 5145 sb = new StringBuilder("{"); 5146 for (int i = 0; i < length; i++) { 5147 sb.append("[").append(cinfo[i]).append("] "); 5148 } 5149 sb.append("}"); 5150 s = sb.toString(); 5151 } else if (req == RIL_REQUEST_GET_HARDWARE_CONFIG) { 5152 ArrayList<HardwareConfig> hwcfgs = (ArrayList<HardwareConfig>) ret; 5153 sb = new StringBuilder(" "); 5154 for (HardwareConfig hwcfg : hwcfgs) { 5155 sb.append("[").append(hwcfg).append("] "); 5156 } 5157 s = sb.toString(); 5158 } else { 5159 s = ret.toString(); 5160 } 5161 return s; 5162 } 5163 writeMetricsCallRing(char[] response)5164 void writeMetricsCallRing(char[] response) { 5165 mMetrics.writeRilCallRing(mPhoneId, response); 5166 } 5167 writeMetricsSrvcc(int state)5168 void writeMetricsSrvcc(int state) { 5169 mMetrics.writeRilSrvcc(mPhoneId, state); 5170 } 5171 writeMetricsModemRestartEvent(String reason)5172 void writeMetricsModemRestartEvent(String reason) { 5173 mMetrics.writeModemRestartEvent(mPhoneId, reason); 5174 } 5175 5176 /** 5177 * Notify all registrants that the ril has connected or disconnected. 5178 * 5179 * @param rilVer is the version of the ril or -1 if disconnected. 5180 */ 5181 @UnsupportedAppUsage notifyRegistrantsRilConnectionChanged(int rilVer)5182 void notifyRegistrantsRilConnectionChanged(int rilVer) { 5183 mRilVersion = rilVer; 5184 if (mRilConnectedRegistrants != null) { 5185 mRilConnectedRegistrants.notifyRegistrants( 5186 new AsyncResult(null, new Integer(rilVer), null)); 5187 } 5188 } 5189 5190 @UnsupportedAppUsage 5191 void notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec)5192 notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) { 5193 int response = RIL_UNSOL_CDMA_INFO_REC; 5194 if (infoRec.record instanceof CdmaInformationRecords.CdmaDisplayInfoRec) { 5195 if (mDisplayInfoRegistrants != null) { 5196 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5197 mDisplayInfoRegistrants.notifyRegistrants( 5198 new AsyncResult(null, infoRec.record, null)); 5199 } 5200 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaSignalInfoRec) { 5201 if (mSignalInfoRegistrants != null) { 5202 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5203 mSignalInfoRegistrants.notifyRegistrants( 5204 new AsyncResult(null, infoRec.record, null)); 5205 } 5206 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaNumberInfoRec) { 5207 if (mNumberInfoRegistrants != null) { 5208 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5209 mNumberInfoRegistrants.notifyRegistrants( 5210 new AsyncResult(null, infoRec.record, null)); 5211 } 5212 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaRedirectingNumberInfoRec) { 5213 if (mRedirNumInfoRegistrants != null) { 5214 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5215 mRedirNumInfoRegistrants.notifyRegistrants( 5216 new AsyncResult(null, infoRec.record, null)); 5217 } 5218 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaLineControlInfoRec) { 5219 if (mLineControlInfoRegistrants != null) { 5220 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5221 mLineControlInfoRegistrants.notifyRegistrants( 5222 new AsyncResult(null, infoRec.record, null)); 5223 } 5224 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53ClirInfoRec) { 5225 if (mT53ClirInfoRegistrants != null) { 5226 if (RILJ_LOGD) unsljLogRet(response, infoRec.record); 5227 mT53ClirInfoRegistrants.notifyRegistrants( 5228 new AsyncResult(null, infoRec.record, null)); 5229 } 5230 } else if (infoRec.record instanceof CdmaInformationRecords.CdmaT53AudioControlInfoRec) { 5231 if (mT53AudCntrlInfoRegistrants != null) { 5232 if (RILJ_LOGD) { 5233 unsljLogRet(response, infoRec.record); 5234 } 5235 mT53AudCntrlInfoRegistrants.notifyRegistrants( 5236 new AsyncResult(null, infoRec.record, null)); 5237 } 5238 } 5239 } 5240 5241 @UnsupportedAppUsage requestToString(int request)5242 static String requestToString(int request) { 5243 switch(request) { 5244 case RIL_REQUEST_GET_SIM_STATUS: 5245 return "GET_SIM_STATUS"; 5246 case RIL_REQUEST_ENTER_SIM_PIN: 5247 return "ENTER_SIM_PIN"; 5248 case RIL_REQUEST_ENTER_SIM_PUK: 5249 return "ENTER_SIM_PUK"; 5250 case RIL_REQUEST_ENTER_SIM_PIN2: 5251 return "ENTER_SIM_PIN2"; 5252 case RIL_REQUEST_ENTER_SIM_PUK2: 5253 return "ENTER_SIM_PUK2"; 5254 case RIL_REQUEST_CHANGE_SIM_PIN: 5255 return "CHANGE_SIM_PIN"; 5256 case RIL_REQUEST_CHANGE_SIM_PIN2: 5257 return "CHANGE_SIM_PIN2"; 5258 case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: 5259 return "ENTER_NETWORK_DEPERSONALIZATION"; 5260 case RIL_REQUEST_GET_CURRENT_CALLS: 5261 return "GET_CURRENT_CALLS"; 5262 case RIL_REQUEST_DIAL: 5263 return "DIAL"; 5264 case RIL_REQUEST_GET_IMSI: 5265 return "GET_IMSI"; 5266 case RIL_REQUEST_HANGUP: 5267 return "HANGUP"; 5268 case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: 5269 return "HANGUP_WAITING_OR_BACKGROUND"; 5270 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: 5271 return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; 5272 case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: 5273 return "REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; 5274 case RIL_REQUEST_CONFERENCE: 5275 return "CONFERENCE"; 5276 case RIL_REQUEST_UDUB: 5277 return "UDUB"; 5278 case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: 5279 return "LAST_CALL_FAIL_CAUSE"; 5280 case RIL_REQUEST_SIGNAL_STRENGTH: 5281 return "SIGNAL_STRENGTH"; 5282 case RIL_REQUEST_VOICE_REGISTRATION_STATE: 5283 return "VOICE_REGISTRATION_STATE"; 5284 case RIL_REQUEST_DATA_REGISTRATION_STATE: 5285 return "DATA_REGISTRATION_STATE"; 5286 case RIL_REQUEST_OPERATOR: 5287 return "OPERATOR"; 5288 case RIL_REQUEST_RADIO_POWER: 5289 return "RADIO_POWER"; 5290 case RIL_REQUEST_DTMF: 5291 return "DTMF"; 5292 case RIL_REQUEST_SEND_SMS: 5293 return "SEND_SMS"; 5294 case RIL_REQUEST_SEND_SMS_EXPECT_MORE: 5295 return "SEND_SMS_EXPECT_MORE"; 5296 case RIL_REQUEST_SETUP_DATA_CALL: 5297 return "SETUP_DATA_CALL"; 5298 case RIL_REQUEST_SIM_IO: 5299 return "SIM_IO"; 5300 case RIL_REQUEST_SEND_USSD: 5301 return "SEND_USSD"; 5302 case RIL_REQUEST_CANCEL_USSD: 5303 return "CANCEL_USSD"; 5304 case RIL_REQUEST_GET_CLIR: 5305 return "GET_CLIR"; 5306 case RIL_REQUEST_SET_CLIR: 5307 return "SET_CLIR"; 5308 case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: 5309 return "QUERY_CALL_FORWARD_STATUS"; 5310 case RIL_REQUEST_SET_CALL_FORWARD: 5311 return "SET_CALL_FORWARD"; 5312 case RIL_REQUEST_QUERY_CALL_WAITING: 5313 return "QUERY_CALL_WAITING"; 5314 case RIL_REQUEST_SET_CALL_WAITING: 5315 return "SET_CALL_WAITING"; 5316 case RIL_REQUEST_SMS_ACKNOWLEDGE: 5317 return "SMS_ACKNOWLEDGE"; 5318 case RIL_REQUEST_GET_IMEI: 5319 return "GET_IMEI"; 5320 case RIL_REQUEST_GET_IMEISV: 5321 return "GET_IMEISV"; 5322 case RIL_REQUEST_ANSWER: 5323 return "ANSWER"; 5324 case RIL_REQUEST_DEACTIVATE_DATA_CALL: 5325 return "DEACTIVATE_DATA_CALL"; 5326 case RIL_REQUEST_QUERY_FACILITY_LOCK: 5327 return "QUERY_FACILITY_LOCK"; 5328 case RIL_REQUEST_SET_FACILITY_LOCK: 5329 return "SET_FACILITY_LOCK"; 5330 case RIL_REQUEST_CHANGE_BARRING_PASSWORD: 5331 return "CHANGE_BARRING_PASSWORD"; 5332 case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: 5333 return "QUERY_NETWORK_SELECTION_MODE"; 5334 case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: 5335 return "SET_NETWORK_SELECTION_AUTOMATIC"; 5336 case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: 5337 return "SET_NETWORK_SELECTION_MANUAL"; 5338 case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : 5339 return "QUERY_AVAILABLE_NETWORKS "; 5340 case RIL_REQUEST_DTMF_START: 5341 return "DTMF_START"; 5342 case RIL_REQUEST_DTMF_STOP: 5343 return "DTMF_STOP"; 5344 case RIL_REQUEST_BASEBAND_VERSION: 5345 return "BASEBAND_VERSION"; 5346 case RIL_REQUEST_SEPARATE_CONNECTION: 5347 return "SEPARATE_CONNECTION"; 5348 case RIL_REQUEST_SET_MUTE: 5349 return "SET_MUTE"; 5350 case RIL_REQUEST_GET_MUTE: 5351 return "GET_MUTE"; 5352 case RIL_REQUEST_QUERY_CLIP: 5353 return "QUERY_CLIP"; 5354 case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: 5355 return "LAST_DATA_CALL_FAIL_CAUSE"; 5356 case RIL_REQUEST_DATA_CALL_LIST: 5357 return "DATA_CALL_LIST"; 5358 case RIL_REQUEST_RESET_RADIO: 5359 return "RESET_RADIO"; 5360 case RIL_REQUEST_OEM_HOOK_RAW: 5361 return "OEM_HOOK_RAW"; 5362 case RIL_REQUEST_OEM_HOOK_STRINGS: 5363 return "OEM_HOOK_STRINGS"; 5364 case RIL_REQUEST_SCREEN_STATE: 5365 return "SCREEN_STATE"; 5366 case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: 5367 return "SET_SUPP_SVC_NOTIFICATION"; 5368 case RIL_REQUEST_WRITE_SMS_TO_SIM: 5369 return "WRITE_SMS_TO_SIM"; 5370 case RIL_REQUEST_DELETE_SMS_ON_SIM: 5371 return "DELETE_SMS_ON_SIM"; 5372 case RIL_REQUEST_SET_BAND_MODE: 5373 return "SET_BAND_MODE"; 5374 case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: 5375 return "QUERY_AVAILABLE_BAND_MODE"; 5376 case RIL_REQUEST_STK_GET_PROFILE: 5377 return "REQUEST_STK_GET_PROFILE"; 5378 case RIL_REQUEST_STK_SET_PROFILE: 5379 return "REQUEST_STK_SET_PROFILE"; 5380 case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: 5381 return "REQUEST_STK_SEND_ENVELOPE_COMMAND"; 5382 case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: 5383 return "REQUEST_STK_SEND_TERMINAL_RESPONSE"; 5384 case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: 5385 return "REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; 5386 case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "REQUEST_EXPLICIT_CALL_TRANSFER"; 5387 case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: 5388 return "REQUEST_SET_PREFERRED_NETWORK_TYPE"; 5389 case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: 5390 return "REQUEST_GET_PREFERRED_NETWORK_TYPE"; 5391 case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: 5392 return "REQUEST_GET_NEIGHBORING_CELL_IDS"; 5393 case RIL_REQUEST_SET_LOCATION_UPDATES: 5394 return "REQUEST_SET_LOCATION_UPDATES"; 5395 case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: 5396 return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE"; 5397 case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: 5398 return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE"; 5399 case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: 5400 return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE"; 5401 case RIL_REQUEST_SET_TTY_MODE: 5402 return "RIL_REQUEST_SET_TTY_MODE"; 5403 case RIL_REQUEST_QUERY_TTY_MODE: 5404 return "RIL_REQUEST_QUERY_TTY_MODE"; 5405 case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: 5406 return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; 5407 case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: 5408 return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; 5409 case RIL_REQUEST_CDMA_FLASH: 5410 return "RIL_REQUEST_CDMA_FLASH"; 5411 case RIL_REQUEST_CDMA_BURST_DTMF: 5412 return "RIL_REQUEST_CDMA_BURST_DTMF"; 5413 case RIL_REQUEST_CDMA_SEND_SMS: 5414 return "RIL_REQUEST_CDMA_SEND_SMS"; 5415 case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: 5416 return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE"; 5417 case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: 5418 return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG"; 5419 case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: 5420 return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG"; 5421 case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: 5422 return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG"; 5423 case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: 5424 return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG"; 5425 case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: 5426 return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION"; 5427 case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: 5428 return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY"; 5429 case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: 5430 return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION"; 5431 case RIL_REQUEST_CDMA_SUBSCRIPTION: 5432 return "RIL_REQUEST_CDMA_SUBSCRIPTION"; 5433 case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: 5434 return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM"; 5435 case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: 5436 return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM"; 5437 case RIL_REQUEST_DEVICE_IDENTITY: 5438 return "RIL_REQUEST_DEVICE_IDENTITY"; 5439 case RIL_REQUEST_GET_SMSC_ADDRESS: 5440 return "RIL_REQUEST_GET_SMSC_ADDRESS"; 5441 case RIL_REQUEST_SET_SMSC_ADDRESS: 5442 return "RIL_REQUEST_SET_SMSC_ADDRESS"; 5443 case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: 5444 return "REQUEST_EXIT_EMERGENCY_CALLBACK_MODE"; 5445 case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: 5446 return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS"; 5447 case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: 5448 return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING"; 5449 case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: 5450 return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE"; 5451 case RIL_REQUEST_ISIM_AUTHENTICATION: 5452 return "RIL_REQUEST_ISIM_AUTHENTICATION"; 5453 case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: 5454 return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU"; 5455 case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: 5456 return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS"; 5457 case RIL_REQUEST_VOICE_RADIO_TECH: 5458 return "RIL_REQUEST_VOICE_RADIO_TECH"; 5459 case RIL_REQUEST_GET_CELL_INFO_LIST: 5460 return "RIL_REQUEST_GET_CELL_INFO_LIST"; 5461 case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: 5462 return "RIL_REQUEST_SET_CELL_INFO_LIST_RATE"; 5463 case RIL_REQUEST_SET_INITIAL_ATTACH_APN: 5464 return "RIL_REQUEST_SET_INITIAL_ATTACH_APN"; 5465 case RIL_REQUEST_SET_DATA_PROFILE: 5466 return "RIL_REQUEST_SET_DATA_PROFILE"; 5467 case RIL_REQUEST_IMS_REGISTRATION_STATE: 5468 return "RIL_REQUEST_IMS_REGISTRATION_STATE"; 5469 case RIL_REQUEST_IMS_SEND_SMS: 5470 return "RIL_REQUEST_IMS_SEND_SMS"; 5471 case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: 5472 return "RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC"; 5473 case RIL_REQUEST_SIM_OPEN_CHANNEL: 5474 return "RIL_REQUEST_SIM_OPEN_CHANNEL"; 5475 case RIL_REQUEST_SIM_CLOSE_CHANNEL: 5476 return "RIL_REQUEST_SIM_CLOSE_CHANNEL"; 5477 case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: 5478 return "RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL"; 5479 case RIL_REQUEST_NV_READ_ITEM: 5480 return "RIL_REQUEST_NV_READ_ITEM"; 5481 case RIL_REQUEST_NV_WRITE_ITEM: 5482 return "RIL_REQUEST_NV_WRITE_ITEM"; 5483 case RIL_REQUEST_NV_WRITE_CDMA_PRL: 5484 return "RIL_REQUEST_NV_WRITE_CDMA_PRL"; 5485 case RIL_REQUEST_NV_RESET_CONFIG: 5486 return "RIL_REQUEST_NV_RESET_CONFIG"; 5487 case RIL_REQUEST_SET_UICC_SUBSCRIPTION: 5488 return "RIL_REQUEST_SET_UICC_SUBSCRIPTION"; 5489 case RIL_REQUEST_ALLOW_DATA: 5490 return "RIL_REQUEST_ALLOW_DATA"; 5491 case RIL_REQUEST_GET_HARDWARE_CONFIG: 5492 return "GET_HARDWARE_CONFIG"; 5493 case RIL_REQUEST_SIM_AUTHENTICATION: 5494 return "RIL_REQUEST_SIM_AUTHENTICATION"; 5495 case RIL_REQUEST_SHUTDOWN: 5496 return "RIL_REQUEST_SHUTDOWN"; 5497 case RIL_REQUEST_SET_RADIO_CAPABILITY: 5498 return "RIL_REQUEST_SET_RADIO_CAPABILITY"; 5499 case RIL_REQUEST_GET_RADIO_CAPABILITY: 5500 return "RIL_REQUEST_GET_RADIO_CAPABILITY"; 5501 case RIL_REQUEST_START_LCE: 5502 return "RIL_REQUEST_START_LCE"; 5503 case RIL_REQUEST_STOP_LCE: 5504 return "RIL_REQUEST_STOP_LCE"; 5505 case RIL_REQUEST_PULL_LCEDATA: 5506 return "RIL_REQUEST_PULL_LCEDATA"; 5507 case RIL_REQUEST_GET_ACTIVITY_INFO: 5508 return "RIL_REQUEST_GET_ACTIVITY_INFO"; 5509 case RIL_REQUEST_SET_ALLOWED_CARRIERS: 5510 return "RIL_REQUEST_SET_ALLOWED_CARRIERS"; 5511 case RIL_REQUEST_GET_ALLOWED_CARRIERS: 5512 return "RIL_REQUEST_GET_ALLOWED_CARRIERS"; 5513 case RIL_REQUEST_SET_SIM_CARD_POWER: 5514 return "RIL_REQUEST_SET_SIM_CARD_POWER"; 5515 case RIL_REQUEST_SEND_DEVICE_STATE: 5516 return "RIL_REQUEST_SEND_DEVICE_STATE"; 5517 case RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER: 5518 return "RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER"; 5519 case RIL_RESPONSE_ACKNOWLEDGEMENT: 5520 return "RIL_RESPONSE_ACKNOWLEDGEMENT"; 5521 case RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION: 5522 return "RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION"; 5523 case RIL_REQUEST_START_NETWORK_SCAN: 5524 return "RIL_REQUEST_START_NETWORK_SCAN"; 5525 case RIL_REQUEST_STOP_NETWORK_SCAN: 5526 return "RIL_REQUEST_STOP_NETWORK_SCAN"; 5527 case RIL_REQUEST_GET_SLOT_STATUS: 5528 return "RIL_REQUEST_GET_SLOT_STATUS"; 5529 case RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING: 5530 return "RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING"; 5531 case RIL_REQUEST_START_KEEPALIVE: 5532 return "RIL_REQUEST_START_KEEPALIVE"; 5533 case RIL_REQUEST_STOP_KEEPALIVE: 5534 return "RIL_REQUEST_STOP_KEEPALIVE"; 5535 case RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA: 5536 return "RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA"; 5537 case RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA: 5538 return "RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA"; 5539 case RIL_REQUEST_ENABLE_MODEM: 5540 return "RIL_REQUEST_ENABLE_MODEM"; 5541 case RIL_REQUEST_GET_MODEM_STATUS: 5542 return "RIL_REQUEST_GET_MODEM_STATUS"; 5543 default: return "<unknown request>"; 5544 } 5545 } 5546 5547 @UnsupportedAppUsage responseToString(int request)5548 static String responseToString(int request) { 5549 switch(request) { 5550 case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: 5551 return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; 5552 case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: 5553 return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; 5554 case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: 5555 return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED"; 5556 case RIL_UNSOL_RESPONSE_NEW_SMS: 5557 return "UNSOL_RESPONSE_NEW_SMS"; 5558 case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: 5559 return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT"; 5560 case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: 5561 return "UNSOL_RESPONSE_NEW_SMS_ON_SIM"; 5562 case RIL_UNSOL_ON_USSD: 5563 return "UNSOL_ON_USSD"; 5564 case RIL_UNSOL_ON_USSD_REQUEST: 5565 return "UNSOL_ON_USSD_REQUEST"; 5566 case RIL_UNSOL_NITZ_TIME_RECEIVED: 5567 return "UNSOL_NITZ_TIME_RECEIVED"; 5568 case RIL_UNSOL_SIGNAL_STRENGTH: 5569 return "UNSOL_SIGNAL_STRENGTH"; 5570 case RIL_UNSOL_DATA_CALL_LIST_CHANGED: 5571 return "UNSOL_DATA_CALL_LIST_CHANGED"; 5572 case RIL_UNSOL_SUPP_SVC_NOTIFICATION: 5573 return "UNSOL_SUPP_SVC_NOTIFICATION"; 5574 case RIL_UNSOL_STK_SESSION_END: 5575 return "UNSOL_STK_SESSION_END"; 5576 case RIL_UNSOL_STK_PROACTIVE_COMMAND: 5577 return "UNSOL_STK_PROACTIVE_COMMAND"; 5578 case RIL_UNSOL_STK_EVENT_NOTIFY: 5579 return "UNSOL_STK_EVENT_NOTIFY"; 5580 case RIL_UNSOL_STK_CALL_SETUP: 5581 return "UNSOL_STK_CALL_SETUP"; 5582 case RIL_UNSOL_SIM_SMS_STORAGE_FULL: 5583 return "UNSOL_SIM_SMS_STORAGE_FULL"; 5584 case RIL_UNSOL_SIM_REFRESH: 5585 return "UNSOL_SIM_REFRESH"; 5586 case RIL_UNSOL_CALL_RING: 5587 return "UNSOL_CALL_RING"; 5588 case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: 5589 return "UNSOL_RESPONSE_SIM_STATUS_CHANGED"; 5590 case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: 5591 return "UNSOL_RESPONSE_CDMA_NEW_SMS"; 5592 case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: 5593 return "UNSOL_RESPONSE_NEW_BROADCAST_SMS"; 5594 case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: 5595 return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL"; 5596 case RIL_UNSOL_RESTRICTED_STATE_CHANGED: 5597 return "UNSOL_RESTRICTED_STATE_CHANGED"; 5598 case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: 5599 return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE"; 5600 case RIL_UNSOL_CDMA_CALL_WAITING: 5601 return "UNSOL_CDMA_CALL_WAITING"; 5602 case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: 5603 return "UNSOL_CDMA_OTA_PROVISION_STATUS"; 5604 case RIL_UNSOL_CDMA_INFO_REC: 5605 return "UNSOL_CDMA_INFO_REC"; 5606 case RIL_UNSOL_OEM_HOOK_RAW: 5607 return "UNSOL_OEM_HOOK_RAW"; 5608 case RIL_UNSOL_RINGBACK_TONE: 5609 return "UNSOL_RINGBACK_TONE"; 5610 case RIL_UNSOL_RESEND_INCALL_MUTE: 5611 return "UNSOL_RESEND_INCALL_MUTE"; 5612 case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: 5613 return "CDMA_SUBSCRIPTION_SOURCE_CHANGED"; 5614 case RIL_UNSOl_CDMA_PRL_CHANGED: 5615 return "UNSOL_CDMA_PRL_CHANGED"; 5616 case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: 5617 return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE"; 5618 case RIL_UNSOL_RIL_CONNECTED: 5619 return "UNSOL_RIL_CONNECTED"; 5620 case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: 5621 return "UNSOL_VOICE_RADIO_TECH_CHANGED"; 5622 case RIL_UNSOL_CELL_INFO_LIST: 5623 return "UNSOL_CELL_INFO_LIST"; 5624 case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: 5625 return "UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED"; 5626 case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: 5627 return "RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED"; 5628 case RIL_UNSOL_SRVCC_STATE_NOTIFY: 5629 return "UNSOL_SRVCC_STATE_NOTIFY"; 5630 case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: 5631 return "RIL_UNSOL_HARDWARE_CONFIG_CHANGED"; 5632 case RIL_UNSOL_RADIO_CAPABILITY: 5633 return "RIL_UNSOL_RADIO_CAPABILITY"; 5634 case RIL_UNSOL_ON_SS: 5635 return "UNSOL_ON_SS"; 5636 case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: 5637 return "UNSOL_STK_CC_ALPHA_NOTIFY"; 5638 case RIL_UNSOL_LCEDATA_RECV: 5639 return "UNSOL_LCE_INFO_RECV"; 5640 case RIL_UNSOL_PCO_DATA: 5641 return "UNSOL_PCO_DATA"; 5642 case RIL_UNSOL_MODEM_RESTART: 5643 return "UNSOL_MODEM_RESTART"; 5644 case RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION: 5645 return "RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION"; 5646 case RIL_UNSOL_NETWORK_SCAN_RESULT: 5647 return "RIL_UNSOL_NETWORK_SCAN_RESULT"; 5648 case RIL_UNSOL_ICC_SLOT_STATUS: 5649 return "RIL_UNSOL_ICC_SLOT_STATUS"; 5650 case RIL_UNSOL_KEEPALIVE_STATUS: 5651 return "RIL_UNSOL_KEEPALIVE_STATUS"; 5652 case RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG: 5653 return "RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG"; 5654 default: 5655 return "<unknown response>"; 5656 } 5657 } 5658 5659 @UnsupportedAppUsage riljLog(String msg)5660 void riljLog(String msg) { 5661 Rlog.d(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]")); 5662 } 5663 riljLoge(String msg)5664 void riljLoge(String msg) { 5665 Rlog.e(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]")); 5666 } 5667 riljLoge(String msg, Exception e)5668 void riljLoge(String msg, Exception e) { 5669 Rlog.e(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]"), e); 5670 } 5671 riljLogv(String msg)5672 void riljLogv(String msg) { 5673 Rlog.v(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]")); 5674 } 5675 5676 @UnsupportedAppUsage unsljLog(int response)5677 void unsljLog(int response) { 5678 riljLog("[UNSL]< " + responseToString(response)); 5679 } 5680 5681 @UnsupportedAppUsage unsljLogMore(int response, String more)5682 void unsljLogMore(int response, String more) { 5683 riljLog("[UNSL]< " + responseToString(response) + " " + more); 5684 } 5685 5686 @UnsupportedAppUsage unsljLogRet(int response, Object ret)5687 void unsljLogRet(int response, Object ret) { 5688 riljLog("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 5689 } 5690 5691 @UnsupportedAppUsage unsljLogvRet(int response, Object ret)5692 void unsljLogvRet(int response, Object ret) { 5693 riljLogv("[UNSL]< " + responseToString(response) + " " + retToString(response, ret)); 5694 } 5695 5696 @Override setPhoneType(int phoneType)5697 public void setPhoneType(int phoneType) { // Called by GsmCdmaPhone 5698 if (RILJ_LOGD) riljLog("setPhoneType=" + phoneType + " old value=" + mPhoneType); 5699 mPhoneType = phoneType; 5700 } 5701 5702 /* (non-Javadoc) 5703 * @see com.android.internal.telephony.BaseCommands#testingEmergencyCall() 5704 */ 5705 @Override testingEmergencyCall()5706 public void testingEmergencyCall() { 5707 if (RILJ_LOGD) riljLog("testingEmergencyCall"); 5708 mTestingEmergencyCall.set(true); 5709 } 5710 dump(FileDescriptor fd, PrintWriter pw, String[] args)5711 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 5712 pw.println("RIL: " + this); 5713 pw.println(" mWakeLock=" + mWakeLock); 5714 pw.println(" mWakeLockTimeout=" + mWakeLockTimeout); 5715 synchronized (mRequestList) { 5716 synchronized (mWakeLock) { 5717 pw.println(" mWakeLockCount=" + mWakeLockCount); 5718 } 5719 int count = mRequestList.size(); 5720 pw.println(" mRequestList count=" + count); 5721 for (int i = 0; i < count; i++) { 5722 RILRequest rr = mRequestList.valueAt(i); 5723 pw.println(" [" + rr.mSerial + "] " + requestToString(rr.mRequest)); 5724 } 5725 } 5726 pw.println(" mLastNITZTimeInfo=" + Arrays.toString(mLastNITZTimeInfo)); 5727 pw.println(" mTestingEmergencyCall=" + mTestingEmergencyCall.get()); 5728 mClientWakelockTracker.dumpClientRequestTracker(pw); 5729 } 5730 getClientRequestStats()5731 public List<ClientRequestStats> getClientRequestStats() { 5732 return mClientWakelockTracker.getClientRequestStats(); 5733 } 5734 5735 /** Append the data to the end of an ArrayList */ appendPrimitiveArrayToArrayList(byte[] src, ArrayList<Byte> dst)5736 public static void appendPrimitiveArrayToArrayList(byte[] src, ArrayList<Byte> dst) { 5737 for (byte b : src) { 5738 dst.add(b); 5739 } 5740 } 5741 primitiveArrayToArrayList(byte[] arr)5742 public static ArrayList<Byte> primitiveArrayToArrayList(byte[] arr) { 5743 ArrayList<Byte> arrayList = new ArrayList<>(arr.length); 5744 for (byte b : arr) { 5745 arrayList.add(b); 5746 } 5747 return arrayList; 5748 } 5749 5750 /** Convert a primitive int array to an ArrayList<Integer>. */ primitiveArrayToArrayList(int[] arr)5751 public static ArrayList<Integer> primitiveArrayToArrayList(int[] arr) { 5752 ArrayList<Integer> arrayList = new ArrayList<>(arr.length); 5753 for (int i : arr) { 5754 arrayList.add(i); 5755 } 5756 return arrayList; 5757 } 5758 5759 /** Convert an ArrayList of Bytes to an exactly-sized primitive array */ arrayListToPrimitiveArray(ArrayList<Byte> bytes)5760 public static byte[] arrayListToPrimitiveArray(ArrayList<Byte> bytes) { 5761 byte[] ret = new byte[bytes.size()]; 5762 for (int i = 0; i < ret.length; i++) { 5763 ret[i] = bytes.get(i); 5764 } 5765 return ret; 5766 } 5767 convertHalHwConfigList( ArrayList<android.hardware.radio.V1_0.HardwareConfig> hwListRil, RIL ril)5768 static ArrayList<HardwareConfig> convertHalHwConfigList( 5769 ArrayList<android.hardware.radio.V1_0.HardwareConfig> hwListRil, 5770 RIL ril) { 5771 int num; 5772 ArrayList<HardwareConfig> response; 5773 HardwareConfig hw; 5774 5775 num = hwListRil.size(); 5776 response = new ArrayList<HardwareConfig>(num); 5777 5778 if (RILJ_LOGV) { 5779 ril.riljLog("convertHalHwConfigList: num=" + num); 5780 } 5781 for (android.hardware.radio.V1_0.HardwareConfig hwRil : hwListRil) { 5782 int type = hwRil.type; 5783 switch(type) { 5784 case HardwareConfig.DEV_HARDWARE_TYPE_MODEM: { 5785 hw = new HardwareConfig(type); 5786 HardwareConfigModem hwModem = hwRil.modem.get(0); 5787 hw.assignModem(hwRil.uuid, hwRil.state, hwModem.rilModel, hwModem.rat, 5788 hwModem.maxVoice, hwModem.maxData, hwModem.maxStandby); 5789 break; 5790 } 5791 case HardwareConfig.DEV_HARDWARE_TYPE_SIM: { 5792 hw = new HardwareConfig(type); 5793 hw.assignSim(hwRil.uuid, hwRil.state, hwRil.sim.get(0).modemUuid); 5794 break; 5795 } 5796 default: { 5797 throw new RuntimeException( 5798 "RIL_REQUEST_GET_HARDWARE_CONFIG invalid hardward type:" + type); 5799 } 5800 } 5801 5802 response.add(hw); 5803 } 5804 5805 return response; 5806 } 5807 convertHalRadioCapability( android.hardware.radio.V1_0.RadioCapability rcRil, RIL ril)5808 static RadioCapability convertHalRadioCapability( 5809 android.hardware.radio.V1_0.RadioCapability rcRil, RIL ril) { 5810 int session = rcRil.session; 5811 int phase = rcRil.phase; 5812 // convert to public bitmask {@link TelephonyManager.NetworkTypeBitMask} 5813 int rat = convertToNetworkTypeBitMask(rcRil.raf); 5814 String logicModemUuid = rcRil.logicalModemUuid; 5815 int status = rcRil.status; 5816 5817 ril.riljLog("convertHalRadioCapability: session=" + session + 5818 ", phase=" + phase + 5819 ", rat=" + rat + 5820 ", logicModemUuid=" + logicModemUuid + 5821 ", status=" + status + ", rcRil.raf=" + rcRil.raf); 5822 RadioCapability rc = new RadioCapability( 5823 ril.mPhoneId, session, phase, rat, logicModemUuid, status); 5824 return rc; 5825 } 5826 convertHalLceData(LceDataInfo halData, RIL ril)5827 static LinkCapacityEstimate convertHalLceData(LceDataInfo halData, RIL ril) { 5828 final LinkCapacityEstimate lce = new LinkCapacityEstimate( 5829 halData.lastHopCapacityKbps, 5830 Byte.toUnsignedInt(halData.confidenceLevel), 5831 halData.lceSuspended ? LinkCapacityEstimate.STATUS_SUSPENDED 5832 : LinkCapacityEstimate.STATUS_ACTIVE); 5833 5834 ril.riljLog("LCE capacity information received:" + lce); 5835 return lce; 5836 } 5837 convertHalLceData( android.hardware.radio.V1_2.LinkCapacityEstimate halData, RIL ril)5838 static LinkCapacityEstimate convertHalLceData( 5839 android.hardware.radio.V1_2.LinkCapacityEstimate halData, RIL ril) { 5840 final LinkCapacityEstimate lce = new LinkCapacityEstimate( 5841 halData.downlinkCapacityKbps, 5842 halData.uplinkCapacityKbps); 5843 ril.riljLog("LCE capacity information received:" + lce); 5844 return lce; 5845 } 5846 5847 /** 5848 * Convert CellInfo defined in 1.0/types.hal to CellInfo type. 5849 * @param records List of CellInfo defined in 1.0/types.hal 5850 * @return List of converted CellInfo object 5851 */ 5852 @VisibleForTesting convertHalCellInfoList( ArrayList<android.hardware.radio.V1_0.CellInfo> records)5853 public static ArrayList<CellInfo> convertHalCellInfoList( 5854 ArrayList<android.hardware.radio.V1_0.CellInfo> records) { 5855 ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size()); 5856 5857 final long nanotime = SystemClock.elapsedRealtimeNanos(); 5858 for (android.hardware.radio.V1_0.CellInfo record : records) { 5859 record.timeStamp = nanotime; 5860 response.add(CellInfo.create(record)); 5861 } 5862 5863 return response; 5864 } 5865 5866 /** 5867 * Convert CellInfo defined in 1.2/types.hal to CellInfo type. 5868 * @param records List of CellInfo defined in 1.2/types.hal 5869 * @return List of converted CellInfo object 5870 */ 5871 @VisibleForTesting convertHalCellInfoList_1_2( ArrayList<android.hardware.radio.V1_2.CellInfo> records)5872 public static ArrayList<CellInfo> convertHalCellInfoList_1_2( 5873 ArrayList<android.hardware.radio.V1_2.CellInfo> records) { 5874 ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size()); 5875 5876 final long nanotime = SystemClock.elapsedRealtimeNanos(); 5877 for (android.hardware.radio.V1_2.CellInfo record : records) { 5878 record.timeStamp = nanotime; 5879 response.add(CellInfo.create(record)); 5880 } 5881 return response; 5882 } 5883 5884 /** 5885 * Convert CellInfo defined in 1.4/types.hal to CellInfo type. 5886 * @param records List of CellInfo defined in 1.4/types.hal. 5887 * @return List of converted CellInfo object. 5888 */ 5889 @VisibleForTesting convertHalCellInfoList_1_4( ArrayList<android.hardware.radio.V1_4.CellInfo> records)5890 public static ArrayList<CellInfo> convertHalCellInfoList_1_4( 5891 ArrayList<android.hardware.radio.V1_4.CellInfo> records) { 5892 ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size()); 5893 5894 final long nanotime = SystemClock.elapsedRealtimeNanos(); 5895 for (android.hardware.radio.V1_4.CellInfo record : records) { 5896 response.add(CellInfo.create(record, nanotime)); 5897 } 5898 return response; 5899 } 5900 5901 /** 5902 * Convert SetupDataCallResult defined in 1.0 or 1.4/types.hal into DataCallResponse 5903 * @param dcResult setup data call result 5904 * @return converted DataCallResponse object 5905 */ 5906 @VisibleForTesting convertDataCallResult(Object dcResult)5907 public static DataCallResponse convertDataCallResult(Object dcResult) { 5908 if (dcResult == null) return null; 5909 5910 int cause, suggestedRetryTime, cid, active, mtu; 5911 String ifname; 5912 int protocolType; 5913 String[] addresses = null; 5914 String[] dnses = null; 5915 String[] gateways = null; 5916 String[] pcscfs = null; 5917 if (dcResult instanceof android.hardware.radio.V1_0.SetupDataCallResult) { 5918 final android.hardware.radio.V1_0.SetupDataCallResult result = 5919 (android.hardware.radio.V1_0.SetupDataCallResult) dcResult; 5920 cause = result.status; 5921 suggestedRetryTime = result.suggestedRetryTime; 5922 cid = result.cid; 5923 active = result.active; 5924 protocolType = ApnSetting.getProtocolIntFromString(result.type); 5925 ifname = result.ifname; 5926 if (!TextUtils.isEmpty(result.addresses)) { 5927 addresses = result.addresses.split("\\s+"); 5928 } 5929 if (!TextUtils.isEmpty(result.dnses)) { 5930 dnses = result.dnses.split("\\s+"); 5931 } 5932 if (!TextUtils.isEmpty(result.gateways)) { 5933 gateways = result.gateways.split("\\s+"); 5934 } 5935 if (!TextUtils.isEmpty(result.pcscf)) { 5936 pcscfs = result.pcscf.split("\\s+"); 5937 } 5938 mtu = result.mtu; 5939 } else if (dcResult instanceof android.hardware.radio.V1_4.SetupDataCallResult) { 5940 final android.hardware.radio.V1_4.SetupDataCallResult result = 5941 (android.hardware.radio.V1_4.SetupDataCallResult) dcResult; 5942 cause = result.cause; 5943 suggestedRetryTime = result.suggestedRetryTime; 5944 cid = result.cid; 5945 active = result.active; 5946 protocolType = result.type; 5947 ifname = result.ifname; 5948 addresses = result.addresses.stream().toArray(String[]::new); 5949 dnses = result.dnses.stream().toArray(String[]::new); 5950 gateways = result.gateways.stream().toArray(String[]::new); 5951 pcscfs = result.pcscf.stream().toArray(String[]::new); 5952 mtu = result.mtu; 5953 } else { 5954 Rlog.e(RILJ_LOG_TAG, "Unsupported SetupDataCallResult " + dcResult); 5955 return null; 5956 } 5957 5958 // Process address 5959 List<LinkAddress> laList = new ArrayList<>(); 5960 if (addresses != null) { 5961 for (String address : addresses) { 5962 address = address.trim(); 5963 if (address.isEmpty()) continue; 5964 5965 try { 5966 LinkAddress la; 5967 // Check if the address contains prefix length. If yes, LinkAddress 5968 // can parse that. 5969 if (address.split("/").length == 2) { 5970 la = new LinkAddress(address); 5971 } else { 5972 InetAddress ia = NetworkUtils.numericToInetAddress(address); 5973 la = new LinkAddress(ia, (ia instanceof Inet4Address) ? 32 : 128); 5974 } 5975 5976 laList.add(la); 5977 } catch (IllegalArgumentException e) { 5978 Rlog.e(RILJ_LOG_TAG, "Unknown address: " + address, e); 5979 } 5980 } 5981 } 5982 5983 // Process dns 5984 List<InetAddress> dnsList = new ArrayList<>(); 5985 if (dnses != null) { 5986 for (String dns : dnses) { 5987 dns = dns.trim(); 5988 InetAddress ia; 5989 try { 5990 ia = NetworkUtils.numericToInetAddress(dns); 5991 dnsList.add(ia); 5992 } catch (IllegalArgumentException e) { 5993 Rlog.e(RILJ_LOG_TAG, "Unknown dns: " + dns, e); 5994 } 5995 } 5996 } 5997 5998 // Process gateway 5999 List<InetAddress> gatewayList = new ArrayList<>(); 6000 if (gateways != null) { 6001 for (String gateway : gateways) { 6002 gateway = gateway.trim(); 6003 InetAddress ia; 6004 try { 6005 ia = NetworkUtils.numericToInetAddress(gateway); 6006 gatewayList.add(ia); 6007 } catch (IllegalArgumentException e) { 6008 Rlog.e(RILJ_LOG_TAG, "Unknown gateway: " + gateway, e); 6009 } 6010 } 6011 } 6012 6013 // Process gateway 6014 List<InetAddress> pcscfList = new ArrayList<>(); 6015 if (pcscfs != null) { 6016 for (String pcscf : pcscfs) { 6017 pcscf = pcscf.trim(); 6018 InetAddress ia; 6019 try { 6020 ia = NetworkUtils.numericToInetAddress(pcscf); 6021 pcscfList.add(ia); 6022 } catch (IllegalArgumentException e) { 6023 Rlog.e(RILJ_LOG_TAG, "Unknown pcscf: " + pcscf, e); 6024 } 6025 } 6026 } 6027 6028 return new DataCallResponse(cause, suggestedRetryTime, cid, active, protocolType, ifname, 6029 laList, dnsList, gatewayList, pcscfList, mtu); 6030 } 6031 6032 /** 6033 * Convert SetupDataCallResult defined in 1.0 or 1.4/types.hal into DataCallResponse 6034 * @param dataCallResultList List of SetupDataCallResult defined in 1.0 or 1.4/types.hal 6035 * @return List of converted DataCallResponse object 6036 */ 6037 @VisibleForTesting convertDataCallResultList( List<? extends Object> dataCallResultList)6038 public static ArrayList<DataCallResponse> convertDataCallResultList( 6039 List<? extends Object> dataCallResultList) { 6040 ArrayList<DataCallResponse> response = 6041 new ArrayList<DataCallResponse>(dataCallResultList.size()); 6042 6043 for (Object obj : dataCallResultList) { 6044 response.add(convertDataCallResult(obj)); 6045 } 6046 return response; 6047 } 6048 6049 /** 6050 * Get the HAL version. 6051 * 6052 * @return the current HalVersion 6053 */ getHalVersion()6054 public HalVersion getHalVersion() { 6055 return mRadioVersion; 6056 } 6057 } 6058