예제 #1
0
    def stress_test(self, setup_func=None, network_check_func=None, test_sms=False):
        if setup_func and not setup_func():
            self.log.error("Test setup %s failed", setup_func.__name__)
            return False
        fail_count = collections.defaultdict(int)
        for i in range(1, self.phone_call_iteration + 1):
            msg = "Stress Call Test %s Iteration: <%s> / <%s>" % (
                self.test_name, i, self.phone_call_iteration)
            self.log.info(msg)
            iteration_result = True
            ensure_phones_idle(self.log, self.android_devices)
            if not self._setup_phone_call():
                fail_count["dialing"] += 1
                iteration_result = False
                self.log.error("%s call dialing failure.", msg)

            if network_check_func and not network_check_func(self.log,
                                                             self.caller):
                fail_count["caller_network_check"] += 1
                iteration_result = False
                self.log.error("%s network check %s failure.", msg,
                               network_check_func.__name__)

            if network_check_func and not network_check_func(self.log,
                                                             self.callee):
                fail_count["callee_network_check"] += 1
                iteration_result = False
                self.log.error("%s network check failure.", msg)

            time.sleep(self.phone_call_duration)

            if not verify_incall_state(self.log, [self.caller, self.callee],
                                       True):
                self.log.error("%s call dropped.", msg)
                iteration_result = False
                fail_count["drop"] += 1

            self._hangup_call()

            if test_sms and not sms_send_receive_verify(
                    self.log, self.caller, self.callee, [rand_ascii_str(180)]):
                fail_count["sms"] += 1

            self.log.info("%s %s" % (msg, str(iteration_result)))
            if not iteration_result:
                self._take_bug_report("%s_%s" % (self.test_name, i), self.begin_time)

            if self.sleep_time_between_test_iterations:
                self.caller.droid.goToSleepNow()
                self.callee.droid.goToSleepNow()
                time.sleep(self.sleep_time_between_test_iterations)


        test_result = True
        for failure, count in fail_count.items():
            if count:
                self.log.error("%s: %s %s failures in %s iterations".format(
                    self.test_name, count, failure, self.phone_call_iteration))
                test_result = False
        return test_result
 def setup_test(self):
     ensure_phones_idle(self.log, self.android_devices)
     self.virtualPhoneHandle = self.anritsu.get_VirtualPhone()
     self.ad.droid.connectivityToggleAirplaneMode(True)
     self.ad.adb.shell("setprop net.lte.ims.volte.provisioned 1",
                       ignore_status=True)
     return True
 def setup_test(self):
     if getattr(self, "qxdm_log", True):
         start_qxdm_loggers(self.log, self.android_devices)
     ensure_phones_idle(self.log, self.android_devices)
     toggle_airplane_mode(self.log, self.ad, True)
     self.ad.adb.shell("logcat -c -b all", ignore_status=True)
     return True
예제 #4
0
 def _setup_phone_active_call_wfc(self,
                                  ad,
                                  ssid,
                                  password,
                                  airplane_mode,
                                  wfc_mode,
                                  setup_volte=False):
     if setup_volte and (not phone_setup_volte(self.log, ad)):
         self.log.error("Phone failed to setup VoLTE.")
         return False
     if not phone_setup_iwlan(self.log, ad, airplane_mode, wfc_mode, ssid,
                              password):
         self.log.error("DUT Failed to Set Up WiFi Calling")
         return False
     ensure_phones_idle(self.log, [ad, self.android_devices[1]])
     if not phone_idle_iwlan(self.log, ad):
         self.log.error("DUT not in WFC enabled state.")
         return False
     if not call_setup_teardown(self.log,
                                ad,
                                self.android_devices[1],
                                ad_hangup=None,
                                verify_caller_func=is_phone_in_call_iwlan):
         self.log.error("Setup Call failed.")
         return False
     ad.droid.goToSleepNow()
     return True
 def setup_test(self):
     if getattr(self, "qxdm_log", True):
         start_qxdm_loggers(self.log, self.android_devices)
     ensure_phones_idle(self.log, self.android_devices)
     toggle_airplane_mode(self.log, self.ad, True)
     self.ad.adb.shell("setprop net.lte.ims.volte.provisioned 1",
                       ignore_status=True)
     return True
    def setup_test(self):
        if getattr(self, "diag_logger", None):
            for logger in self.diag_logger:
                self.log.info("Starting a diagnostic session %s", logger)
                self.logger_sessions.append((logger, logger.start()))

        if self.skip_reset_between_cases:
            ensure_phones_idle(self.log, self.android_devices)
        ensure_phones_default_state(self.log, self.android_devices)
