adid && coord
This commit is contained in:
parent
bd51549d08
commit
c64c17d86e
@ -3,6 +3,8 @@ FROM pre_android/ready
|
||||
# Set up node
|
||||
RUN npm install -g n && n install 22.14.0 && n use 22.14.0 && hash -r
|
||||
|
||||
RUN node --version
|
||||
|
||||
# Set up httptoolkit-server
|
||||
RUN git clone https://github.com/httptoolkit/httptoolkit-server /httptoolkit-server
|
||||
|
||||
|
@ -56,6 +56,18 @@ wss.on("connection", (ws) => {
|
||||
dataSplit[3],
|
||||
dataSplit[4],
|
||||
]);
|
||||
} else if (data.startsWith("setcoord")) {
|
||||
const dataSplit = data.split(" ");
|
||||
const res = await spawnPromise("bash", [
|
||||
"/conf/set_geo.sh",
|
||||
dataSplit[1],
|
||||
dataSplit[2],
|
||||
]);
|
||||
send_notification(
|
||||
res.code === 0,
|
||||
"Setting the moch location",
|
||||
res.output
|
||||
);
|
||||
}
|
||||
});
|
||||
ws.on("close", (_) => {
|
||||
|
13
android/conf/set_geo.sh
Normal file
13
android/conf/set_geo.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
ko=$((
|
||||
echo "auth $(cat ~/.emulator_console_auth_token)"
|
||||
echo "geo fix $1 $2 0.0"
|
||||
sleep 0.2
|
||||
) | telnet localhost 5554 | grep KO: );
|
||||
|
||||
if [ -z "${ko}" ]; then
|
||||
exit 0
|
||||
else
|
||||
echo "$ko"
|
||||
exit 1;
|
||||
fi
|
@ -1,8 +1,15 @@
|
||||
rm -f /opt/android-sdk-linux/.android/avd/virtual_dev.avd/*.lock
|
||||
adb start-server
|
||||
emulator -avd virtual_dev -writable-system -no-window -no-audio &
|
||||
adb wait-for-device
|
||||
adb emu avd snapshot load configured
|
||||
cat > /simple.gpx << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gpx version="1.1" creator="ChatGPT" xmlns="http://www.topografix.com/GPX/1/1">
|
||||
<wpt lat="37.422" lon="-122.084">
|
||||
<name>Simple Waypoint</name>
|
||||
</wpt>
|
||||
</gpx>
|
||||
EOF
|
||||
|
||||
emulator -grpc 5556 -avd virtual_dev -snapshot configured -no-window -no-audio -debug all,-adb,-gles1emu,-gles,-mtport,-metrics,-memory,-car,-tvremote &
|
||||
adb wait-for-device
|
||||
|
||||
export PATH=$PATH:/root/culebraDependencies
|
||||
|
@ -23,6 +23,7 @@ services:
|
||||
- 10001:10001 # api port
|
||||
- 3000:3000 # android server port
|
||||
- 3001:3001 # Notifications server
|
||||
- 5556:5556 # emulator grpc port
|
||||
volumes:
|
||||
- $PWD/shared_buffer:/shared_buffer
|
||||
- $PWD/android/conf:/conf
|
||||
|
@ -161,6 +161,11 @@
|
||||
</section>
|
||||
|
||||
<div class="tab-section" >
|
||||
<form id="set_coords" hx-post="/setcoord" hx-target="#resp">
|
||||
<input type="text" name="lon"/>
|
||||
<input type="text" name="lat"/>
|
||||
<button type="submit">Submit coords</button>
|
||||
</form>
|
||||
<div class="tab">
|
||||
<button class="tablinks active" onclick="open_tab(event, 'httptoolkit-tab')">HttpToolkit UI</button>
|
||||
<button class="tablinks" onclick="open_tab(event, 'logs-tab')">Logs</button>
|
||||
|
@ -109,4 +109,15 @@ app.post("/drag", function (req, res) {
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
app.post("/setcoord", function (req, res) {
|
||||
console.log(req.body);
|
||||
console.log(req.body.lat);
|
||||
console.log(req.body.lon);
|
||||
const lat = Number(req.body.lat);
|
||||
const lon = Number(req.body.lon);
|
||||
console.log(lat, lon);
|
||||
android_websocket.send(`setcoord ${lat} ${lon}`);
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
app.listen(8080, () => console.log("Listening in port 8080"));
|
||||
|
@ -4,6 +4,6 @@ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/andro
|
||||
|
||||
RUN sdkmanager --channel=2 "system-images;android-30;google_apis;x86_64" \
|
||||
&& echo no | avdmanager create avd -n virtual_dev -b google_apis/x86_64 -k "system-images;android-30;google_apis;x86_64" \
|
||||
&& apt-get update && apt-get install -y iproute2 iputils-ping npm git
|
||||
&& apt-get update && apt-get install -y iproute2 iputils-ping npm git libxml2-utils telnet
|
||||
|
||||
CMD bash /preconf/docker-entrypoint.sh
|
||||
|
@ -2,6 +2,9 @@ adb start-server
|
||||
emulator -avd virtual_dev -writable-system -no-window -no-audio &
|
||||
bash /preconf/install_culebra.sh
|
||||
|
||||
# Save the ad id while the emulator is still up
|
||||
su root cat /data/data/com.google.android.gms/shared_prefs/adid_settings.xml | xmllint --xpath 'string(//map/string[@name="adid_key"])' - > /adid
|
||||
|
||||
adb emu avd snapshot save configured
|
||||
|
||||
adb emu kill
|
||||
|
Loading…
x
Reference in New Issue
Block a user