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