def _wait_for_device(self, dut):
        """ Wait for device to come back online

        Args:
            1. dut - ad object
        """
        while dut.serial not in android_device.list_adb_devices():
            pass
        dut.adb.wait_for_device()
Exemple #2
0
    def __init__(self, serial_number):
        """Initializes the ACTS library components.

        @param serial_number Serial number of the android device to be tested,
               None if there is only one device connected to the host.

        """
        if not serial_number:
            ads = android_device.get_all_instances()
            if not ads:
                msg = "No android device found, abort!"
                logging.error(msg)
                raise XmlRpcServerError(msg)
            self.ad = ads[0]
        elif serial_number in android_device.list_adb_devices():
            self.ad = android_device.AndroidDevice(serial_number)
        else:
            msg = ("Specified Android device %s can't be found, abort!"
                   ) % serial_number
            logging.error(msg)
            raise XmlRpcServerError(msg)
    def __init__(self, serial_number, log_dir, test_station):
        """Initializes the ACTS library components.

        @test_station string represting teststation's hostname.
        @param serial_number Serial number of the android device to be tested,
               None if there is only one device connected to the host.
        @param log_dir Path to store output logs of this run.

        """
        # Cleanup all existing logs for this device when starting.
        shutil.rmtree(log_dir, ignore_errors=True)
        logger.setup_test_logger(log_path=log_dir, prefix="ANDROID_XMLRPC")
        if not serial_number:
            ads = android_device.get_all_instances()
            if not ads:
                msg = "No android device found, abort!"
                logging.error(msg)
                raise XmlRpcServerError(msg)
            self.ad = ads[0]
        elif serial_number in android_device.list_adb_devices():
            self.ad = android_device.AndroidDevice(serial_number)
        else:
            msg = ("Specified Android device %s can't be found, abort!"
                   ) % serial_number
            logging.error(msg)
            raise XmlRpcServerError(msg)
        # Even if we find one attenuator assume the rig has attenuators for now.
        # With the single IP attenuator, this will be a easy check.
        rig_has_attenuator = False
        count = 0
        for i in range(1, self.NUM_ATTEN + 1):
            atten_addr = test_station + '-attenuator-' + '%d' % i
            if subprocess.Popen(['ping', '-c', '2', atten_addr],
                                stdout=subprocess.PIPE).communicate()[0]:
                rig_has_attenuator = True
                count = count + 1
        if rig_has_attenuator and count == self.NUM_ATTEN:
            atten = attenuator.create([{
                "Address": test_station + '-attenuator-1',
                "Port": 23,
                "Model": "minicircuits",
                "InstrumentCount": 1,
                "Paths": ["Attenuator-1"]
            }, {
                "Address": test_station + '-attenuator-2',
                "Port": 23,
                "Model": "minicircuits",
                "InstrumentCount": 1,
                "Paths": ["Attenuator-2"]
            }, {
                "Address": test_station + '-attenuator-3',
                "Port": 23,
                "Model": "minicircuits",
                "InstrumentCount": 1,
                "Paths": ["Attenuator-3"]
            }, {
                "Address": test_station + '-attenuator-4',
                "Port": 23,
                "Model": "minicircuits",
                "InstrumentCount": 1,
                "Paths": ["Attenuator-4"]
            }])
            device = 0
            # Set attenuation on all attenuators to 0.
            for device in range(len(atten)):
                atten[device].set_atten(0)
            attenuator.destroy(atten)
        elif rig_has_attenuator and count < self.NUM_ATTEN:
            msg = 'One or more attenuators are down.'
            logging.error(msg)
            raise XmlRpcServerError(msg)
Exemple #4
0
 def _wait_for_device(self, ad):
     while ad.serial not in android_device.list_adb_devices():
         pass
     ad.adb.wait_for_device()
    def test_factory_modem_offline(self):
        """Trigger Modem Factory Offline and verify if Modem Offline

        1. Device in Fastboot
        2. Wipe Userdata and set the fastboot command for factory
        3. Device will bootup in adb, verify Modem Offline
        4. Reboot again, and verify camping

        """
        try:
            ad = self.android_devices[0]
            skip_setup_wizard = True

            # Pull sl4a apk from device
            out = ad.adb.shell("pm path %s" % SL4A_APK_NAME)
            result = re.search(r"package:(.*)", out)
            if not result:
                ad.log.error("Couldn't find sl4a apk")
                return False
            else:
                sl4a_apk = result.group(1)
                ad.log.info("Get sl4a apk from %s", sl4a_apk)
                ad.pull_files([sl4a_apk], "/tmp/")
            ad.stop_services()

            # Fastboot Wipe
            if ad.serial in list_adb_devices():
                ad.log.info("Reboot to bootloader")
                ad.adb.reboot("bootloader", ignore_status=True)
                time.sleep(10)
            if ad.serial in list_fastboot_devices():
                ad.log.info("Wipe in fastboot")
                ad.fastboot._w(timeout=300, ignore_status=True)
                time.sleep(30)

                # Factory Silent Mode Test
                ad.log.info("Factory Offline in fastboot")
                ad.fastboot.oem("continue-factory")
                time.sleep(30)
                ad.wait_for_boot_completion()
                ad.root_adb()
                ad.log.info("Re-install sl4a")
                ad.adb.shell("settings put global verifier_verify_adb_installs"
                             " 0")
                ad.adb.install("-r /tmp/base.apk")
                time.sleep(10)
                try:
                    ad.start_adb_logcat()
                except:
                    ad.log.error("Failed to start adb logcat!")
                bring_up_sl4a(ad)
                radio_state = ad.droid.telephonyIsRadioOn()
                ad.log.info("Radio State is %s", radio_state)
                if radio_state:
                    ad.log.error("Radio state is ON in Factory Mode")
                    return False
                toggle_airplane_mode(self.log, ad, True)
                time.sleep(5)
                toggle_airplane_mode(self.log, ad, False)
                radio_state = ad.droid.telephonyIsRadioOn()
                ad.log.info("Radio State is %s", radio_state)
                if ad.droid.telephonyIsRadioOn():
                    ad.log.error("Radio state is ON after Airplane Toggle")
                    return False
                ad.log.info("Rebooting and verifying back in service")

                # Bring it back to Online Mode
                ad.stop_services()
                ad.adb.reboot()
                ad.wait_for_boot_completion()
                ad.root_adb()
                bring_up_sl4a(ad)
                radio_state = ad.droid.telephonyIsRadioOn()
                ad.log.info("Radio State is %s", radio_state)
                if not radio_state:
                    ad.log.error("Radio state is OFF in Online Mode")
                    return False
                return True
        except Exception as e:
            ad.log.error(e)
            return False
        finally:
            ad.exit_setup_wizard()
            bring_up_sl4a(ad)