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