diff --git a/dev/devicelab/lib/tasks/integration_tests.dart b/dev/devicelab/lib/tasks/integration_tests.dart index a9a8d5e5ea8..5441794efe9 100644 --- a/dev/devicelab/lib/tasks/integration_tests.dart +++ b/dev/devicelab/lib/tasks/integration_tests.dart @@ -4,7 +4,7 @@ import '../framework/devices.dart'; import '../framework/framework.dart'; -import '../framework/talkback.dart'; +import '../framework/talkback.dart' hide adbPath; import '../framework/task_result.dart'; import '../framework/utils.dart'; @@ -265,20 +265,38 @@ class DriverTest { Future call() { return inDirectory(testDirectory, () async { String deviceId; + Device? selectedDevice; if (deviceIdOverride != null) { deviceId = deviceIdOverride!; } else { - final Device device = await devices.workingDevice; - await device.unlock(); - deviceId = device.deviceId; + selectedDevice = await devices.workingDevice; + await selectedDevice.unlock(); + deviceId = selectedDevice.deviceId; } await flutter('packages', options: ['get']); + final bool isAndroidRun = selectedDevice != null + ? selectedDevice is AndroidDevice + : const { + DeviceOperatingSystem.android, + DeviceOperatingSystem.androidArm, + DeviceOperatingSystem.androidArm64, + }.contains(deviceOperatingSystem); + + String? devicelabAdbPath; + if (isAndroidRun) { + try { + devicelabAdbPath = adbPath; + } on DeviceException { + devicelabAdbPath = null; + } + } // Make the device ID available in the driver code, so tools like ADB can // reference it if needed. final Map env = { if (environment != null) ...environment!, - 'DEVICE_ID_NUMBER': deviceId, + 'FLUTTER_DEVICE_ID_NUMBER': deviceId, + if (devicelabAdbPath != null) 'FLUTTER_ADB_PATH': devicelabAdbPath, }; final List options = [ diff --git a/dev/integration_tests/android_verified_input/test_driver/main_test.dart b/dev/integration_tests/android_verified_input/test_driver/main_test.dart index 641d8ed74ba..4499a5da37a 100644 --- a/dev/integration_tests/android_verified_input/test_driver/main_test.dart +++ b/dev/integration_tests/android_verified_input/test_driver/main_test.dart @@ -28,7 +28,8 @@ Future main() async { final Future inputEventWasVerified = driver.requestData('input_was_verified'); // Passed in by the driver task. - final String? deviceId = Platform.environment['DEVICE_ID_NUMBER']; + final String? deviceId = Platform.environment['FLUTTER_DEVICE_ID_NUMBER']; + final String? adbPath = Platform.environment['FLUTTER_ADB_PATH']; // Keep issuing taps until we get the requested data. The actual setup // of the platform view is asynchronous so we might have to tap more than @@ -37,7 +38,7 @@ Future main() async { inputEventWasVerified.whenComplete(() => stop = true); while (!stop) { // We must use the Android input tool to get verified input events. - final ProcessResult result = await Process.run('adb', [ + final ProcessResult result = await Process.run(adbPath ?? 'adb', [ if (deviceId != null) ...['-s', deviceId], 'shell', 'input',