예제 #1
0
    def __init__(self, serial="", customflasher_path=""):
        """Initialize the client.

        If serial not provided, find single device connected. Error if
        zero or > 1 devices connected.

        Args:
            serial: optional string, serial number for the device.
            customflasher_path: optional string, set device to use specified
                                binary to flash a device
        """
        if serial != "":
            self.device = android_device.AndroidDevice(serial,
                                                       device_callback_port=-1)
        else:
            serials = android_device.list_adb_devices()
            if len(serials) == 0:
                serials = android_device.list_fastboot_devices()
                if len(serials) == 0:
                    raise android_device.AndroidDeviceError(
                        "ADB and fastboot could not find any target devices.")
            if len(serials) > 1:
                print("ADB or fastboot found more than one device: %s" %
                      serials)
            self.device = android_device.AndroidDevice(serials[0],
                                                       device_callback_port=-1)
            if customflasher_path:
                self.device.SetCustomFlasherPath(customflasher_path)
예제 #2
0
    def Extend(self, properties):
        """Adds properties to a DeviceInfo object, using AndroidDevice

        Args:
            properties: list of strings, list of properties to update
        """
        serial = getattr(self, "device_serial", None)
        ad = android_device.AndroidDevice(serial)
        for prop in properties:
            val = getattr(ad, prop, None)
            if val is None:
                continue
            setattr(self, prop, val)
예제 #3
0
    def SetSerial(self, serial):
        """Sets device serial.

        Args:
            serial: string, a device serial.

        Returns:
            True if successful; False otherwise.
        """
        if not serial:
            print("no serial is given to BuildFlasher.SetSerial.")
            return False

        self.device = android_device.AndroidDevice(serial,
                                                   device_callback_port=-1)
        return True
예제 #4
0
 def Run(self, arg_line):
     """Performs the requested operation on the selected DUT."""
     args = self.arg_parser.ParseLine(arg_line)
     device = android_device.AndroidDevice(args.serial,
                                           device_callback_port=-1)
     device.waitForBootCompletion()
     adb_proxy = adb.AdbProxy(serial=args.serial)
     adb_proxy.root()
     try:
         if args.operation == "wifi_on":
             adb_proxy.shell("svc wifi enable")
             if args.ap:
                 adb_proxy.install(
                     "../testcases/DATA/app/WifiUtil/WifiUtil.apk")
                 adb_proxy.shell(
                     "am instrument -e method \"connectToNetwork\" "
                     "-e ssid %s "
                     "-w com.android.tradefed.utils.wifi/.WifiUtil" %
                     args.ap)
         elif args.operation == "wifi_off":
             adb_proxy.shell("svc wifi disable")
     except adb.AdbError as e:
         logging.exception(e)
         return False
예제 #5
0
 def setUp(self):
     """SetUp tasks"""
     available_serials = android_device.list_adb_devices()
     self.assertGreater(len(available_serials), 0, 'no device available.')
     self.dut = android_device.AndroidDevice(available_serials[0])