diff --git a/docs/redroid/README.md b/docs/redroid/README.md index abfa1ec..564b635 100644 --- a/docs/redroid/README.md +++ b/docs/redroid/README.md @@ -1,15 +1,48 @@ # About This Image -This Image contains a browser-accessible version of [Redroid](https://github.com/remote-android/redroid-doc). +This experimental image contains a browser-accessible version of [Redroid](https://github.com/remote-android/redroid-doc). redroid (Remote-Android) is a multi-arch, GPU enabled, Android in Cloud solution. +The image utilizes Docker in Docker (DinD) to automate launching Redroid and [scrcpy docs](https://github.com/Genymobile/scrcpy). + ![Screenshot][Image_Screenshot] [Image_Screenshot]: https://f.hubspotusercontent30.net/hubfs/5856039/dockerhub/image-screenshots/redroid.png "Image Screenshot" -## Important !! +## Host Dependencies + +This image requires the "binder_linux" host level kernel modules installed and enabled. + +Below is an example for installing binder_linux on Ubuntu 22.04 LTS host +``` +sudo apt install linux-modules-extra-`uname -r` +sudo modprobe binder_linux devices="binder,hwbinder,vndbinder" +``` +See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-file#getting-started) for more details. + + +## Container Permissions + +Using this container requires the `--privileged` flag to power both the Docker in Docker processes and the permissions +needed by the redroid containers + +``` +sudo docker run --rm -it --privileged --shm-size=512m -p 6901:6901 -e VNC_PW=password kasmweb/redroid:develop +``` + +## Example for installing binder_linux on Ubuntu 22.04 LTS host +``` +sudo apt install linux-modules-extra-`uname -r` +sudo modprobe binder_linux devices="binder,hwbinder,vndbinder" +``` + +The left ALT key is mapped as the hotkey for scrcpy + +- Alt+R - rotate the android device +- Alt+F - fullscreen the android device +- Alt+Up/Alt+Down - Increase the volume of the device + +See [scrcpy docs](https://github.com/Genymobile/scrcpy) for more details. -This image requires host level kernel modules to be installed and loaded. -See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-file#getting-started) for more details # Environment Variables @@ -22,3 +55,4 @@ See [Redroid Docs](https://github.com/remote-android/redroid-doc?tab=readme-ov-f * `REDROID_SHOW_CONSOLE` - Display the scrcpy console after launching the redroid device. * `REDROID_DISABLE_AUTOSTART` - If set to "1", the container will not automatically pull and start the redroid container and scrcpy. * `REDROID_DISABLE_HOST_CHECKS` - If set to "1", the container will not check for the presence of required host level kernel modules. +* `ANDROID_VERSION` - The version of android (redroid) image to automatically load. Options are `14.0.0`, `13.0.0` (Default), `12.0.0`, `11.0.0`, `10.0.0`, `9.0.0`, `8.1.0`. diff --git a/src/ubuntu/install/redroid/custom_startup.sh b/src/ubuntu/install/redroid/custom_startup.sh index f8bd860..1e4e4c6 100644 --- a/src/ubuntu/install/redroid/custom_startup.sh +++ b/src/ubuntu/install/redroid/custom_startup.sh @@ -34,16 +34,6 @@ function check_modules() { notify-send -u critical -t 0 -i "${ICON_ERROR}" "Redroid Error" "${msg}" exit 1 fi - - # Check for ashmem_linux module - if lsmod | grep -q ashmem_linux; then - echo "ashmem_linux module is loaded." - else - msg="Host level module ashmem_linux is not loaded. Cannot continue.\nSee https://github.com/remote-android/redroid-doc?tab=readme-ov-file#getting-started for more details." - echo msg - notify-send -u critical -t 0 -i "${ICON_ERROR}" "Redroid Error" "${msg}" - exit 1 - fi } start_android() { @@ -63,6 +53,7 @@ start_android() { adb connect localhost:5555 sleep 5 } + start_scrcpy() { if [ "$REDROID_SHOW_CONSOLE" == "1" ]; then @@ -71,7 +62,32 @@ start_scrcpy() { scrcpy --audio-codec=aac -s localhost:5555 --shortcut-mod=lalt --print-fps --max-fps=${REDROID_FPS} fi + wait_for_process $SCRCPY_PGREP } + +wait_for_process() { + process_match=$1 + timeout=60 + interval=1 + elapsed_time=0 + + echo "Waiting for $process_match..." + while [[ $elapsed_time -lt $timeout ]]; do + if pgrep -x $process_match > /dev/null; then + echo "$process_match is running, continuing..." + break + fi + sleep $interval + elapsed_time=$((elapsed_time + interval)) + done + + if ! pgrep -x $process_match > /dev/null + then + echo "Did not find process $process_match" + fi + +} + kasm_startup() { if [ -n "$KASM_URL" ] ; then URL=$KASM_URL