I maintain a very specialized telemetry project and I needed a way to provide routes to it for testing, from the comfort of my desk.
This example console application illustrates the nifty usage of sending GPS positions to our Android emulator.
The Route provider (KmlFileRouteProvider) parses a KML file and return the points.
var provider = new KmlFileRouteProvider("chapmans-peak-drive.kml");
var route = provider.GetRoute().ToList();I used Sam Cragg's KML implementation found here to read the locations from the file.
When we create the TCP connection to our emulator, we need to provide the contents of the .emulator_console_auth_token file found in %USERPROFILE% (Windows) or $HOME (*nix).
var authToken = AuthTokenReader.GetToken();The emulator listens for connections on ports 5554 to 5585 and accepts connections from localhost only.
using var client = new EmulatorConnection("127.0.0.1", 5554, authToken);
client.Connect();foreach (var command in route.Select(point => $"geo fix {point.Latitude} {point.Longitude}"))
{
client.SendCommand(command);
}There are many commands you can send to the emulator this way and the "geo" command used here is just the tip of the iceberg.
All emulator commands can be found here : https://developer.android.com/studio/run/emulator-console
To https://www.chapmanspeakdrive.co.za/ for maintaining one of the world's most scenic drives and for the usage of their imagery.
