RILTest.java revision 5095bb70036ea1d3b0211f270abdebd41bff89f1
1/*
2 * Copyright (C) 2017 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 static com.android.internal.telephony.RILConstants.RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU;
20import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ALLOW_DATA;
21import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE;
22import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CHANGE_SIM_PIN;
23import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CHANGE_SIM_PIN2;
24import static com.android.internal.telephony.RILConstants.RIL_REQUEST_CONFERENCE;
25import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DATA_REGISTRATION_STATE;
26import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DELETE_SMS_ON_SIM;
27import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DEVICE_IDENTITY;
28import static com.android.internal.telephony.RILConstants.RIL_REQUEST_DTMF;
29import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION;
30import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PIN;
31import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PIN2;
32import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PUK;
33import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PUK2;
34import static com.android.internal.telephony.RILConstants.RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE;
35import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_ACTIVITY_INFO;
36import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_CELL_INFO_LIST;
37import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_CURRENT_CALLS;
38import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_HARDWARE_CONFIG;
39import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_IMSI;
40import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_RADIO_CAPABILITY;
41import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SIM_STATUS;
42import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SMSC_ADDRESS;
43import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP;
44import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND;
45import static com.android.internal.telephony.RILConstants.RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND;
46import static com.android.internal.telephony.RILConstants.RIL_REQUEST_IMS_REGISTRATION_STATE;
47import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ISIM_AUTHENTICATION;
48import static com.android.internal.telephony.RILConstants.RIL_REQUEST_LAST_CALL_FAIL_CAUSE;
49import static com.android.internal.telephony.RILConstants.RIL_REQUEST_NV_READ_ITEM;
50import static com.android.internal.telephony.RILConstants.RIL_REQUEST_NV_RESET_CONFIG;
51import static com.android.internal.telephony.RILConstants.RIL_REQUEST_NV_WRITE_ITEM;
52import static com.android.internal.telephony.RILConstants.RIL_REQUEST_OPERATOR;
53import static com.android.internal.telephony.RILConstants.RIL_REQUEST_PULL_LCEDATA;
54import static com.android.internal.telephony.RILConstants.RIL_REQUEST_RADIO_POWER;
55import static com.android.internal.telephony.RILConstants.RIL_REQUEST_REPORT_SMS_MEMORY_STATUS;
56import static com.android.internal.telephony.RILConstants.RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING;
57import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_DEVICE_STATE;
58import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS;
59import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS_EXPECT_MORE;
60import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_INITIAL_ATTACH_APN;
61import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SIM_CARD_POWER;
62import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SMSC_ADDRESS;
63import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER;
64import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE;
65import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SHUTDOWN;
66import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIGNAL_STRENGTH;
67import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIM_AUTHENTICATION;
68import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIM_CLOSE_CHANNEL;
69import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SIM_OPEN_CHANNEL;
70import static com.android.internal.telephony.RILConstants.RIL_REQUEST_START_LCE;
71import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM;
72import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STOP_LCE;
73import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE;
74import static com.android.internal.telephony.RILConstants.RIL_REQUEST_UDUB;
75import static com.android.internal.telephony.RILConstants.RIL_REQUEST_VOICE_RADIO_TECH;
76import static com.android.internal.telephony.RILConstants.RIL_REQUEST_VOICE_REGISTRATION_STATE;
77import static com.android.internal.telephony.RILConstants.RIL_REQUEST_WRITE_SMS_TO_SIM;
78
79import static junit.framework.Assert.assertEquals;
80import static junit.framework.Assert.assertFalse;
81import static junit.framework.Assert.assertNotNull;
82import static junit.framework.Assert.assertTrue;
83
84import static org.junit.Assert.fail;
85import static org.mockito.Matchers.any;
86import static org.mockito.Matchers.eq;
87import static org.mockito.Mockito.doReturn;
88import static org.mockito.Mockito.mock;
89import static org.mockito.Mockito.spy;
90import static org.mockito.Mockito.verify;
91
92import android.content.Context;
93import android.content.pm.ApplicationInfo;
94import android.hardware.radio.V1_0.DataProfileInfo;
95import android.hardware.radio.V1_0.GsmSmsMessage;
96import android.hardware.radio.V1_0.IRadio;
97import android.hardware.radio.V1_0.NvWriteItem;
98import android.hardware.radio.V1_0.RadioError;
99import android.hardware.radio.V1_0.RadioResponseInfo;
100import android.hardware.radio.V1_0.RadioResponseType;
101import android.hardware.radio.V1_0.SmsWriteArgs;
102import android.net.ConnectivityManager;
103import android.os.Handler;
104import android.os.HandlerThread;
105import android.os.IPowerManager;
106import android.os.Message;
107import android.os.PowerManager;
108import android.os.WorkSource;
109import android.support.test.filters.FlakyTest;
110import android.telephony.CellIdentityCdma;
111import android.telephony.CellIdentityGsm;
112import android.telephony.CellIdentityLte;
113import android.telephony.CellIdentityWcdma;
114import android.telephony.CellInfo;
115import android.telephony.CellInfoCdma;
116import android.telephony.CellInfoGsm;
117import android.telephony.CellInfoLte;
118import android.telephony.CellInfoWcdma;
119import android.telephony.CellSignalStrengthCdma;
120import android.telephony.CellSignalStrengthGsm;
121import android.telephony.CellSignalStrengthLte;
122import android.telephony.CellSignalStrengthWcdma;
123import android.telephony.SmsManager;
124import android.telephony.TelephonyManager;
125
126import com.android.internal.telephony.RIL.RilHandler;
127import com.android.internal.telephony.dataconnection.ApnSetting;
128import com.android.internal.telephony.dataconnection.DataProfile;
129
130import org.junit.After;
131import org.junit.Before;
132import org.junit.Test;
133import org.mockito.ArgumentCaptor;
134import org.mockito.Mock;
135import org.mockito.MockitoAnnotations;
136
137import java.lang.reflect.InvocationTargetException;
138import java.lang.reflect.Method;
139import java.util.ArrayList;
140
141public class RILTest extends TelephonyTest {
142
143    // refer to RIL#DEFAULT_BLOCKING_MESSAGE_RESPONSE_TIMEOUT_MS
144    private static final int DEFAULT_BLOCKING_MESSAGE_RESPONSE_TIMEOUT_MS = 2000;
145
146    // refer to RIL#DEFAULT_WAKE_LOCK_TIMEOUT_MS
147    private static final int DEFAULT_WAKE_LOCK_TIMEOUT_MS = 60000;
148
149    @Mock
150    private ConnectivityManager mConnectionManager;
151    @Mock
152    private IRadio mRadioProxy;
153
154    private RilHandler mRilHandler;
155    private RIL mRILInstance;
156    private RIL mRILUnderTest;
157    private RILTestHandler mTestHandler;
158    ArgumentCaptor<Integer> mSerialNumberCaptor = ArgumentCaptor.forClass(Integer.class);
159
160    // Constants
161    private static final String ALPHA_LONG = "long";
162    private static final String ALPHA_SHORT = "short";
163    private static final int ARFCN = 690;
164    private static final int BASESTATION_ID = 65531;
165    private static final int BIT_ERROR_RATE = 99;
166    private static final int BSIC = 8;
167    private static final int CI = 268435456;
168    private static final int CID = 65535;
169    private static final int CQI = 2147483647;
170    private static final int DBM = 74;
171    private static final int EARFCN = 262140;
172    private static final int ECIO = 124;
173    private static final String EMPTY_ALPHA_LONG = "";
174    private static final String EMPTY_ALPHA_SHORT = "";
175    private static final int LAC = 65535;
176    private static final int LATITUDE = 1292000;
177    private static final int LONGITUDE = 1295000;
178    private static final int MCC = 120;
179    private static final String MCC_STR = "120";
180    private static final int MNC = 260;
181    private static final String MNC_STR = "260";
182    private static final int NETWORK_ID = 65534;
183    private static final int PCI = 503;
184    private static final int PSC = 500;
185    private static final int RIL_TIMESTAMP_TYPE_OEM_RIL = 3;
186    private static final int RSSNR = 2147483647;
187    private static final int RSRP = 96;
188    private static final int RSRQ = 10;
189    private static final int SIGNAL_NOICE_RATIO = 6;
190    private static final int SIGNAL_STRENGTH = 24;
191    private static final int SYSTEM_ID = 65533;
192    private static final int TAC = 65535;
193    private static final int TIME_ADVANCE = 4;
194    private static final long TIMESTAMP = 215924934;
195    private static final int UARFCN = 690;
196    private static final int TYPE_CDMA = 2;
197    private static final int TYPE_GSM = 1;
198    private static final int TYPE_LTE = 3;
199    private static final int TYPE_WCDMA = 4;
200
201    private class RILTestHandler extends HandlerThread {
202
203        RILTestHandler(String name) {
204            super(name);
205        }
206
207        @Override
208        protected void onLooperPrepared() {
209            super.onLooperPrepared();
210            createTelephonyDevController();
211            Context context = new ContextFixture().getTestDouble();
212            doReturn(true).when(mConnectionManager)
213                    .isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
214            doReturn(mConnectionManager).when(context)
215                    .getSystemService(Context.CONNECTIVITY_SERVICE);
216            PowerManager powerManager = createPowerManager(context);
217            doReturn(powerManager).when(context).getSystemService(Context.POWER_SERVICE);
218            doReturn(new ApplicationInfo()).when(context).getApplicationInfo();
219
220            mRILInstance = new RIL(context, RILConstants.PREFERRED_NETWORK_MODE,
221                    Phone.PREFERRED_CDMA_SUBSCRIPTION, 0);
222            mRILUnderTest = spy(mRILInstance);
223            doReturn(mRadioProxy).when(mRILUnderTest).getRadioProxy(any());
224
225            mRilHandler = mRILUnderTest.getRilHandler();
226
227            setReady(true);
228        }
229
230        private PowerManager createPowerManager(Context context) {
231            return new PowerManager(context, mock(IPowerManager.class), new Handler(getLooper()));
232        }
233
234        private void createTelephonyDevController() {
235            try {
236                TelephonyDevController.create();
237            } catch (RuntimeException e) {
238            }
239        }
240    }
241
242    @Before
243    public void setUp() {
244        MockitoAnnotations.initMocks(this);
245        mTestHandler = new RILTestHandler(getClass().getSimpleName());
246        mTestHandler.start();
247        waitUntilReady();
248    }
249
250    @After
251    public void tearDown() throws Exception {
252        mTestHandler.quit();
253    }
254
255    @FlakyTest
256    @Test
257    public void testGetIccCardStatus() throws Exception {
258        mRILUnderTest.getIccCardStatus(obtainMessage());
259        verify(mRadioProxy).getIccCardStatus(mSerialNumberCaptor.capture());
260        verifyRILResponse(
261                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_SIM_STATUS);
262    }
263
264    @FlakyTest
265    @Test
266    public void testSupplyIccPinForApp() throws Exception {
267        String pin = "1234";
268        String aid = "2345";
269        mRILUnderTest.supplyIccPinForApp(pin, aid, obtainMessage());
270        verify(mRadioProxy).supplyIccPinForApp(mSerialNumberCaptor.capture(), eq(pin), eq(aid));
271        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ENTER_SIM_PIN);
272    }
273
274    @FlakyTest
275    @Test
276    public void testSupplyIccPukForApp() throws Exception {
277        String puk = "pukcode";
278        String newPin = "1314";
279        String aid = "2345";
280        mRILUnderTest.supplyIccPukForApp(puk, newPin, aid, obtainMessage());
281        verify(mRadioProxy)
282                .supplyIccPukForApp(mSerialNumberCaptor.capture(), eq(puk), eq(newPin), eq(aid));
283        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ENTER_SIM_PUK);
284    }
285
286    @FlakyTest
287    @Test
288    public void testSupplyIccPin2ForApp() throws Exception {
289        String pin = "1234";
290        String aid = "2345";
291        mRILUnderTest.supplyIccPin2ForApp(pin, aid, obtainMessage());
292        verify(mRadioProxy).supplyIccPin2ForApp(
293                mSerialNumberCaptor.capture(), eq(pin), eq(aid));
294        verifyRILResponse(
295                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ENTER_SIM_PIN2);
296    }
297
298    @FlakyTest
299    @Test
300    public void testSupplyIccPuk2ForApp() throws Exception {
301        String puk = "pukcode";
302        String newPin = "1314";
303        String aid = "2345";
304        mRILUnderTest.supplyIccPuk2ForApp(puk, newPin, aid, obtainMessage());
305        verify(mRadioProxy)
306                .supplyIccPuk2ForApp(mSerialNumberCaptor.capture(), eq(puk), eq(newPin), eq(aid));
307        verifyRILResponse(
308                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ENTER_SIM_PUK2);
309    }
310
311    @FlakyTest
312    @Test
313    public void testChangeIccPinForApp() throws Exception {
314        String oldPin = "1234";
315        String newPin = "1314";
316        String aid = "2345";
317        mRILUnderTest.changeIccPinForApp(oldPin, newPin, aid, obtainMessage());
318        verify(mRadioProxy).changeIccPinForApp(
319                mSerialNumberCaptor.capture(), eq(oldPin), eq(newPin), eq(aid));
320        verifyRILResponse(
321                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_CHANGE_SIM_PIN);
322    }
323
324    @FlakyTest
325    @Test
326    public void testChangeIccPin2ForApp() throws Exception {
327        String oldPin2 = "1234";
328        String newPin2 = "1314";
329        String aid = "2345";
330        mRILUnderTest.changeIccPin2ForApp(oldPin2, newPin2, aid, obtainMessage());
331        verify(mRadioProxy).changeIccPin2ForApp(
332                mSerialNumberCaptor.capture(), eq(oldPin2), eq(newPin2), eq(aid));
333        verifyRILResponse(
334                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_CHANGE_SIM_PIN2);
335    }
336
337    @FlakyTest
338    @Test
339    public void testSupplyNetworkDepersonalization() throws Exception {
340        String netpin = "1234";
341        mRILUnderTest.supplyNetworkDepersonalization(netpin, obtainMessage());
342        verify(mRadioProxy).supplyNetworkDepersonalization(
343                mSerialNumberCaptor.capture(), eq(netpin));
344        verifyRILResponse(
345                mRILUnderTest,
346                mSerialNumberCaptor.getValue(),
347                RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION);
348    }
349
350    @FlakyTest
351    @Test
352    public void testGetCurrentCalls() throws Exception {
353        mRILUnderTest.getCurrentCalls(obtainMessage());
354        verify(mRadioProxy).getCurrentCalls(mSerialNumberCaptor.capture());
355        verifyRILResponse(
356                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_CURRENT_CALLS);
357    }
358
359    @FlakyTest
360    @Test
361    public void testGetIMSIForApp() throws Exception {
362        String aid = "1234";
363        mRILUnderTest.getIMSIForApp(aid, obtainMessage());
364        verify(mRadioProxy).getImsiForApp(mSerialNumberCaptor.capture(), eq(aid));
365        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_IMSI);
366    }
367
368    @FlakyTest
369    @Test
370    public void testHangupWaitingOrBackground() throws Exception {
371        mRILUnderTest.hangupWaitingOrBackground(obtainMessage());
372        verify(mRadioProxy).hangupWaitingOrBackground(mSerialNumberCaptor.capture());
373        verifyRILResponse(
374                mRILUnderTest,
375                mSerialNumberCaptor.getValue(),
376                RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
377    }
378
379    @FlakyTest
380    @Test
381    public void testHangupForegroundResumeBackground() throws Exception {
382        mRILUnderTest.hangupForegroundResumeBackground(obtainMessage());
383        verify(mRadioProxy).hangupForegroundResumeBackground(mSerialNumberCaptor.capture());
384        verifyRILResponse(
385                mRILUnderTest,
386                mSerialNumberCaptor.getValue(),
387                RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
388    }
389
390    @FlakyTest
391    @Test
392    public void testHangupConnection() throws Exception {
393        int gsmIndex = 0;
394        mRILUnderTest.hangupConnection(gsmIndex, obtainMessage());
395        verify(mRadioProxy).hangup(mSerialNumberCaptor.capture(), eq(gsmIndex));
396        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_HANGUP);
397    }
398
399    @FlakyTest
400    @Test
401    public void testSwitchWaitingOrHoldingAndActive() throws Exception {
402        mRILUnderTest.switchWaitingOrHoldingAndActive(obtainMessage());
403        verify(mRadioProxy).switchWaitingOrHoldingAndActive(mSerialNumberCaptor.capture());
404        verifyRILResponse(
405                mRILUnderTest,
406                mSerialNumberCaptor.getValue(),
407                RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
408    }
409
410    @FlakyTest
411    @Test
412    public void testConference() throws Exception {
413        mRILUnderTest.conference(obtainMessage());
414        verify(mRadioProxy).conference(mSerialNumberCaptor.capture());
415        verifyRILResponse(
416                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_CONFERENCE);
417    }
418
419    @FlakyTest
420    @Test
421    public void testRejectCall() throws Exception {
422        mRILUnderTest.rejectCall(obtainMessage());
423        verify(mRadioProxy).rejectCall(mSerialNumberCaptor.capture());
424        verifyRILResponse(
425                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_UDUB);
426    }
427
428    @FlakyTest
429    @Test
430    public void testGetLastCallFailCause() throws Exception {
431        mRILUnderTest.getLastCallFailCause(obtainMessage());
432        verify(mRadioProxy).getLastCallFailCause(mSerialNumberCaptor.capture());
433        verifyRILResponse(
434                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
435    }
436
437    @FlakyTest
438    @Test
439    public void testGetSignalStrength() throws Exception {
440        mRILUnderTest.getSignalStrength(obtainMessage());
441        verify(mRadioProxy).getSignalStrength(mSerialNumberCaptor.capture());
442        verifyRILResponse(
443                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SIGNAL_STRENGTH);
444    }
445
446    @FlakyTest
447    @Test
448    public void testGetVoiceRegistrationState() throws Exception {
449        mRILUnderTest.getVoiceRegistrationState(obtainMessage());
450        verify(mRadioProxy).getVoiceRegistrationState(mSerialNumberCaptor.capture());
451        verifyRILResponse(
452                mRILUnderTest,
453                mSerialNumberCaptor.getValue(),
454                RIL_REQUEST_VOICE_REGISTRATION_STATE);
455    }
456
457    @FlakyTest
458    @Test
459    public void testGetDataRegistrationState() throws Exception {
460        mRILUnderTest.getDataRegistrationState(obtainMessage());
461        verify(mRadioProxy).getDataRegistrationState(mSerialNumberCaptor.capture());
462        verifyRILResponse(
463                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_DATA_REGISTRATION_STATE);
464    }
465
466    @FlakyTest
467    @Test
468    public void testGetOperator() throws Exception {
469        mRILUnderTest.getOperator(obtainMessage());
470        verify(mRadioProxy).getOperator(mSerialNumberCaptor.capture());
471        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_OPERATOR);
472    }
473
474    @FlakyTest
475    @Test
476    public void testSetRadioPower() throws Exception {
477        boolean on = true;
478        mRILUnderTest.setRadioPower(on, obtainMessage());
479        verify(mRadioProxy).setRadioPower(mSerialNumberCaptor.capture(), eq(on));
480        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_RADIO_POWER);
481    }
482
483    @FlakyTest
484    @Test
485    public void testSendDtmf() throws Exception {
486        char c = 'c';
487        mRILUnderTest.sendDtmf(c, obtainMessage());
488        verify(mRadioProxy).sendDtmf(mSerialNumberCaptor.capture(), eq(c + ""));
489        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_DTMF);
490    }
491
492    @FlakyTest
493    @Test
494    public void testSendSMS() throws Exception {
495        String smscPdu = "smscPdu";
496        String pdu = "pdu";
497        GsmSmsMessage msg = new GsmSmsMessage();
498        msg.smscPdu = smscPdu;
499        msg.pdu = pdu;
500        mRILUnderTest.sendSMS(smscPdu, pdu, obtainMessage());
501        verify(mRadioProxy).sendSms(mSerialNumberCaptor.capture(), eq(msg));
502        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SEND_SMS);
503    }
504
505    @FlakyTest
506    @Test
507    public void testSendSMSExpectMore() throws Exception {
508        String smscPdu = "smscPdu";
509        String pdu = "pdu";
510        GsmSmsMessage msg = new GsmSmsMessage();
511        msg.smscPdu = smscPdu;
512        msg.pdu = pdu;
513        mRILUnderTest.sendSMSExpectMore(smscPdu, pdu, obtainMessage());
514        verify(mRadioProxy).sendSMSExpectMore(mSerialNumberCaptor.capture(), eq(msg));
515        verifyRILResponse(
516                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SEND_SMS_EXPECT_MORE);
517    }
518
519    @FlakyTest
520    @Test
521    public void testWriteSmsToSim() throws Exception {
522        String smscPdu = "smscPdu";
523        String pdu = "pdu";
524        int status = SmsManager.STATUS_ON_ICC_READ;
525        SmsWriteArgs args = new SmsWriteArgs();
526        args.status = 1;
527        args.smsc = smscPdu;
528        args.pdu = pdu;
529        mRILUnderTest.writeSmsToSim(status, smscPdu, pdu, obtainMessage());
530        verify(mRadioProxy).writeSmsToSim(mSerialNumberCaptor.capture(), eq(args));
531        verifyRILResponse(
532                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_WRITE_SMS_TO_SIM);
533    }
534
535    @FlakyTest
536    @Test
537    public void testDeleteSmsOnSim() throws Exception {
538        int index = 0;
539        mRILUnderTest.deleteSmsOnSim(index, obtainMessage());
540        verify(mRadioProxy).deleteSmsOnSim(mSerialNumberCaptor.capture(), eq(index));
541        verifyRILResponse(
542                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_DELETE_SMS_ON_SIM);
543    }
544
545    @FlakyTest
546    @Test
547    public void testGetDeviceIdentity() throws Exception {
548        mRILUnderTest.getDeviceIdentity(obtainMessage());
549        verify(mRadioProxy).getDeviceIdentity(mSerialNumberCaptor.capture());
550        verifyRILResponse(
551                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_DEVICE_IDENTITY);
552    }
553
554    @FlakyTest
555    @Test
556    public void testExitEmergencyCallbackMode() throws Exception {
557        mRILUnderTest.exitEmergencyCallbackMode(obtainMessage());
558        verify(mRadioProxy).exitEmergencyCallbackMode(mSerialNumberCaptor.capture());
559        verifyRILResponse(
560                mRILUnderTest,
561                mSerialNumberCaptor.getValue(),
562                RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
563    }
564
565    @FlakyTest
566    @Test
567    public void testGetSmscAddress() throws Exception {
568        mRILUnderTest.getSmscAddress(obtainMessage());
569        verify(mRadioProxy).getSmscAddress(mSerialNumberCaptor.capture());
570        verifyRILResponse(
571                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_SMSC_ADDRESS);
572    }
573
574    @FlakyTest
575    @Test
576    public void testSetSmscAddress() throws Exception {
577        String address = "address";
578        mRILUnderTest.setSmscAddress(address, obtainMessage());
579        verify(mRadioProxy).setSmscAddress(mSerialNumberCaptor.capture(), eq(address));
580        verifyRILResponse(
581                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_SMSC_ADDRESS);
582    }
583
584    @FlakyTest
585    @Test
586    public void testReportSmsMemoryStatus() throws Exception {
587        boolean available = true;
588        mRILUnderTest.reportSmsMemoryStatus(available, obtainMessage());
589        verify(mRadioProxy).reportSmsMemoryStatus(mSerialNumberCaptor.capture(), eq(available));
590        verifyRILResponse(
591                mRILUnderTest,
592                mSerialNumberCaptor.getValue(),
593                RIL_REQUEST_REPORT_SMS_MEMORY_STATUS);
594    }
595
596    @FlakyTest
597    @Test
598    public void testReportStkServiceIsRunning() throws Exception {
599        mRILUnderTest.reportStkServiceIsRunning(obtainMessage());
600        verify(mRadioProxy).reportStkServiceIsRunning(mSerialNumberCaptor.capture());
601        verifyRILResponse(
602                mRILUnderTest,
603                mSerialNumberCaptor.getValue(),
604                RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
605    }
606
607    @FlakyTest
608    @Test
609    public void testGetCdmaSubscriptionSource() throws Exception {
610        mRILUnderTest.getCdmaSubscriptionSource(obtainMessage());
611        verify(mRadioProxy).getCdmaSubscriptionSource(mSerialNumberCaptor.capture());
612        verifyRILResponse(
613                mRILUnderTest,
614                mSerialNumberCaptor.getValue(),
615                RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
616    }
617
618    @FlakyTest
619    @Test
620    public void testRequestIsimAuthentication() throws Exception {
621        String nonce = "nonce";
622        mRILUnderTest.requestIsimAuthentication(nonce, obtainMessage());
623        verify(mRadioProxy).requestIsimAuthentication(mSerialNumberCaptor.capture(), eq(nonce));
624        verifyRILResponse(
625                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ISIM_AUTHENTICATION);
626    }
627
628    @FlakyTest
629    @Test
630    public void testAcknowledgeIncomingGsmSmsWithPdu() throws Exception {
631        boolean success = true;
632        String ackPdu = "ackPdu";
633        mRILUnderTest.acknowledgeIncomingGsmSmsWithPdu(success, ackPdu, obtainMessage());
634        verify(mRadioProxy).acknowledgeIncomingGsmSmsWithPdu(
635                mSerialNumberCaptor.capture(), eq(success), eq(ackPdu));
636        verifyRILResponse(
637                mRILUnderTest,
638                mSerialNumberCaptor.getValue(),
639                RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU);
640    }
641
642    @FlakyTest
643    @Test
644    public void testGetVoiceRadioTechnology() throws Exception {
645        mRILUnderTest.getVoiceRadioTechnology(obtainMessage());
646        verify(mRadioProxy).getVoiceRadioTechnology(mSerialNumberCaptor.capture());
647        verifyRILResponse(
648                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_VOICE_RADIO_TECH);
649    }
650
651    @FlakyTest
652    @Test
653    public void testGetCellInfoList() throws Exception {
654        mRILUnderTest.getCellInfoList(obtainMessage(), null);
655        verify(mRadioProxy).getCellInfoList(mSerialNumberCaptor.capture());
656        verifyRILResponse(
657                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_CELL_INFO_LIST);
658    }
659
660    @FlakyTest
661    @Test
662    public void testSetCellInfoListRate() throws Exception {
663        int rateInMillis = 1000;
664        mRILUnderTest.setCellInfoListRate(rateInMillis, obtainMessage(), null);
665        verify(mRadioProxy).setCellInfoListRate(mSerialNumberCaptor.capture(), eq(rateInMillis));
666        verifyRILResponse(
667                mRILUnderTest,
668                mSerialNumberCaptor.getValue(),
669                RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE);
670    }
671
672    @FlakyTest
673    @Test
674    public void testSetInitialAttachApn() throws Exception {
675        ApnSetting apnSetting = new ApnSetting(
676                -1, "22210", "Vodafone IT", "web.omnitel.it", "", "",
677                "", "", "", "", "", 0, new String[]{"DUN"}, "IP", "IP", true, 0, 0,
678                0, false, 0, 0, 0, 0, "", "");
679        DataProfile dataProfile = new DataProfile(apnSetting);
680        boolean isRoaming = false;
681
682        mRILUnderTest.setInitialAttachApn(dataProfile, isRoaming, obtainMessage());
683        verify(mRadioProxy).setInitialAttachApn(
684                mSerialNumberCaptor.capture(),
685                eq((DataProfileInfo) invokeMethod(
686                        mRILInstance,
687                        "convertToHalDataProfile",
688                        new Class<?>[] {DataProfile.class},
689                        new Object[] {dataProfile})),
690                eq(dataProfile.modemCognitive),
691                eq(isRoaming));
692        verifyRILResponse(
693                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_INITIAL_ATTACH_APN);
694    }
695
696    @FlakyTest
697    @Test
698    public void testGetImsRegistrationState() throws Exception {
699        mRILUnderTest.getImsRegistrationState(obtainMessage());
700        verify(mRadioProxy).getImsRegistrationState(mSerialNumberCaptor.capture());
701        verifyRILResponse(
702                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_IMS_REGISTRATION_STATE);
703    }
704
705    @FlakyTest
706    @Test
707    public void testIccOpenLogicalChannel() throws Exception {
708        String aid = "aid";
709        int p2 = 0;
710        mRILUnderTest.iccOpenLogicalChannel(aid, p2, obtainMessage());
711        verify(mRadioProxy).iccOpenLogicalChannel(mSerialNumberCaptor.capture(), eq(aid), eq(p2));
712        verifyRILResponse(
713                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SIM_OPEN_CHANNEL);
714    }
715
716    @FlakyTest
717    @Test
718    public void testIccCloseLogicalChannel() throws Exception {
719        int channel = 1;
720        mRILUnderTest.iccCloseLogicalChannel(channel, obtainMessage());
721        verify(mRadioProxy).iccCloseLogicalChannel(mSerialNumberCaptor.capture(), eq(channel));
722        verifyRILResponse(
723                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SIM_CLOSE_CHANNEL);
724    }
725
726    @FlakyTest
727    @Test
728    public void testNvWriteItem() throws Exception {
729        int itemId = 1;
730        String itemValue = "value";
731        mRILUnderTest.nvWriteItem(itemId, itemValue, obtainMessage());
732        NvWriteItem item = new NvWriteItem();
733        item.itemId = itemId;
734        item.value = itemValue;
735        verify(mRadioProxy).nvWriteItem(mSerialNumberCaptor.capture(), eq(item));
736        verifyRILResponse(
737                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_NV_WRITE_ITEM);
738    }
739
740    @FlakyTest
741    @Test
742    public void testNvReadItem() throws Exception {
743        int itemId = 1;
744        mRILUnderTest.nvReadItem(itemId, obtainMessage());
745        verify(mRadioProxy).nvReadItem(mSerialNumberCaptor.capture(), eq(itemId));
746        verifyRILResponse(
747                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_NV_READ_ITEM);
748    }
749
750    @FlakyTest
751    @Test
752    public void testNvResetConfig() throws Exception {
753        int resetType = 1;
754        mRILUnderTest.nvResetConfig(resetType, obtainMessage());
755        verify(mRadioProxy).nvResetConfig(
756                mSerialNumberCaptor.capture(),
757                eq((Integer) invokeMethod(
758                        mRILInstance,
759                        "convertToHalResetNvType",
760                        new Class<?>[] {Integer.TYPE},
761                        new Object[] {resetType})));
762        verifyRILResponse(
763                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_NV_RESET_CONFIG);
764    }
765
766    @FlakyTest
767    @Test
768    public void testSetDataAllowed() throws Exception {
769        boolean allowed = true;
770        mRILUnderTest.setDataAllowed(allowed, obtainMessage());
771        verify(mRadioProxy).setDataAllowed(mSerialNumberCaptor.capture(), eq(allowed));
772        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_ALLOW_DATA);
773    }
774
775    @FlakyTest
776    @Test
777    public void testGetHardwareConfig() throws Exception {
778        mRILUnderTest.getHardwareConfig(obtainMessage());
779        verify(mRadioProxy).getHardwareConfig(mSerialNumberCaptor.capture());
780        verifyRILResponse(
781                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_HARDWARE_CONFIG);
782    }
783
784    @FlakyTest
785    @Test
786    public void testRequestIccSimAuthentication() throws Exception {
787        int authContext = 1;
788        String data = "data";
789        String aid = "aid";
790        mRILUnderTest.requestIccSimAuthentication(authContext, data, aid, obtainMessage());
791        verify(mRadioProxy).requestIccSimAuthentication(
792                mSerialNumberCaptor.capture(), eq(authContext), eq(data), eq(aid));
793        verifyRILResponse(
794                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SIM_AUTHENTICATION);
795    }
796
797    @FlakyTest
798    @Test
799    public void testRequestShutdown() throws Exception {
800        mRILUnderTest.requestShutdown(obtainMessage());
801        verify(mRadioProxy).requestShutdown(mSerialNumberCaptor.capture());
802        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SHUTDOWN);
803    }
804
805    @FlakyTest
806    @Test
807    public void testGetRadioCapability() throws Exception {
808        mRILUnderTest.getRadioCapability(obtainMessage());
809        verify(mRadioProxy).getRadioCapability(mSerialNumberCaptor.capture());
810        verifyRILResponse(
811                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_RADIO_CAPABILITY);
812    }
813
814    @FlakyTest
815    @Test
816    public void testStartLceService() throws Exception {
817        int reportIntervalMs = 1000;
818        boolean pullMode = false;
819        mRILUnderTest.startLceService(reportIntervalMs, pullMode, obtainMessage());
820        verify(mRadioProxy).startLceService(
821                mSerialNumberCaptor.capture(), eq(reportIntervalMs), eq(pullMode));
822        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_START_LCE);
823    }
824
825    @FlakyTest
826    @Test
827    public void testStopLceService() throws Exception {
828        mRILUnderTest.stopLceService(obtainMessage());
829        verify(mRadioProxy).stopLceService(mSerialNumberCaptor.capture());
830        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_STOP_LCE);
831    }
832
833    @FlakyTest
834    @Test
835    public void testPullLceData() throws Exception {
836        mRILUnderTest.pullLceData(obtainMessage());
837        verify(mRadioProxy).pullLceData(mSerialNumberCaptor.capture());
838        verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_PULL_LCEDATA);
839    }
840
841    @FlakyTest
842    @Test
843    public void testGetModemActivityInfo() throws Exception {
844        mRILUnderTest.getModemActivityInfo(obtainMessage());
845        verify(mRadioProxy).getModemActivityInfo(mSerialNumberCaptor.capture());
846        verifyRILResponse(
847                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_ACTIVITY_INFO);
848    }
849
850    @FlakyTest
851    @Test
852    public void testGetModemActivityInfoTimeout() {
853        mRILUnderTest.getModemActivityInfo(obtainMessage());
854        assertEquals(1, mRILUnderTest.getRilRequestList().size());
855        waitForHandlerActionDelayed(mRilHandler, 10, DEFAULT_BLOCKING_MESSAGE_RESPONSE_TIMEOUT_MS);
856        assertEquals(0, mRILUnderTest.getRilRequestList().size());
857    }
858
859    @FlakyTest
860    @Test
861    public void testSendDeviceState() throws Exception {
862        int stateType = 1;
863        boolean state = false;
864        mRILUnderTest.sendDeviceState(stateType, state, obtainMessage());
865        verify(mRadioProxy).sendDeviceState(
866                mSerialNumberCaptor.capture(), eq(stateType), eq(state));
867        verifyRILResponse(
868                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SEND_DEVICE_STATE);
869    }
870
871    @FlakyTest
872    @Test
873    public void testSetUnsolResponseFilter() throws Exception {
874        int filter = 1;
875        mRILUnderTest.setUnsolResponseFilter(filter, obtainMessage());
876        verify(mRadioProxy).setIndicationFilter(mSerialNumberCaptor.capture(), eq(filter));
877        verifyRILResponse(
878                mRILUnderTest,
879                mSerialNumberCaptor.getValue(),
880                RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
881    }
882
883    @FlakyTest
884    @Test
885    public void testSetSimCardPowerForPowerDownState() throws Exception {
886        mRILUnderTest.setSimCardPower(TelephonyManager.CARD_POWER_DOWN, obtainMessage());
887        verify(mRadioProxy).setSimCardPower(mSerialNumberCaptor.capture(), eq(false));
888        verifyRILResponse(
889                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_SIM_CARD_POWER);
890    }
891
892    @FlakyTest
893    @Test
894    public void testSetSimCardPowerForPowerUpState() throws Exception {
895        mRILUnderTest.setSimCardPower(TelephonyManager.CARD_POWER_UP, obtainMessage());
896        verify(mRadioProxy).setSimCardPower(mSerialNumberCaptor.capture(), eq(true));
897        verifyRILResponse(
898                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SET_SIM_CARD_POWER);
899    }
900
901    @FlakyTest
902    @Test
903    public void testHandleCallSetupRequestFromSim() throws Exception {
904        boolean accept = true;
905        mRILUnderTest.handleCallSetupRequestFromSim(accept, obtainMessage());
906        verify(mRadioProxy).handleStkCallSetupRequestFromSim(
907                mSerialNumberCaptor.capture(), eq(accept));
908        verifyRILResponse(
909                mRILUnderTest,
910                mSerialNumberCaptor.getValue(),
911                RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
912    }
913
914    @FlakyTest
915    @Test
916    public void testWakeLockTimeout() throws Exception {
917        invokeMethod(
918                mRILInstance,
919                "obtainRequest",
920                new Class<?>[] {Integer.TYPE, Message.class, WorkSource.class},
921                new Object[] {RIL_REQUEST_GET_SIM_STATUS, obtainMessage(), null});
922
923        // The wake lock should be held when obtain a RIL request.
924        assertTrue(mRILInstance.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
925
926        waitForHandlerActionDelayed(mRilHandler, 10, DEFAULT_WAKE_LOCK_TIMEOUT_MS);
927
928        // The wake lock should be released after processed the time out event.
929        assertFalse(mRILInstance.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
930    }
931
932    private Message obtainMessage() {
933        return mTestHandler.getThreadHandler().obtainMessage();
934    }
935
936    private static void verifyRILResponse(RIL ril, int serial, int requestType) {
937        RadioResponseInfo responseInfo =
938                createFakeRadioResponseInfo(serial, RadioError.NONE, RadioResponseType.SOLICITED);
939
940        RILRequest rr = ril.processResponse(responseInfo);
941        assertNotNull(rr);
942
943        assertEquals(serial, rr.getSerial());
944        assertEquals(requestType, rr.getRequest());
945        assertTrue(ril.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
946
947        ril.processResponseDone(rr, responseInfo, null);
948        assertEquals(0, ril.getRilRequestList().size());
949        assertFalse(ril.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
950    }
951
952    private static Object invokeMethod(
953            Object instance, String methodName, Class<?>[] parameterClasses, Object[] parameters) {
954        try {
955            Method method = instance.getClass().getDeclaredMethod(methodName, parameterClasses);
956            method.setAccessible(true);
957            return method.invoke(instance, parameters);
958        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
959            fail(instance.getClass() + " " + methodName + " " + e.getClass().getName());
960        }
961        return null;
962    }
963
964    private static RadioResponseInfo createFakeRadioResponseInfo(int serial, int error, int type) {
965        RadioResponseInfo respInfo = new RadioResponseInfo();
966        respInfo.serial = serial;
967        respInfo.error = error;
968        respInfo.type = type;
969        return respInfo;
970    }
971
972    @Test
973    public void testConvertHalCellInfoListForLTE() throws Exception {
974        android.hardware.radio.V1_0.CellInfoLte lte = new android.hardware.radio.V1_0.CellInfoLte();
975        lte.cellIdentityLte.ci = CI;
976        lte.cellIdentityLte.pci = PCI;
977        lte.cellIdentityLte.tac = TAC;
978        lte.cellIdentityLte.earfcn = EARFCN;
979        lte.cellIdentityLte.mcc = MCC_STR;
980        lte.cellIdentityLte.mnc = MNC_STR;
981        lte.signalStrengthLte.signalStrength = SIGNAL_STRENGTH;
982        lte.signalStrengthLte.rsrp = RSRP;
983        lte.signalStrengthLte.rsrq = RSRQ;
984        lte.signalStrengthLte.rssnr = RSSNR;
985        lte.signalStrengthLte.cqi = CQI;
986        lte.signalStrengthLte.timingAdvance = TIME_ADVANCE;
987        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
988        record.cellInfoType = TYPE_LTE;
989        record.registered = false;
990        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
991        record.timeStamp = TIMESTAMP;
992        record.lte.add(lte);
993        ArrayList<android.hardware.radio.V1_0.CellInfo> records =
994                new ArrayList<android.hardware.radio.V1_0.CellInfo>();
995        records.add(record);
996
997        ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records);
998
999        assertEquals(1, ret.size());
1000        CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0);
1001        CellInfoLte expected = new CellInfoLte();
1002        expected.setRegistered(false);
1003        expected.setTimeStamp(TIMESTAMP);
1004        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1005        CellIdentityLte cil = new CellIdentityLte(
1006                CI, PCI, TAC, EARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1007        CellSignalStrengthLte css = new CellSignalStrengthLte(
1008                SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE);
1009        expected.setCellIdentity(cil);
1010        expected.setCellSignalStrength(css);
1011        assertEquals(expected, cellInfoLte);
1012    }
1013
1014    @Test
1015    public void testConvertHalCellInfoListForGSM() throws Exception {
1016        android.hardware.radio.V1_0.CellInfoGsm cellinfo =
1017                new android.hardware.radio.V1_0.CellInfoGsm();
1018        cellinfo.cellIdentityGsm.lac = LAC;
1019        cellinfo.cellIdentityGsm.cid = CID;
1020        cellinfo.cellIdentityGsm.bsic = BSIC;
1021        cellinfo.cellIdentityGsm.arfcn = ARFCN;
1022        cellinfo.cellIdentityGsm.mcc = MCC_STR;
1023        cellinfo.cellIdentityGsm.mnc = MNC_STR;
1024        cellinfo.signalStrengthGsm.signalStrength = SIGNAL_STRENGTH;
1025        cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE;
1026        cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE;
1027        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
1028        record.cellInfoType = TYPE_GSM;
1029        record.registered = false;
1030        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1031        record.timeStamp = TIMESTAMP;
1032        record.gsm.add(cellinfo);
1033        ArrayList<android.hardware.radio.V1_0.CellInfo> records =
1034                new ArrayList<android.hardware.radio.V1_0.CellInfo>();
1035        records.add(record);
1036
1037        ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records);
1038
1039        assertEquals(1, ret.size());
1040        CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
1041        CellInfoGsm expected = new CellInfoGsm();
1042        expected.setRegistered(false);
1043        expected.setTimeStamp(TIMESTAMP);
1044        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1045        CellIdentityGsm ci = new CellIdentityGsm(
1046                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1047        CellSignalStrengthGsm cs = new CellSignalStrengthGsm();
1048        cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE);
1049        expected.setCellIdentity(ci);
1050        expected.setCellSignalStrength(cs);
1051        assertEquals(expected, cellInfoGsm);
1052    }
1053
1054    @Test
1055    public void testConvertHalCellInfoListForWcdma() throws Exception {
1056        android.hardware.radio.V1_0.CellInfoWcdma cellinfo =
1057                new android.hardware.radio.V1_0.CellInfoWcdma();
1058        cellinfo.cellIdentityWcdma.lac = LAC;
1059        cellinfo.cellIdentityWcdma.cid = CID;
1060        cellinfo.cellIdentityWcdma.psc = PSC;
1061        cellinfo.cellIdentityWcdma.uarfcn = UARFCN;
1062        cellinfo.cellIdentityWcdma.mcc = MCC_STR;
1063        cellinfo.cellIdentityWcdma.mnc = MNC_STR;
1064        cellinfo.signalStrengthWcdma.signalStrength = SIGNAL_STRENGTH;
1065        cellinfo.signalStrengthWcdma.bitErrorRate = BIT_ERROR_RATE;
1066        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
1067        record.cellInfoType = TYPE_WCDMA;
1068        record.registered = false;
1069        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1070        record.timeStamp = TIMESTAMP;
1071        record.wcdma.add(cellinfo);
1072        ArrayList<android.hardware.radio.V1_0.CellInfo> records =
1073                new ArrayList<android.hardware.radio.V1_0.CellInfo>();
1074        records.add(record);
1075
1076        ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records);
1077
1078        assertEquals(1, ret.size());
1079        CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
1080        CellInfoWcdma expected = new CellInfoWcdma();
1081        expected.setRegistered(false);
1082        expected.setTimeStamp(TIMESTAMP);
1083        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1084        CellIdentityWcdma ci = new CellIdentityWcdma(
1085                LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1086        CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE);
1087        expected.setCellIdentity(ci);
1088        expected.setCellSignalStrength(cs);
1089        assertEquals(expected, cellInfoWcdma);
1090    }
1091
1092    @Test
1093    public void testConvertHalCellInfoListForCdma() throws Exception {
1094        android.hardware.radio.V1_0.CellInfoCdma cellinfo =
1095                new android.hardware.radio.V1_0.CellInfoCdma();
1096        cellinfo.cellIdentityCdma.networkId = NETWORK_ID;
1097        cellinfo.cellIdentityCdma.systemId = SYSTEM_ID;
1098        cellinfo.cellIdentityCdma.baseStationId = BASESTATION_ID;
1099        cellinfo.cellIdentityCdma.longitude = LONGITUDE;
1100        cellinfo.cellIdentityCdma.latitude = LATITUDE;
1101        cellinfo.signalStrengthCdma.dbm = DBM;
1102        cellinfo.signalStrengthCdma.ecio = ECIO;
1103        cellinfo.signalStrengthEvdo.dbm = DBM;
1104        cellinfo.signalStrengthEvdo.ecio = ECIO;
1105        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO;
1106        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
1107        record.cellInfoType = TYPE_CDMA;
1108        record.registered = false;
1109        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1110        record.timeStamp = TIMESTAMP;
1111        record.cdma.add(cellinfo);
1112        ArrayList<android.hardware.radio.V1_0.CellInfo> records =
1113                new ArrayList<android.hardware.radio.V1_0.CellInfo>();
1114        records.add(record);
1115
1116        ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records);
1117
1118        assertEquals(1, ret.size());
1119        CellInfoCdma cellInfoCdma = (CellInfoCdma) ret.get(0);
1120        CellInfoCdma expected = new CellInfoCdma();
1121        expected.setRegistered(false);
1122        expected.setTimeStamp(TIMESTAMP);
1123        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1124        CellIdentityCdma ci = new CellIdentityCdma(
1125                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
1126                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1127        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
1128                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
1129        expected.setCellIdentity(ci);
1130        expected.setCellSignalStrength(cs);
1131        assertEquals(expected, cellInfoCdma);
1132    }
1133
1134    @Test
1135    public void testConvertHalCellInfoList_1_2ForLTE() throws Exception {
1136        ArrayList<CellInfo> ret = getCellInfoListForLTE(MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1137
1138        assertEquals(1, ret.size());
1139        CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0);
1140        CellInfoLte expected = new CellInfoLte();
1141        expected.setRegistered(false);
1142        expected.setTimeStamp(TIMESTAMP);
1143        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1144        CellIdentityLte cil = new CellIdentityLte(
1145                CI, PCI, TAC, EARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1146        CellSignalStrengthLte css = new CellSignalStrengthLte(
1147                SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE);
1148        expected.setCellIdentity(cil);
1149        expected.setCellSignalStrength(css);
1150        assertEquals(expected, cellInfoLte);
1151    }
1152
1153    @Test
1154    public void testConvertHalCellInfoList_1_2_ForLTEWithEmptyOperatorInfo() throws Exception {
1155        ArrayList<CellInfo> ret = getCellInfoListForLTE(
1156                MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1157
1158        assertEquals(1, ret.size());
1159        CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0);
1160        CellInfoLte expected = new CellInfoLte();
1161        expected.setRegistered(false);
1162        expected.setTimeStamp(TIMESTAMP);
1163        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1164        CellIdentityLte cil = new CellIdentityLte(
1165                CI, PCI, TAC, EARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1166        CellSignalStrengthLte css = new CellSignalStrengthLte(
1167                SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE);
1168        expected.setCellIdentity(cil);
1169        expected.setCellSignalStrength(css);
1170        assertEquals(expected, cellInfoLte);
1171    }
1172
1173    @Test
1174    public void testConvertHalCellInfoList_1_2ForLTEWithEmptyMccMnc() throws Exception {
1175        // MCC/MNC will be set as INT_MAX if unknown
1176        ArrayList<CellInfo> ret = getCellInfoListForLTE(
1177                String.valueOf(Integer.MAX_VALUE), String.valueOf(Integer.MAX_VALUE),
1178                ALPHA_LONG, ALPHA_SHORT);
1179
1180        assertEquals(1, ret.size());
1181        CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0);
1182        CellInfoLte expected = new CellInfoLte();
1183        expected.setRegistered(false);
1184        expected.setTimeStamp(TIMESTAMP);
1185        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1186        CellIdentityLte cil = new CellIdentityLte(
1187                CI, PCI, TAC, EARFCN, null, null, ALPHA_LONG, ALPHA_SHORT);
1188        CellSignalStrengthLte css = new CellSignalStrengthLte(
1189                SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE);
1190        expected.setCellIdentity(cil);
1191        expected.setCellSignalStrength(css);
1192        assertEquals(expected, cellInfoLte);
1193    }
1194
1195    @Test
1196    public void testConvertHalCellInfoList_1_2ForGSM() throws Exception {
1197        ArrayList<CellInfo> ret = getCellInfoListForGSM(MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1198
1199        assertEquals(1, ret.size());
1200        CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
1201        CellInfoGsm expected = new CellInfoGsm();
1202        expected.setRegistered(false);
1203        expected.setTimeStamp(TIMESTAMP);
1204        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1205        CellIdentityGsm ci = new CellIdentityGsm(
1206                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1207        CellSignalStrengthGsm cs = new CellSignalStrengthGsm();
1208        cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE);
1209        expected.setCellIdentity(ci);
1210        expected.setCellSignalStrength(cs);
1211        assertEquals(expected, cellInfoGsm);
1212    }
1213
1214    @Test
1215    public void testConvertHalCellInfoList_1_2ForGSMWithEmptyOperatorInfo() throws Exception {
1216        ArrayList<CellInfo> ret = getCellInfoListForGSM(
1217                MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1218
1219        assertEquals(1, ret.size());
1220        CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
1221        CellInfoGsm expected = new CellInfoGsm();
1222        expected.setRegistered(false);
1223        expected.setTimeStamp(TIMESTAMP);
1224        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1225        CellIdentityGsm ci = new CellIdentityGsm(
1226                LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1227        CellSignalStrengthGsm cs = new CellSignalStrengthGsm();
1228        cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE);
1229        expected.setCellIdentity(ci);
1230        expected.setCellSignalStrength(cs);
1231        assertEquals(expected, cellInfoGsm);
1232    }
1233
1234    @Test
1235    public void testConvertHalCellInfoList_1_2ForGSMWithEmptyMccMnc() throws Exception {
1236        // MCC/MNC will be set as INT_MAX if unknown
1237        ArrayList<CellInfo> ret = getCellInfoListForGSM(
1238                String.valueOf(Integer.MAX_VALUE), String.valueOf(Integer.MAX_VALUE),
1239                ALPHA_LONG, ALPHA_SHORT);
1240
1241        assertEquals(1, ret.size());
1242        CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
1243        CellInfoGsm expected = new CellInfoGsm();
1244        expected.setRegistered(false);
1245        expected.setTimeStamp(TIMESTAMP);
1246        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1247        CellIdentityGsm ci = new CellIdentityGsm(
1248                LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT);
1249        CellSignalStrengthGsm cs = new CellSignalStrengthGsm();
1250        cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE);
1251        expected.setCellIdentity(ci);
1252        expected.setCellSignalStrength(cs);
1253        assertEquals(expected, cellInfoGsm);
1254    }
1255
1256    @Test
1257    public void testConvertHalCellInfoList_1_2ForWcdma() throws Exception {
1258        ArrayList<CellInfo> ret = getCellInfoListForWcdma(
1259                MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1260
1261        assertEquals(1, ret.size());
1262        CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
1263        CellInfoWcdma expected = new CellInfoWcdma();
1264        expected.setRegistered(false);
1265        expected.setTimeStamp(TIMESTAMP);
1266        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1267        CellIdentityWcdma ci = new CellIdentityWcdma(
1268                LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT);
1269        CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE);
1270        expected.setCellIdentity(ci);
1271        expected.setCellSignalStrength(cs);
1272        assertEquals(expected, cellInfoWcdma);
1273    }
1274
1275    @Test
1276    public void testConvertHalCellInfoList_1_2ForWcdmaWithEmptyOperatorInfo() throws Exception {
1277        ArrayList<CellInfo> ret = getCellInfoListForWcdma(
1278                MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1279
1280        assertEquals(1, ret.size());
1281        CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
1282        CellInfoWcdma expected = new CellInfoWcdma();
1283        expected.setRegistered(false);
1284        expected.setTimeStamp(TIMESTAMP);
1285        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1286        CellIdentityWcdma ci = new CellIdentityWcdma(
1287                LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1288        CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE);
1289        expected.setCellIdentity(ci);
1290        expected.setCellSignalStrength(cs);
1291        assertEquals(expected, cellInfoWcdma);
1292    }
1293
1294    @Test
1295    public void testConvertHalCellInfoList_1_2ForWcdmaWithEmptyMccMnc() throws Exception {
1296        // MCC/MNC will be set as INT_MAX if unknown
1297        ArrayList<CellInfo> ret = getCellInfoListForWcdma(
1298                String.valueOf(Integer.MAX_VALUE), String.valueOf(Integer.MAX_VALUE),
1299                ALPHA_LONG, ALPHA_SHORT);
1300
1301        assertEquals(1, ret.size());
1302        CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0);
1303        CellInfoWcdma expected = new CellInfoWcdma();
1304        expected.setRegistered(false);
1305        expected.setTimeStamp(TIMESTAMP);
1306        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1307        CellIdentityWcdma ci = new CellIdentityWcdma(
1308                LAC, CID, PSC, UARFCN, null, null, ALPHA_LONG, ALPHA_SHORT);
1309        CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE);
1310        expected.setCellIdentity(ci);
1311        expected.setCellSignalStrength(cs);
1312        assertEquals(expected, cellInfoWcdma);
1313    }
1314
1315    @Test
1316    public void testConvertHalCellInfoList_1_2ForCdma() throws Exception {
1317        ArrayList<CellInfo> ret = getCellInfoListForCdma(ALPHA_LONG, ALPHA_SHORT);
1318
1319        assertEquals(1, ret.size());
1320        CellInfoCdma cellInfoCdma = (CellInfoCdma) ret.get(0);
1321        CellInfoCdma expected = new CellInfoCdma();
1322        expected.setRegistered(false);
1323        expected.setTimeStamp(TIMESTAMP);
1324        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1325        CellIdentityCdma ci = new CellIdentityCdma(
1326                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
1327                ALPHA_LONG, ALPHA_SHORT);
1328        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
1329                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
1330        expected.setCellIdentity(ci);
1331        expected.setCellSignalStrength(cs);
1332        assertEquals(expected, cellInfoCdma);
1333    }
1334
1335    @Test
1336    public void testConvertHalCellInfoList_1_2ForCdmaWithEmptyOperatorInfd() throws Exception {
1337        ArrayList<CellInfo> ret = getCellInfoListForCdma(EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1338
1339        assertEquals(1, ret.size());
1340        CellInfoCdma cellInfoCdma = (CellInfoCdma) ret.get(0);
1341        CellInfoCdma expected = new CellInfoCdma();
1342        expected.setRegistered(false);
1343        expected.setTimeStamp(TIMESTAMP);
1344        expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL);
1345        CellIdentityCdma ci = new CellIdentityCdma(
1346                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
1347                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
1348        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
1349                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
1350        expected.setCellIdentity(ci);
1351        expected.setCellSignalStrength(cs);
1352        assertEquals(expected, cellInfoCdma);
1353    }
1354
1355    private ArrayList<CellInfo> getCellInfoListForLTE(
1356            String mcc, String mnc, String alphaLong, String alphaShort) {
1357        android.hardware.radio.V1_2.CellInfoLte lte = new android.hardware.radio.V1_2.CellInfoLte();
1358        lte.cellIdentityLte.base.ci = CI;
1359        lte.cellIdentityLte.base.pci = PCI;
1360        lte.cellIdentityLte.base.tac = TAC;
1361        lte.cellIdentityLte.base.earfcn = EARFCN;
1362        lte.cellIdentityLte.base.mcc = mcc;
1363        lte.cellIdentityLte.base.mnc = mnc;
1364        lte.cellIdentityLte.operatorNames.alphaLong = alphaLong;
1365        lte.cellIdentityLte.operatorNames.alphaShort = alphaShort;
1366        lte.signalStrengthLte.signalStrength = SIGNAL_STRENGTH;
1367        lte.signalStrengthLte.rsrp = RSRP;
1368        lte.signalStrengthLte.rsrq = RSRQ;
1369        lte.signalStrengthLte.rssnr = RSSNR;
1370        lte.signalStrengthLte.cqi = CQI;
1371        lte.signalStrengthLte.timingAdvance = TIME_ADVANCE;
1372        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
1373        record.cellInfoType = TYPE_LTE;
1374        record.registered = false;
1375        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1376        record.timeStamp = TIMESTAMP;
1377        record.lte.add(lte);
1378        ArrayList<android.hardware.radio.V1_2.CellInfo> records =
1379                new ArrayList<android.hardware.radio.V1_2.CellInfo>();
1380        records.add(record);
1381        return RIL.convertHalCellInfoList_1_2(records);
1382    }
1383
1384    private ArrayList<CellInfo> getCellInfoListForGSM(
1385            String mcc, String mnc, String alphaLong, String alphaShort) {
1386        android.hardware.radio.V1_2.CellInfoGsm cellinfo =
1387                new android.hardware.radio.V1_2.CellInfoGsm();
1388        cellinfo.cellIdentityGsm.base.lac = LAC;
1389        cellinfo.cellIdentityGsm.base.cid = CID;
1390        cellinfo.cellIdentityGsm.base.bsic = BSIC;
1391        cellinfo.cellIdentityGsm.base.arfcn = ARFCN;
1392        cellinfo.cellIdentityGsm.base.mcc = mcc;
1393        cellinfo.cellIdentityGsm.base.mnc = mnc;
1394        cellinfo.cellIdentityGsm.operatorNames.alphaLong = alphaLong;
1395        cellinfo.cellIdentityGsm.operatorNames.alphaShort = alphaShort;
1396        cellinfo.signalStrengthGsm.signalStrength = SIGNAL_STRENGTH;
1397        cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE;
1398        cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE;
1399        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
1400        record.cellInfoType = TYPE_GSM;
1401        record.registered = false;
1402        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1403        record.timeStamp = TIMESTAMP;
1404        record.gsm.add(cellinfo);
1405        ArrayList<android.hardware.radio.V1_2.CellInfo> records =
1406                new ArrayList<android.hardware.radio.V1_2.CellInfo>();
1407        records.add(record);
1408
1409        return RIL.convertHalCellInfoList_1_2(records);
1410    }
1411
1412    private ArrayList<CellInfo> getCellInfoListForWcdma(
1413            String mcc, String mnc, String alphaLong, String alphaShort) {
1414        android.hardware.radio.V1_2.CellInfoWcdma cellinfo =
1415                new android.hardware.radio.V1_2.CellInfoWcdma();
1416        cellinfo.cellIdentityWcdma.base.lac = LAC;
1417        cellinfo.cellIdentityWcdma.base.cid = CID;
1418        cellinfo.cellIdentityWcdma.base.psc = PSC;
1419        cellinfo.cellIdentityWcdma.base.uarfcn = UARFCN;
1420        cellinfo.cellIdentityWcdma.base.mcc = mcc;
1421        cellinfo.cellIdentityWcdma.base.mnc = mnc;
1422        cellinfo.cellIdentityWcdma.operatorNames.alphaLong = alphaLong;
1423        cellinfo.cellIdentityWcdma.operatorNames.alphaShort = alphaShort;
1424        cellinfo.signalStrengthWcdma.signalStrength = SIGNAL_STRENGTH;
1425        cellinfo.signalStrengthWcdma.bitErrorRate = BIT_ERROR_RATE;
1426        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
1427        record.cellInfoType = TYPE_WCDMA;
1428        record.registered = false;
1429        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1430        record.timeStamp = TIMESTAMP;
1431        record.wcdma.add(cellinfo);
1432        ArrayList<android.hardware.radio.V1_2.CellInfo> records =
1433                new ArrayList<android.hardware.radio.V1_2.CellInfo>();
1434        records.add(record);
1435
1436        return RIL.convertHalCellInfoList_1_2(records);
1437    }
1438
1439    private ArrayList<CellInfo> getCellInfoListForCdma(String alphaLong, String alphaShort) {
1440        android.hardware.radio.V1_2.CellInfoCdma cellinfo =
1441                new android.hardware.radio.V1_2.CellInfoCdma();
1442        cellinfo.cellIdentityCdma.base.networkId = NETWORK_ID;
1443        cellinfo.cellIdentityCdma.base.systemId = SYSTEM_ID;
1444        cellinfo.cellIdentityCdma.base.baseStationId = BASESTATION_ID;
1445        cellinfo.cellIdentityCdma.base.longitude = LONGITUDE;
1446        cellinfo.cellIdentityCdma.base.latitude = LATITUDE;
1447        cellinfo.cellIdentityCdma.operatorNames.alphaLong = alphaLong;
1448        cellinfo.cellIdentityCdma.operatorNames.alphaShort = alphaShort;
1449        cellinfo.signalStrengthCdma.dbm = DBM;
1450        cellinfo.signalStrengthCdma.ecio = ECIO;
1451        cellinfo.signalStrengthEvdo.dbm = DBM;
1452        cellinfo.signalStrengthEvdo.ecio = ECIO;
1453        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO;
1454        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
1455        record.cellInfoType = TYPE_CDMA;
1456        record.registered = false;
1457        record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL;
1458        record.timeStamp = TIMESTAMP;
1459        record.cdma.add(cellinfo);
1460        ArrayList<android.hardware.radio.V1_2.CellInfo> records =
1461                new ArrayList<android.hardware.radio.V1_2.CellInfo>();
1462        records.add(record);
1463
1464        return RIL.convertHalCellInfoList_1_2(records);
1465    }
1466}
1467