From 815d8e723dadb79ec908be7ee533d6134b537930 Mon Sep 17 00:00:00 2001 From: filip131311 Date: Thu, 31 Oct 2024 18:33:17 +0100 Subject: [PATCH] init --- .../src/devices/AndroidEmulatorDevice.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/vscode-extension/src/devices/AndroidEmulatorDevice.ts b/packages/vscode-extension/src/devices/AndroidEmulatorDevice.ts index 408b54d4..3d45ed23 100644 --- a/packages/vscode-extension/src/devices/AndroidEmulatorDevice.ts +++ b/packages/vscode-extension/src/devices/AndroidEmulatorDevice.ts @@ -178,16 +178,17 @@ export class AndroidEmulatorDevice extends DeviceBase { "location_mode", "3", ]); - // note that geo fix command takes arguments: $longitude , $latitude so the order is reversed compared to most conventions - await exec(ADB_PATH, [ - "-s", - this.serial!, - "emu", - "geo", - "fix", - settings.location.longitude.toString(), - settings.location.latitude.toString(), - ]); + + // This is a work around for the problem with emu geo command not working when passed, 0 0 coordinates + // when provided coordinates are close enough to 0 that the adb assumes they are 0 we pass the smallest + // working number instead. Moreover note that geo fix command takes arguments: + // $longitude , $latitude so the order is reversed compared to most conventions + const areCoordinatesToCloseToZero = + Math.abs(settings.location.latitude) < 0.00001 && + Math.abs(settings.location.longitude) < 0.00001; + const lat = areCoordinatesToCloseToZero ? "0.00001" : settings.location.latitude.toString(); + const long = areCoordinatesToCloseToZero ? "0.00001" : settings.location.longitude.toString(); + await exec(ADB_PATH, ["-s", this.serial!, "emu", "geo", "fix", long, lat]); } return shouldRestart; }