adid && coord

This commit is contained in:
Andrii Dokhniak 2025-05-25 16:38:52 +02:00
parent bd51549d08
commit c64c17d86e
9 changed files with 59 additions and 5 deletions

View File

@ -3,6 +3,8 @@ FROM pre_android/ready
# Set up node # Set up node
RUN npm install -g n && n install 22.14.0 && n use 22.14.0 && hash -r RUN npm install -g n && n install 22.14.0 && n use 22.14.0 && hash -r
RUN node --version
# Set up httptoolkit-server # Set up httptoolkit-server
RUN git clone https://github.com/httptoolkit/httptoolkit-server /httptoolkit-server RUN git clone https://github.com/httptoolkit/httptoolkit-server /httptoolkit-server

View File

@ -56,6 +56,18 @@ wss.on("connection", (ws) => {
dataSplit[3], dataSplit[3],
dataSplit[4], 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", (_) => { ws.on("close", (_) => {

13
android/conf/set_geo.sh Normal file
View 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

View File

@ -1,8 +1,15 @@
rm -f /opt/android-sdk-linux/.android/avd/virtual_dev.avd/*.lock rm -f /opt/android-sdk-linux/.android/avd/virtual_dev.avd/*.lock
adb start-server adb start-server
emulator -avd virtual_dev -writable-system -no-window -no-audio & cat > /simple.gpx << EOF
adb wait-for-device <?xml version="1.0" encoding="UTF-8"?>
adb emu avd snapshot load configured <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 adb wait-for-device
export PATH=$PATH:/root/culebraDependencies export PATH=$PATH:/root/culebraDependencies

View File

@ -23,6 +23,7 @@ services:
- 10001:10001 # api port - 10001:10001 # api port
- 3000:3000 # android server port - 3000:3000 # android server port
- 3001:3001 # Notifications server - 3001:3001 # Notifications server
- 5556:5556 # emulator grpc port
volumes: volumes:
- $PWD/shared_buffer:/shared_buffer - $PWD/shared_buffer:/shared_buffer
- $PWD/android/conf:/conf - $PWD/android/conf:/conf

View File

@ -161,6 +161,11 @@
</section> </section>
<div class="tab-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"> <div class="tab">
<button class="tablinks active" onclick="open_tab(event, 'httptoolkit-tab')">HttpToolkit UI</button> <button class="tablinks active" onclick="open_tab(event, 'httptoolkit-tab')">HttpToolkit UI</button>
<button class="tablinks" onclick="open_tab(event, 'logs-tab')">Logs</button> <button class="tablinks" onclick="open_tab(event, 'logs-tab')">Logs</button>

View File

@ -109,4 +109,15 @@ app.post("/drag", function (req, res) {
res.sendStatus(200); 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")); app.listen(8080, () => console.log("Listening in port 8080"));

View File

@ -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" \ 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" \ && 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 CMD bash /preconf/docker-entrypoint.sh

View File

@ -2,6 +2,9 @@ adb start-server
emulator -avd virtual_dev -writable-system -no-window -no-audio & emulator -avd virtual_dev -writable-system -no-window -no-audio &
bash /preconf/install_culebra.sh 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 avd snapshot save configured
adb emu kill adb emu kill