1 /* 2 * Copyright (C) 2016 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.RIL_UNSOL_CALL_RING; 20 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION; 21 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_CALL_WAITING; 22 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_INFO_REC; 23 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_OTA_PROVISION_STATUS; 24 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL; 25 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED; 26 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CELL_INFO_LIST; 27 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_DATA_CALL_LIST_CHANGED; 28 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE; 29 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE; 30 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_HARDWARE_CONFIG_CHANGED; 31 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_KEEPALIVE_STATUS; 32 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_LCEDATA_RECV; 33 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_MODEM_RESTART; 34 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NETWORK_SCAN_RESULT; 35 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NITZ_TIME_RECEIVED; 36 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_SS; 37 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_USSD; 38 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PCO_DATA; 39 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG; 40 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RADIO_CAPABILITY; 41 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESEND_INCALL_MUTE; 42 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED; 43 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_CDMA_NEW_SMS; 44 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED; 45 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED; 46 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS; 47 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS; 48 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM; 49 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT; 50 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED; 51 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED; 52 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESTRICTED_STATE_CHANGED; 53 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RIL_CONNECTED; 54 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RINGBACK_TONE; 55 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIGNAL_STRENGTH; 56 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIM_REFRESH; 57 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIM_SMS_STORAGE_FULL; 58 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SRVCC_STATE_NOTIFY; 59 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_STK_CALL_SETUP; 60 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_STK_CC_ALPHA_NOTIFY; 61 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_STK_EVENT_NOTIFY; 62 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_STK_PROACTIVE_COMMAND; 63 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_STK_SESSION_END; 64 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SUPP_SVC_NOTIFICATION; 65 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED; 66 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_VOICE_RADIO_TECH_CHANGED; 67 import static com.android.internal.telephony.RILConstants.RIL_UNSOl_CDMA_PRL_CHANGED; 68 69 import android.hardware.radio.V1_0.CdmaCallWaiting; 70 import android.hardware.radio.V1_0.CdmaInformationRecord; 71 import android.hardware.radio.V1_0.CdmaLineControlInfoRecord; 72 import android.hardware.radio.V1_0.CdmaNumberInfoRecord; 73 import android.hardware.radio.V1_0.CdmaRedirectingNumberInfoRecord; 74 import android.hardware.radio.V1_0.CdmaSignalInfoRecord; 75 import android.hardware.radio.V1_0.CdmaSmsMessage; 76 import android.hardware.radio.V1_0.CdmaT53AudioControlInfoRecord; 77 import android.hardware.radio.V1_0.CfData; 78 import android.hardware.radio.V1_0.LceDataInfo; 79 import android.hardware.radio.V1_0.PcoDataInfo; 80 import android.hardware.radio.V1_0.SetupDataCallResult; 81 import android.hardware.radio.V1_0.SimRefreshResult; 82 import android.hardware.radio.V1_0.SsInfoData; 83 import android.hardware.radio.V1_0.StkCcUnsolSsResult; 84 import android.hardware.radio.V1_0.SuppSvcNotification; 85 import android.hardware.radio.V1_2.CellConnectionStatus; 86 import android.hardware.radio.V1_2.IRadioIndication; 87 import android.os.AsyncResult; 88 import android.os.SystemProperties; 89 import android.telephony.CellInfo; 90 import android.telephony.PcoData; 91 import android.telephony.PhysicalChannelConfig; 92 import android.telephony.SignalStrength; 93 import android.telephony.SmsMessage; 94 95 import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; 96 import com.android.internal.telephony.cdma.CdmaInformationRecords; 97 import com.android.internal.telephony.cdma.SmsMessageConverter; 98 import com.android.internal.telephony.dataconnection.KeepaliveStatus; 99 import com.android.internal.telephony.gsm.SsData; 100 import com.android.internal.telephony.gsm.SuppServiceNotification; 101 import com.android.internal.telephony.nano.TelephonyProto.SmsSession; 102 import com.android.internal.telephony.uicc.IccRefreshResponse; 103 import com.android.internal.telephony.uicc.IccUtils; 104 105 import java.util.ArrayList; 106 import java.util.List; 107 108 public class RadioIndication extends IRadioIndication.Stub { 109 RIL mRil; 110 111 RadioIndication(RIL ril) { 112 mRil = ril; 113 } 114 115 /** 116 * Indicates when radio state changes. 117 * @param indicationType RadioIndicationType 118 * @param radioState android.hardware.radio.V1_0.RadioState 119 */ 120 public void radioStateChanged(int indicationType, int radioState) { 121 mRil.processIndication(indicationType); 122 123 CommandsInterface.RadioState newState = getRadioStateFromInt(radioState); 124 if (RIL.RILJ_LOGD) { 125 mRil.unsljLogMore(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, "radioStateChanged: " + 126 newState); 127 } 128 129 mRil.setRadioState(newState); 130 } 131 132 public void callStateChanged(int indicationType) { 133 mRil.processIndication(indicationType); 134 135 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED); 136 137 mRil.mCallStateRegistrants.notifyRegistrants(); 138 } 139 140 /** 141 * Indicates when either voice or data network state changed 142 * @param indicationType RadioIndicationType 143 */ 144 public void networkStateChanged(int indicationType) { 145 mRil.processIndication(indicationType); 146 147 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED); 148 149 mRil.mNetworkStateRegistrants.notifyRegistrants(); 150 } 151 152 public void newSms(int indicationType, ArrayList<Byte> pdu) { 153 mRil.processIndication(indicationType); 154 155 byte[] pduArray = RIL.arrayListToPrimitiveArray(pdu); 156 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS); 157 158 mRil.writeMetricsNewSms(SmsSession.Event.Tech.SMS_GSM, 159 SmsSession.Event.Format.SMS_FORMAT_3GPP); 160 161 SmsMessage sms = SmsMessage.newFromCMT(pduArray); 162 if (mRil.mGsmSmsRegistrant != null) { 163 mRil.mGsmSmsRegistrant.notifyRegistrant(new AsyncResult(null, sms, null)); 164 } 165 } 166 167 public void newSmsStatusReport(int indicationType, ArrayList<Byte> pdu) { 168 mRil.processIndication(indicationType); 169 170 byte[] pduArray = RIL.arrayListToPrimitiveArray(pdu); 171 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT); 172 173 if (mRil.mSmsStatusRegistrant != null) { 174 mRil.mSmsStatusRegistrant.notifyRegistrant(new AsyncResult(null, pduArray, null)); 175 } 176 } 177 178 public void newSmsOnSim(int indicationType, int recordNumber) { 179 mRil.processIndication(indicationType); 180 181 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM); 182 183 if (mRil.mSmsOnSimRegistrant != null) { 184 mRil.mSmsOnSimRegistrant.notifyRegistrant(new AsyncResult(null, recordNumber, null)); 185 } 186 } 187 188 public void onUssd(int indicationType, int ussdModeType, String msg) { 189 mRil.processIndication(indicationType); 190 191 if (RIL.RILJ_LOGD) mRil.unsljLogMore(RIL_UNSOL_ON_USSD, "" + ussdModeType); 192 193 // todo: Clean this up with a parcelable class for better self-documentation 194 String[] resp = new String[2]; 195 resp[0] = "" + ussdModeType; 196 resp[1] = msg; 197 if (mRil.mUSSDRegistrant != null) { 198 mRil.mUSSDRegistrant.notifyRegistrant(new AsyncResult (null, resp, null)); 199 } 200 } 201 202 public void nitzTimeReceived(int indicationType, String nitzTime, long receivedTime) { 203 mRil.processIndication(indicationType); 204 205 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NITZ_TIME_RECEIVED, nitzTime); 206 207 // todo: Clean this up with a parcelable class for better self-documentation 208 Object[] result = new Object[2]; 209 result[0] = nitzTime; 210 result[1] = receivedTime; 211 212 boolean ignoreNitz = SystemProperties.getBoolean( 213 TelephonyProperties.PROPERTY_IGNORE_NITZ, false); 214 215 if (ignoreNitz) { 216 if (RIL.RILJ_LOGD) mRil.riljLog("ignoring UNSOL_NITZ_TIME_RECEIVED"); 217 } else { 218 if (mRil.mNITZTimeRegistrant != null) { 219 mRil.mNITZTimeRegistrant.notifyRegistrant(new AsyncResult (null, result, null)); 220 } 221 // in case NITZ time registrant isn't registered yet, or a new registrant 222 // registers later 223 mRil.mLastNITZTimeInfo = result; 224 } 225 } 226 227 public void currentSignalStrength(int indicationType, 228 android.hardware.radio.V1_0.SignalStrength signalStrength) { 229 mRil.processIndication(indicationType); 230 231 SignalStrength ss = RIL.convertHalSignalStrength(signalStrength); 232 // Note this is set to "verbose" because it happens frequently 233 if (RIL.RILJ_LOGV) mRil.unsljLogvRet(RIL_UNSOL_SIGNAL_STRENGTH, ss); 234 235 if (mRil.mSignalStrengthRegistrant != null) { 236 mRil.mSignalStrengthRegistrant.notifyRegistrant(new AsyncResult (null, ss, null)); 237 } 238 } 239 240 /** 241 * Indicates current link capacity estimate. 242 */ 243 public void currentLinkCapacityEstimate(int indicationType, 244 android.hardware.radio.V1_2.LinkCapacityEstimate lce) { 245 mRil.processIndication(indicationType); 246 247 LinkCapacityEstimate response = RIL.convertHalLceData(lce, mRil); 248 249 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_LCEDATA_RECV, response); 250 251 if (mRil.mLceInfoRegistrants != null) { 252 mRil.mLceInfoRegistrants.notifyRegistrants(new AsyncResult(null, response, null)); 253 } 254 } 255 256 /** 257 * Indicates the current signal strength of the camped or primary serving cell. 258 */ 259 public void currentSignalStrength_1_2(int indicationType, 260 android.hardware.radio.V1_2.SignalStrength signalStrength) { 261 mRil.processIndication(indicationType); 262 263 SignalStrength ss = RIL.convertHalSignalStrength_1_2(signalStrength); 264 // Note this is set to "verbose" because it happens frequently 265 if (RIL.RILJ_LOGV) mRil.unsljLogvRet(RIL_UNSOL_SIGNAL_STRENGTH, ss); 266 267 if (mRil.mSignalStrengthRegistrant != null) { 268 mRil.mSignalStrengthRegistrant.notifyRegistrant(new AsyncResult(null, ss, null)); 269 } 270 } 271 272 /** 273 * Indicates current physical channel configuration. 274 */ 275 public void currentPhysicalChannelConfigs(int indicationType, 276 ArrayList<android.hardware.radio.V1_2.PhysicalChannelConfig> configs) { 277 List<PhysicalChannelConfig> response = new ArrayList<>(configs.size()); 278 279 for (android.hardware.radio.V1_2.PhysicalChannelConfig config : configs) { 280 int status; 281 switch (config.status) { 282 case CellConnectionStatus.PRIMARY_SERVING: 283 status = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING; 284 break; 285 case CellConnectionStatus.SECONDARY_SERVING: 286 status = PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING; 287 break; 288 default: 289 // only PRIMARY_SERVING and SECONDARY_SERVING are supported. 290 mRil.riljLoge("Unsupported CellConnectionStatus in PhysicalChannelConfig: " 291 + config.status); 292 status = PhysicalChannelConfig.CONNECTION_UNKNOWN; 293 break; 294 } 295 296 response.add(new PhysicalChannelConfig(status, config.cellBandwidthDownlink)); 297 } 298 299 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG, response); 300 301 mRil.mPhysicalChannelConfigurationRegistrants.notifyRegistrants( 302 new AsyncResult(null, response, null)); 303 } 304 305 public void dataCallListChanged(int indicationType, ArrayList<SetupDataCallResult> dcList) { 306 mRil.processIndication(indicationType); 307 308 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, dcList); 309 310 mRil.mDataCallListChangedRegistrants.notifyRegistrants( 311 new AsyncResult(null, dcList, null)); 312 } 313 314 public void suppSvcNotify(int indicationType, SuppSvcNotification suppSvcNotification) { 315 mRil.processIndication(indicationType); 316 317 SuppServiceNotification notification = new SuppServiceNotification(); 318 notification.notificationType = suppSvcNotification.isMT ? 1 : 0; 319 notification.code = suppSvcNotification.code; 320 notification.index = suppSvcNotification.index; 321 notification.type = suppSvcNotification.type; 322 notification.number = suppSvcNotification.number; 323 324 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SUPP_SVC_NOTIFICATION, notification); 325 326 if (mRil.mSsnRegistrant != null) { 327 mRil.mSsnRegistrant.notifyRegistrant(new AsyncResult (null, notification, null)); 328 } 329 } 330 331 public void stkSessionEnd(int indicationType) { 332 mRil.processIndication(indicationType); 333 334 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_SESSION_END); 335 336 if (mRil.mCatSessionEndRegistrant != null) { 337 mRil.mCatSessionEndRegistrant.notifyRegistrant(new AsyncResult (null, null, null)); 338 } 339 } 340 341 public void stkProactiveCommand(int indicationType, String cmd) { 342 mRil.processIndication(indicationType); 343 344 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_PROACTIVE_COMMAND); 345 346 if (mRil.mCatProCmdRegistrant != null) { 347 mRil.mCatProCmdRegistrant.notifyRegistrant(new AsyncResult (null, cmd, null)); 348 } 349 } 350 351 public void stkEventNotify(int indicationType, String cmd) { 352 mRil.processIndication(indicationType); 353 354 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_EVENT_NOTIFY); 355 356 if (mRil.mCatEventRegistrant != null) { 357 mRil.mCatEventRegistrant.notifyRegistrant(new AsyncResult (null, cmd, null)); 358 } 359 } 360 361 public void stkCallSetup(int indicationType, long timeout) { 362 mRil.processIndication(indicationType); 363 364 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_STK_CALL_SETUP, timeout); 365 366 if (mRil.mCatCallSetUpRegistrant != null) { 367 mRil.mCatCallSetUpRegistrant.notifyRegistrant(new AsyncResult (null, timeout, null)); 368 } 369 } 370 371 public void simSmsStorageFull(int indicationType) { 372 mRil.processIndication(indicationType); 373 374 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_SIM_SMS_STORAGE_FULL); 375 376 if (mRil.mIccSmsFullRegistrant != null) { 377 mRil.mIccSmsFullRegistrant.notifyRegistrant(); 378 } 379 } 380 381 public void simRefresh(int indicationType, SimRefreshResult refreshResult) { 382 mRil.processIndication(indicationType); 383 384 IccRefreshResponse response = new IccRefreshResponse(); 385 response.refreshResult = refreshResult.type; 386 response.efId = refreshResult.efId; 387 response.aid = refreshResult.aid; 388 389 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SIM_REFRESH, response); 390 391 mRil.mIccRefreshRegistrants.notifyRegistrants(new AsyncResult (null, response, null)); 392 } 393 394 public void callRing(int indicationType, boolean isGsm, CdmaSignalInfoRecord record) { 395 mRil.processIndication(indicationType); 396 397 char response[] = null; 398 399 // Ignore record for gsm 400 if (!isGsm) { 401 // todo: Clean this up with a parcelable class for better self-documentation 402 response = new char[4]; 403 response[0] = (char) (record.isPresent ? 1 : 0); 404 response[1] = (char) record.signalType; 405 response[2] = (char) record.alertPitch; 406 response[3] = (char) record.signal; 407 mRil.writeMetricsCallRing(response); 408 } 409 410 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CALL_RING, response); 411 412 if (mRil.mRingRegistrant != null) { 413 mRil.mRingRegistrant.notifyRegistrant(new AsyncResult (null, response, null)); 414 } 415 } 416 417 public void simStatusChanged(int indicationType) { 418 mRil.processIndication(indicationType); 419 420 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED); 421 422 mRil.mIccStatusChangedRegistrants.notifyRegistrants(); 423 } 424 425 public void cdmaNewSms(int indicationType, CdmaSmsMessage msg) { 426 mRil.processIndication(indicationType); 427 428 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_CDMA_NEW_SMS); 429 430 mRil.writeMetricsNewSms(SmsSession.Event.Tech.SMS_CDMA, 431 SmsSession.Event.Format.SMS_FORMAT_3GPP2); 432 433 // todo: conversion from CdmaSmsMessage to SmsMessage should be contained in this class so 434 // that usage of auto-generated HAL classes is limited to this file 435 SmsMessage sms = SmsMessageConverter.newSmsMessageFromCdmaSmsMessage(msg); 436 if (mRil.mCdmaSmsRegistrant != null) { 437 mRil.mCdmaSmsRegistrant.notifyRegistrant(new AsyncResult(null, sms, null)); 438 } 439 } 440 441 public void newBroadcastSms(int indicationType, ArrayList<Byte> data) { 442 mRil.processIndication(indicationType); 443 444 byte response[] = RIL.arrayListToPrimitiveArray(data); 445 if (RIL.RILJ_LOGD) { 446 mRil.unsljLogvRet(RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, 447 IccUtils.bytesToHexString(response)); 448 } 449 450 if (mRil.mGsmBroadcastSmsRegistrant != null) { 451 mRil.mGsmBroadcastSmsRegistrant.notifyRegistrant(new AsyncResult(null, response, null)); 452 } 453 } 454 455 public void cdmaRuimSmsStorageFull(int indicationType) { 456 mRil.processIndication(indicationType); 457 458 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL); 459 460 if (mRil.mIccSmsFullRegistrant != null) { 461 mRil.mIccSmsFullRegistrant.notifyRegistrant(); 462 } 463 } 464 465 public void restrictedStateChanged(int indicationType, int state) { 466 mRil.processIndication(indicationType); 467 468 if (RIL.RILJ_LOGD) mRil.unsljLogvRet(RIL_UNSOL_RESTRICTED_STATE_CHANGED, state); 469 470 if (mRil.mRestrictedStateRegistrant != null) { 471 mRil.mRestrictedStateRegistrant.notifyRegistrant(new AsyncResult (null, state, null)); 472 } 473 } 474 475 public void enterEmergencyCallbackMode(int indicationType) { 476 mRil.processIndication(indicationType); 477 478 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE); 479 480 if (mRil.mEmergencyCallbackModeRegistrant != null) { 481 mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant(); 482 } 483 } 484 485 public void cdmaCallWaiting(int indicationType, CdmaCallWaiting callWaitingRecord) { 486 mRil.processIndication(indicationType); 487 488 // todo: create a CdmaCallWaitingNotification constructor that takes in these fields to make 489 // sure no fields are missing 490 CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification(); 491 notification.number = callWaitingRecord.number; 492 notification.numberPresentation = CdmaCallWaitingNotification.presentationFromCLIP( 493 callWaitingRecord.numberPresentation); 494 notification.name = callWaitingRecord.name; 495 notification.namePresentation = notification.numberPresentation; 496 notification.isPresent = callWaitingRecord.signalInfoRecord.isPresent ? 1 : 0; 497 notification.signalType = callWaitingRecord.signalInfoRecord.signalType; 498 notification.alertPitch = callWaitingRecord.signalInfoRecord.alertPitch; 499 notification.signal = callWaitingRecord.signalInfoRecord.signal; 500 notification.numberType = callWaitingRecord.numberType; 501 notification.numberPlan = callWaitingRecord.numberPlan; 502 503 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_CALL_WAITING, notification); 504 505 mRil.mCallWaitingInfoRegistrants.notifyRegistrants( 506 new AsyncResult (null, notification, null)); 507 } 508 509 public void cdmaOtaProvisionStatus(int indicationType, int status) { 510 mRil.processIndication(indicationType); 511 512 int response[] = new int[1]; 513 response[0] = status; 514 515 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, response); 516 517 mRil.mOtaProvisionRegistrants.notifyRegistrants(new AsyncResult (null, response, null)); 518 } 519 520 public void cdmaInfoRec(int indicationType, 521 android.hardware.radio.V1_0.CdmaInformationRecords records) { 522 mRil.processIndication(indicationType); 523 524 int numberOfInfoRecs = records.infoRec.size(); 525 for (int i = 0; i < numberOfInfoRecs; i++) { 526 CdmaInformationRecord record = records.infoRec.get(i); 527 int id = record.name; 528 CdmaInformationRecords cdmaInformationRecords; 529 switch (id) { 530 case CdmaInformationRecords.RIL_CDMA_DISPLAY_INFO_REC: 531 case CdmaInformationRecords.RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: 532 CdmaInformationRecords.CdmaDisplayInfoRec cdmaDisplayInfoRec = 533 new CdmaInformationRecords.CdmaDisplayInfoRec(id, 534 record.display.get(0).alphaBuf); 535 cdmaInformationRecords = new CdmaInformationRecords(cdmaDisplayInfoRec); 536 break; 537 538 case CdmaInformationRecords.RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: 539 case CdmaInformationRecords.RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: 540 case CdmaInformationRecords.RIL_CDMA_CONNECTED_NUMBER_INFO_REC: 541 CdmaNumberInfoRecord numInfoRecord = record.number.get(0); 542 CdmaInformationRecords.CdmaNumberInfoRec cdmaNumberInfoRec = 543 new CdmaInformationRecords.CdmaNumberInfoRec(id, 544 numInfoRecord.number, 545 numInfoRecord.numberType, 546 numInfoRecord.numberPlan, 547 numInfoRecord.pi, 548 numInfoRecord.si); 549 cdmaInformationRecords = new CdmaInformationRecords(cdmaNumberInfoRec); 550 break; 551 552 case CdmaInformationRecords.RIL_CDMA_SIGNAL_INFO_REC: 553 CdmaSignalInfoRecord signalInfoRecord = record.signal.get(0); 554 CdmaInformationRecords.CdmaSignalInfoRec cdmaSignalInfoRec = 555 new CdmaInformationRecords.CdmaSignalInfoRec( 556 signalInfoRecord.isPresent ? 1 : 0, 557 signalInfoRecord.signalType, 558 signalInfoRecord.alertPitch, 559 signalInfoRecord.signal); 560 cdmaInformationRecords = new CdmaInformationRecords(cdmaSignalInfoRec); 561 break; 562 563 case CdmaInformationRecords.RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: 564 CdmaRedirectingNumberInfoRecord redirectingNumberInfoRecord = 565 record.redir.get(0); 566 CdmaInformationRecords.CdmaRedirectingNumberInfoRec 567 cdmaRedirectingNumberInfoRec = 568 new CdmaInformationRecords.CdmaRedirectingNumberInfoRec( 569 redirectingNumberInfoRecord.redirectingNumber.number, 570 redirectingNumberInfoRecord.redirectingNumber.numberType, 571 redirectingNumberInfoRecord.redirectingNumber.numberPlan, 572 redirectingNumberInfoRecord.redirectingNumber.pi, 573 redirectingNumberInfoRecord.redirectingNumber.si, 574 redirectingNumberInfoRecord.redirectingReason); 575 cdmaInformationRecords = new CdmaInformationRecords( 576 cdmaRedirectingNumberInfoRec); 577 break; 578 579 case CdmaInformationRecords.RIL_CDMA_LINE_CONTROL_INFO_REC: 580 CdmaLineControlInfoRecord lineControlInfoRecord = record.lineCtrl.get(0); 581 CdmaInformationRecords.CdmaLineControlInfoRec cdmaLineControlInfoRec = 582 new CdmaInformationRecords.CdmaLineControlInfoRec( 583 lineControlInfoRecord.lineCtrlPolarityIncluded, 584 lineControlInfoRecord.lineCtrlToggle, 585 lineControlInfoRecord.lineCtrlReverse, 586 lineControlInfoRecord.lineCtrlPowerDenial); 587 cdmaInformationRecords = new CdmaInformationRecords(cdmaLineControlInfoRec); 588 break; 589 590 case CdmaInformationRecords.RIL_CDMA_T53_CLIR_INFO_REC: 591 CdmaInformationRecords.CdmaT53ClirInfoRec cdmaT53ClirInfoRec = 592 new CdmaInformationRecords.CdmaT53ClirInfoRec(record.clir.get(0).cause); 593 cdmaInformationRecords = new CdmaInformationRecords(cdmaT53ClirInfoRec); 594 break; 595 596 case CdmaInformationRecords.RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: 597 CdmaT53AudioControlInfoRecord audioControlInfoRecord = record.audioCtrl.get(0); 598 CdmaInformationRecords.CdmaT53AudioControlInfoRec cdmaT53AudioControlInfoRec = 599 new CdmaInformationRecords.CdmaT53AudioControlInfoRec( 600 audioControlInfoRecord.upLink, 601 audioControlInfoRecord.downLink); 602 cdmaInformationRecords = new CdmaInformationRecords(cdmaT53AudioControlInfoRec); 603 break; 604 605 default: 606 throw new RuntimeException("RIL_UNSOL_CDMA_INFO_REC: unsupported record. Got " 607 + CdmaInformationRecords.idToString(id) + " "); 608 } 609 610 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_INFO_REC, cdmaInformationRecords); 611 mRil.notifyRegistrantsCdmaInfoRec(cdmaInformationRecords); 612 } 613 } 614 615 public void indicateRingbackTone(int indicationType, boolean start) { 616 mRil.processIndication(indicationType); 617 618 if (RIL.RILJ_LOGD) mRil.unsljLogvRet(RIL_UNSOL_RINGBACK_TONE, start); 619 620 mRil.mRingbackToneRegistrants.notifyRegistrants(new AsyncResult(null, start, null)); 621 } 622 623 public void resendIncallMute(int indicationType) { 624 mRil.processIndication(indicationType); 625 626 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESEND_INCALL_MUTE); 627 628 mRil.mResendIncallMuteRegistrants.notifyRegistrants(); 629 } 630 631 public void cdmaSubscriptionSourceChanged(int indicationType, int cdmaSource) { 632 mRil.processIndication(indicationType); 633 634 int response[] = new int[1]; 635 response[0] = cdmaSource; 636 637 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, response); 638 639 mRil.mCdmaSubscriptionChangedRegistrants.notifyRegistrants( 640 new AsyncResult (null, response, null)); 641 } 642 643 public void cdmaPrlChanged(int indicationType, int version) { 644 mRil.processIndication(indicationType); 645 646 int response[] = new int[1]; 647 response[0] = version; 648 649 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOl_CDMA_PRL_CHANGED, response); 650 651 mRil.mCdmaPrlChangedRegistrants.notifyRegistrants( 652 new AsyncResult (null, response, null)); 653 } 654 655 public void exitEmergencyCallbackMode(int indicationType) { 656 mRil.processIndication(indicationType); 657 658 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE); 659 660 mRil.mExitEmergencyCallbackModeRegistrants.notifyRegistrants(); 661 } 662 663 public void rilConnected(int indicationType) { 664 mRil.processIndication(indicationType); 665 666 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RIL_CONNECTED); 667 668 // Initial conditions 669 mRil.setRadioPower(false, null); 670 mRil.setCdmaSubscriptionSource(mRil.mCdmaSubscription, null); 671 mRil.setCellInfoListRate(); 672 // todo: this should not require a version number now. Setting it to latest RIL version for 673 // now. 674 mRil.notifyRegistrantsRilConnectionChanged(15); 675 } 676 677 public void voiceRadioTechChanged(int indicationType, int rat) { 678 mRil.processIndication(indicationType); 679 680 int response[] = new int[1]; 681 response[0] = rat; 682 683 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, response); 684 685 mRil.mVoiceRadioTechChangedRegistrants.notifyRegistrants( 686 new AsyncResult (null, response, null)); 687 } 688 689 /** Get unsolicited message for cellInfoList */ 690 public void cellInfoList(int indicationType, 691 ArrayList<android.hardware.radio.V1_0.CellInfo> records) { 692 mRil.processIndication(indicationType); 693 694 ArrayList<CellInfo> response = RIL.convertHalCellInfoList(records); 695 696 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CELL_INFO_LIST, response); 697 698 mRil.mRilCellInfoListRegistrants.notifyRegistrants(new AsyncResult(null, response, null)); 699 } 700 701 /** Get unsolicited message for cellInfoList using HAL V1_2 */ 702 public void cellInfoList_1_2(int indicationType, 703 ArrayList<android.hardware.radio.V1_2.CellInfo> records) { 704 mRil.processIndication(indicationType); 705 706 ArrayList<CellInfo> response = RIL.convertHalCellInfoList_1_2(records); 707 708 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CELL_INFO_LIST, response); 709 710 mRil.mRilCellInfoListRegistrants.notifyRegistrants(new AsyncResult(null, response, null)); 711 } 712 713 /** Incremental network scan results */ 714 public void networkScanResult(int indicationType, 715 android.hardware.radio.V1_1.NetworkScanResult result) { 716 responseCellInfos(indicationType, result); 717 } 718 719 /** Incremental network scan results with HAL V1_2 */ 720 public void networkScanResult_1_2(int indicationType, 721 android.hardware.radio.V1_2.NetworkScanResult result) { 722 responseCellInfos_1_2(indicationType, result); 723 } 724 725 public void imsNetworkStateChanged(int indicationType) { 726 mRil.processIndication(indicationType); 727 728 if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED); 729 730 mRil.mImsNetworkStateChangedRegistrants.notifyRegistrants(); 731 } 732 733 public void subscriptionStatusChanged(int indicationType, boolean activate) { 734 mRil.processIndication(indicationType); 735 736 int response[] = new int[1]; 737 response[0] = activate ? 1 : 0; 738 739 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, response); 740 741 mRil.mSubscriptionStatusRegistrants.notifyRegistrants( 742 new AsyncResult (null, response, null)); 743 } 744 745 public void srvccStateNotify(int indicationType, int state) { 746 mRil.processIndication(indicationType); 747 748 int response[] = new int[1]; 749 response[0] = state; 750 751 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SRVCC_STATE_NOTIFY, response); 752 753 mRil.writeMetricsSrvcc(state); 754 755 mRil.mSrvccStateRegistrants.notifyRegistrants( 756 new AsyncResult (null, response, null)); 757 } 758 759 public void hardwareConfigChanged( 760 int indicationType, 761 ArrayList<android.hardware.radio.V1_0.HardwareConfig> configs) { 762 mRil.processIndication(indicationType); 763 764 ArrayList<HardwareConfig> response = RIL.convertHalHwConfigList(configs, mRil); 765 766 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_HARDWARE_CONFIG_CHANGED, response); 767 768 mRil.mHardwareConfigChangeRegistrants.notifyRegistrants( 769 new AsyncResult (null, response, null)); 770 } 771 772 public void radioCapabilityIndication(int indicationType, 773 android.hardware.radio.V1_0.RadioCapability rc) { 774 mRil.processIndication(indicationType); 775 776 RadioCapability response = RIL.convertHalRadioCapability(rc, mRil); 777 778 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_RADIO_CAPABILITY, response); 779 780 mRil.mPhoneRadioCapabilityChangedRegistrants.notifyRegistrants( 781 new AsyncResult (null, response, null)); 782 } 783 784 public void onSupplementaryServiceIndication(int indicationType, StkCcUnsolSsResult ss) { 785 mRil.processIndication(indicationType); 786 787 int num; 788 SsData ssData = new SsData(); 789 790 ssData.serviceType = ssData.ServiceTypeFromRILInt(ss.serviceType); 791 ssData.requestType = ssData.RequestTypeFromRILInt(ss.requestType); 792 ssData.teleserviceType = ssData.TeleserviceTypeFromRILInt(ss.teleserviceType); 793 ssData.serviceClass = ss.serviceClass; // This is service class sent in the SS request. 794 ssData.result = ss.result; // This is the result of the SS request. 795 796 if (ssData.serviceType.isTypeCF() && 797 ssData.requestType.isTypeInterrogation()) { 798 CfData cfData = ss.cfData.get(0); 799 num = cfData.cfInfo.size(); 800 ssData.cfInfo = new CallForwardInfo[num]; 801 802 for (int i = 0; i < num; i++) { 803 android.hardware.radio.V1_0.CallForwardInfo cfInfo = cfData.cfInfo.get(i); 804 ssData.cfInfo[i] = new CallForwardInfo(); 805 806 ssData.cfInfo[i].status = cfInfo.status; 807 ssData.cfInfo[i].reason = cfInfo.reason; 808 ssData.cfInfo[i].serviceClass = cfInfo.serviceClass; 809 ssData.cfInfo[i].toa = cfInfo.toa; 810 ssData.cfInfo[i].number = cfInfo.number; 811 ssData.cfInfo[i].timeSeconds = cfInfo.timeSeconds; 812 813 mRil.riljLog("[SS Data] CF Info " + i + " : " + ssData.cfInfo[i]); 814 } 815 } else { 816 SsInfoData ssInfo = ss.ssInfo.get(0); 817 num = ssInfo.ssInfo.size(); 818 ssData.ssInfo = new int[num]; 819 for (int i = 0; i < num; i++) { 820 ssData.ssInfo[i] = ssInfo.ssInfo.get(i); 821 mRil.riljLog("[SS Data] SS Info " + i + " : " + ssData.ssInfo[i]); 822 } 823 } 824 825 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_ON_SS, ssData); 826 827 if (mRil.mSsRegistrant != null) { 828 mRil.mSsRegistrant.notifyRegistrant(new AsyncResult(null, ssData, null)); 829 } 830 } 831 832 public void stkCallControlAlphaNotify(int indicationType, String alpha) { 833 mRil.processIndication(indicationType); 834 835 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_STK_CC_ALPHA_NOTIFY, alpha); 836 837 if (mRil.mCatCcAlphaRegistrant != null) { 838 mRil.mCatCcAlphaRegistrant.notifyRegistrant(new AsyncResult (null, alpha, null)); 839 } 840 } 841 842 public void lceData(int indicationType, LceDataInfo lce) { 843 mRil.processIndication(indicationType); 844 845 LinkCapacityEstimate response = RIL.convertHalLceData(lce, mRil); 846 847 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_LCEDATA_RECV, response); 848 849 if (mRil.mLceInfoRegistrants != null) { 850 mRil.mLceInfoRegistrants.notifyRegistrants(new AsyncResult(null, response, null)); 851 } 852 } 853 854 public void pcoData(int indicationType, PcoDataInfo pco) { 855 mRil.processIndication(indicationType); 856 857 PcoData response = new PcoData(pco.cid, 858 pco.bearerProto, 859 pco.pcoId, 860 RIL.arrayListToPrimitiveArray(pco.contents)); 861 862 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_PCO_DATA, response); 863 864 mRil.mPcoDataRegistrants.notifyRegistrants(new AsyncResult(null, response, null)); 865 } 866 867 public void modemReset(int indicationType, String reason) { 868 mRil.processIndication(indicationType); 869 870 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_MODEM_RESTART, reason); 871 872 mRil.writeMetricsModemRestartEvent(reason); 873 mRil.mModemResetRegistrants.notifyRegistrants(new AsyncResult(null, reason, null)); 874 } 875 876 /** 877 * Indicates when the carrier info to encrypt IMSI is being requested 878 * @param indicationType RadioIndicationType 879 */ 880 public void carrierInfoForImsiEncryption(int indicationType) { 881 mRil.processIndication(indicationType); 882 883 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION, null); 884 885 mRil.mCarrierInfoForImsiEncryptionRegistrants.notifyRegistrants( 886 new AsyncResult(null, null, null)); 887 } 888 889 /** 890 * Indicates a change in the status of an ongoing Keepalive session 891 * @param indicationType RadioIndicationType 892 * @param halStatus Status of the ongoing Keepalive session 893 */ 894 public void keepaliveStatus( 895 int indicationType, android.hardware.radio.V1_1.KeepaliveStatus halStatus) { 896 mRil.processIndication(indicationType); 897 898 if (RIL.RILJ_LOGD) { 899 mRil.unsljLogRet(RIL_UNSOL_KEEPALIVE_STATUS, 900 "handle=" + halStatus.sessionHandle + " code=" + halStatus.code); 901 } 902 903 KeepaliveStatus ks = new KeepaliveStatus(halStatus.sessionHandle, halStatus.code); 904 mRil.mNattKeepaliveStatusRegistrants.notifyRegistrants(new AsyncResult(null, ks, null)); 905 } 906 907 private CommandsInterface.RadioState getRadioStateFromInt(int stateInt) { 908 CommandsInterface.RadioState state; 909 910 switch(stateInt) { 911 case android.hardware.radio.V1_0.RadioState.OFF: 912 state = CommandsInterface.RadioState.RADIO_OFF; 913 break; 914 case android.hardware.radio.V1_0.RadioState.UNAVAILABLE: 915 state = CommandsInterface.RadioState.RADIO_UNAVAILABLE; 916 break; 917 case android.hardware.radio.V1_0.RadioState.ON: 918 state = CommandsInterface.RadioState.RADIO_ON; 919 break; 920 default: 921 throw new RuntimeException("Unrecognized RadioState: " + stateInt); 922 } 923 return state; 924 } 925 926 private void responseCellInfos(int indicationType, 927 android.hardware.radio.V1_1.NetworkScanResult result) { 928 mRil.processIndication(indicationType); 929 930 NetworkScanResult nsr = null; 931 ArrayList<CellInfo> infos = RIL.convertHalCellInfoList(result.networkInfos); 932 nsr = new NetworkScanResult(result.status, result.error, infos); 933 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); 934 mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); 935 } 936 937 private void responseCellInfos_1_2(int indicationType, 938 android.hardware.radio.V1_2.NetworkScanResult result) { 939 mRil.processIndication(indicationType); 940 941 NetworkScanResult nsr = null; 942 ArrayList<CellInfo> infos = RIL.convertHalCellInfoList_1_2(result.networkInfos); 943 nsr = new NetworkScanResult(result.status, result.error, infos); 944 if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); 945 mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); 946 } 947 } 948