예제 #7
0
def two_phone_call_leave_voice_mail(
        log,
        caller,
        caller_idle_func,
        caller_in_call_check_func,
        callee,
        callee_idle_func,
        wait_time_in_call=WAIT_TIME_LEAVE_VOICE_MAIL):
    """Call from caller to callee, reject on callee, caller leave a voice mail.

    1. Caller call Callee.
    2. Callee reject incoming call.
    3. Caller leave a voice mail.
    4. Verify callee received the voice mail notification.

    Args:
        caller: caller android device object.
        caller_idle_func: function to check caller's idle state.
        caller_in_call_check_func: function to check caller's in-call state.
        callee: callee android device object.
        callee_idle_func: function to check callee's idle state.
        wait_time_in_call: time to wait when leaving a voice mail.
            This is optional, default is WAIT_TIME_LEAVE_VOICE_MAIL

    Returns:
        True: if voice message is received on callee successfully.
        False: for errors
    """

    ads = [caller, callee]

    # Make sure phones are idle.
    ensure_phones_idle(log, ads)
    if caller_idle_func and not caller_idle_func(log, caller):
        log.error("Caller Failed to Reselect")
        return False
    if callee_idle_func and not callee_idle_func(log, callee):
        log.error("Callee Failed to Reselect")
        return False

    # TODO: b/26337871 Need to use proper API to check phone registered.
    time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL)

    # Make call and leave a message.
    if not call_reject_leave_message(
            log, caller, callee, caller_in_call_check_func, wait_time_in_call):
        log.error("make a call and leave a message failed.")
        return False
    return True
def airplane_mode_test(log, ad):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        WifiUtils.wifi_toggle_state(log, ad, False)

        log.info("Step1: ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            log.error("Failed initial attach")
            return False
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            log.error("Failed to disable cell data connection")
            return False
        if verify_http_connection(log, ad):
            log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Failed to enable cell data connection")
            return False

        time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)

        log.info("Step4 verify internet")
        return verify_http_connection(log, ad)
    finally:
        toggle_airplane_mode(log, ad, False)
예제 #9
0
 def _setup_phone_active_call(self, ad, phone_setup_func,
                              phone_idle_check_func,
                              phone_in_call_check_func):
     if not phone_setup_func(self.log, ad):
         self.log.error("DUT Failed to Set Up Properly: {}".format(
             phone_setup_func.__name__))
         return False
     ensure_phones_idle(self.log, [ad, self.android_devices[1]])
     if not phone_idle_check_func(self.log, ad):
         self.log.error("DUT not in correct idle state: {}".format(
             phone_idle_check_func.__name__))
         return False
     if not call_setup_teardown(
             self.log,
             ad,
             self.android_devices[1],
             ad_hangup=None,
             verify_caller_func=phone_in_call_check_func):
         self.log.error("Setup Call failed.")
         return False
     ad.droid.goToSleepNow()
     return True
