From 24890e9a4cb906aa373cdec19d95a788de6990fc Mon Sep 17 00:00:00 2001 From: Andrii Dokhniak Date: Wed, 9 Apr 2025 14:48:21 +0200 Subject: [PATCH] Installing all types of packages --- android/conf/install.sh | 2 +- http_server/code/index.html | 2 +- http_server/code/index.mjs | 21 +++++------ pre_android/Dockerfile | 7 ++-- pre_android/preconf/docker-entrypoint.sh | 4 --- pre_android/preconf/install_cert.sh | 45 ------------------------ 6 files changed, 16 insertions(+), 65 deletions(-) delete mode 100644 pre_android/preconf/install_cert.sh diff --git a/android/conf/install.sh b/android/conf/install.sh index 42d63c1..8fc425f 100644 --- a/android/conf/install.sh +++ b/android/conf/install.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e # -r to replace an existing application if any -/opt/android-sdk-linux/platform-tools/adb install -r /shared_buffer/app.apk +/opt/android-sdk-linux/platform-tools/adb install-multiple -r /shared_buffer/*.apk diff --git a/http_server/code/index.html b/http_server/code/index.html index 09edaf1..0780381 100644 --- a/http_server/code/index.html +++ b/http_server/code/index.html @@ -148,7 +148,7 @@
diff --git a/http_server/code/index.mjs b/http_server/code/index.mjs index 5066b91..32d82bf 100644 --- a/http_server/code/index.mjs +++ b/http_server/code/index.mjs @@ -6,6 +6,8 @@ import { waitFullBoot, } from "./screenshot.mjs"; +import { execSync } from 'node:child_process'; + import fileUpload from 'express-fileupload'; const device_size_x = 320; @@ -62,19 +64,18 @@ app.post("/back", function (req, res) { // default options app.use(fileUpload()); -app.post('/upload_apk',function (req, res) { +app.post('/upload_apk', async function (req, res) { if (!req.files || Object.keys(req.files).length === 0) { return res.status(400).send('No files were uploaded.'); } - let file = req.files.app; - let uploadPath = '/shared_buffer/app.apk'; - - file.mv(uploadPath, function(err) { - if (err) - return res.status(500).send(err); - android_websocket.send(`install`); - res.send('File uploaded!'); - }); + execSync("rm -rf /shared_buffer/*"); + console.log(req.files); + for (const [idx, file] of req.files.app.entries()) { + let uploadPath = '/shared_buffer/app' + idx + '.apk'; + await file.mv(uploadPath); + } + android_websocket.send(`install`); + res.send('Files uploaded!'); }) app.post("/home", function (req, res) { diff --git a/pre_android/Dockerfile b/pre_android/Dockerfile index 4789670..95efdde 100644 --- a/pre_android/Dockerfile +++ b/pre_android/Dockerfile @@ -2,9 +2,8 @@ FROM runmymind/docker-android-sdk:ubuntu-standalone-20230511 ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/android-sdk-linux/cmdline-tools/latest/bin:/opt/android-sdk-linux/cmdline-tools/tools/bin:/opt/android-sdk-linux/tools/bin:/opt/android-sdk-linux/build-tools/32.0.0:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/emulator:/opt/android-sdk-linux/bin -RUN sdkmanager "system-images;android-33;google_apis;x86_64" -RUN echo no | avdmanager create avd -n virtual_dev -b google_apis/x86_64 -k "system-images;android-33;google_apis;x86_64" - -RUN apt-get update && apt-get install -y iproute2 iputils-ping iptables redsocks npm git +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 CMD bash /preconf/docker-entrypoint.sh diff --git a/pre_android/preconf/docker-entrypoint.sh b/pre_android/preconf/docker-entrypoint.sh index 770c6ea..149ae85 100644 --- a/pre_android/preconf/docker-entrypoint.sh +++ b/pre_android/preconf/docker-entrypoint.sh @@ -1,9 +1,5 @@ -hashed_name=`openssl x509 -inform PEM -subject_hash_old -in /ca-cert.pem | head -1` - adb start-server emulator -avd virtual_dev -writable-system -no-window -no-audio & -cp /ca-cert.pem /$hashed_name.0 -bash /preconf/install_cert.sh $hashed_name.0 bash /preconf/install_culebra.sh adb emu avd snapshot save configured diff --git a/pre_android/preconf/install_cert.sh b/pre_android/preconf/install_cert.sh deleted file mode 100644 index 0c0b5a6..0000000 --- a/pre_android/preconf/install_cert.sh +++ /dev/null @@ -1,45 +0,0 @@ -wait-for-offline() { - while [ $(adb devices | grep offline | wc -l) -eq 0 ]; do - sleep 0.1 - done -} - -adb wait-for-device -adb root - -wait-for-offline -adb wait-for-device -adb shell avbctl disable-verification - -#here may be the issue with the bypass (start) -adb wait-for-device -adb reboot - -adb wait-for-device -adb root -#(end) - -wait-for-offline -adb wait-for-device -adb remount - -adb wait-for-device -adb reboot - -adb wait-for-device -adb root - -wait-for-offline -adb wait-for-device -adb remount - -adb wait-for-device -adb push /$1 /system/etc/security/cacerts -adb shell chmod 664 /system/etc/security/cacerts/$1 -adb reboot - -#wait for complete boot -adb wait-for-device -while [ "$(adb shell getprop sys.boot_completed | tr -d '\r')" != "1" ]; do - sleep 1 -done