This reverts commit 9d9109aa6f.
This commit is contained in:
@@ -52,7 +52,7 @@ String _findMatchId(List<String> idList, String idPattern) {
|
||||
DeviceDiscovery get devices => DeviceDiscovery();
|
||||
|
||||
/// Device operating system the test is configured to test.
|
||||
enum DeviceOperatingSystem { android, androidArm64 ,ios, fuchsia, fake }
|
||||
enum DeviceOperatingSystem { android, ios, fuchsia, fake }
|
||||
|
||||
/// Device OS to test on.
|
||||
DeviceOperatingSystem deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
@@ -63,8 +63,6 @@ abstract class DeviceDiscovery {
|
||||
switch (deviceOperatingSystem) {
|
||||
case DeviceOperatingSystem.android:
|
||||
return AndroidDeviceDiscovery();
|
||||
case DeviceOperatingSystem.androidArm64:
|
||||
return AndroidDeviceDiscovery(cpu: _AndroidCPU.arm64);
|
||||
case DeviceOperatingSystem.ios:
|
||||
return IosDeviceDiscovery();
|
||||
case DeviceOperatingSystem.fuchsia:
|
||||
@@ -157,18 +155,12 @@ abstract class Device {
|
||||
}
|
||||
}
|
||||
|
||||
enum _AndroidCPU {
|
||||
arm64,
|
||||
}
|
||||
|
||||
class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
factory AndroidDeviceDiscovery({_AndroidCPU cpu}) {
|
||||
return _instance ??= AndroidDeviceDiscovery._(cpu);
|
||||
factory AndroidDeviceDiscovery() {
|
||||
return _instance ??= AndroidDeviceDiscovery._();
|
||||
}
|
||||
|
||||
AndroidDeviceDiscovery._(this.cpu);
|
||||
|
||||
final _AndroidCPU cpu;
|
||||
AndroidDeviceDiscovery._();
|
||||
|
||||
// Parses information about a device. Example:
|
||||
//
|
||||
@@ -193,16 +185,6 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
return _workingDevice;
|
||||
}
|
||||
|
||||
Future<bool> _matchesCPURequirement(AndroidDevice device) async {
|
||||
if (cpu == null)
|
||||
return true;
|
||||
switch (cpu) {
|
||||
case _AndroidCPU.arm64:
|
||||
return device.isArm64();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Picks a random Android device out of connected devices and sets it as
|
||||
/// [workingDevice].
|
||||
@override
|
||||
@@ -214,22 +196,8 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
if (allDevices.isEmpty)
|
||||
throw const DeviceException('No Android devices detected');
|
||||
|
||||
if (cpu != null) {
|
||||
for (final AndroidDevice device in allDevices) {
|
||||
if (await _matchesCPURequirement(device)) {
|
||||
_workingDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO(yjbanov): filter out and warn about those with low battery level
|
||||
_workingDevice = allDevices[math.Random().nextInt(allDevices.length)];
|
||||
}
|
||||
|
||||
if (_workingDevice == null)
|
||||
throw const DeviceException('Cannot find a suitable Android device');
|
||||
|
||||
// TODO(yjbanov): filter out and warn about those with low battery level
|
||||
_workingDevice = allDevices[math.Random().nextInt(allDevices.length)];
|
||||
print('Device chosen: $_workingDevice');
|
||||
}
|
||||
|
||||
@@ -238,11 +206,6 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
final String matchedId = _findMatchId(await discoverDevices(), deviceId);
|
||||
if (matchedId != null) {
|
||||
_workingDevice = AndroidDevice(deviceId: matchedId);
|
||||
if (cpu != null) {
|
||||
if (!await _matchesCPURequirement(_workingDevice)) {
|
||||
throw DeviceException('The selected device $matchedId does not match the cpu requirement');
|
||||
}
|
||||
}
|
||||
print('Choose device by ID: $matchedId');
|
||||
return;
|
||||
}
|
||||
@@ -481,11 +444,6 @@ class AndroidDevice extends Device {
|
||||
return wakefulness;
|
||||
}
|
||||
|
||||
Future<bool> isArm64() async {
|
||||
final String cpuInfo = await shellEval('getprop', const <String>['ro.product.cpu.abi']);
|
||||
return cpuInfo.contains('arm64');
|
||||
}
|
||||
|
||||
Future<void> _updateDeviceInfo() async {
|
||||
String info;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user