From 7d898d2931b622fd113e08b05117e53533bf6069 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 29 Jun 2023 11:27:41 +0100 Subject: [PATCH] Add additional logging and fallbacks --- .../Utilities/DeviceTest.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index 0e5d0ed3909..4f8f1d98471 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -26,6 +26,11 @@ public class DeviceTest: BaseTest protected static bool IsDeviceAttached (bool refreshCachedValue = false) { if (string.IsNullOrEmpty (_shellEchoOutput) || refreshCachedValue) { + // run this twice as sometimes the first time returns the + // device as "offline". + RunAdbCommand ("devices"); + var devices = RunAdbCommand ("devices"); + TestContext.Out.WriteLine ($"LOG adb devices: {devices}"); _shellEchoOutput = RunAdbCommand ("shell echo OK", timeout: 15); } return _shellEchoOutput.Contains ("OK"); @@ -58,11 +63,14 @@ public void DeviceSetup () DeviceAbi = RunAdbCommand ("shell getprop ro.product.cpu.abilist64").Trim (); if (string.IsNullOrEmpty (DeviceAbi)) - DeviceAbi = RunAdbCommand ("shell getprop ro.product.cpu.abi") ?? RunAdbCommand ("shell getprop ro.product.cpu.abi2"); + DeviceAbi = (RunAdbCommand ("shell getprop ro.product.cpu.abi") ?? RunAdbCommand ("shell getprop ro.product.cpu.abi2")) ?? "x86_64"; if (DeviceAbi.Contains (",")) { DeviceAbi = DeviceAbi.Split (',')[0]; } + } else { + TestContext.Out.WriteLine ($"LOG GetSdkVersion: {DeviceSdkVersion}"); + DeviceAbi = "x86_64"; } } catch (Exception ex) { Console.Error.WriteLine ("Failed to determine whether there is Android target emulator or not: " + ex);