Android - scripting telnet session for sending GPS tracks
All,
I am familiar with the ability to fake GPS information to the emulator through the use of the geo fix long lat altitude
command when connected through the emulator.
What I'd like to do is have a simulation running on potentially a different computer produce lat, long, altitudes that should be sent over to the Android device to fake the emulator into thinking it has received a GPS update.
I see various solutions for scripting a telnet session; it seems like the best solution is, in pseudocode:
while true:
if position update generated / received
open subprocess and call "echo 'geo fix lon lat altitude' | nc localhost 5554"
This seems like a big hack, although it works on Mac (not on Windows). Is there a b开发者_运维问答etter way to do this? (I cannot generate the tracks ahead of time and feed them in as a route; the Android system is part of a real time simulation, but as it's running on an emulator there is no position updates. Another system is responsible for calculating these position updates).
edit: Alternative method, perhaps more clean, is to use the telnetlib library of python.
import telnetlib
tn = telnetlib.Telnet("localhost",5554)
while True:
if position update generated / received
tn.write("geo fix longitude latitude altitude\r\n")
Maybe this is close to what you're looking for
https://github.com/xperimental/fakegps
Netcat (the nc in the above example) compiles for just about anything, including windows and android itself.
In short, that doesn't look like a hack of a solution, it looks like a very traditional unix scripting style solution that could be easily made to work on any modern platform.
If you don't like opening a new connection for each fix, you should be able to just write a program that generates fixes to standard output and pipe it into netcat.
精彩评论