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