예제 #10
0
 def setup_test(self):
     ensure_phones_idle(self.log, self.android_devices)
     wputils.dut_rockbottom(self.ad)
     return True
    def setup_class(self):
        sim_conf_file = self.user_params.get("sim_conf_file")
        if not sim_conf_file:
            self.log.info("\"sim_conf_file\" is not provided test bed config!")
        else:
            # If the sim_conf_file is not a full path, attempt to find it
            # relative to the config file.
            if not os.path.isfile(sim_conf_file):
                sim_conf_file = os.path.join(
                    self.user_params[Config.key_config_path], sim_conf_file)
                if not os.path.isfile(sim_conf_file):
                    self.log.error("Unable to load user config %s ",
                                   sim_conf_file)
                    return False

        setattr(
            self, "diag_logger",
            self.register_controller(acts.controllers.diag_logger,
                                     required=False))

        if not self.user_params.get("Attenuator"):
            ensure_phones_default_state(self.log, self.android_devices)
        else:
            ensure_phones_idle(self.log, self.android_devices)
        for ad in self.android_devices:
            setup_droid_properties(self.log, ad, sim_conf_file)

            # Setup VoWiFi MDN for Verizon. b/33187374
            build_id = ad.build_info["build_id"]
            if "vzw" in [
                    sub["operator"] for sub in ad.cfg["subscription"].values()
            ] and ad.is_apk_installed("com.google.android.wfcactivation"):
                ad.log.info("setup VoWiFi MDN per b/33187374")
                ad.adb.shell("setprop dbg.vzw.force_wfc_nv_enabled true")
                ad.adb.shell("am start --ei EXTRA_LAUNCH_CARRIER_APP 0 -n "
                             "\"com.google.android.wfcactivation/"
                             ".VzwEmergencyAddressActivity\"")
            # Start telephony monitor
            if not ad.is_apk_running("com.google.telephonymonitor"):
                ad.log.info("TelephonyMonitor is not running, start it now")
                ad.adb.shell(
                    'am broadcast -a '
                    'com.google.gservices.intent.action.GSERVICES_OVERRIDE -e '
                    '"ce.telephony_monitor_enable" "true"')
            # Sub ID setup
            initial_set_up_for_subid_infomation(self.log, ad)
            if "enable_wifi_verbose_logging" in self.user_params:
                ad.droid.wifiEnableVerboseLogging(WIFI_VERBOSE_LOGGING_ENABLED)
            # If device is setup already, skip the following setup procedures
            if getattr(ad, "telephony_test_setup", None):
                continue
            # Disable Emergency alerts
            # Set chrome browser start with no-first-run verification and
            # disable-fre. Give permission to read from and write to storage.
            for cmd in (
                    "am start -n com.google.android.setupwizard/."
                    "SetupWizardExitActivity",
                    "pm disable com.android.cellbroadcastreceiver",
                    "pm grant com.android.chrome "
                    "android.permission.READ_EXTERNAL_STORAGE",
                    "pm grant com.android.chrome "
                    "android.permission.WRITE_EXTERNAL_STORAGE",
                    "rm /data/local/chrome-command-line",
                    "am set-debug-app --persistent com.android.chrome",
                    'echo "chrome --no-default-browser-check --no-first-run '
                    '--disable-fre" > /data/local/tmp/chrome-command-line'):
                ad.adb.shell(cmd)

            # Ensure that a test class starts from a consistent state that
            # improves chances of valid network selection and facilitates
            # logging.
            try:
                if not set_phone_screen_on(self.log, ad):
                    self.log.error("Failed to set phone screen-on time.")
                    return False
                if not set_phone_silent_mode(self.log, ad):
                    self.log.error("Failed to set phone silent mode.")
                    return False
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND, True)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING, True)
                ad.droid.telephonyAdjustPreciseCallStateListenLevel(
                    PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND, True)
            except Exception as e:
                self.log.error("Failure with %s", e)
            setattr(ad, "telephony_test_setup", True)

        return True
예제 #12
0
 def setup_test(self):
     if getattr(self, "qxdm_log", True):
         start_qxdm_loggers(self.log, self.android_devices)
     ensure_phones_idle(self.log, self.android_devices)
     toggle_airplane_mode(self.log, self.ad, True)
     return True
예제 #13
0
 def setup_test(self):
     ensure_phones_idle(self.log, self.android_devices)
     self.virtualPhoneHandle = self.anritsu.get_VirtualPhone()
     self.ad.droid.connectivityToggleAirplaneMode(True)
     return True
