1 /* 2 * Copyright (C) 2021 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 android.telephony.mockmodem; 18 19 import android.content.Context; 20 import android.hardware.radio.RadioError; 21 import android.hardware.radio.RadioIndicationType; 22 import android.hardware.radio.RadioResponseInfo; 23 import android.hardware.radio.network.BarringInfo; 24 import android.hardware.radio.network.BarringTypeSpecificInfo; 25 import android.hardware.radio.network.CellIdentity; 26 import android.hardware.radio.network.Domain; 27 import android.hardware.radio.network.EmergencyRegResult; 28 import android.hardware.radio.network.IRadioNetwork; 29 import android.hardware.radio.network.IRadioNetworkIndication; 30 import android.hardware.radio.network.IRadioNetworkResponse; 31 import android.hardware.radio.network.NetworkScanRequest; 32 import android.hardware.radio.network.RadioAccessSpecifier; 33 import android.hardware.radio.network.RegState; 34 import android.hardware.radio.network.SignalThresholdInfo; 35 import android.hardware.radio.sim.CardStatus; 36 import android.os.AsyncResult; 37 import android.os.Handler; 38 import android.os.Message; 39 import android.os.RemoteException; 40 import android.telephony.NetworkRegistrationInfo; 41 import android.telephony.mockmodem.MockModemConfigBase.SimInfoChangedResult; 42 import android.util.Log; 43 import android.util.SparseArray; 44 45 import java.util.ArrayList; 46 47 public class IRadioNetworkImpl extends IRadioNetwork.Stub { 48 private static final String TAG = "MRNW"; 49 50 private final MockModemService mService; 51 private IRadioNetworkResponse mRadioNetworkResponse; 52 private IRadioNetworkIndication mRadioNetworkIndication; 53 private MockModemConfigInterface mMockModemConfigInterface; 54 private final Object mCacheUpdateMutex; 55 private final Handler mHandler; 56 private int mSubId; 57 private String mTag; 58 59 // ***** Events 60 static final int EVENT_RADIO_STATE_CHANGED = 1; 61 static final int EVENT_SIM_STATUS_CHANGED = 2; 62 static final int EVENT_PREFERRED_MODE_CHANGED = 3; 63 64 // ***** Cache of modem attributes/status 65 private int mNetworkTypeBitmap; 66 private boolean mNetworkSelectionMode; 67 private boolean mNullCipherAndIntegrityEnabled; 68 69 private int mRadioState; 70 private boolean mSimReady; 71 72 private MockNetworkService mServiceState; 73 IRadioNetworkImpl( MockModemService service, Context context, MockModemConfigInterface configInterface, int instanceId)74 public IRadioNetworkImpl( 75 MockModemService service, 76 Context context, 77 MockModemConfigInterface configInterface, 78 int instanceId) { 79 mTag = TAG + "-" + instanceId; 80 Log.d(mTag, "Instantiated"); 81 82 this.mService = service; 83 mMockModemConfigInterface = configInterface; 84 mCacheUpdateMutex = new Object(); 85 mHandler = new IRadioNetworkHandler(); 86 mSubId = instanceId; 87 mServiceState = new MockNetworkService(context); 88 89 // Default network type GPRS|EDGE|UMTS|HSDPA|HSUPA|HSPA|LTE|HSPA+|GSM|LTE_CA|NR 90 mNetworkTypeBitmap = 91 MockNetworkService.GSM 92 | MockNetworkService.WCDMA 93 | MockNetworkService.LTE 94 | MockNetworkService.NR; 95 mServiceState.updateHighestRegisteredRat(mNetworkTypeBitmap); 96 97 // Null security algorithms are allowed by default 98 mNullCipherAndIntegrityEnabled = true; 99 100 mMockModemConfigInterface.registerForRadioStateChanged( 101 mSubId, mHandler, EVENT_RADIO_STATE_CHANGED, null); 102 mMockModemConfigInterface.registerForCardStatusChanged( 103 mSubId, mHandler, EVENT_SIM_STATUS_CHANGED, null); 104 } 105 106 /** Handler class to handle callbacks */ 107 private final class IRadioNetworkHandler extends Handler { 108 @Override handleMessage(Message msg)109 public void handleMessage(Message msg) { 110 AsyncResult ar; 111 synchronized (mCacheUpdateMutex) { 112 switch (msg.what) { 113 case EVENT_SIM_STATUS_CHANGED: 114 Log.d(mTag, "Received EVENT_SIM_STATUS_CHANGED"); 115 boolean oldSimReady = mSimReady; 116 ar = (AsyncResult) msg.obj; 117 if (ar != null && ar.exception == null) { 118 mSimReady = updateSimReady(ar); 119 if (oldSimReady != mSimReady) { 120 updateNetworkStatus(); 121 } 122 } else { 123 Log.e(mTag, msg.what + " failure. Exception: " + ar.exception); 124 } 125 break; 126 127 case EVENT_RADIO_STATE_CHANGED: 128 Log.d(mTag, "Received EVENT_RADIO_STATE_CHANGED"); 129 int oldRadioState = mRadioState; 130 ar = (AsyncResult) msg.obj; 131 if (ar != null && ar.exception == null) { 132 mRadioState = (int) ar.result; 133 Log.i(mTag, "Radio state: " + mRadioState); 134 if (oldRadioState != mRadioState) { 135 updateNetworkStatus(); 136 } 137 } else { 138 Log.e(mTag, msg.what + " failure. Exception: " + ar.exception); 139 } 140 break; 141 142 case EVENT_PREFERRED_MODE_CHANGED: 143 Log.d(mTag, "Received EVENT_PREFERRED_MODE_CHANGED"); 144 mServiceState.updateNetworkStatus( 145 MockNetworkService.NETWORK_UPDATE_PREFERRED_MODE_CHANGE); 146 updateNetworkStatus(); 147 break; 148 } 149 } 150 } 151 } 152 153 // Implementation of IRadioNetwork utility functions 154 notifyServiceStateChange()155 private void notifyServiceStateChange() { 156 Log.d(mTag, "notifyServiceStateChange"); 157 158 Handler handler = mMockModemConfigInterface.getMockModemConfigHandler(mSubId); 159 Message msg = 160 handler.obtainMessage( 161 MockModemConfigBase.EVENT_SERVICE_STATE_CHANGE, mServiceState); 162 handler.sendMessage(msg); 163 } 164 updateNetworkStatus()165 private void updateNetworkStatus() { 166 updateNetworkStatus(Domain.CS | Domain.PS); 167 } 168 updateNetworkStatus(int domainBitmask)169 private void updateNetworkStatus(int domainBitmask) { 170 if (mRadioState != MockModemConfigInterface.RADIO_STATE_ON) { 171 // Update to OOS state 172 mServiceState.updateServiceState(RegState.NOT_REG_MT_NOT_SEARCHING_OP, domainBitmask); 173 } else if (!mSimReady) { 174 // Update to Searching state 175 mServiceState.updateServiceState(RegState.NOT_REG_MT_SEARCHING_OP, domainBitmask); 176 } else if (mServiceState.isHomeCellExisted() && mServiceState.getIsHomeCamping()) { 177 // Update to Home state 178 mServiceState.updateServiceState(RegState.REG_HOME, domainBitmask); 179 } else if (mServiceState.isRoamingCellExisted() && mServiceState.getIsRoamingCamping()) { 180 // Update to Roaming state 181 mServiceState.updateServiceState(RegState.REG_ROAMING, domainBitmask); 182 } else if (mServiceState.getRegFailCause() != 0) { 183 mServiceState.updateServiceState(RegState.REG_DENIED, domainBitmask); 184 } else { 185 // Update to Searching state 186 mServiceState.updateServiceState(RegState.NOT_REG_MT_SEARCHING_OP, domainBitmask); 187 } 188 189 unsolNetworkStateChanged(); 190 unsolCurrentSignalStrength(); 191 unsolCellInfoList(); 192 } 193 updateSimReady(AsyncResult ar)194 private boolean updateSimReady(AsyncResult ar) { 195 String simPlmn = ""; 196 CardStatus cardStatus = new CardStatus(); 197 cardStatus = (CardStatus) ar.result; 198 199 if (cardStatus.cardState != CardStatus.STATE_PRESENT) { 200 return false; 201 } 202 203 int numApplications = cardStatus.applications.length; 204 if (numApplications < 1) { 205 return false; 206 } 207 208 for (int i = 0; i < numApplications; i++) { 209 android.hardware.radio.sim.AppStatus rilAppStatus = cardStatus.applications[i]; 210 if (rilAppStatus.appState == android.hardware.radio.sim.AppStatus.APP_STATE_READY) { 211 Log.i(mTag, "SIM is ready"); 212 simPlmn = mMockModemConfigInterface.getSimInfo(mSubId, 213 SimInfoChangedResult.SIM_INFO_TYPE_MCC_MNC, mTag); 214 mServiceState.updateSimPlmn(simPlmn); 215 return true; 216 } 217 } 218 219 mServiceState.updateSimPlmn(simPlmn); 220 return false; 221 } 222 changeNetworkService(int carrierId, boolean registration)223 public boolean changeNetworkService(int carrierId, boolean registration) { 224 Log.d(mTag, "changeNetworkService: carrier id(" + carrierId + "): " + registration); 225 return changeNetworkService(carrierId, registration, Domain.CS | Domain.PS); 226 } 227 228 /** Change Network Service */ changeNetworkService( int carrierId, boolean registration, int domainBitmask)229 public boolean changeNetworkService( 230 int carrierId, 231 boolean registration, 232 int domainBitmask) { 233 return changeNetworkService(carrierId, registration, domainBitmask, 0 /* regFailCause */); 234 } 235 236 /** Change Network Service */ changeNetworkService( int carrierId, boolean registration, int domainBitmask, int regFailCause)237 public boolean changeNetworkService( 238 int carrierId, 239 boolean registration, 240 int domainBitmask, 241 int regFailCause) { 242 Log.d( 243 mTag, 244 "changeNetworkService: carrier id(" 245 + carrierId 246 + "): " 247 + registration 248 + " with domainBitmask = " 249 + domainBitmask); 250 251 synchronized (mCacheUpdateMutex) { 252 // TODO: compare carrierId and sim to decide home or roming 253 mServiceState.setRegFailCause(regFailCause); 254 mServiceState.setServiceStatus(false, registration); 255 updateNetworkStatus(domainBitmask); 256 } 257 258 return true; 259 } 260 261 /** 262 * Updates the emergency registration state. 263 * @param regResult the emergency registration state. 264 */ setEmergencyRegResult(MockEmergencyRegResult regResult)265 public void setEmergencyRegResult(MockEmergencyRegResult regResult) { 266 Log.d(mTag, "setEmergencyRegResult"); 267 268 synchronized (mCacheUpdateMutex) { 269 mServiceState.setEmergencyRegResult(convertEmergencyRegResult(regResult)); 270 } 271 } 272 273 /** 274 * Resets the current emergency mode. 275 */ resetEmergencyMode()276 public void resetEmergencyMode() { 277 synchronized (mCacheUpdateMutex) { 278 mServiceState.setEmergencyMode(0); 279 } 280 } 281 282 /** 283 * Returns the current emergency mode. 284 */ getEmergencyMode()285 public int getEmergencyMode() { 286 Log.d(mTag, "getEmergencyMode"); 287 288 synchronized (mCacheUpdateMutex) { 289 return mServiceState.getEmergencyMode(); 290 } 291 } 292 293 /** 294 * @return whether emergency network scan is triggered. 295 */ isEmergencyNetworkScanTriggered()296 public boolean isEmergencyNetworkScanTriggered() { 297 synchronized (mCacheUpdateMutex) { 298 return mServiceState.isEmergencyNetworkScanTriggered(); 299 } 300 } 301 302 /** 303 * @return whether emergency network scan is canceled. 304 */ isEmergencyNetworkScanCanceled()305 public boolean isEmergencyNetworkScanCanceled() { 306 synchronized (mCacheUpdateMutex) { 307 return mServiceState.isEmergencyNetworkScanCanceled(); 308 } 309 } 310 311 /** 312 * @return the list of preferred network type. 313 */ getEmergencyNetworkScanAccessNetwork()314 public int[] getEmergencyNetworkScanAccessNetwork() { 315 synchronized (mCacheUpdateMutex) { 316 return mServiceState.getEmergencyNetworkScanAccessNetwork(); 317 } 318 } 319 320 /** 321 * @return the preferred scan type. 322 */ getEmergencyNetworkScanType()323 public int getEmergencyNetworkScanType() { 324 synchronized (mCacheUpdateMutex) { 325 return mServiceState.getEmergencyNetworkScanType(); 326 } 327 } 328 329 /** 330 * Resets the emergency network scan attributes. 331 */ resetEmergencyNetworkScan()332 public void resetEmergencyNetworkScan() { 333 synchronized (mCacheUpdateMutex) { 334 mServiceState.resetEmergencyNetworkScan(); 335 } 336 } 337 338 // Implementation of IRadioNetwork functions 339 @Override getAllowedNetworkTypesBitmap(int serial)340 public void getAllowedNetworkTypesBitmap(int serial) { 341 Log.d(mTag, "getAllowedNetworkTypesBitmap"); 342 int networkTypeBitmap = mNetworkTypeBitmap; 343 344 RadioResponseInfo rsp = mService.makeSolRsp(serial); 345 try { 346 mRadioNetworkResponse.getAllowedNetworkTypesBitmapResponse(rsp, networkTypeBitmap); 347 } catch (RemoteException ex) { 348 Log.e(mTag, "Failed to getAllowedNetworkTypesBitmap from AIDL. Exception" + ex); 349 } 350 } 351 352 @Override getAvailableBandModes(int serial)353 public void getAvailableBandModes(int serial) { 354 Log.d(mTag, "getAvailableBandModes"); 355 356 int[] bandModes = new int[0]; 357 RadioResponseInfo rsp = mService.makeSolRsp(serial); 358 try { 359 mRadioNetworkResponse.getAvailableBandModesResponse(rsp, bandModes); 360 } catch (RemoteException ex) { 361 Log.e(mTag, "Failed to getAvailableBandModes from AIDL. Exception" + ex); 362 } 363 } 364 365 @Override getAvailableNetworks(int serial)366 public void getAvailableNetworks(int serial) { 367 Log.d(mTag, "getAvailableNetworks"); 368 369 android.hardware.radio.network.OperatorInfo[] networkInfos = 370 new android.hardware.radio.network.OperatorInfo[0]; 371 RadioResponseInfo rsp = mService.makeSolRsp(serial); 372 try { 373 mRadioNetworkResponse.getAvailableNetworksResponse(rsp, networkInfos); 374 } catch (RemoteException ex) { 375 Log.e(mTag, "Failed to getAvailableNetworks from AIDL. Exception" + ex); 376 } 377 } 378 379 @Override getBarringInfo(int serial)380 public void getBarringInfo(int serial) { 381 Log.d(mTag, "getBarringInfo"); 382 383 CellIdentity cellIdentity; 384 BarringInfo[] barringInfos; 385 synchronized (mCacheUpdateMutex) { 386 cellIdentity = mServiceState.getPrimaryCellIdentity(); 387 barringInfos = mServiceState.getBarringInfo(); 388 } 389 390 RadioResponseInfo rsp = mService.makeSolRsp(serial); 391 try { 392 mRadioNetworkResponse.getBarringInfoResponse(rsp, cellIdentity, barringInfos); 393 } catch (RemoteException ex) { 394 Log.e(mTag, "Failed to getBarringInfo from AIDL. Exception" + ex); 395 } 396 } 397 398 @Override getCdmaRoamingPreference(int serial)399 public void getCdmaRoamingPreference(int serial) { 400 Log.d(mTag, "getCdmaRoamingPreference"); 401 int type = 0; 402 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 403 try { 404 mRadioNetworkResponse.getCdmaRoamingPreferenceResponse(rsp, type); 405 } catch (RemoteException ex) { 406 Log.e(mTag, "Failed to getCdmaRoamingPreference from AIDL. Exception" + ex); 407 } 408 } 409 410 @Override getCellInfoList(int serial)411 public void getCellInfoList(int serial) { 412 Log.d(mTag, "getCellInfoList"); 413 android.hardware.radio.network.CellInfo[] cells; 414 415 synchronized (mCacheUpdateMutex) { 416 cells = mServiceState.getCells(); 417 } 418 419 RadioResponseInfo rsp = mService.makeSolRsp(serial); 420 try { 421 mRadioNetworkResponse.getCellInfoListResponse(rsp, cells); 422 } catch (RemoteException ex) { 423 Log.e(mTag, "Failed to getCellInfoList from AIDL. Exception" + ex); 424 } 425 } 426 427 @Override getDataRegistrationState(int serial)428 public void getDataRegistrationState(int serial) { 429 Log.d(mTag, "getDataRegistrationState"); 430 431 android.hardware.radio.network.RegStateResult dataRegResponse = 432 new android.hardware.radio.network.RegStateResult(); 433 434 dataRegResponse.cellIdentity = new android.hardware.radio.network.CellIdentity(); 435 dataRegResponse.reasonForDenial = mServiceState.getRegFailCause(); 436 437 synchronized (mCacheUpdateMutex) { 438 dataRegResponse.regState = 439 mServiceState.getRegistration(android.hardware.radio.network.Domain.PS); 440 dataRegResponse.rat = mServiceState.getRegistrationRat(); 441 if (mServiceState.isInService()) { 442 dataRegResponse.registeredPlmn = 443 mServiceState.getPrimaryCellOperatorInfo().operatorNumeric; 444 } 445 446 dataRegResponse.cellIdentity = mServiceState.getPrimaryCellIdentity(); 447 } 448 449 // TODO: support accessTechnologySpecificInfo 450 dataRegResponse.accessTechnologySpecificInfo = 451 android.hardware.radio.network.AccessTechnologySpecificInfo.noinit(true); 452 453 RadioResponseInfo rsp = mService.makeSolRsp(serial); 454 try { 455 mRadioNetworkResponse.getDataRegistrationStateResponse(rsp, dataRegResponse); 456 } catch (RemoteException ex) { 457 Log.e(mTag, "Failed to getRadioCapability from AIDL. Exception" + ex); 458 } 459 } 460 461 @Override getImsRegistrationState(int serial)462 public void getImsRegistrationState(int serial) { 463 Log.d(mTag, "getImsRegistrationState"); 464 boolean isRegistered = false; 465 int ratFamily = 0; 466 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 467 try { 468 mRadioNetworkResponse.getImsRegistrationStateResponse(rsp, isRegistered, ratFamily); 469 } catch (RemoteException ex) { 470 Log.e(mTag, "Failed to getImsRegistrationState from AIDL. Exception" + ex); 471 } 472 } 473 474 @Override getNetworkSelectionMode(int serial)475 public void getNetworkSelectionMode(int serial) { 476 Log.d(mTag, "getNetworkSelectionMode"); 477 478 RadioResponseInfo rsp = mService.makeSolRsp(serial); 479 try { 480 mRadioNetworkResponse.getNetworkSelectionModeResponse(rsp, mNetworkSelectionMode); 481 } catch (RemoteException ex) { 482 Log.e(mTag, "Failed to getNetworkSelectionMode from AIDL. Exception" + ex); 483 } 484 } 485 486 @Override getOperator(int serial)487 public void getOperator(int serial) { 488 Log.d(mTag, "getOperator"); 489 490 String longName = ""; 491 String shortName = ""; 492 String numeric = ""; 493 494 synchronized (mCacheUpdateMutex) { 495 if (mServiceState.isInService()) { 496 android.hardware.radio.network.OperatorInfo operatorInfo = 497 mServiceState.getPrimaryCellOperatorInfo(); 498 longName = operatorInfo.alphaLong; 499 shortName = operatorInfo.alphaShort; 500 numeric = operatorInfo.operatorNumeric; 501 } 502 } 503 RadioResponseInfo rsp = mService.makeSolRsp(serial); 504 try { 505 mRadioNetworkResponse.getOperatorResponse(rsp, longName, shortName, numeric); 506 } catch (RemoteException ex) { 507 Log.e(mTag, "Failed to getOperator from AIDL. Exception" + ex); 508 } 509 } 510 511 @Override getSignalStrength(int serial)512 public void getSignalStrength(int serial) { 513 Log.d(mTag, "getSignalStrength"); 514 515 android.hardware.radio.network.SignalStrength signalStrength = 516 new android.hardware.radio.network.SignalStrength(); 517 518 synchronized (mCacheUpdateMutex) { 519 if (mServiceState.getIsHomeCamping() 520 && mRadioState == MockModemConfigInterface.RADIO_STATE_ON) { 521 signalStrength = mServiceState.getSignalStrength(); 522 } 523 } 524 525 RadioResponseInfo rsp = mService.makeSolRsp(serial); 526 try { 527 mRadioNetworkResponse.getSignalStrengthResponse(rsp, signalStrength); 528 } catch (RemoteException ex) { 529 Log.e(mTag, "Failed to getSignalStrength from AIDL. Exception" + ex); 530 } 531 } 532 533 @Override getSystemSelectionChannels(int serial)534 public void getSystemSelectionChannels(int serial) { 535 Log.d(mTag, "getSystemSelectionChannels"); 536 537 android.hardware.radio.network.RadioAccessSpecifier[] specifiers = 538 new android.hardware.radio.network.RadioAccessSpecifier[0]; 539 RadioResponseInfo rsp = mService.makeSolRsp(serial); 540 try { 541 mRadioNetworkResponse.getSystemSelectionChannelsResponse(rsp, specifiers); 542 } catch (RemoteException ex) { 543 Log.e(mTag, "Failed to getSystemSelectionChannels from AIDL. Exception" + ex); 544 } 545 } 546 547 @Override getVoiceRadioTechnology(int serial)548 public void getVoiceRadioTechnology(int serial) { 549 Log.d(mTag, "getVoiceRadioTechnology"); 550 int rat; 551 552 synchronized (mCacheUpdateMutex) { 553 rat = mServiceState.getRegistrationRat(); 554 } 555 556 RadioResponseInfo rsp = mService.makeSolRsp(serial); 557 try { 558 mRadioNetworkResponse.getVoiceRadioTechnologyResponse(rsp, rat); 559 } catch (RemoteException ex) { 560 Log.e(mTag, "Failed to getVoiceRadioTechnology from AIDL. Exception" + ex); 561 } 562 } 563 564 @Override getVoiceRegistrationState(int serial)565 public void getVoiceRegistrationState(int serial) { 566 Log.d(mTag, "getVoiceRegistrationState"); 567 568 android.hardware.radio.network.RegStateResult voiceRegResponse = 569 new android.hardware.radio.network.RegStateResult(); 570 571 voiceRegResponse.cellIdentity = new android.hardware.radio.network.CellIdentity(); 572 voiceRegResponse.reasonForDenial = mServiceState.getRegFailCause(); 573 574 synchronized (mCacheUpdateMutex) { 575 voiceRegResponse.regState = 576 mServiceState.getRegistration(android.hardware.radio.network.Domain.CS); 577 voiceRegResponse.rat = mServiceState.getRegistrationRat(); 578 if (mServiceState.isInService()) { 579 voiceRegResponse.registeredPlmn = 580 mServiceState.getPrimaryCellOperatorInfo().operatorNumeric; 581 } 582 583 voiceRegResponse.cellIdentity = mServiceState.getPrimaryCellIdentity(); 584 } 585 586 // TODO: support accessTechnologySpecificInfo 587 voiceRegResponse.accessTechnologySpecificInfo = 588 android.hardware.radio.network.AccessTechnologySpecificInfo.noinit(true); 589 590 RadioResponseInfo rsp = mService.makeSolRsp(serial); 591 try { 592 mRadioNetworkResponse.getVoiceRegistrationStateResponse(rsp, voiceRegResponse); 593 } catch (RemoteException ex) { 594 Log.e(mTag, "Failed to getVoiceRegistrationState from AIDL. Exception" + ex); 595 } 596 } 597 598 @Override isNrDualConnectivityEnabled(int serial)599 public void isNrDualConnectivityEnabled(int serial) { 600 Log.d(mTag, "isNrDualConnectivityEnabled"); 601 boolean isEnabled = false; 602 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 603 try { 604 mRadioNetworkResponse.isNrDualConnectivityEnabledResponse(rsp, isEnabled); 605 } catch (RemoteException ex) { 606 Log.e(mTag, "Failed to isNrDualConnectivityEnabled from AIDL. Exception" + ex); 607 } 608 } 609 610 @Override responseAcknowledgement()611 public void responseAcknowledgement() { 612 Log.d(mTag, "responseAcknowledgement"); 613 } 614 615 @Override setAllowedNetworkTypesBitmap(int serial, int networkTypeBitmap)616 public void setAllowedNetworkTypesBitmap(int serial, int networkTypeBitmap) { 617 Log.d(mTag, "setAllowedNetworkTypesBitmap"); 618 boolean isModeChange = false; 619 620 if (mNetworkTypeBitmap != networkTypeBitmap) { 621 mNetworkTypeBitmap = networkTypeBitmap; 622 synchronized (mCacheUpdateMutex) { 623 isModeChange = mServiceState.updateHighestRegisteredRat(mNetworkTypeBitmap); 624 } 625 if (isModeChange) { 626 mHandler.obtainMessage(EVENT_PREFERRED_MODE_CHANGED).sendToTarget(); 627 } 628 } 629 630 RadioResponseInfo rsp = mService.makeSolRsp(serial); 631 try { 632 mRadioNetworkResponse.setAllowedNetworkTypesBitmapResponse(rsp); 633 } catch (RemoteException ex) { 634 Log.e(mTag, "Failed to setAllowedNetworkTypesBitmap from AIDL. Exception" + ex); 635 } 636 } 637 638 @Override setBandMode(int serial, int mode)639 public void setBandMode(int serial, int mode) { 640 Log.d(mTag, "setBandMode"); 641 642 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 643 try { 644 mRadioNetworkResponse.setBandModeResponse(rsp); 645 } catch (RemoteException ex) { 646 Log.e(mTag, "Failed to setBandMode from AIDL. Exception" + ex); 647 } 648 } 649 650 @Override setBarringPassword( int serial, String facility, String oldPassword, String newPassword)651 public void setBarringPassword( 652 int serial, String facility, String oldPassword, String newPassword) { 653 Log.d(mTag, "setBarringPassword"); 654 655 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 656 try { 657 mRadioNetworkResponse.setBarringPasswordResponse(rsp); 658 } catch (RemoteException ex) { 659 Log.e(mTag, "Failed to setBarringPassword from AIDL. Exception" + ex); 660 } 661 } 662 663 @Override setCdmaRoamingPreference(int serial, int type)664 public void setCdmaRoamingPreference(int serial, int type) { 665 Log.d(mTag, "setCdmaRoamingPreference"); 666 667 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 668 try { 669 mRadioNetworkResponse.setCdmaRoamingPreferenceResponse(rsp); 670 } catch (RemoteException ex) { 671 Log.e(mTag, "Failed to setCdmaRoamingPreference from AIDL. Exception" + ex); 672 } 673 } 674 675 @Override setCellInfoListRate(int serial, int rate)676 public void setCellInfoListRate(int serial, int rate) { 677 Log.d(mTag, "setCellInfoListRate"); 678 679 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 680 try { 681 mRadioNetworkResponse.setCellInfoListRateResponse(rsp); 682 } catch (RemoteException ex) { 683 Log.e(mTag, "Failed to setCellInfoListRate from AIDL. Exception" + ex); 684 } 685 } 686 687 @Override setIndicationFilter(int serial, int indicationFilter)688 public void setIndicationFilter(int serial, int indicationFilter) { 689 Log.d(mTag, "setIndicationFilter"); 690 691 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 692 try { 693 mRadioNetworkResponse.setIndicationFilterResponse(rsp); 694 } catch (RemoteException ex) { 695 Log.e(mTag, "Failed to setIndicationFilter from AIDL. Exception" + ex); 696 } 697 } 698 699 @Override setLinkCapacityReportingCriteria( int serial, int hysteresisMs, int hysteresisDlKbps, int hysteresisUlKbps, int[] thresholdsDownlinkKbps, int[] thresholdsUplinkKbps, int accessNetwork)700 public void setLinkCapacityReportingCriteria( 701 int serial, 702 int hysteresisMs, 703 int hysteresisDlKbps, 704 int hysteresisUlKbps, 705 int[] thresholdsDownlinkKbps, 706 int[] thresholdsUplinkKbps, 707 int accessNetwork) { 708 Log.d(mTag, "setLinkCapacityReportingCriteria"); 709 710 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 711 try { 712 mRadioNetworkResponse.setLinkCapacityReportingCriteriaResponse(rsp); 713 } catch (RemoteException ex) { 714 Log.e(mTag, "Failed to setLinkCapacityReportingCriteria from AIDL. Exception" + ex); 715 } 716 } 717 718 @Override setLocationUpdates(int serial, boolean enable)719 public void setLocationUpdates(int serial, boolean enable) { 720 Log.d(mTag, "setLocationUpdates"); 721 722 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 723 try { 724 mRadioNetworkResponse.setLocationUpdatesResponse(rsp); 725 } catch (RemoteException ex) { 726 Log.e(mTag, "Failed to setLocationUpdates from AIDL. Exception" + ex); 727 } 728 } 729 730 @Override setNetworkSelectionModeAutomatic(int serial)731 public void setNetworkSelectionModeAutomatic(int serial) { 732 Log.d(mTag, "setNetworkSelectionModeAutomatic"); 733 734 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 735 try { 736 mRadioNetworkResponse.setNetworkSelectionModeAutomaticResponse(rsp); 737 } catch (RemoteException ex) { 738 Log.e(mTag, "Failed to setNetworkSelectionModeAutomatic from AIDL. Exception" + ex); 739 } 740 } 741 742 @Override setNetworkSelectionModeManual(int serial, String operatorNumeric, int ran)743 public void setNetworkSelectionModeManual(int serial, String operatorNumeric, int ran) { 744 Log.d(mTag, "setNetworkSelectionModeManual"); 745 746 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 747 try { 748 mRadioNetworkResponse.setNetworkSelectionModeManualResponse(rsp); 749 } catch (RemoteException ex) { 750 Log.e(mTag, "Failed to setNetworkSelectionModeManual from AIDL. Exception" + ex); 751 } 752 } 753 754 @Override setNrDualConnectivityState(int serial, byte nrDualConnectivityState)755 public void setNrDualConnectivityState(int serial, byte nrDualConnectivityState) { 756 Log.d(mTag, "setNrDualConnectivityState"); 757 758 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 759 try { 760 mRadioNetworkResponse.setNrDualConnectivityStateResponse(rsp); 761 } catch (RemoteException ex) { 762 Log.e(mTag, "Failed to setNrDualConnectivityState from AIDL. Exception" + ex); 763 } 764 } 765 766 @Override setResponseFunctions( IRadioNetworkResponse radioNetworkResponse, IRadioNetworkIndication radioNetworkIndication)767 public void setResponseFunctions( 768 IRadioNetworkResponse radioNetworkResponse, 769 IRadioNetworkIndication radioNetworkIndication) { 770 Log.d(mTag, "setResponseFunctions"); 771 mRadioNetworkResponse = radioNetworkResponse; 772 mRadioNetworkIndication = radioNetworkIndication; 773 mService.countDownLatch(MockModemService.LATCH_RADIO_INTERFACES_READY); 774 } 775 776 @Override setSignalStrengthReportingCriteria( int serial, SignalThresholdInfo[] signalThresholdInfos)777 public void setSignalStrengthReportingCriteria( 778 int serial, SignalThresholdInfo[] signalThresholdInfos) { 779 Log.d(mTag, "setSignalStrengthReportingCriteria"); 780 781 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 782 try { 783 mRadioNetworkResponse.setSignalStrengthReportingCriteriaResponse(rsp); 784 } catch (RemoteException ex) { 785 Log.e(mTag, "Failed to setSignalStrengthReportingCriteria from AIDL. Exception" + ex); 786 } 787 } 788 789 @Override setSuppServiceNotifications(int serial, boolean enable)790 public void setSuppServiceNotifications(int serial, boolean enable) { 791 Log.d(mTag, "setSuppServiceNotifications"); 792 793 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 794 try { 795 mRadioNetworkResponse.setSuppServiceNotificationsResponse(rsp); 796 } catch (RemoteException ex) { 797 Log.e(mTag, "Failed to setSuppServiceNotifications from AIDL. Exception" + ex); 798 } 799 } 800 801 @Override setSystemSelectionChannels( int serial, boolean specifyChannels, RadioAccessSpecifier[] specifiers)802 public void setSystemSelectionChannels( 803 int serial, boolean specifyChannels, RadioAccessSpecifier[] specifiers) { 804 Log.d(mTag, "setSystemSelectionChannels"); 805 806 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 807 try { 808 mRadioNetworkResponse.setSystemSelectionChannelsResponse(rsp); 809 } catch (RemoteException ex) { 810 Log.e(mTag, "Failed to setSystemSelectionChannels from AIDL. Exception" + ex); 811 } 812 } 813 814 @Override startNetworkScan(int serial, NetworkScanRequest request)815 public void startNetworkScan(int serial, NetworkScanRequest request) { 816 Log.d(mTag, "startNetworkScan"); 817 818 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 819 try { 820 mRadioNetworkResponse.startNetworkScanResponse(rsp); 821 } catch (RemoteException ex) { 822 Log.e(mTag, "Failed to startNetworkScan from AIDL. Exception" + ex); 823 } 824 } 825 826 @Override stopNetworkScan(int serial)827 public void stopNetworkScan(int serial) { 828 Log.d(mTag, "stopNetworkScan"); 829 830 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 831 try { 832 mRadioNetworkResponse.stopNetworkScanResponse(rsp); 833 } catch (RemoteException ex) { 834 Log.e(mTag, "Failed to stopNetworkScan from AIDL. Exception" + ex); 835 } 836 } 837 838 @Override supplyNetworkDepersonalization(int serial, String netPin)839 public void supplyNetworkDepersonalization(int serial, String netPin) { 840 Log.d(mTag, "supplyNetworkDepersonalization"); 841 int remainingRetries = 0; 842 843 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 844 try { 845 mRadioNetworkResponse.supplyNetworkDepersonalizationResponse(rsp, remainingRetries); 846 } catch (RemoteException ex) { 847 Log.e(mTag, "Failed to supplyNetworkDepersonalization from AIDL. Exception" + ex); 848 } 849 } 850 851 @Override setUsageSetting(int serial, int usageSetting)852 public void setUsageSetting(int serial, int usageSetting) { 853 Log.d(mTag, "setUsageSetting"); 854 int remainingRetries = 0; 855 856 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 857 try { 858 mRadioNetworkResponse.setUsageSettingResponse(rsp); 859 } catch (RemoteException ex) { 860 Log.e(mTag, "Failed to setUsageSetting from AIDL. Exception" + ex); 861 } 862 } 863 864 @Override getUsageSetting(int serial)865 public void getUsageSetting(int serial) { 866 Log.d(mTag, "getUsageSetting"); 867 868 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 869 try { 870 mRadioNetworkResponse.getUsageSettingResponse(rsp, -1 /* Invalid value */); 871 } catch (RemoteException ex) { 872 Log.e(mTag, "Failed to getUsageSetting from AIDL. Exception" + ex); 873 } 874 } 875 876 @Override setEmergencyMode(int serial, int emcModeType)877 public void setEmergencyMode(int serial, int emcModeType) { 878 Log.d(TAG, "setEmergencyMode"); 879 880 EmergencyRegResult result; 881 synchronized (mCacheUpdateMutex) { 882 mServiceState.setEmergencyMode(emcModeType); 883 result = mServiceState.getEmergencyRegResult(); 884 } 885 886 RadioResponseInfo rsp = mService.makeSolRsp(serial); 887 try { 888 mRadioNetworkResponse.setEmergencyModeResponse(rsp, result); 889 } catch (RemoteException ex) { 890 Log.e(TAG, "Failed to setEmergencyMode from AIDL. Exception" + ex); 891 } 892 } 893 894 @Override triggerEmergencyNetworkScan(int serial, android.hardware.radio.network.EmergencyNetworkScanTrigger request)895 public void triggerEmergencyNetworkScan(int serial, 896 android.hardware.radio.network.EmergencyNetworkScanTrigger request) { 897 Log.d(TAG, "triggerEmergencyNetworkScan"); 898 899 synchronized (mCacheUpdateMutex) { 900 mServiceState.setEmergencyNetworkScanTriggered(true, 901 request.accessNetwork, request.scanType); 902 } 903 904 RadioResponseInfo rsp = mService.makeSolRsp(serial); 905 try { 906 mRadioNetworkResponse.triggerEmergencyNetworkScanResponse(rsp); 907 } catch (RemoteException ex) { 908 Log.e(TAG, "Failed to triggerEmergencyNetworkScan from AIDL. Exception" + ex); 909 } 910 } 911 912 @Override cancelEmergencyNetworkScan(int serial, boolean resetScan)913 public void cancelEmergencyNetworkScan(int serial, boolean resetScan) { 914 Log.d(TAG, "cancelEmergencyNetworkScan"); 915 916 synchronized (mCacheUpdateMutex) { 917 mServiceState.setEmergencyNetworkScanCanceled(true); 918 } 919 920 RadioResponseInfo rsp = mService.makeSolRsp(serial); 921 try { 922 mRadioNetworkResponse.cancelEmergencyNetworkScanResponse(rsp); 923 } catch (RemoteException ex) { 924 Log.e(TAG, "Failed to cancelEmergencyNetworkScan from AIDL. Exception" + ex); 925 } 926 } 927 928 @Override exitEmergencyMode(int serial)929 public void exitEmergencyMode(int serial) { 930 Log.d(TAG, "exitEmergencyMode"); 931 932 synchronized (mCacheUpdateMutex) { 933 mServiceState.setEmergencyMode(0); 934 } 935 936 RadioResponseInfo rsp = mService.makeSolRsp(serial); 937 try { 938 mRadioNetworkResponse.exitEmergencyModeResponse(rsp); 939 } catch (RemoteException ex) { 940 Log.e(TAG, "Failed to exitEmergencyMode from AIDL. Exception" + ex); 941 } 942 } 943 944 @Override setNullCipherAndIntegrityEnabled(int serial, boolean isEnabled)945 public void setNullCipherAndIntegrityEnabled(int serial, boolean isEnabled) { 946 Log.d(TAG, "setNullCipherAndIntegrityEnabled"); 947 948 mNullCipherAndIntegrityEnabled = isEnabled; 949 950 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.NONE); 951 try { 952 mRadioNetworkResponse.setNullCipherAndIntegrityEnabledResponse(rsp); 953 } catch (RemoteException ex) { 954 Log.e(TAG, "Failed to setNullCipherAndIntegrityEnabled from AIDL. Exception " + ex); 955 } 956 } 957 958 @Override isNullCipherAndIntegrityEnabled(int serial)959 public void isNullCipherAndIntegrityEnabled(int serial) { 960 Log.d(TAG, "isNullCipherAndIntegrityEnabled"); 961 962 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.NONE); 963 try { 964 mRadioNetworkResponse.isNullCipherAndIntegrityEnabledResponse(rsp, 965 mNullCipherAndIntegrityEnabled); 966 } catch (RemoteException ex) { 967 Log.e(TAG, "Failed to call isNullCipherAndIntegrityEnabled from AIDL. Exception " + ex); 968 } 969 } 970 971 @Override isN1ModeEnabled(int serial)972 public void isN1ModeEnabled(int serial) { 973 Log.d(TAG, "isN1ModeEnabled"); 974 975 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 976 try { 977 mRadioNetworkResponse.isN1ModeEnabledResponse(rsp, false); 978 } catch (RemoteException ex) { 979 Log.e(TAG, "Failed to isN1ModeEnabled from AIDL. Exception " + ex); 980 } 981 } 982 983 @Override setN1ModeEnabled(int serial, boolean enable)984 public void setN1ModeEnabled(int serial, boolean enable) { 985 Log.d(TAG, "setN1ModeEnabled"); 986 987 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 988 try { 989 mRadioNetworkResponse.setN1ModeEnabledResponse(rsp); 990 } catch (RemoteException ex) { 991 Log.e(TAG, "Failed to setN1ModeEnabled from AIDL. Exception " + ex); 992 } 993 } 994 995 @Override isCellularIdentifierTransparencyEnabled(int serial)996 public void isCellularIdentifierTransparencyEnabled(int serial) { 997 Log.d(TAG, "isCellularIdentifierTransparencyEnabled"); 998 999 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 1000 try { 1001 mRadioNetworkResponse.isCellularIdentifierTransparencyEnabledResponse(rsp, false); 1002 } catch (RemoteException ex) { 1003 Log.e( 1004 TAG, 1005 "Failed to isCellularIdentifierTransparencyEnabled from AIDL. Exception " + ex); 1006 } 1007 } 1008 1009 @Override setCellularIdentifierTransparencyEnabled(int serial, boolean enable)1010 public void setCellularIdentifierTransparencyEnabled(int serial, boolean enable) { 1011 Log.d(TAG, "setCellularIdentifierTransparencyEnabled"); 1012 1013 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 1014 try { 1015 mRadioNetworkResponse.setCellularIdentifierTransparencyEnabledResponse(rsp); 1016 } catch (RemoteException ex) { 1017 Log.e( 1018 TAG, 1019 "Failed to setCellularIdentifierTransparencyEnabled from AIDL. Exception " + ex); 1020 } 1021 } 1022 1023 @Override isSecurityAlgorithmsUpdatedEnabled(int serial)1024 public void isSecurityAlgorithmsUpdatedEnabled(int serial) { 1025 Log.d(TAG, "isSecurityAlgorithmsUpdatedEnabled"); 1026 1027 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 1028 try { 1029 mRadioNetworkResponse.isSecurityAlgorithmsUpdatedEnabledResponse(rsp, false); 1030 } catch (RemoteException ex) { 1031 Log.e(TAG, "Failed to isSecurityAlgorithmsUpdatedEnabled from AIDL. Exception " + ex); 1032 } 1033 } 1034 1035 @Override setSecurityAlgorithmsUpdatedEnabled(int serial, boolean enable)1036 public void setSecurityAlgorithmsUpdatedEnabled(int serial, boolean enable) { 1037 Log.d(TAG, "setSecurityAlgorithmsUpdatedEnabled"); 1038 1039 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 1040 try { 1041 mRadioNetworkResponse.setSecurityAlgorithmsUpdatedEnabledResponse(rsp); 1042 } catch (RemoteException ex) { 1043 Log.e(TAG, "Failed to setSecurityAlgorithmsUpdatedEnabled from AIDL. Exception " + ex); 1044 } 1045 } 1046 1047 @Override getInterfaceHash()1048 public String getInterfaceHash() { 1049 return IRadioNetwork.HASH; 1050 } 1051 1052 @Override getInterfaceVersion()1053 public int getInterfaceVersion() { 1054 return IRadioNetwork.VERSION; 1055 } 1056 unsolNetworkStateChanged()1057 public void unsolNetworkStateChanged() { 1058 Log.d(mTag, "unsolNetworkStateChanged"); 1059 1060 // Notify other module 1061 notifyServiceStateChange(); 1062 1063 if (mRadioNetworkIndication != null) { 1064 try { 1065 mRadioNetworkIndication.networkStateChanged(RadioIndicationType.UNSOLICITED); 1066 } catch (RemoteException ex) { 1067 Log.e(mTag, "Failed to invoke networkStateChanged from AIDL. Exception" + ex); 1068 } 1069 } else { 1070 Log.e(mTag, "null mRadioNetworkIndication"); 1071 } 1072 } 1073 unsolCurrentSignalStrength()1074 public void unsolCurrentSignalStrength() { 1075 Log.d(mTag, "unsolCurrentSignalStrength"); 1076 if (mRadioState != MockModemConfigInterface.RADIO_STATE_ON) { 1077 return; 1078 } 1079 1080 if (mRadioNetworkIndication != null) { 1081 android.hardware.radio.network.SignalStrength signalStrength = 1082 new android.hardware.radio.network.SignalStrength(); 1083 1084 synchronized (mCacheUpdateMutex) { 1085 signalStrength = mServiceState.getSignalStrength(); 1086 } 1087 1088 try { 1089 mRadioNetworkIndication.currentSignalStrength( 1090 RadioIndicationType.UNSOLICITED, signalStrength); 1091 } catch (RemoteException ex) { 1092 Log.e( 1093 mTag, 1094 "Failed to invoke currentSignalStrength change from AIDL. Exception" + ex); 1095 } 1096 } else { 1097 Log.e(mTag, "null mRadioNetworkIndication"); 1098 } 1099 } 1100 unsolCellInfoList()1101 public void unsolCellInfoList() { 1102 Log.d(mTag, "unsolCellInfoList"); 1103 1104 if (mRadioState != MockModemConfigInterface.RADIO_STATE_ON) { 1105 return; 1106 } 1107 1108 if (mRadioNetworkIndication != null) { 1109 android.hardware.radio.network.CellInfo[] cells; 1110 1111 synchronized (mCacheUpdateMutex) { 1112 cells = mServiceState.getCells(); 1113 } 1114 try { 1115 mRadioNetworkIndication.cellInfoList(RadioIndicationType.UNSOLICITED, cells); 1116 } catch (RemoteException ex) { 1117 Log.e(mTag, "Failed to invoke cellInfoList change from AIDL. Exception" + ex); 1118 } 1119 } else { 1120 Log.e(mTag, "null mRadioNetworkIndication"); 1121 } 1122 } 1123 unsolBarringInfoChanged( SparseArray<android.telephony.BarringInfo.BarringServiceInfo> barringServiceInfos)1124 public boolean unsolBarringInfoChanged( 1125 SparseArray<android.telephony.BarringInfo.BarringServiceInfo> barringServiceInfos) { 1126 Log.d(mTag, "unsolBarringInfoChanged"); 1127 1128 if (mRadioState != MockModemConfigInterface.RADIO_STATE_ON) { 1129 Log.d(mTag, "unsolBarringInfoChanged radio is off"); 1130 return false; 1131 } 1132 1133 if (mRadioNetworkIndication != null) { 1134 CellIdentity cellIdentity = new CellIdentity(); 1135 BarringInfo[] halBarringInfos = convertBarringInfo(barringServiceInfos); 1136 synchronized (mCacheUpdateMutex) { 1137 cellIdentity = mServiceState.getPrimaryCellIdentity(); 1138 mServiceState.updateBarringInfos(halBarringInfos); 1139 } 1140 1141 try { 1142 mRadioNetworkIndication.barringInfoChanged(RadioIndicationType.UNSOLICITED, 1143 cellIdentity, halBarringInfos); 1144 return true; 1145 } catch (RemoteException ex) { 1146 Log.e(mTag, "Failed to invoke barringInfoChanged change from AIDL. Exception" + ex); 1147 } 1148 } else { 1149 Log.e(mTag, "null mRadioNetworkIndication"); 1150 } 1151 return false; 1152 } 1153 unsolEmergencyNetworkScanResult(MockEmergencyRegResult regResult)1154 public boolean unsolEmergencyNetworkScanResult(MockEmergencyRegResult regResult) { 1155 Log.d(TAG, "unsolEmergencyNetworkScanResult"); 1156 1157 if (mRadioState != MockModemConfigInterface.RADIO_STATE_ON) { 1158 return false; 1159 } 1160 1161 if (mRadioNetworkIndication != null) { 1162 EmergencyRegResult result = convertEmergencyRegResult(regResult); 1163 1164 synchronized (mCacheUpdateMutex) { 1165 mServiceState.setEmergencyRegResult(result); 1166 } 1167 1168 try { 1169 mRadioNetworkIndication.emergencyNetworkScanResult( 1170 RadioIndicationType.UNSOLICITED, result); 1171 return true; 1172 } catch (RemoteException ex) { 1173 Log.e(TAG, 1174 "Failed to invoke emergencyNetworkScanResult change from AIDL. Exception" 1175 + ex); 1176 } 1177 } else { 1178 Log.e(TAG, "null mRadioNetworkIndication"); 1179 } 1180 return false; 1181 } 1182 convertEmergencyRegResult(MockEmergencyRegResult regResult)1183 private static EmergencyRegResult convertEmergencyRegResult(MockEmergencyRegResult regResult) { 1184 1185 EmergencyRegResult result = new EmergencyRegResult(); 1186 1187 result.accessNetwork = regResult.getAccessNetwork(); 1188 result.regState = convertRegState(regResult.getRegState()); 1189 result.emcDomain = regResult.getDomain(); 1190 result.isVopsSupported = regResult.isVopsSupported(); 1191 result.isEmcBearerSupported = regResult.isEmcBearerSupported(); 1192 result.nwProvidedEmc = (byte) regResult.getNwProvidedEmc(); 1193 result.nwProvidedEmf = (byte) regResult.getNwProvidedEmf(); 1194 result.mcc = regResult.getMcc(); 1195 result.mnc = regResult.getMnc(); 1196 1197 return result; 1198 } 1199 1200 /** 1201 * Convert RegistrationState to RegState 1202 * @param regState Registration state 1203 * @return Converted registration state. 1204 */ convertRegState(@etworkRegistrationInfo.RegistrationState int regState)1205 private static int convertRegState(@NetworkRegistrationInfo.RegistrationState int regState) { 1206 switch (regState) { 1207 case NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING: 1208 return RegState.NOT_REG_MT_NOT_SEARCHING_OP_EM; 1209 case NetworkRegistrationInfo.REGISTRATION_STATE_HOME: 1210 return RegState.REG_HOME; 1211 case NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING: 1212 return RegState.NOT_REG_MT_SEARCHING_OP_EM; 1213 case NetworkRegistrationInfo.REGISTRATION_STATE_DENIED: 1214 return RegState.REG_DENIED_EM; 1215 case NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN: 1216 return RegState.UNKNOWN_EM; 1217 case NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING: 1218 return RegState.REG_ROAMING; 1219 default: 1220 return RegState.NOT_REG_MT_NOT_SEARCHING_OP_EM; 1221 } 1222 } 1223 convertBarringInfo( SparseArray<android.telephony.BarringInfo.BarringServiceInfo> barringServiceInfos)1224 private BarringInfo[] convertBarringInfo( 1225 SparseArray<android.telephony.BarringInfo.BarringServiceInfo> barringServiceInfos) { 1226 ArrayList<BarringInfo> halBarringInfo = new ArrayList<>(); 1227 1228 for (int i = BarringInfo.SERVICE_TYPE_CS_SERVICE; i <= BarringInfo.SERVICE_TYPE_SMS; i++) { 1229 android.telephony.BarringInfo.BarringServiceInfo serviceInfo = 1230 barringServiceInfos.get(i); 1231 if (serviceInfo != null) { 1232 BarringInfo barringInfo = new BarringInfo(); 1233 barringInfo.serviceType = i; 1234 barringInfo.barringType = serviceInfo.getBarringType(); 1235 barringInfo.barringTypeSpecificInfo = new BarringTypeSpecificInfo(); 1236 barringInfo.barringTypeSpecificInfo.isBarred = serviceInfo.isConditionallyBarred(); 1237 barringInfo.barringTypeSpecificInfo.factor = 1238 serviceInfo.getConditionalBarringFactor(); 1239 barringInfo.barringTypeSpecificInfo.timeSeconds = 1240 serviceInfo.getConditionalBarringTimeSeconds(); 1241 halBarringInfo.add(barringInfo); 1242 } 1243 } 1244 return halBarringInfo.toArray(new BarringInfo[0]); 1245 } 1246 1247 /** 1248 * Waits for the event of network service. 1249 * 1250 * @param latchIndex The index of the event. 1251 * @param waitMs The timeout in milliseconds. 1252 */ waitForLatchCountdown(int latchIndex, int waitMs)1253 public boolean waitForLatchCountdown(int latchIndex, int waitMs) { 1254 return mServiceState.waitForLatchCountdown(latchIndex, waitMs); 1255 } 1256 1257 /** 1258 * Resets the CountDownLatches 1259 */ resetAllLatchCountdown()1260 public void resetAllLatchCountdown() { 1261 mServiceState.resetAllLatchCountdown(); 1262 } 1263 } 1264