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 static android.telephony.mockmodem.MockSimService.COMMAND_GET_RESPONSE; 20 import static android.telephony.mockmodem.MockSimService.COMMAND_READ_BINARY; 21 import static android.telephony.mockmodem.MockSimService.EF_ICCID; 22 23 import android.hardware.radio.RadioError; 24 import android.hardware.radio.RadioIndicationType; 25 import android.hardware.radio.RadioResponseInfo; 26 import android.hardware.radio.sim.CardStatus; 27 import android.hardware.radio.sim.Carrier; 28 import android.hardware.radio.sim.CarrierRestrictions; 29 import android.hardware.radio.sim.IRadioSim; 30 import android.hardware.radio.sim.IRadioSimIndication; 31 import android.hardware.radio.sim.IRadioSimResponse; 32 import android.hardware.radio.sim.SimRefreshResult; 33 import android.os.AsyncResult; 34 import android.os.Build; 35 import android.os.Handler; 36 import android.os.Message; 37 import android.os.RemoteException; 38 import android.telephony.mockmodem.MockModemConfigBase.SimInfoChangedResult; 39 import android.telephony.mockmodem.MockSimService.SimAppData; 40 import android.util.Log; 41 42 import java.util.ArrayList; 43 44 public class IRadioSimImpl extends IRadioSim.Stub { 45 private static final String TAG = "MRSIM"; 46 private final MockModemService mService; 47 private IRadioSimResponse mRadioSimResponse; 48 private IRadioSimIndication mRadioSimIndication; 49 private MockModemConfigInterface mMockModemConfigInterface; 50 private Object mCacheUpdateMutex; 51 private final Handler mHandler; 52 private int mSubId; 53 private String mTag; 54 55 // ***** Events 56 static final int EVENT_SIM_CARD_STATUS_CHANGED = 1; 57 static final int EVENT_SIM_APP_DATA_CHANGED = 2; 58 static final int EVENT_SIM_INFO_CHANGED = 3; 59 60 // ***** Cache of modem attributes/status 61 private CardStatus mCardStatus; 62 private ArrayList<SimAppData> mSimAppList; 63 64 private Carrier[] mCarrierList; 65 private int mCarrierRestrictionStatus = 66 CarrierRestrictions.CarrierRestrictionStatus.UNKNOWN; 67 IRadioSimImpl( MockModemService service, MockModemConfigInterface configInterface, int instanceId)68 public IRadioSimImpl( 69 MockModemService service, MockModemConfigInterface configInterface, int instanceId) { 70 mTag = TAG + "-" + instanceId; 71 Log.d(mTag, "Instantiated"); 72 73 this.mService = service; 74 mMockModemConfigInterface = configInterface; 75 mSubId = instanceId; 76 mCardStatus = new CardStatus(); 77 mCacheUpdateMutex = new Object(); 78 mHandler = new IRadioSimHandler(); 79 80 // Register events 81 mMockModemConfigInterface.registerForCardStatusChanged( 82 mSubId, mHandler, EVENT_SIM_CARD_STATUS_CHANGED, null); 83 84 // Register events 85 mMockModemConfigInterface.registerForSimAppDataChanged( 86 mSubId, mHandler, EVENT_SIM_APP_DATA_CHANGED, null); 87 88 // Register events 89 mMockModemConfigInterface.registerForSimInfoChanged( 90 mSubId, mHandler, EVENT_SIM_INFO_CHANGED, null); 91 } 92 93 /** Handler class to handle callbacks */ 94 private final class IRadioSimHandler extends Handler { 95 @Override handleMessage(Message msg)96 public void handleMessage(Message msg) { 97 AsyncResult ar; 98 synchronized (mCacheUpdateMutex) { 99 switch (msg.what) { 100 case EVENT_SIM_CARD_STATUS_CHANGED: 101 Log.d(mTag, "Received EVENT_SIM_CARD_STATUS_CHANGED"); 102 ar = (AsyncResult) msg.obj; 103 if (ar != null && ar.exception == null) { 104 mCardStatus = (CardStatus) ar.result; 105 Log.i(mTag, "Sim card status: " + mCardStatus); 106 simStatusChanged(); 107 } else { 108 Log.e(mTag, msg.what + " failure. Exception: " + ar.exception); 109 } 110 break; 111 112 case EVENT_SIM_APP_DATA_CHANGED: 113 Log.d(mTag, "Received EVENT_SIM_APP_DATA_CHANGED"); 114 ar = (AsyncResult) msg.obj; 115 if (ar != null && ar.exception == null) { 116 mSimAppList = (ArrayList<SimAppData>) ar.result; 117 if (mSimAppList != null) { 118 Log.i(mTag, "number of SIM app data: " + mSimAppList.size()); 119 } else { 120 Log.e(mTag, "mSimAppList = null"); 121 } 122 } else { 123 Log.e(mTag, msg.what + " failure. Exception: " + ar.exception); 124 } 125 break; 126 127 case EVENT_SIM_INFO_CHANGED: 128 ar = (AsyncResult) msg.obj; 129 if (ar != null && ar.exception == null) { 130 SimInfoChangedResult simInfoChangeResult = 131 (SimInfoChangedResult) ar.result; 132 Log.d(mTag, "Received EVENT_SIM_INFO_CHANGED: " + simInfoChangeResult); 133 SimRefreshResult simRefreshResult = new SimRefreshResult(); 134 switch (simInfoChangeResult.mSimInfoType) { 135 case SimInfoChangedResult.SIM_INFO_TYPE_MCC_MNC: 136 case SimInfoChangedResult.SIM_INFO_TYPE_IMSI: 137 if (simRefreshResult != null) { 138 simRefreshResult.type = 139 SimRefreshResult.TYPE_SIM_FILE_UPDATE; 140 simRefreshResult.efId = simInfoChangeResult.mEfId; 141 simRefreshResult.aid = simInfoChangeResult.mAid; 142 simRefresh(simRefreshResult); 143 } 144 break; 145 } 146 } else { 147 Log.e(mTag, msg.what + " failure. Exception: " + ar.exception); 148 } 149 break; 150 } 151 } 152 } 153 } 154 155 // Implementation of IRadioSim functions 156 @Override setResponseFunctions( IRadioSimResponse radioSimResponse, IRadioSimIndication radioSimIndication)157 public void setResponseFunctions( 158 IRadioSimResponse radioSimResponse, IRadioSimIndication radioSimIndication) { 159 Log.d(mTag, "setResponseFunctions"); 160 mRadioSimResponse = radioSimResponse; 161 mRadioSimIndication = radioSimIndication; 162 mService.countDownLatch(MockModemService.LATCH_RADIO_INTERFACES_READY); 163 } 164 165 @Override responseAcknowledgement()166 public void responseAcknowledgement() { 167 Log.d(mTag, "responseAcknowledgement"); 168 // TODO 169 // acknowledgeRequest(in int serial); 170 } 171 172 @Override areUiccApplicationsEnabled(int serial)173 public void areUiccApplicationsEnabled(int serial) { 174 Log.d(mTag, "areUiccApplicationsEnabled"); 175 176 boolean enabled = true; 177 178 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 179 try { 180 mRadioSimResponse.areUiccApplicationsEnabledResponse(rsp, enabled); 181 } catch (RemoteException ex) { 182 Log.e(mTag, "Failed to areUiccApplicationsEnabled from AIDL. Exception" + ex); 183 } 184 } 185 186 @Override changeIccPin2ForApp(int serial, String oldPin2, String newPin2, String aid)187 public void changeIccPin2ForApp(int serial, String oldPin2, String newPin2, String aid) { 188 Log.d(mTag, "changeIccPin2ForApp"); 189 // TODO: cache value 190 191 int remainingRetries = 3; 192 193 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 194 try { 195 mRadioSimResponse.changeIccPin2ForAppResponse(rsp, remainingRetries); 196 } catch (RemoteException ex) { 197 Log.e(mTag, "Failed to changeIccPin2ForApp from AIDL. Exception" + ex); 198 } 199 } 200 201 @Override changeIccPinForApp(int serial, String oldPin, String newPin, String aid)202 public void changeIccPinForApp(int serial, String oldPin, String newPin, String aid) { 203 Log.d(mTag, "changeIccPinForApp"); 204 // TODO: cache value 205 206 int remainingRetries = 3; 207 208 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 209 try { 210 mRadioSimResponse.changeIccPinForAppResponse(rsp, remainingRetries); 211 } catch (RemoteException ex) { 212 Log.e(mTag, "Failed to changeIccPinForApp from AIDL. Exception" + ex); 213 } 214 } 215 216 @Override enableUiccApplications(int serial, boolean enable)217 public void enableUiccApplications(int serial, boolean enable) { 218 Log.d(mTag, "enableUiccApplications"); 219 // TODO: cache value 220 221 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 222 try { 223 mRadioSimResponse.enableUiccApplicationsResponse(rsp); 224 } catch (RemoteException ex) { 225 Log.e(mTag, "Failed to enableUiccApplications from AIDL. Exception" + ex); 226 } 227 } 228 229 @Override getAllowedCarriers(int serial)230 public void getAllowedCarriers(int serial) { 231 Log.d(mTag, "getAllowedCarriers"); 232 233 android.hardware.radio.sim.CarrierRestrictions carriers = 234 new android.hardware.radio.sim.CarrierRestrictions(); 235 if (mCarrierList == null || mCarrierList.length < 1) { 236 carriers.allowedCarriers = new Carrier[0]; 237 } else { 238 carriers.allowedCarriers = mCarrierList; 239 } 240 carriers.excludedCarriers = new Carrier[0]; 241 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) { 242 carriers.status = mCarrierRestrictionStatus; 243 } 244 int multiSimPolicy = android.hardware.radio.sim.SimLockMultiSimPolicy.NO_MULTISIM_POLICY; 245 246 RadioResponseInfo rsp = mService.makeSolRsp(serial); 247 try { 248 mRadioSimResponse.getAllowedCarriersResponse(rsp, carriers, multiSimPolicy); 249 } catch (RemoteException ex) { 250 Log.e(mTag, "Failed to getAllowedCarriers from AIDL. Exception" + ex); 251 } 252 } 253 254 @Override getCdmaSubscription(int serial)255 public void getCdmaSubscription(int serial) { 256 Log.d(mTag, "getCdmaSubscription"); 257 258 String mdn = ""; 259 String hSid = ""; 260 String hNid = ""; 261 String min = ""; 262 String prl = ""; 263 264 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 265 try { 266 mRadioSimResponse.getCdmaSubscriptionResponse(rsp, mdn, hSid, hNid, min, prl); 267 } catch (RemoteException ex) { 268 Log.e(mTag, "Failed to getCdmaSubscription from AIDL. Exception" + ex); 269 } 270 } 271 272 @Override getCdmaSubscriptionSource(int serial)273 public void getCdmaSubscriptionSource(int serial) { 274 Log.d(mTag, "getCdmaSubscriptionSource"); 275 276 int source = 0; // CdmaSubscriptionSource.RUIM_SIM 277 278 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 279 try { 280 mRadioSimResponse.getCdmaSubscriptionSourceResponse(rsp, source); 281 } catch (RemoteException ex) { 282 Log.e(mTag, "Failed to getCdmaSubscriptionSource from AIDL. Exception" + ex); 283 } 284 } 285 286 @Override getFacilityLockForApp( int serial, String facility, String password, int serviceClass, String appId)287 public void getFacilityLockForApp( 288 int serial, String facility, String password, int serviceClass, String appId) { 289 Log.d(mTag, "getFacilityLockForApp"); 290 int numOfSimApp = mSimAppList.size(); 291 int responseError = RadioError.NONE; 292 int simAppIdx; 293 boolean isHandled = false; 294 boolean isFacilitySupport = true; 295 int responseData = -1; 296 297 synchronized (mCacheUpdateMutex) { 298 // TODO: check service class 299 for (simAppIdx = 0; 300 simAppIdx < numOfSimApp && isFacilitySupport && !isHandled; 301 simAppIdx++) { 302 switch (facility) { 303 case "FD": // FDN status query 304 if (appId.equals(mSimAppList.get(simAppIdx).getAid())) { 305 responseData = mSimAppList.get(simAppIdx).getFdnStatus(); 306 isHandled = true; 307 } 308 break; 309 case "SC": // PIN1 status query 310 if (appId.equals(mSimAppList.get(simAppIdx).getAid())) { 311 responseData = mSimAppList.get(simAppIdx).getPin1State(); 312 isHandled = true; 313 } 314 break; 315 default: 316 isFacilitySupport = false; 317 break; 318 } 319 } 320 } 321 322 if (!isHandled) { 323 Log.e(mTag, "Not support sim application aid = " + appId); 324 responseError = RadioError.NO_SUCH_ELEMENT; 325 } else if (!isFacilitySupport) { 326 Log.e(mTag, "Not support facility = " + facility); 327 responseError = RadioError.REQUEST_NOT_SUPPORTED; 328 } else if (responseData == -1) { 329 responseError = RadioError.INTERNAL_ERR; 330 } 331 332 RadioResponseInfo rsp = mService.makeSolRsp(serial, responseError); 333 try { 334 mRadioSimResponse.getFacilityLockForAppResponse(rsp, responseData); 335 } catch (RemoteException ex) { 336 Log.e(mTag, "Failed to getFacilityLockForApp from AIDL. Exception" + ex); 337 } 338 } 339 340 @Override getIccCardStatus(int serial)341 public void getIccCardStatus(int serial) { 342 Log.d(mTag, "getIccCardStatus"); 343 CardStatus cardStatus; 344 345 synchronized (mCacheUpdateMutex) { 346 cardStatus = mCardStatus; 347 } 348 349 RadioResponseInfo rsp = mService.makeSolRsp(serial); 350 try { 351 mRadioSimResponse.getIccCardStatusResponse(rsp, cardStatus); 352 } catch (RemoteException ex) { 353 Log.e(mTag, "Failed to getIccCardStatus from AIDL. Exception" + ex); 354 } 355 } 356 357 @Override getImsiForApp(int serial, String aid)358 public void getImsiForApp(int serial, String aid) { 359 Log.d(mTag, "getImsiForApp"); 360 String imsi = ""; 361 int numOfSimApp = mSimAppList.size(); 362 int responseError = RadioError.NONE; 363 int simAppIdx; 364 boolean isHandled; 365 366 synchronized (mCacheUpdateMutex) { 367 for (simAppIdx = 0, isHandled = false; 368 simAppIdx < numOfSimApp && !isHandled; 369 simAppIdx++) { 370 if (aid.equals(mSimAppList.get(simAppIdx).getAid())) { 371 imsi = mSimAppList.get(simAppIdx).getImsi(); 372 isHandled = true; 373 } 374 } 375 } 376 377 if (!isHandled) { 378 Log.e(mTag, "Not support sim application aid = " + aid); 379 responseError = RadioError.NO_SUCH_ELEMENT; 380 } 381 382 RadioResponseInfo rsp = mService.makeSolRsp(serial, responseError); 383 try { 384 mRadioSimResponse.getImsiForAppResponse(rsp, imsi); 385 } catch (RemoteException ex) { 386 Log.e(mTag, "Failed to getImsiForApp from AIDL. Exception" + ex); 387 } 388 } 389 390 @Override getSimPhonebookCapacity(int serial)391 public void getSimPhonebookCapacity(int serial) { 392 Log.d(mTag, "getSimPhonebookCapacity"); 393 394 android.hardware.radio.sim.PhonebookCapacity capacity = 395 new android.hardware.radio.sim.PhonebookCapacity(); 396 397 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 398 try { 399 mRadioSimResponse.getSimPhonebookCapacityResponse(rsp, capacity); 400 } catch (RemoteException ex) { 401 Log.e(mTag, "Failed to getSimPhonebookCapacity from AIDL. Exception" + ex); 402 } 403 } 404 405 @Override getSimPhonebookRecords(int serial)406 public void getSimPhonebookRecords(int serial) { 407 Log.d(mTag, "getSimPhonebookRecords"); 408 409 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 410 try { 411 mRadioSimResponse.getSimPhonebookRecordsResponse(rsp); 412 } catch (RemoteException ex) { 413 Log.e(mTag, "Failed to getSimPhonebookRecords from AIDL. Exception" + ex); 414 } 415 } 416 417 @Override iccCloseLogicalChannel(int serial, int channelId)418 public void iccCloseLogicalChannel(int serial, int channelId) { 419 Log.d(mTag, "iccCloseLogicalChannel"); 420 // TODO: cache value 421 422 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 423 try { 424 mRadioSimResponse.iccCloseLogicalChannelResponse(rsp); 425 } catch (RemoteException ex) { 426 Log.e(mTag, "Failed to iccCloseLogicalChannel from AIDL. Exception" + ex); 427 } 428 } 429 430 @Override iccCloseLogicalChannelWithSessionInfo(int serial, android.hardware.radio.sim.SessionInfo sessionInfo)431 public void iccCloseLogicalChannelWithSessionInfo(int serial, 432 android.hardware.radio.sim.SessionInfo sessionInfo) { 433 Log.d(mTag, "iccCloseLogicalChannelWithSessionInfo"); 434 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 435 try { 436 mRadioSimResponse.iccCloseLogicalChannelWithSessionInfoResponse(rsp); 437 } catch (RemoteException ex) { 438 Log.e(mTag, 439 "Failed to iccCloseLogicalChannelWithSessionInfo from AIDL. Exception" + ex); 440 } 441 } 442 encodeBcdString(String str)443 private String encodeBcdString(String str) { 444 StringBuffer bcdString = new StringBuffer(); 445 446 if (str.length() % 2 != 0) { 447 Log.d(mTag, "Invalid string(" + str + ") for Bcd format"); 448 return ""; 449 } 450 451 for (int i = 0; i < str.length(); i += 2) { 452 bcdString.append(str.substring(i + 1, i + 2)); 453 bcdString.append(str.substring(i, i + 1)); 454 } 455 456 return bcdString.toString(); 457 } 458 getIccIoResult( android.hardware.radio.sim.IccIoResult iccIoResult, int command, int fileId, String path, int p1, int p2, int p3, String aid)459 private int getIccIoResult( 460 android.hardware.radio.sim.IccIoResult iccIoResult, 461 int command, 462 int fileId, 463 String path, 464 int p1, 465 int p2, 466 int p3, 467 String aid) { 468 int numOfSimApp = mSimAppList.size(); 469 int simAppIdx; 470 boolean foundAid; 471 int responseError = RadioError.GENERIC_FAILURE; 472 473 if (iccIoResult == null) { 474 return responseError; 475 } 476 477 synchronized (mCacheUpdateMutex) { 478 for (simAppIdx = 0, foundAid = false; simAppIdx < numOfSimApp; simAppIdx++) { 479 if (aid.equals(mSimAppList.get(simAppIdx).getAid())) { 480 foundAid = true; 481 break; 482 } 483 } 484 485 if (!foundAid) { 486 Log.e(mTag, "Not support sim application aid = " + aid); 487 iccIoResult.sw1 = 0x6A; 488 iccIoResult.sw2 = 0x82; 489 } else { 490 switch (fileId) { 491 case EF_ICCID: 492 if (command == COMMAND_READ_BINARY) { 493 String bcdIccid = 494 encodeBcdString(mSimAppList.get(simAppIdx).getIccid()); 495 iccIoResult.simResponse = bcdIccid; 496 Log.d(mTag, "Get IccIo result: ICCID = " + iccIoResult.simResponse); 497 iccIoResult.sw1 = 0x90; 498 responseError = RadioError.NONE; 499 } else if (command == COMMAND_GET_RESPONSE) { 500 iccIoResult.simResponse = mSimAppList.get(simAppIdx).getIccidInfo(); 501 Log.d(mTag, "Get IccIo result: ICCID = " + iccIoResult.simResponse); 502 iccIoResult.sw1 = 0x90; 503 responseError = RadioError.NONE; 504 } else { 505 Log.d( 506 mTag, 507 "Command(" 508 + command 509 + ") not support for file id = 0x" 510 + Integer.toHexString(fileId)); 511 iccIoResult.sw1 = 0x6A; 512 iccIoResult.sw2 = 0x82; 513 } 514 break; 515 default: 516 Log.d(mTag, "Not find EF file id = 0x" + Integer.toHexString(fileId)); 517 iccIoResult.sw1 = 0x6A; 518 iccIoResult.sw2 = 0x82; 519 break; 520 } 521 } 522 } 523 524 return responseError; 525 } 526 527 @Override iccIoForApp(int serial, android.hardware.radio.sim.IccIo iccIo)528 public void iccIoForApp(int serial, android.hardware.radio.sim.IccIo iccIo) { 529 Log.d(mTag, "iccIoForApp"); 530 int responseError = RadioError.NONE; 531 android.hardware.radio.sim.IccIoResult iccIoResult = 532 new android.hardware.radio.sim.IccIoResult(); 533 534 switch (iccIo.command) { 535 case COMMAND_READ_BINARY: 536 case COMMAND_GET_RESPONSE: 537 responseError = 538 getIccIoResult( 539 iccIoResult, 540 iccIo.command, 541 iccIo.fileId, 542 iccIo.path, 543 iccIo.p1, 544 iccIo.p2, 545 iccIo.p3, 546 iccIo.aid); 547 break; 548 default: 549 responseError = RadioError.REQUEST_NOT_SUPPORTED; 550 break; 551 } 552 553 RadioResponseInfo rsp = mService.makeSolRsp(serial, responseError); 554 try { 555 mRadioSimResponse.iccIoForAppResponse(rsp, iccIoResult); 556 } catch (RemoteException ex) { 557 Log.e(mTag, "Failed to iccIoForApp from AIDL. Exception" + ex); 558 } 559 } 560 561 @Override iccOpenLogicalChannel(int serial, String aid, int p2)562 public void iccOpenLogicalChannel(int serial, String aid, int p2) { 563 Log.d(mTag, "iccOpenLogicalChannel"); 564 // TODO: cache value 565 int channelId = 0; 566 byte[] selectResponse = new byte[0]; 567 568 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 569 try { 570 mRadioSimResponse.iccOpenLogicalChannelResponse(rsp, channelId, selectResponse); 571 } catch (RemoteException ex) { 572 Log.e(mTag, "Failed to iccOpenLogicalChannel from AIDL. Exception" + ex); 573 } 574 } 575 576 @Override iccTransmitApduBasicChannel( int serial, android.hardware.radio.sim.SimApdu message)577 public void iccTransmitApduBasicChannel( 578 int serial, android.hardware.radio.sim.SimApdu message) { 579 Log.d(mTag, "iccTransmitApduBasicChannel"); 580 // TODO: cache value 581 android.hardware.radio.sim.IccIoResult iccIoResult = 582 new android.hardware.radio.sim.IccIoResult(); 583 584 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 585 try { 586 mRadioSimResponse.iccTransmitApduBasicChannelResponse(rsp, iccIoResult); 587 } catch (RemoteException ex) { 588 Log.e(mTag, "Failed to iccTransmitApduBasicChannel from AIDL. Exception" + ex); 589 } 590 } 591 592 @Override iccTransmitApduLogicalChannel( int serial, android.hardware.radio.sim.SimApdu message)593 public void iccTransmitApduLogicalChannel( 594 int serial, android.hardware.radio.sim.SimApdu message) { 595 Log.d(mTag, "iccTransmitApduLogicalChannel"); 596 // TODO: cache value 597 android.hardware.radio.sim.IccIoResult iccIoResult = 598 new android.hardware.radio.sim.IccIoResult(); 599 600 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 601 try { 602 mRadioSimResponse.iccTransmitApduBasicChannelResponse(rsp, iccIoResult); 603 } catch (RemoteException ex) { 604 Log.e(mTag, "Failed to iccTransmitApduLogicalChannel from AIDL. Exception" + ex); 605 } 606 } 607 608 @Override reportStkServiceIsRunning(int serial)609 public void reportStkServiceIsRunning(int serial) { 610 Log.d(mTag, "reportStkServiceIsRunning"); 611 612 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 613 try { 614 mRadioSimResponse.reportStkServiceIsRunningResponse(rsp); 615 } catch (RemoteException ex) { 616 Log.e(mTag, "Failed to reportStkServiceIsRunning from AIDL. Exception" + ex); 617 } 618 } 619 620 @Override requestIccSimAuthentication( int serial, int authContext, String authData, String aid)621 public void requestIccSimAuthentication( 622 int serial, int authContext, String authData, String aid) { 623 Log.d(mTag, "requestIccSimAuthentication"); 624 // TODO: cache value 625 android.hardware.radio.sim.IccIoResult iccIoResult = 626 new android.hardware.radio.sim.IccIoResult(); 627 628 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 629 try { 630 mRadioSimResponse.requestIccSimAuthenticationResponse(rsp, iccIoResult); 631 } catch (RemoteException ex) { 632 Log.e(mTag, "Failed to requestIccSimAuthentication from AIDL. Exception" + ex); 633 } 634 } 635 636 @Override sendEnvelope(int serial, String contents)637 public void sendEnvelope(int serial, String contents) { 638 Log.d(mTag, "sendEnvelope"); 639 // TODO: cache value 640 String commandResponse = ""; 641 642 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 643 try { 644 mRadioSimResponse.sendEnvelopeResponse(rsp, commandResponse); 645 } catch (RemoteException ex) { 646 Log.e(mTag, "Failed to sendEnvelope from AIDL. Exception" + ex); 647 } 648 } 649 650 @Override sendEnvelopeWithStatus(int serial, String contents)651 public void sendEnvelopeWithStatus(int serial, String contents) { 652 Log.d(mTag, "sendEnvelopeWithStatus"); 653 // TODO: cache value 654 android.hardware.radio.sim.IccIoResult iccIoResult = 655 new android.hardware.radio.sim.IccIoResult(); 656 657 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 658 try { 659 mRadioSimResponse.sendEnvelopeWithStatusResponse(rsp, iccIoResult); 660 } catch (RemoteException ex) { 661 Log.e(mTag, "Failed to sendEnvelopeWithStatus from AIDL. Exception" + ex); 662 } 663 } 664 665 @Override sendTerminalResponseToSim(int serial, String contents)666 public void sendTerminalResponseToSim(int serial, String contents) { 667 Log.d(mTag, "sendTerminalResponseToSim"); 668 // TODO: cache value 669 670 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 671 try { 672 mRadioSimResponse.sendTerminalResponseToSimResponse(rsp); 673 } catch (RemoteException ex) { 674 Log.e(mTag, "Failed to sendTerminalResponseToSim from AIDL. Exception" + ex); 675 } 676 } 677 678 @Override setAllowedCarriers( int serial, android.hardware.radio.sim.CarrierRestrictions carriers, int multiSimPolicy)679 public void setAllowedCarriers( 680 int serial, 681 android.hardware.radio.sim.CarrierRestrictions carriers, 682 int multiSimPolicy) { 683 Log.d(mTag, "sendTerminalResponseToSim"); 684 // TODO: cache value 685 686 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 687 try { 688 mRadioSimResponse.setAllowedCarriersResponse(rsp); 689 } catch (RemoteException ex) { 690 Log.e(mTag, "Failed to setAllowedCarriers from AIDL. Exception" + ex); 691 } 692 } 693 694 @Override setCarrierInfoForImsiEncryption( int serial, android.hardware.radio.sim.ImsiEncryptionInfo imsiEncryptionInfo)695 public void setCarrierInfoForImsiEncryption( 696 int serial, android.hardware.radio.sim.ImsiEncryptionInfo imsiEncryptionInfo) { 697 Log.d(mTag, "setCarrierInfoForImsiEncryption"); 698 // TODO: cache value 699 700 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 701 try { 702 mRadioSimResponse.setCarrierInfoForImsiEncryptionResponse(rsp); 703 } catch (RemoteException ex) { 704 Log.e(mTag, "Failed to setCarrierInfoForImsiEncryption from AIDL. Exception" + ex); 705 } 706 } 707 708 @Override setCdmaSubscriptionSource(int serial, int cdmaSub)709 public void setCdmaSubscriptionSource(int serial, int cdmaSub) { 710 Log.d(mTag, "setCdmaSubscriptionSource"); 711 // TODO: cache value 712 713 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 714 try { 715 mRadioSimResponse.setCdmaSubscriptionSourceResponse(rsp); 716 } catch (RemoteException ex) { 717 Log.e(mTag, "Failed to setCdmaSubscriptionSource from AIDL. Exception" + ex); 718 } 719 } 720 721 @Override setFacilityLockForApp( int serial, String facility, boolean lockState, String password, int serviceClass, String appId)722 public void setFacilityLockForApp( 723 int serial, 724 String facility, 725 boolean lockState, 726 String password, 727 int serviceClass, 728 String appId) { 729 Log.d(mTag, "setFacilityLockForApp"); 730 // TODO: cache value 731 int retry = 10; 732 733 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 734 try { 735 mRadioSimResponse.setFacilityLockForAppResponse(rsp, retry); 736 } catch (RemoteException ex) { 737 Log.e(mTag, "Failed to setFacilityLockForApp from AIDL. Exception" + ex); 738 } 739 } 740 741 @Override setSimCardPower(int serial, int powerUp)742 public void setSimCardPower(int serial, int powerUp) { 743 Log.d(mTag, "setSimCardPower"); 744 // TODO: cache value 745 746 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 747 try { 748 mRadioSimResponse.setSimCardPowerResponse(rsp); 749 } catch (RemoteException ex) { 750 Log.e(mTag, "Failed to setSimCardPower from AIDL. Exception" + ex); 751 } 752 } 753 754 @Override setUiccSubscription(int serial, android.hardware.radio.sim.SelectUiccSub uiccSub)755 public void setUiccSubscription(int serial, android.hardware.radio.sim.SelectUiccSub uiccSub) { 756 Log.d(mTag, "setUiccSubscription"); 757 // TODO: cache value 758 759 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 760 try { 761 mRadioSimResponse.setUiccSubscriptionResponse(rsp); 762 } catch (RemoteException ex) { 763 Log.e(mTag, "Failed to setUiccSubscription from AIDL. Exception" + ex); 764 } 765 } 766 767 @Override supplyIccPin2ForApp(int serial, String pin2, String aid)768 public void supplyIccPin2ForApp(int serial, String pin2, String aid) { 769 Log.d(mTag, "supplyIccPin2ForApp"); 770 // TODO: cache value 771 int setFacilityLockForApp = 10; 772 773 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 774 try { 775 mRadioSimResponse.supplyIccPin2ForAppResponse(rsp, setFacilityLockForApp); 776 } catch (RemoteException ex) { 777 Log.e(mTag, "Failed to supplyIccPin2ForApp from AIDL. Exception" + ex); 778 } 779 } 780 781 @Override supplyIccPinForApp(int serial, String pin, String aid)782 public void supplyIccPinForApp(int serial, String pin, String aid) { 783 Log.d(mTag, "supplyIccPinForApp"); 784 // TODO: cache value 785 int setFacilityLockForApp = 10; 786 787 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 788 try { 789 mRadioSimResponse.supplyIccPinForAppResponse(rsp, setFacilityLockForApp); 790 } catch (RemoteException ex) { 791 Log.e(mTag, "Failed to supplyIccPinForApp from AIDL. Exception" + ex); 792 } 793 } 794 795 @Override supplyIccPuk2ForApp(int serial, String puk2, String pin2, String aid)796 public void supplyIccPuk2ForApp(int serial, String puk2, String pin2, String aid) { 797 Log.d(mTag, "supplyIccPuk2ForApp"); 798 // TODO: cache value 799 int setFacilityLockForApp = 10; 800 801 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 802 try { 803 mRadioSimResponse.supplyIccPuk2ForAppResponse(rsp, setFacilityLockForApp); 804 } catch (RemoteException ex) { 805 Log.e(mTag, "Failed to supplyIccPuk2ForApp from AIDL. Exception" + ex); 806 } 807 } 808 809 @Override supplyIccPukForApp(int serial, String puk, String pin, String aid)810 public void supplyIccPukForApp(int serial, String puk, String pin, String aid) { 811 Log.d(mTag, "supplyIccPukForApp"); 812 // TODO: cache value 813 int setFacilityLockForApp = 10; 814 815 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 816 try { 817 mRadioSimResponse.supplyIccPukForAppResponse(rsp, setFacilityLockForApp); 818 } catch (RemoteException ex) { 819 Log.e(mTag, "Failed to supplyIccPukForApp from AIDL. Exception" + ex); 820 } 821 } 822 823 @Override supplySimDepersonalization(int serial, int persoType, String controlKey)824 public void supplySimDepersonalization(int serial, int persoType, String controlKey) { 825 Log.d(mTag, "supplySimDepersonalization"); 826 // TODO: cache value 827 int retPersoType = persoType; 828 int setFacilityLockForApp = 10; 829 830 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 831 try { 832 mRadioSimResponse.supplySimDepersonalizationResponse( 833 rsp, retPersoType, setFacilityLockForApp); 834 } catch (RemoteException ex) { 835 Log.e(mTag, "Failed to supplySimDepersonalization from AIDL. Exception" + ex); 836 } 837 } 838 839 @Override updateSimPhonebookRecords( int serial, android.hardware.radio.sim.PhonebookRecordInfo recordInfo)840 public void updateSimPhonebookRecords( 841 int serial, android.hardware.radio.sim.PhonebookRecordInfo recordInfo) { 842 Log.d(mTag, "updateSimPhonebookRecords"); 843 // TODO: cache value 844 int updatedRecordIndex = 0; 845 846 RadioResponseInfo rsp = mService.makeSolRsp(serial, RadioError.REQUEST_NOT_SUPPORTED); 847 try { 848 mRadioSimResponse.updateSimPhonebookRecordsResponse(rsp, updatedRecordIndex); 849 } catch (RemoteException ex) { 850 Log.e(mTag, "Failed to updateSimPhonebookRecords from AIDL. Exception" + ex); 851 } 852 } 853 carrierInfoForImsiEncryption()854 public void carrierInfoForImsiEncryption() { 855 Log.d(mTag, "carrierInfoForImsiEncryption"); 856 857 if (mRadioSimIndication != null) { 858 try { 859 mRadioSimIndication.carrierInfoForImsiEncryption(RadioIndicationType.UNSOLICITED); 860 } catch (RemoteException ex) { 861 Log.e(mTag, "Failed to carrierInfoForImsiEncryption from AIDL. Exception" + ex); 862 } 863 } else { 864 Log.e(mTag, "null mRadioSimIndication"); 865 } 866 } 867 cdmaSubscriptionSourceChanged(int cdmaSource)868 public void cdmaSubscriptionSourceChanged(int cdmaSource) { 869 Log.d(mTag, "carrierInfoForImsiEncryption"); 870 871 if (mRadioSimIndication != null) { 872 try { 873 mRadioSimIndication.cdmaSubscriptionSourceChanged( 874 RadioIndicationType.UNSOLICITED, cdmaSource); 875 } catch (RemoteException ex) { 876 Log.e(mTag, "Failed to cdmaSubscriptionSourceChanged from AIDL. Exception" + ex); 877 } 878 } else { 879 Log.e(mTag, "null mRadioSimIndication"); 880 } 881 } 882 simPhonebookChanged()883 public void simPhonebookChanged() { 884 Log.d(mTag, "simPhonebookChanged"); 885 886 if (mRadioSimIndication != null) { 887 try { 888 mRadioSimIndication.simPhonebookChanged(RadioIndicationType.UNSOLICITED); 889 } catch (RemoteException ex) { 890 Log.e(mTag, "Failed to simPhonebookChanged from AIDL. Exception" + ex); 891 } 892 } else { 893 Log.e(mTag, "null mRadioSimIndication"); 894 } 895 } 896 simPhonebookRecordsReceived( byte status, android.hardware.radio.sim.PhonebookRecordInfo[] records)897 public void simPhonebookRecordsReceived( 898 byte status, android.hardware.radio.sim.PhonebookRecordInfo[] records) { 899 Log.d(mTag, "simPhonebookRecordsReceived"); 900 901 if (mRadioSimIndication != null) { 902 try { 903 mRadioSimIndication.simPhonebookRecordsReceived( 904 RadioIndicationType.UNSOLICITED, status, records); 905 } catch (RemoteException ex) { 906 Log.e(mTag, "Failed to simPhonebookRecordsReceived from AIDL. Exception" + ex); 907 } 908 } else { 909 Log.e(mTag, "null mRadioSimIndication"); 910 } 911 } 912 simRefresh(SimRefreshResult refreshResult)913 public void simRefresh(SimRefreshResult refreshResult) { 914 Log.d(mTag, "simRefresh"); 915 916 if (mRadioSimIndication != null) { 917 try { 918 mRadioSimIndication.simRefresh(RadioIndicationType.UNSOLICITED, refreshResult); 919 } catch (RemoteException ex) { 920 Log.e(mTag, "Failed to simRefresh from AIDL. Exception" + ex); 921 } 922 } else { 923 Log.e(mTag, "null mRadioSimIndication"); 924 } 925 } 926 simStatusChanged()927 public void simStatusChanged() { 928 Log.d(mTag, "simStatusChanged"); 929 930 if (mRadioSimIndication != null) { 931 try { 932 mRadioSimIndication.simStatusChanged(RadioIndicationType.UNSOLICITED); 933 } catch (RemoteException ex) { 934 Log.e(mTag, "Failed to simStatusChanged from AIDL. Exception" + ex); 935 } 936 } else { 937 Log.e(mTag, "null mRadioSimIndication"); 938 } 939 } 940 stkEventNotify(String cmd)941 public void stkEventNotify(String cmd) { 942 Log.d(mTag, "stkEventNotify"); 943 944 if (mRadioSimIndication != null) { 945 try { 946 mRadioSimIndication.stkEventNotify(RadioIndicationType.UNSOLICITED, cmd); 947 } catch (RemoteException ex) { 948 Log.e(mTag, "Failed to stkEventNotify from AIDL. Exception" + ex); 949 } 950 } else { 951 Log.e(mTag, "null mRadioSimIndication"); 952 } 953 } 954 stkProactiveCommand(String cmd)955 public void stkProactiveCommand(String cmd) { 956 Log.d(mTag, "stkProactiveCommand"); 957 958 if (mRadioSimIndication != null) { 959 try { 960 mRadioSimIndication.stkProactiveCommand(RadioIndicationType.UNSOLICITED, cmd); 961 } catch (RemoteException ex) { 962 Log.e(mTag, "Failed to stkProactiveCommand from AIDL. Exception" + ex); 963 } 964 } else { 965 Log.e(mTag, "null mRadioSimIndication"); 966 } 967 } 968 stkSessionEnd()969 public void stkSessionEnd() { 970 Log.d(mTag, "stkSessionEnd"); 971 972 if (mRadioSimIndication != null) { 973 try { 974 mRadioSimIndication.stkSessionEnd(RadioIndicationType.UNSOLICITED); 975 } catch (RemoteException ex) { 976 Log.e(mTag, "Failed to stkSessionEnd from AIDL. Exception" + ex); 977 } 978 } else { 979 Log.e(mTag, "null mRadioSimIndication"); 980 } 981 } 982 subscriptionStatusChanged(boolean activate)983 public void subscriptionStatusChanged(boolean activate) { 984 Log.d(mTag, "subscriptionStatusChanged"); 985 986 if (mRadioSimIndication != null) { 987 try { 988 mRadioSimIndication.subscriptionStatusChanged( 989 RadioIndicationType.UNSOLICITED, activate); 990 } catch (RemoteException ex) { 991 Log.e(mTag, "Failed to subscriptionStatusChanged from AIDL. Exception" + ex); 992 } 993 } else { 994 Log.e(mTag, "null mRadioSimIndication"); 995 } 996 } 997 uiccApplicationsEnablementChanged(boolean enabled)998 public void uiccApplicationsEnablementChanged(boolean enabled) { 999 Log.d(mTag, "uiccApplicationsEnablementChanged"); 1000 1001 if (mRadioSimIndication != null) { 1002 try { 1003 mRadioSimIndication.uiccApplicationsEnablementChanged( 1004 RadioIndicationType.UNSOLICITED, enabled); 1005 } catch (RemoteException ex) { 1006 Log.e( 1007 mTag, 1008 "Failed to uiccApplicationsEnablementChanged from AIDL. Exception" + ex); 1009 } 1010 } else { 1011 Log.e(mTag, "null mRadioSimIndication"); 1012 } 1013 } 1014 1015 @Override getInterfaceHash()1016 public String getInterfaceHash() { 1017 return IRadioSim.HASH; 1018 } 1019 1020 @Override getInterfaceVersion()1021 public int getInterfaceVersion() { 1022 return IRadioSim.VERSION; 1023 } 1024 updateCarrierRestrictionStatusInfo(Carrier[] carrierList, int carrierRestrictionStatus)1025 public void updateCarrierRestrictionStatusInfo(Carrier[] carrierList, int carrierRestrictionStatus) { 1026 mCarrierList = carrierList; 1027 mCarrierRestrictionStatus = carrierRestrictionStatus; 1028 } 1029 } 1030