def update_details(binary_manager: binaries_util.BinaryManager, device: Device) -> None: check( device.HasField("android"), AssertionError(f"Expected Android device: {device}"), ) build_fingerprint = "" try: adb_fingerprint_result = adb_check( device.android.serial, ["shell", "getprop ro.build.fingerprint"], verbose=True, ) build_fingerprint = adb_fingerprint_result.stdout build_fingerprint = build_fingerprint.strip() except subprocess.CalledProcessError: log("Failed to get device fingerprint") device_properties = "" ensure_amber_installed(device.android.serial, binary_manager) try: device_properties = get_device_driver_details(device.android.serial) except devices_util.GetDeviceDetailsError as ex: log(f"WARNING: Failed to get device driver details: {ex}") device.android.build_fingerprint = build_fingerprint device.device_properties = device_properties
def update_device(binary_manager: binaries_util.BinaryManager, device: Device) -> None: """ Updates a device. This mostly just means setting the "device_properties" field of the device to the output of "amber -d -V". Android devices will also have their build_fingerprint updated. :param binary_manager: :param device: :return: """ if device.HasField("preprocess"): pass elif device.HasField("swift_shader"): _update_device_swiftshader(binary_manager, device) elif device.HasField("host"): _update_device_host(binary_manager, device) elif device.HasField("android"): android_device.update_details(binary_manager, device) elif device.HasField("shader_compiler"): _update_device_shader_compiler(binary_manager, device) else: raise AssertionError(f"Unrecognized device type: {device}")
def _update_device_host(binary_manager: binaries_util.BinaryManager, device: Device) -> None: check( device.HasField("host"), AssertionError(f"Expected host device: {device}"), ) amber_path = binary_manager.get_binary_path_by_name( binaries_util.AMBER_NAME).path driver_details = "" try: driver_details = host_device_util.get_driver_details( amber_path, custom_launcher=list(device.host.custom_launcher)) except GetDeviceDetailsError as ex: log(f"WARNING: Failed to get device driver details: {ex}") device.device_properties = driver_details
def _update_device_shader_compiler(binary_manager: binaries_util.BinaryManager, device: Device) -> None: check( device.HasField("shader_compiler"), AssertionError(f"Expected shader_compiler device: {device}"), ) # The only thing we can do is update the shader compiler binary if it is a built-in binary. if binaries_util.is_built_in_binary_name(device.shader_compiler.binary): # Remove existing binaries with this name from the device's binaries list. binaries = list(device.binaries) binaries = [ b for b in binaries if b.name != device.shader_compiler.binary ] del device.binaries[:] device.binaries.extend(binaries) # Add our latest version of the binary. device.binaries.extend( [binary_manager.get_binary_by_name(device.shader_compiler.binary)])
def _update_device_swiftshader(binary_manager: binaries_util.BinaryManager, device: Device) -> None: check( device.HasField("swift_shader"), AssertionError(f"Expected SwiftShader device: {device}"), ) amber_path = binary_manager.get_binary_path_by_name( binaries_util.AMBER_NAME).path swift_shader_binary_and_path = binary_manager.get_binary_path_by_name( binaries_util.SWIFT_SHADER_NAME) driver_details = "" try: driver_details = host_device_util.get_driver_details( amber_path, swift_shader_binary_and_path.path) except GetDeviceDetailsError as ex: log(f"WARNING: Failed to get device driver details: {ex}") device.device_properties = driver_details del device.binaries[:] device.binaries.extend([swift_shader_binary_and_path.binary])