Pular para o conteúdo principal

ADB Location mock

If you don't want to use a mock location app, you can use ADB to inject coordinates directly into the device. This method requires enabling developer options and USB debugging on your Android device.

Note: WSL users might find problems with ADB USB, Check out this guide here if needed.

#!/bin/bash
LAT="-22.98861"
LON="-43.24833"

echo "Granting permissions and setting providers..."
adb shell appops set com.android.shell android:mock_location allow
adb shell cmd location providers add-test-provider gps
adb shell cmd location providers add-test-provider network
adb shell cmd location providers add-test-provider fused

adb shell cmd location providers set-test-provider-enabled gps true
adb shell cmd location providers set-test-provider-enabled network true
adb shell cmd location providers set-test-provider-enabled fused true

echo "Injecting coordinates continuously... (Press Ctrl+C to stop)"
while true; do
adb shell cmd location providers set-test-provider-location gps --location ${LAT},${LON}
adb shell cmd location providers set-test-provider-location network --location ${LAT},${LON}
adb shell cmd location providers set-test-provider-location fused --location ${LAT},${LON}
sleep 2
done