RadioIndication.java revision 8e9d1e601dce62cd0328701d7054e03db24727c7
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 = new ArrayList<>();
235
236        for (SetupDataCallResult dcResult : dcList) {
237            response.add(RIL.convertDataCallResult(dcResult));
238        }
239
240        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, response);
241
242        mRil.mDataCallListChangedRegistrants.notifyRegistrants(
243                new AsyncResult(null, response, null));
244    }
245
246    public void suppSvcNotify(int indicationType, SuppSvcNotification suppSvcNotification) {
247        mRil.processIndication(indicationType);
248
249        SuppServiceNotification notification = new SuppServiceNotification();
250        notification.notificationType = suppSvcNotification.isMT ? 1 : 0;
251        notification.code = suppSvcNotification.code;
252        notification.index = suppSvcNotification.index;
253        notification.type = suppSvcNotification.type;
254        notification.number = suppSvcNotification.number;
255
256        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SUPP_SVC_NOTIFICATION, notification);
257
258        if (mRil.mSsnRegistrant != null) {
259            mRil.mSsnRegistrant.notifyRegistrant(new AsyncResult (null, notification, null));
260        }
261    }
262
263    public void stkSessionEnd(int indicationType) {
264        mRil.processIndication(indicationType);
265
266        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_SESSION_END);
267
268        if (mRil.mCatSessionEndRegistrant != null) {
269            mRil.mCatSessionEndRegistrant.notifyRegistrant(new AsyncResult (null, null, null));
270        }
271    }
272
273    public void stkProactiveCommand(int indicationType, String cmd) {
274        mRil.processIndication(indicationType);
275
276        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_PROACTIVE_COMMAND);
277
278        if (mRil.mCatProCmdRegistrant != null) {
279            mRil.mCatProCmdRegistrant.notifyRegistrant(new AsyncResult (null, cmd, null));
280        }
281    }
282
283    public void stkEventNotify(int indicationType, String cmd) {
284        mRil.processIndication(indicationType);
285
286        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_STK_EVENT_NOTIFY);
287
288        if (mRil.mCatEventRegistrant != null) {
289            mRil.mCatEventRegistrant.notifyRegistrant(new AsyncResult (null, cmd, null));
290        }
291    }
292
293    public void stkCallSetup(int indicationType, long timeout) {
294        mRil.processIndication(indicationType);
295
296        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_STK_CALL_SETUP, timeout);
297
298        if (mRil.mCatCallSetUpRegistrant != null) {
299            mRil.mCatCallSetUpRegistrant.notifyRegistrant(new AsyncResult (null, timeout, null));
300        }
301    }
302
303    public void simSmsStorageFull(int indicationType) {
304        mRil.processIndication(indicationType);
305
306        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_SIM_SMS_STORAGE_FULL);
307
308        if (mRil.mIccSmsFullRegistrant != null) {
309            mRil.mIccSmsFullRegistrant.notifyRegistrant();
310        }
311    }
312
313    public void simRefresh(int indicationType, SimRefreshResult refreshResult) {
314        mRil.processIndication(indicationType);
315
316        IccRefreshResponse response = new IccRefreshResponse();
317        response.refreshResult = refreshResult.type;
318        response.efId = refreshResult.efId;
319        response.aid = refreshResult.aid;
320
321        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SIM_REFRESH, response);
322
323        mRil.mIccRefreshRegistrants.notifyRegistrants(new AsyncResult (null, response, null));
324    }
325
326    public void callRing(int indicationType, boolean isGsm, CdmaSignalInfoRecord record) {
327        mRil.processIndication(indicationType);
328
329        char response[] = null;
330
331        // Ignore record for gsm
332        if (!isGsm) {
333            // todo: Clean this up with a parcelable class for better self-documentation
334            response = new char[4];
335            response[0] = (char) (record.isPresent ? 1 : 0);
336            response[1] = (char) record.signalType;
337            response[2] = (char) record.alertPitch;
338            response[3] = (char) record.signal;
339            mRil.writeMetricsCallRing(response);
340        }
341
342        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CALL_RING, response);
343
344        if (mRil.mRingRegistrant != null) {
345            mRil.mRingRegistrant.notifyRegistrant(new AsyncResult (null, response, null));
346        }
347    }
348
349    public void simStatusChanged(int indicationType) {
350        mRil.processIndication(indicationType);
351
352        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED);
353
354        mRil.mIccStatusChangedRegistrants.notifyRegistrants();
355    }
356
357    public void cdmaNewSms(int indicationType, CdmaSmsMessage msg) {
358        mRil.processIndication(indicationType);
359
360        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_CDMA_NEW_SMS);
361
362        mRil.writeMetricsNewSms(SmsSession.Event.Tech.SMS_CDMA,
363                SmsSession.Event.Format.SMS_FORMAT_3GPP2);
364
365        // todo: conversion from CdmaSmsMessage to SmsMessage should be contained in this class so
366        // that usage of auto-generated HAL classes is limited to this file
367        SmsMessage sms = SmsMessage.newCdmaSmsFromRil(msg);
368        if (mRil.mCdmaSmsRegistrant != null) {
369            mRil.mCdmaSmsRegistrant.notifyRegistrant(new AsyncResult(null, sms, null));
370        }
371    }
372
373    public void newBroadcastSms(int indicationType, ArrayList<Byte> data) {
374        mRil.processIndication(indicationType);
375
376        byte response[] = RIL.arrayListToPrimitiveArray(data);
377        if (RIL.RILJ_LOGD) {
378            mRil.unsljLogvRet(RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS,
379                    IccUtils.bytesToHexString(response));
380        }
381
382        if (mRil.mGsmBroadcastSmsRegistrant != null) {
383            mRil.mGsmBroadcastSmsRegistrant.notifyRegistrant(new AsyncResult(null, response, null));
384        }
385    }
386
387    public void cdmaRuimSmsStorageFull(int indicationType) {
388        mRil.processIndication(indicationType);
389
390        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL);
391
392        if (mRil.mIccSmsFullRegistrant != null) {
393            mRil.mIccSmsFullRegistrant.notifyRegistrant();
394        }
395    }
396
397    public void restrictedStateChanged(int indicationType, int state) {
398        mRil.processIndication(indicationType);
399
400        if (RIL.RILJ_LOGD) mRil.unsljLogvRet(RIL_UNSOL_RESTRICTED_STATE_CHANGED, state);
401
402        if (mRil.mRestrictedStateRegistrant != null) {
403            mRil.mRestrictedStateRegistrant.notifyRegistrant(new AsyncResult (null, state, null));
404        }
405    }
406
407    public void enterEmergencyCallbackMode(int indicationType) {
408        mRil.processIndication(indicationType);
409
410        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE);
411
412        if (mRil.mEmergencyCallbackModeRegistrant != null) {
413            mRil.mEmergencyCallbackModeRegistrant.notifyRegistrant();
414        }
415    }
416
417    public void cdmaCallWaiting(int indicationType, CdmaCallWaiting callWaitingRecord) {
418        mRil.processIndication(indicationType);
419
420        // todo: create a CdmaCallWaitingNotification constructor that takes in these fields to make
421        // sure no fields are missing
422        CdmaCallWaitingNotification notification = new CdmaCallWaitingNotification();
423        notification.number = callWaitingRecord.number;
424        notification.numberPresentation = CdmaCallWaitingNotification.presentationFromCLIP(
425                callWaitingRecord.numberPresentation);
426        notification.name = callWaitingRecord.name;
427        notification.namePresentation = notification.numberPresentation;
428        notification.isPresent = callWaitingRecord.signalInfoRecord.isPresent ? 1 : 0;
429        notification.signalType = callWaitingRecord.signalInfoRecord.signalType;
430        notification.alertPitch = callWaitingRecord.signalInfoRecord.alertPitch;
431        notification.signal = callWaitingRecord.signalInfoRecord.signal;
432        notification.numberType = callWaitingRecord.numberType;
433        notification.numberPlan = callWaitingRecord.numberPlan;
434
435        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_CALL_WAITING, notification);
436
437        mRil.mCallWaitingInfoRegistrants.notifyRegistrants(
438                new AsyncResult (null, notification, null));
439    }
440
441    public void cdmaOtaProvisionStatus(int indicationType, int status) {
442        mRil.processIndication(indicationType);
443
444        int response[] = new int[1];
445        response[0] = status;
446
447        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, response);
448
449        mRil.mOtaProvisionRegistrants.notifyRegistrants(new AsyncResult (null, response, null));
450    }
451
452    public void cdmaInfoRec(int indicationType,
453                            android.hardware.radio.V1_0.CdmaInformationRecords records) {
454        mRil.processIndication(indicationType);
455
456        int numberOfInfoRecs = records.infoRec.size();
457        for (int i = 0; i < numberOfInfoRecs; i++) {
458            CdmaInformationRecord record = records.infoRec.get(i);
459            int id = record.name;
460            CdmaInformationRecords cdmaInformationRecords;
461            switch (id) {
462                case CdmaInformationRecords.RIL_CDMA_DISPLAY_INFO_REC:
463                case CdmaInformationRecords.RIL_CDMA_EXTENDED_DISPLAY_INFO_REC:
464                    CdmaInformationRecords.CdmaDisplayInfoRec cdmaDisplayInfoRec =
465                            new CdmaInformationRecords.CdmaDisplayInfoRec(id,
466                            record.display.get(0).alphaBuf);
467                    cdmaInformationRecords = new CdmaInformationRecords(cdmaDisplayInfoRec);
468                    break;
469
470                case CdmaInformationRecords.RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
471                case CdmaInformationRecords.RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
472                case CdmaInformationRecords.RIL_CDMA_CONNECTED_NUMBER_INFO_REC:
473                    CdmaNumberInfoRecord numInfoRecord = record.number.get(0);
474                    CdmaInformationRecords.CdmaNumberInfoRec cdmaNumberInfoRec =
475                            new CdmaInformationRecords.CdmaNumberInfoRec(id,
476                            numInfoRecord.number,
477                            numInfoRecord.numberType,
478                            numInfoRecord.numberPlan,
479                            numInfoRecord.pi,
480                            numInfoRecord.si);
481                    cdmaInformationRecords = new CdmaInformationRecords(cdmaNumberInfoRec);
482                    break;
483
484                case CdmaInformationRecords.RIL_CDMA_SIGNAL_INFO_REC:
485                    CdmaSignalInfoRecord signalInfoRecord = record.signal.get(0);
486                    CdmaInformationRecords.CdmaSignalInfoRec cdmaSignalInfoRec =
487                            new CdmaInformationRecords.CdmaSignalInfoRec(
488                            signalInfoRecord.isPresent ? 1 : 0,
489                            signalInfoRecord.signalType,
490                            signalInfoRecord.alertPitch,
491                            signalInfoRecord.signal);
492                    cdmaInformationRecords = new CdmaInformationRecords(cdmaSignalInfoRec);
493                    break;
494
495                case CdmaInformationRecords.RIL_CDMA_REDIRECTING_NUMBER_INFO_REC:
496                    CdmaRedirectingNumberInfoRecord redirectingNumberInfoRecord =
497                            record.redir.get(0);
498                    CdmaInformationRecords.CdmaRedirectingNumberInfoRec
499                            cdmaRedirectingNumberInfoRec =
500                            new CdmaInformationRecords.CdmaRedirectingNumberInfoRec(
501                            redirectingNumberInfoRecord.redirectingNumber.number,
502                            redirectingNumberInfoRecord.redirectingNumber.numberType,
503                            redirectingNumberInfoRecord.redirectingNumber.numberPlan,
504                            redirectingNumberInfoRecord.redirectingNumber.pi,
505                            redirectingNumberInfoRecord.redirectingNumber.si,
506                            redirectingNumberInfoRecord.redirectingReason);
507                    cdmaInformationRecords = new CdmaInformationRecords(
508                            cdmaRedirectingNumberInfoRec);
509                    break;
510
511                case CdmaInformationRecords.RIL_CDMA_LINE_CONTROL_INFO_REC:
512                    CdmaLineControlInfoRecord lineControlInfoRecord = record.lineCtrl.get(0);
513                    CdmaInformationRecords.CdmaLineControlInfoRec cdmaLineControlInfoRec =
514                            new CdmaInformationRecords.CdmaLineControlInfoRec(
515                            lineControlInfoRecord.lineCtrlPolarityIncluded,
516                            lineControlInfoRecord.lineCtrlToggle,
517                            lineControlInfoRecord.lineCtrlReverse,
518                            lineControlInfoRecord.lineCtrlPowerDenial);
519                    cdmaInformationRecords = new CdmaInformationRecords(cdmaLineControlInfoRec);
520                    break;
521
522                case CdmaInformationRecords.RIL_CDMA_T53_CLIR_INFO_REC:
523                    CdmaInformationRecords.CdmaT53ClirInfoRec cdmaT53ClirInfoRec =
524                            new CdmaInformationRecords.CdmaT53ClirInfoRec(record.clir.get(0).cause);
525                    cdmaInformationRecords = new CdmaInformationRecords(cdmaT53ClirInfoRec);
526                    break;
527
528                case CdmaInformationRecords.RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC:
529                    CdmaT53AudioControlInfoRecord audioControlInfoRecord = record.audioCtrl.get(0);
530                    CdmaInformationRecords.CdmaT53AudioControlInfoRec cdmaT53AudioControlInfoRec =
531                            new CdmaInformationRecords.CdmaT53AudioControlInfoRec(
532                            audioControlInfoRecord.upLink,
533                            audioControlInfoRecord.downLink);
534                    cdmaInformationRecords = new CdmaInformationRecords(cdmaT53AudioControlInfoRec);
535                    break;
536
537                default:
538                    throw new RuntimeException("RIL_UNSOL_CDMA_INFO_REC: unsupported record. Got "
539                            + CdmaInformationRecords.idToString(id) + " ");
540            }
541
542            if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_INFO_REC, cdmaInformationRecords);
543            mRil.notifyRegistrantsCdmaInfoRec(cdmaInformationRecords);
544        }
545    }
546
547    public void indicateRingbackTone(int indicationType, boolean start) {
548        mRil.processIndication(indicationType);
549
550        if (RIL.RILJ_LOGD) mRil.unsljLogvRet(RIL_UNSOL_RINGBACK_TONE, start);
551
552        mRil.mRingbackToneRegistrants.notifyRegistrants(new AsyncResult(null, start, null));
553    }
554
555    public void resendIncallMute(int indicationType) {
556        mRil.processIndication(indicationType);
557
558        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESEND_INCALL_MUTE);
559
560        mRil.mResendIncallMuteRegistrants.notifyRegistrants();
561    }
562
563    public void cdmaSubscriptionSourceChanged(int indicationType, int cdmaSource) {
564        mRil.processIndication(indicationType);
565
566        int response[] = new int[1];
567        response[0] = cdmaSource;
568
569        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, response);
570
571        mRil.mCdmaSubscriptionChangedRegistrants.notifyRegistrants(
572                new AsyncResult (null, response, null));
573    }
574
575    public void cdmaPrlChanged(int indicationType, int version) {
576        mRil.processIndication(indicationType);
577
578        int response[] = new int[1];
579        response[0] = version;
580
581        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOl_CDMA_PRL_CHANGED, response);
582
583        mRil.mCdmaPrlChangedRegistrants.notifyRegistrants(
584                new AsyncResult (null, response, null));
585    }
586
587    public void exitEmergencyCallbackMode(int indicationType) {
588        mRil.processIndication(indicationType);
589
590        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE);
591
592        mRil.mExitEmergencyCallbackModeRegistrants.notifyRegistrants();
593    }
594
595    public void rilConnected(int indicationType) {
596        mRil.processIndication(indicationType);
597
598        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RIL_CONNECTED);
599
600        // Initial conditions
601        mRil.setRadioPower(false, null);
602        mRil.setCdmaSubscriptionSource(mRil.mCdmaSubscription, null);
603        mRil.setCellInfoListRate();
604        // todo: this should not require a version number now. Setting it to latest RIL version for
605        // now.
606        mRil.notifyRegistrantsRilConnectionChanged(15);
607        // When modem crashes, if user turns the screen off before RIL reconnects, screen
608        // state cannot be sent to modem. Resend the display state here so that modem
609        // has the correct state (to stop signal strength reporting, etc).
610        mRil.updateScreenState(true);
611    }
612
613    public void voiceRadioTechChanged(int indicationType, int rat) {
614        mRil.processIndication(indicationType);
615
616        int response[] = new int[1];
617        response[0] = rat;
618
619        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, response);
620
621        mRil.mVoiceRadioTechChangedRegistrants.notifyRegistrants(
622                new AsyncResult (null, response, null));
623    }
624
625    public void cellInfoList(int indicationType,
626                             ArrayList<android.hardware.radio.V1_0.CellInfo> records) {
627        mRil.processIndication(indicationType);
628
629        ArrayList<CellInfo> response = RIL.convertHalCellInfoList(records);
630
631        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CELL_INFO_LIST, response);
632
633        mRil.mRilCellInfoListRegistrants.notifyRegistrants(new AsyncResult (null, response, null));
634    }
635
636    public void imsNetworkStateChanged(int indicationType) {
637        mRil.processIndication(indicationType);
638
639        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED);
640
641        mRil.mImsNetworkStateChangedRegistrants.notifyRegistrants();
642    }
643
644    public void subscriptionStatusChanged(int indicationType, boolean activate) {
645        mRil.processIndication(indicationType);
646
647        int response[] = new int[1];
648        response[0] = activate ? 1 : 0;
649
650        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, response);
651
652        mRil.mSubscriptionStatusRegistrants.notifyRegistrants(
653                new AsyncResult (null, response, null));
654    }
655
656    public void srvccStateNotify(int indicationType, int state) {
657        mRil.processIndication(indicationType);
658
659        int response[] = new int[1];
660        response[0] = state;
661
662        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SRVCC_STATE_NOTIFY, response);
663
664        mRil.writeMetricsSrvcc(state);
665
666        mRil.mSrvccStateRegistrants.notifyRegistrants(
667                new AsyncResult (null, response, null));
668    }
669
670    public void hardwareConfigChanged(
671            int indicationType,
672            ArrayList<android.hardware.radio.V1_0.HardwareConfig> configs) {
673        mRil.processIndication(indicationType);
674
675        ArrayList<HardwareConfig> response = RIL.convertHalHwConfigList(configs, mRil);
676
677        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_HARDWARE_CONFIG_CHANGED, response);
678
679        mRil.mHardwareConfigChangeRegistrants.notifyRegistrants(
680                new AsyncResult (null, response, null));
681    }
682
683    public void radioCapabilityIndication(int indicationType,
684                                          android.hardware.radio.V1_0.RadioCapability rc) {
685        mRil.processIndication(indicationType);
686
687        RadioCapability response = RIL.convertHalRadioCapability(rc, mRil);
688
689        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_RADIO_CAPABILITY, response);
690
691        mRil.mPhoneRadioCapabilityChangedRegistrants.notifyRegistrants(
692                new AsyncResult (null, response, null));
693    }
694
695    public void onSupplementaryServiceIndication(int indicationType, StkCcUnsolSsResult ss) {
696        mRil.processIndication(indicationType);
697
698        int num;
699        SsData ssData = new SsData();
700
701        ssData.serviceType = ssData.ServiceTypeFromRILInt(ss.serviceType);
702        ssData.requestType = ssData.RequestTypeFromRILInt(ss.requestType);
703        ssData.teleserviceType = ssData.TeleserviceTypeFromRILInt(ss.teleserviceType);
704        ssData.serviceClass = ss.serviceClass; // This is service class sent in the SS request.
705        ssData.result = ss.result; // This is the result of the SS request.
706
707        if (ssData.serviceType.isTypeCF() &&
708                ssData.requestType.isTypeInterrogation()) {
709            CfData cfData = ss.cfData.get(0);
710            num = cfData.cfInfo.size();
711            ssData.cfInfo = new CallForwardInfo[num];
712
713            for (int i = 0; i < num; i++) {
714                android.hardware.radio.V1_0.CallForwardInfo cfInfo = cfData.cfInfo.get(i);
715                ssData.cfInfo[i] = new CallForwardInfo();
716
717                ssData.cfInfo[i].status = cfInfo.status;
718                ssData.cfInfo[i].reason = cfInfo.reason;
719                ssData.cfInfo[i].serviceClass = cfInfo.serviceClass;
720                ssData.cfInfo[i].toa = cfInfo.toa;
721                ssData.cfInfo[i].number = cfInfo.number;
722                ssData.cfInfo[i].timeSeconds = cfInfo.timeSeconds;
723
724                mRil.riljLog("[SS Data] CF Info " + i + " : " +  ssData.cfInfo[i]);
725            }
726        } else {
727            SsInfoData ssInfo = ss.ssInfo.get(0);
728            num = ssInfo.ssInfo.size();
729            ssData.ssInfo = new int[num];
730            for (int i = 0; i < num; i++) {
731                ssData.ssInfo[i] = ssInfo.ssInfo.get(i);
732                mRil.riljLog("[SS Data] SS Info " + i + " : " +  ssData.ssInfo[i]);
733            }
734        }
735    }
736
737    public void stkCallControlAlphaNotify(int indicationType, String alpha) {
738        mRil.processIndication(indicationType);
739
740        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_STK_CC_ALPHA_NOTIFY, alpha);
741
742        if (mRil.mCatCcAlphaRegistrant != null) {
743            mRil.mCatCcAlphaRegistrant.notifyRegistrant(new AsyncResult (null, alpha, null));
744        }
745    }
746
747    public void lceData(int indicationType, LceDataInfo lce) {
748        mRil.processIndication(indicationType);
749
750        ArrayList<Integer> response = RIL.convertHalLceData(lce, mRil);
751
752        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_LCEDATA_RECV, response);
753
754        if (mRil.mLceInfoRegistrant != null) {
755            mRil.mLceInfoRegistrant.notifyRegistrant(new AsyncResult(null, response, null));
756        }
757    }
758
759    public void pcoData(int indicationType, PcoDataInfo pco) {
760        mRil.processIndication(indicationType);
761
762        PcoData response = new PcoData(pco.cid,
763                pco.bearerProto,
764                pco.pcoId,
765                RIL.arrayListToPrimitiveArray(pco.contents));
766
767        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_PCO_DATA, response);
768
769        mRil.mPcoDataRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
770    }
771
772    public void modemReset(int indicationType, String reason) {
773        mRil.processIndication(indicationType);
774
775        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_MODEM_RESTART, reason);
776
777        mRil.writeMetricsModemRestartEvent(reason);
778    }
779
780    private CommandsInterface.RadioState getRadioStateFromInt(int stateInt) {
781        CommandsInterface.RadioState state;
782
783        switch(stateInt) {
784            case android.hardware.radio.V1_0.RadioState.OFF:
785                state = CommandsInterface.RadioState.RADIO_OFF;
786                break;
787            case android.hardware.radio.V1_0.RadioState.UNAVAILABLE:
788                state = CommandsInterface.RadioState.RADIO_UNAVAILABLE;
789                break;
790            case android.hardware.radio.V1_0.RadioState.ON:
791                state = CommandsInterface.RadioState.RADIO_ON;
792                break;
793            default:
794                throw new RuntimeException("Unrecognized RadioState: " + stateInt);
795        }
796        return state;
797    }
798}
799