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