예제 #14
0
def two_phone_call_long_seq(log,
                            phone_a,
                            phone_a_idle_func,
                            phone_a_in_call_check_func,
                            phone_b,
                            phone_b_idle_func,
                            phone_b_in_call_check_func,
                            call_sequence_func=None,
                            wait_time_in_call=WAIT_TIME_IN_CALL):
    """Call process long sequence.
    1. Ensure phone idle and in idle_func check return True.
    2. Call from PhoneA to PhoneB, accept on PhoneB.
    3. Check phone state, hangup on PhoneA.
    4. Ensure phone idle and in idle_func check return True.
    5. Call from PhoneA to PhoneB, accept on PhoneB.
    6. Check phone state, hangup on PhoneB.
    7. Ensure phone idle and in idle_func check return True.
    8. Call from PhoneB to PhoneA, accept on PhoneA.
    9. Check phone state, hangup on PhoneA.
    10. Ensure phone idle and in idle_func check return True.
    11. Call from PhoneB to PhoneA, accept on PhoneA.
    12. Check phone state, hangup on PhoneB.

    Args:
        phone_a: PhoneA's android device object.
        phone_a_idle_func: function to check PhoneA's idle state.
        phone_a_in_call_check_func: function to check PhoneA's in-call state.
        phone_b: PhoneB's android device object.
        phone_b_idle_func: function to check PhoneB's idle state.
        phone_b_in_call_check_func: function to check PhoneB's in-call state.
        call_sequence_func: default parameter, not implemented.
        wait_time_in_call: time to wait in call.
            This is optional, default is WAIT_TIME_IN_CALL

    Returns:
        True: if call sequence succeed.
        False: for errors
    """
    ads = [phone_a, phone_b]

    call_params = [
        (ads[0], ads[1], ads[0], phone_a_in_call_check_func,
         phone_b_in_call_check_func),
        (ads[0], ads[1], ads[1], phone_a_in_call_check_func,
         phone_b_in_call_check_func),
        (ads[1], ads[0], ads[0], phone_b_in_call_check_func,
         phone_a_in_call_check_func),
        (ads[1], ads[0], ads[1], phone_b_in_call_check_func,
         phone_a_in_call_check_func),
    ]

    for param in call_params:
        # Make sure phones are idle.
        ensure_phones_idle(log, ads)
        if phone_a_idle_func and not phone_a_idle_func(log, phone_a):
            log.error("Phone A Failed to Reselect")
            return False
        if phone_b_idle_func and not phone_b_idle_func(log, phone_b):
            log.error("Phone B Failed to Reselect")
            return False

        # TODO: b/26337871 Need to use proper API to check phone registered.
        time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL)

        # Make call.
        log.info("---> Call test: {} to {} <---".format(
            param[0].serial, param[1].serial))
        if not call_setup_teardown(
                log, *param, wait_time_in_call=wait_time_in_call):
            log.error("Call Iteration Failed")
            return False

    return True
    def stress_test(self,
                    setup_func=None,
                    network_check_func=None,
                    test_sms=False,
                    test_video=False):
        for ad in self.android_devices:
            #check for sim and service
            ensure_phone_subscription(self.log, ad)

        if setup_func and not setup_func():
            self.log.error("Test setup %s failed", setup_func.__name__)
            return False
        fail_count = collections.defaultdict(int)
        for i in range(1, self.phone_call_iteration + 1):
            msg = "Stress Call Test %s Iteration: <%s> / <%s>" % (
                self.test_name, i, self.phone_call_iteration)
            begin_time = get_current_epoch_time()
            self.log.info(msg)
            iteration_result = True
            ensure_phones_idle(self.log, self.android_devices)

            if not self._setup_phone_call(test_video, phone_call_duration=self.phone_call_duration):
                fail_count["dialing"] += 1
                iteration_result = False
                self.log.error("%s call dialing failure.", msg)
            else:
                if network_check_func and not network_check_func(
                        self.log, self.caller):
                    fail_count["caller_network_check"] += 1
                    last_call_drop_reason(self.caller, begin_time)
                    iteration_result = False
                    self.log.error("%s network check %s failure.", msg,
                                   network_check_func.__name__)

                if network_check_func and not network_check_func(
                        self.log, self.callee):
                    fail_count["callee_network_check"] += 1
                    last_call_drop_reason(self.callee, begin_time)
                    iteration_result = False
                    self.log.error("%s network check failure.", msg)

                if not verify_incall_state(self.log,
                                           [self.caller, self.callee], True):
                    self.log.error("%s call dropped.", msg)
                    iteration_result = False
                    fail_count["drop"] += 1

                self._hangup_call()

            if test_sms and not sms_send_receive_verify(
                    self.log, self.caller, self.callee, [rand_ascii_str(180)]):
                fail_count["sms"] += 1

            self.log.info("%s %s", msg, iteration_result)
            if not iteration_result:
                self._take_bug_report("%s_CallNo_%s" % (self.test_name, i),
                                      begin_time)
                start_qxdm_loggers(self.log, self.android_devices)

            if self.sleep_time_between_test_iterations:
                self.caller.droid.goToSleepNow()
                self.callee.droid.goToSleepNow()
                time.sleep(self.sleep_time_between_test_iterations)

        test_result = True
        for failure, count in fail_count.items():
            if count:
                self.log.error("%s: %s %s failures in %s iterations",
                               self.test_name, count, failure,
                               self.phone_call_iteration)
                test_result = False
        return test_result
 def teardown_test(self):
     ensure_phones_idle(self.log, self.android_devices)
