Home | History | Annotate | Download | only in policy
      1 /*
      2  * Copyright (C) 2015 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 package com.android.systemui.statusbar.policy;
     17 
     18 import android.content.Intent;
     19 import android.net.ConnectivityManager;
     20 import android.net.NetworkCapabilities;
     21 import android.os.Looper;
     22 import android.support.test.runner.AndroidJUnit4;
     23 import android.telephony.ServiceState;
     24 import android.telephony.SignalStrength;
     25 import android.telephony.SubscriptionInfo;
     26 import android.telephony.TelephonyManager;
     27 import android.test.suitebuilder.annotation.SmallTest;
     28 
     29 import com.android.internal.telephony.PhoneConstants;
     30 import com.android.internal.telephony.TelephonyIntents;
     31 import com.android.settingslib.net.DataUsageController;
     32 import com.android.systemui.R;
     33 import com.android.systemui.statusbar.phone.SignalDrawable;
     34 
     35 import org.junit.Ignore;
     36 import org.junit.Test;
     37 import org.junit.runner.RunWith;
     38 import org.mockito.ArgumentCaptor;
     39 import org.mockito.Mockito;
     40 
     41 import java.util.ArrayList;
     42 import java.util.List;
     43 
     44 import static junit.framework.Assert.assertEquals;
     45 import static junit.framework.Assert.assertTrue;
     46 import static junit.framework.Assert.assertFalse;
     47 import static org.mockito.Mockito.mock;
     48 
     49 @SmallTest
     50 @RunWith(AndroidJUnit4.class)
     51 public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
     52 
     53     @Test
     54     @Ignore("Flaky")
     55     public void testNoIconWithoutMobile() {
     56         // Turn off mobile network support.
     57         Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
     58         // Create a new NetworkController as this is currently handled in constructor.
     59         mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
     60                 mConfig, Looper.getMainLooper(), mCallbackHandler,
     61                 mock(AccessPointControllerImpl.class), mock(DataUsageController.class),
     62                 mMockSubDefaults, mock(DeviceProvisionedController.class));
     63         setupNetworkController();
     64 
     65         verifyLastMobileDataIndicators(false, -1, 0);
     66     }
     67 
     68     @Test
     69     @Ignore("Flaky")
     70     public void testNoSimsIconPresent() {
     71         // No Subscriptions.
     72         mNetworkController.mMobileSignalControllers.clear();
     73         mNetworkController.updateNoSims();
     74 
     75         verifyHasNoSims(true);
     76     }
     77 
     78     @Test
     79     @Ignore("Flaky")
     80     public void testEmergencyOnly() {
     81         setupDefaultSignal();
     82         mNetworkController.recalculateEmergency();
     83         verifyEmergencyOnly(false);
     84 
     85         mMobileSignalController.getState().isEmergency = true;
     86         mNetworkController.recalculateEmergency();
     87         verifyEmergencyOnly(true);
     88     }
     89 
     90     @Test
     91     @Ignore("Flaky")
     92     public void testEmergencyOnlyNoSubscriptions() {
     93         setupDefaultSignal();
     94         setSubscriptions();
     95         mNetworkController.mLastServiceState = new ServiceState();
     96         mNetworkController.mLastServiceState.setEmergencyOnly(true);
     97         mNetworkController.recalculateEmergency();
     98         verifyEmergencyOnly(true);
     99     }
    100 
    101     @Test
    102     @Ignore("Flaky")
    103     public void testNoEmergencyOnlyWrongSubscription() {
    104         setupDefaultSignal();
    105         setDefaultSubId(42);
    106         mNetworkController.recalculateEmergency();
    107         verifyEmergencyOnly(false);
    108     }
    109 
    110     @Test
    111     @Ignore("Flaky")
    112     public void testNoEmengencyNoSubscriptions() {
    113         setupDefaultSignal();
    114         setSubscriptions();
    115         mNetworkController.mLastServiceState = new ServiceState();
    116         mNetworkController.mLastServiceState.setEmergencyOnly(false);
    117         mNetworkController.recalculateEmergency();
    118         verifyEmergencyOnly(false);
    119     }
    120 
    121     @Test
    122     @Ignore("Flaky")
    123     public void testNoSimlessIconWithoutMobile() {
    124         // Turn off mobile network support.
    125         Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
    126         // Create a new NetworkController as this is currently handled in constructor.
    127         mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
    128                 mConfig, Looper.getMainLooper(), mCallbackHandler,
    129                 mock(AccessPointControllerImpl.class), mock(DataUsageController.class),
    130                 mMockSubDefaults, mock(DeviceProvisionedController.class));
    131         setupNetworkController();
    132 
    133         // No Subscriptions.
    134         mNetworkController.mMobileSignalControllers.clear();
    135         mNetworkController.updateNoSims();
    136 
    137         verifyHasNoSims(false);
    138     }
    139 
    140     @Test
    141     @Ignore("Flaky")
    142     public void testSignalStrength() {
    143         for (int testStrength = 0;
    144                 testStrength < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; testStrength++) {
    145             setupDefaultSignal();
    146             setLevel(testStrength);
    147 
    148             verifyLastMobileDataIndicators(true,
    149                     testStrength, DEFAULT_ICON);
    150 
    151             // Verify low inet number indexing.
    152             setConnectivity(NetworkCapabilities.TRANSPORT_CELLULAR, false, true);
    153             verifyLastMobileDataIndicators(true,
    154                     testStrength, DEFAULT_ICON, false, false);
    155         }
    156     }
    157 
    158     @Test
    159     @Ignore("Flaky")
    160     public void testCdmaSignalStrength() {
    161         for (int testStrength = 0;
    162                 testStrength < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; testStrength++) {
    163             setupDefaultSignal();
    164             setCdma();
    165             setLevel(testStrength);
    166 
    167             verifyLastMobileDataIndicators(true,
    168                     testStrength,
    169                     TelephonyIcons.ICON_1X);
    170         }
    171     }
    172 
    173     @Test
    174     @Ignore("Flaky")
    175     public void testSignalRoaming() {
    176         for (int testStrength = 0;
    177                 testStrength < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; testStrength++) {
    178             setupDefaultSignal();
    179             setGsmRoaming(true);
    180             setLevel(testStrength);
    181 
    182             verifyLastMobileDataIndicators(true,
    183                     testStrength,
    184                     DEFAULT_ICON, true);
    185         }
    186     }
    187 
    188     @Test
    189     @Ignore("Flaky")
    190     public void testCdmaSignalRoaming() {
    191         for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
    192                 testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
    193             setupDefaultSignal();
    194             setCdma();
    195             setCdmaRoaming(true);
    196             setLevel(testStrength);
    197 
    198             verifyLastMobileDataIndicators(true,
    199                     testStrength,
    200                     TelephonyIcons.ICON_1X, true);
    201         }
    202     }
    203 
    204     @Test
    205     public void testRoamingNoService_DoesNotCrash() {
    206         setupDefaultSignal();
    207         setCdma();
    208         mServiceState = null;
    209         updateServiceState();
    210     }
    211 
    212     @Test
    213     @Ignore("Flaky")
    214     public void testQsSignalStrength() {
    215         for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
    216                 testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
    217             setupDefaultSignal();
    218             setLevel(testStrength);
    219 
    220             verifyLastQsMobileDataIndicators(true,
    221                     testStrength,
    222                     DEFAULT_QS_ICON, false, false);
    223         }
    224     }
    225 
    226     @Test
    227     @Ignore("Flaky")
    228     public void testCdmaQsSignalStrength() {
    229         for (int testStrength = SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
    230                 testStrength <= SignalStrength.SIGNAL_STRENGTH_GREAT; testStrength++) {
    231             setupDefaultSignal();
    232             setCdma();
    233             setLevel(testStrength);
    234 
    235             verifyLastQsMobileDataIndicators(true,
    236                     testStrength,
    237                     TelephonyIcons.QS_DATA_1X, false, false);
    238         }
    239     }
    240 
    241     @Test
    242     @Ignore("Flaky")
    243     public void testNoBangWithWifi() {
    244         setupDefaultSignal();
    245         setConnectivity(mMobileSignalController.mTransportType, false, false);
    246         setConnectivity(NetworkCapabilities.TRANSPORT_WIFI, true, true);
    247 
    248         verifyLastMobileDataIndicators(true, DEFAULT_LEVEL, 0);
    249     }
    250 
    251     // Some tests of actual NetworkController code, just internals not display stuff
    252     // TODO: Put this somewhere else, maybe in its own file.
    253     @Test
    254     @Ignore("Flaky")
    255     public void testHasCorrectMobileControllers() {
    256         int[] testSubscriptions = new int[] { 1, 5, 3 };
    257         int notTestSubscription = 0;
    258         MobileSignalController mobileSignalController = Mockito.mock(MobileSignalController.class);
    259 
    260         mNetworkController.mMobileSignalControllers.clear();
    261         List<SubscriptionInfo> subscriptions = new ArrayList<>();
    262         for (int i = 0; i < testSubscriptions.length; i++) {
    263             // Force the test controllers into NetworkController.
    264             mNetworkController.mMobileSignalControllers.put(testSubscriptions[i],
    265                     mobileSignalController);
    266 
    267             // Generate a list of subscriptions we will tell the NetworkController to use.
    268             SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
    269             Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
    270             subscriptions.add(mockSubInfo);
    271         }
    272         assertTrue(mNetworkController.hasCorrectMobileControllers(subscriptions));
    273 
    274         // Add a subscription that the NetworkController doesn't know about.
    275         SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
    276         Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(notTestSubscription);
    277         subscriptions.add(mockSubInfo);
    278         assertFalse(mNetworkController.hasCorrectMobileControllers(subscriptions));
    279     }
    280 
    281     @Test
    282     @Ignore("Flaky")
    283     public void testSetCurrentSubscriptions() {
    284         // We will not add one controller to make sure it gets created.
    285         int indexToSkipController = 0;
    286         // We will not add one subscription to make sure it's controller gets removed.
    287         int indexToSkipSubscription = 1;
    288 
    289         int[] testSubscriptions = new int[] { 1, 5, 3 };
    290         MobileSignalController[] mobileSignalControllers = new MobileSignalController[] {
    291                 Mockito.mock(MobileSignalController.class),
    292                 Mockito.mock(MobileSignalController.class),
    293                 Mockito.mock(MobileSignalController.class),
    294         };
    295         mNetworkController.mMobileSignalControllers.clear();
    296         List<SubscriptionInfo> subscriptions = new ArrayList<>();
    297         for (int i = 0; i < testSubscriptions.length; i++) {
    298             if (i != indexToSkipController) {
    299                 // Force the test controllers into NetworkController.
    300                 mNetworkController.mMobileSignalControllers.put(testSubscriptions[i],
    301                         mobileSignalControllers[i]);
    302             }
    303 
    304             if (i != indexToSkipSubscription) {
    305                 // Generate a list of subscriptions we will tell the NetworkController to use.
    306                 SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
    307                 Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
    308                 Mockito.when(mockSubInfo.getSimSlotIndex()).thenReturn(testSubscriptions[i]);
    309                 subscriptions.add(mockSubInfo);
    310             }
    311         }
    312 
    313         // We can only test whether unregister gets called if it thinks its in a listening
    314         // state.
    315         mNetworkController.mListening = true;
    316         mNetworkController.setCurrentSubscriptions(subscriptions);
    317 
    318         for (int i = 0; i < testSubscriptions.length; i++) {
    319             if (i == indexToSkipController) {
    320                 // Make sure a controller was created despite us not adding one.
    321                 assertTrue(mNetworkController.mMobileSignalControllers.indexOfKey(
    322                         testSubscriptions[i]) >= 0);
    323             } else if (i == indexToSkipSubscription) {
    324                 // Make sure the controller that did exist was removed
    325                 assertFalse(mNetworkController.mMobileSignalControllers.indexOfKey(
    326                         testSubscriptions[i]) >= 0);
    327             } else {
    328                 // If a MobileSignalController is around it needs to not be unregistered.
    329                 Mockito.verify(mobileSignalControllers[i], Mockito.never())
    330                         .unregisterListener();
    331             }
    332         }
    333     }
    334 
    335     @Test
    336     @Ignore("Flaky")
    337     public void testHistorySize() {
    338         // Verify valid history size, otherwise it gits printed out the wrong order and whatnot.
    339         assertEquals(0, SignalController.HISTORY_SIZE & (SignalController.HISTORY_SIZE - 1));
    340     }
    341 
    342     private void setCdma() {
    343         setIsGsm(false);
    344         updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
    345                 TelephonyManager.NETWORK_TYPE_CDMA);
    346         setCdmaRoaming(false);
    347     }
    348 
    349     @Test
    350     @Ignore("Flaky")
    351     public void testOnReceive_stringsUpdatedAction_spn() {
    352         String expectedMNetworkName = "Test";
    353         Intent intent = createStringsUpdatedIntent(true /* showSpn */,
    354                 expectedMNetworkName /* spn */,
    355                 false /* showPlmn */,
    356                 "NotTest" /* plmn */);
    357 
    358         mNetworkController.onReceive(mContext, intent);
    359 
    360         assertNetworkNameEquals(expectedMNetworkName);
    361     }
    362 
    363     @Test
    364     @Ignore("Flaky")
    365     public void testOnReceive_stringsUpdatedAction_plmn() {
    366         String expectedMNetworkName = "Test";
    367 
    368         Intent intent = createStringsUpdatedIntent(false /* showSpn */,
    369                 "NotTest" /* spn */,
    370                 true /* showPlmn */,
    371                 expectedMNetworkName /* plmn */);
    372 
    373         mNetworkController.onReceive(mContext, intent);
    374 
    375         assertNetworkNameEquals(expectedMNetworkName);
    376     }
    377 
    378     @Test
    379     @Ignore("Flaky")
    380     public void testOnReceive_stringsUpdatedAction_bothFalse() {
    381         Intent intent = createStringsUpdatedIntent(false /* showSpn */,
    382               "Irrelevant" /* spn */,
    383               false /* showPlmn */,
    384               "Irrelevant" /* plmn */);
    385 
    386         mNetworkController.onReceive(mContext, intent);
    387 
    388         String defaultNetworkName = mMobileSignalController
    389             .getStringIfExists(
    390                 com.android.internal.R.string.lockscreen_carrier_default);
    391         assertNetworkNameEquals(defaultNetworkName);
    392     }
    393 
    394     @Test
    395     @Ignore("Flaky")
    396     public void testOnReceive_stringsUpdatedAction_bothTrueAndNull() {
    397         Intent intent = createStringsUpdatedIntent(true /* showSpn */,
    398             null /* spn */,
    399             true /* showPlmn */,
    400             null /* plmn */);
    401 
    402         mNetworkController.onReceive(mContext, intent);
    403 
    404         String defaultNetworkName = mMobileSignalController.getStringIfExists(
    405                 com.android.internal.R.string.lockscreen_carrier_default);
    406         assertNetworkNameEquals(defaultNetworkName);
    407     }
    408 
    409     @Test
    410     @Ignore("Flaky")
    411     public void testOnReceive_stringsUpdatedAction_bothTrueAndNonNull() {
    412         String spn = "Test1";
    413         String plmn = "Test2";
    414 
    415         Intent intent = createStringsUpdatedIntent(true /* showSpn */,
    416             spn /* spn */,
    417             true /* showPlmn */,
    418             plmn /* plmn */);
    419 
    420         mNetworkController.onReceive(mContext, intent);
    421 
    422         assertNetworkNameEquals(plmn
    423                 + mMobileSignalController.getStringIfExists(
    424                         R.string.status_bar_network_name_separator)
    425                 + spn);
    426     }
    427 
    428     private Intent createStringsUpdatedIntent(boolean showSpn, String spn,
    429             boolean showPlmn, String plmn) {
    430 
    431         Intent intent = new Intent();
    432         intent.setAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
    433 
    434         intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, showSpn);
    435         intent.putExtra(TelephonyIntents.EXTRA_SPN, spn);
    436 
    437         intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
    438         intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
    439         intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);
    440 
    441         return intent;
    442     }
    443 
    444     @Test
    445     @Ignore("Flaky")
    446     public void testOnUpdateDataActivity_dataIn() {
    447         setupDefaultSignal();
    448 
    449         updateDataActivity(TelephonyManager.DATA_ACTIVITY_IN);
    450 
    451         verifyLastQsMobileDataIndicators(true /* visible */,
    452                 DEFAULT_LEVEL /* icon */,
    453                 DEFAULT_QS_ICON /* typeIcon */,
    454                 true /* dataIn */,
    455                 false /* dataOut */);
    456 
    457     }
    458 
    459     @Test
    460     @Ignore("Flaky")
    461     public void testOnUpdateDataActivity_dataOut() {
    462       setupDefaultSignal();
    463 
    464       updateDataActivity(TelephonyManager.DATA_ACTIVITY_OUT);
    465 
    466       verifyLastQsMobileDataIndicators(true /* visible */,
    467               DEFAULT_LEVEL /* icon */,
    468               DEFAULT_QS_ICON /* typeIcon */,
    469               false /* dataIn */,
    470               true /* dataOut */);
    471     }
    472 
    473     @Test
    474     @Ignore("Flaky")
    475     public void testOnUpdateDataActivity_dataInOut() {
    476       setupDefaultSignal();
    477 
    478       updateDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
    479 
    480       verifyLastQsMobileDataIndicators(true /* visible */,
    481               DEFAULT_LEVEL /* icon */,
    482               DEFAULT_QS_ICON /* typeIcon */,
    483               true /* dataIn */,
    484               true /* dataOut */);
    485 
    486     }
    487 
    488     @Test
    489     @Ignore("Flaky")
    490     public void testOnUpdateDataActivity_dataActivityNone() {
    491       setupDefaultSignal();
    492 
    493       updateDataActivity(TelephonyManager.DATA_ACTIVITY_NONE);
    494 
    495       verifyLastQsMobileDataIndicators(true /* visible */,
    496               DEFAULT_LEVEL /* icon */,
    497               DEFAULT_QS_ICON /* typeIcon */,
    498               false /* dataIn */,
    499               false /* dataOut */);
    500 
    501     }
    502 
    503     @Test
    504     @Ignore("Flaky")
    505     public void testCarrierNetworkChange_carrierNetworkChange() {
    506       int strength = SignalStrength.SIGNAL_STRENGTH_GREAT;
    507 
    508       setupDefaultSignal();
    509       setLevel(strength);
    510 
    511       // Verify baseline
    512       verifyLastMobileDataIndicators(true /* visible */,
    513               strength /* strengthIcon */,
    514               DEFAULT_ICON /* typeIcon */);
    515 
    516       // API call is made
    517       setCarrierNetworkChange(true /* enabled */);
    518 
    519       // Carrier network change is true, show special indicator
    520       verifyLastMobileDataIndicators(true /* visible */,
    521               SignalDrawable.getCarrierChangeState(SignalStrength.NUM_SIGNAL_STRENGTH_BINS),
    522               0 /* typeIcon */);
    523 
    524       // Revert back
    525       setCarrierNetworkChange(false /* enabled */);
    526 
    527       // Verify back in previous state
    528       verifyLastMobileDataIndicators(true /* visible */,
    529               strength /* strengthIcon */,
    530               DEFAULT_ICON /* typeIcon */);
    531     }
    532 
    533     @Test
    534     @Ignore("Flaky")
    535     public void testCarrierNetworkChange_roamingBeforeNetworkChange() {
    536       int strength = SignalStrength.SIGNAL_STRENGTH_GREAT;
    537 
    538       setupDefaultSignal();
    539       setLevel(strength);
    540       setGsmRoaming(true);
    541 
    542       // Verify baseline
    543       verifyLastMobileDataIndicators(true /* visible */,
    544               strength /* strengthIcon */,
    545               DEFAULT_ICON /* typeIcon */,
    546               true /* roaming */);
    547 
    548       // API call is made
    549       setCarrierNetworkChange(true /* enabled */);
    550 
    551       // Carrier network change is true, show special indicator, no roaming.
    552       verifyLastMobileDataIndicators(true /* visible */,
    553               SignalDrawable.getCarrierChangeState(SignalStrength.NUM_SIGNAL_STRENGTH_BINS),
    554               0 /* typeIcon */,
    555               false /* roaming */);
    556 
    557       // Revert back
    558       setCarrierNetworkChange(false /* enabled */);
    559 
    560       // Verify back in previous state
    561       verifyLastMobileDataIndicators(true /* visible */,
    562               strength /* strengthIcon */,
    563               DEFAULT_ICON /* typeIcon */,
    564               true /* roaming */);
    565     }
    566 
    567     @Test
    568     @Ignore("Flaky")
    569     public void testCarrierNetworkChange_roamingAfterNetworkChange() {
    570       int strength = SignalStrength.SIGNAL_STRENGTH_GREAT;
    571 
    572       setupDefaultSignal();
    573       setLevel(strength);
    574 
    575       // Verify baseline
    576       verifyLastMobileDataIndicators(true /* visible */,
    577               strength /* strengthIcon */,
    578               DEFAULT_ICON /* typeIcon */,
    579               false /* roaming */);
    580 
    581       // API call is made
    582       setCarrierNetworkChange(true /* enabled */);
    583 
    584       // Carrier network change is true, show special indicator, no roaming.
    585       verifyLastMobileDataIndicators(true /* visible */,
    586               SignalDrawable.getCarrierChangeState(SignalStrength.NUM_SIGNAL_STRENGTH_BINS),
    587               0 /* typeIcon */,
    588               false /* roaming */);
    589 
    590       setGsmRoaming(true);
    591 
    592       // Roaming should not show.
    593       verifyLastMobileDataIndicators(true /* visible */,
    594               SignalDrawable.getCarrierChangeState(SignalStrength.NUM_SIGNAL_STRENGTH_BINS),
    595               0 /* typeIcon */,
    596               false /* roaming */);
    597 
    598       // Revert back
    599       setCarrierNetworkChange(false /* enabled */);
    600 
    601       // Verify back in previous state
    602       verifyLastMobileDataIndicators(true /* visible */,
    603               strength /* strengthIcon */,
    604               DEFAULT_ICON /* typeIcon */,
    605               true /* roaming */);
    606     }
    607 
    608     private void verifyEmergencyOnly(boolean isEmergencyOnly) {
    609         ArgumentCaptor<Boolean> emergencyOnly = ArgumentCaptor.forClass(Boolean.class);
    610         Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setEmergencyCallsOnly(
    611                 emergencyOnly.capture());
    612         assertEquals(isEmergencyOnly, (boolean) emergencyOnly.getValue());
    613     }
    614 }
    615