def data_connectivity_single_bearer(log, ad, nw_gen):
    """Test data connection: single-bearer (no voice).

    Turn off airplane mode, enable Cellular Data.
    Ensure phone data generation is expected.
    Verify Internet.
    Disable Cellular Data, verify Internet is inaccessible.
    Enable Cellular Data, verify Internet.

    Args:
        log: log object.
        ad: android object.
        nw_gen: network generation the phone should on.

    Returns:
        True if success.
        False if failed.
    """
    ensure_phones_idle(log, [ad])

    if not ensure_network_generation_for_subscription(
            log, ad, get_default_data_sub_id(ad), nw_gen,
            MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA):
        log.error("Device failed to reselect in {}s.".format(
            MAX_WAIT_TIME_NW_SELECTION))
        return False

    try:
        log.info("Step1 Airplane Off, Data On.")
        toggle_airplane_mode(log, ad, False)
        ad.droid.telephonyToggleDataConnection(True)
        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Failed to enable data connection.")
            return False

        log.info("Step2 Verify internet")
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        log.info("Step3 Turn off data and verify not connected.")
        ad.droid.telephonyToggleDataConnection(False)
        if not wait_for_cell_data_connection(log, ad, False):
            log.error("Step3 Failed to disable data connection.")
            return False

        if verify_http_connection(log, ad):
            log.error("Step3 Data still available when disabled.")
            return False

        log.info("Step4 Re-enable data.")
        ad.droid.telephonyToggleDataConnection(True)
        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Step4 failed to re-enable data.")
            return False
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        if not is_droid_in_network_generation_for_subscription(
                log, ad, get_default_data_sub_id(ad), nw_gen,
                NETWORK_SERVICE_DATA):
            log.error("Failed: droid is no longer on correct network")
            log.info("Expected:{}, Current:{}".format(
                nw_gen, rat_generation_from_rat(
                    get_network_rat_for_subscription(
                        log, ad, get_default_data_sub_id(
                            ad), NETWORK_SERVICE_DATA))))
            return False
        return True
    finally:
        ad.droid.telephonyToggleDataConnection(True)
예제 #18
0
def airplane_mode_test(log, ad, retries=3):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        wifi_toggle_state(log, ad, False)

        ad.log.info("Step1: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed initial attach")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable data connection.")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            ad.log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            ad.log.error("Failed to disable cell data connection")
            return False

        if not verify_internet_connection(log, ad, expected_state=False):
            ad.log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable cell data connection")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.warning("Data not available on cell")
            return False
        return True
    finally:
        toggle_airplane_mode(log, ad, False)
def airplane_mode_test(log, ad, retries=3):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        wifi_toggle_state(log, ad, False)

        ad.log.info("Step1: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed initial attach")
            return False

        if not wait_for_state(get_service_state_by_adb, "IN_SERVICE",
                              MAX_WAIT_TIME_FOR_STATE_CHANGE,
                              WAIT_TIME_BETWEEN_STATE_CHECK, log, ad):
            ad.log.error("Current service state is not 'IN_SERVICE'.")
            return False

        time.sleep(30)
        if not ad.droid.connectivityNetworkIsConnected():
            ad.log.error("Network is NOT connected!")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable data connection.")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            ad.log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            ad.log.error("Failed to disable cell data connection")
            return False

        if not verify_internet_connection(log, ad, expected_state=False):
            ad.log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_state(get_service_state_by_adb, "IN_SERVICE",
                              MAX_WAIT_TIME_FOR_STATE_CHANGE,
                              WAIT_TIME_BETWEEN_STATE_CHECK, log, ad):
            ad.log.error("Current service state is not 'IN_SERVICE'.")
            return False

        time.sleep(30)
        if not ad.droid.connectivityNetworkIsConnected():
            ad.log.warning("Network is NOT connected!")

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable cell data connection")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.warning("Data not available on cell")
            return False
        return True
    finally:
        toggle_airplane_mode(log, ad, False)