diff --git a/README.md b/README.md index ec32f15..8079fa5 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,26 @@ English | [简体中文](zh/) **ReDroid** (Remote Android) is a lightweight GPU accelerated Android Emulator. You can boot many instances in Linux host or any Linux container envrionments (`Docker`, `K8S`, `LXC` etc.). *ReDroid* supports both arm64 and x86_64 architectures. You can connect to *ReDroid* througth -`VNC` or `WebRTC` (TODO) or `adb` shell. *ReDroid* is suitable for Cloud Gaming, +`VNC` or `WebRTC` (TODO) or `adb shell`. *ReDroid* is suitable for Cloud Gaming, VDI / VMI (Virtual Mobile Infurstrure), Automation Test and more. -Currently supported Android version: -- Android 8 (GPU enabled) -- Android 9 (GPU enabled) -- Android 10 (ongoing) +Currently supported: +- Android 11 (`redroid/redroid:11.0.0-latest`, `redroid/redroid:11.0.0-amd64`, `redroid/redroid:11.0.0-arm64`) +- Android 10 (`redroid/redroid:10.0.0-latest`, `redroid/redroid:10.0.0-amd64`, `redroid/redroid:10.0.0-arm64`) +- Android 9 (`redroid/redroid:9.0.0-latest`, `redroid/redroid:9.0.0-amd64`, `redroid/redroid:9.0.0-arm64`) +- Android 8.1 (`redroid/redroid:8.1.0-latest`, `redroid/redroid:8.1.0-amd64`, `redroid/redroid:8.1.0-arm64`) + + +## Quick Start +*ReDroid* runs on modern linux (kernel 4.14+), and require some Android specific modules (binder, ashmem at least) +check [kernel modules](https://github.com/remote-android/redroid-modules) for more. -## Quick Started via Docker -*ReDroid* runs on modern linux (currently require kernel version 4.14+), and require some Android specific -drivers (binder, ashmem at least) check [kernel modules](https://github.com/remote-android/redroid-modules) -for more details. ```bash -# quick install kernel driver via docker, change *NODE_OS* to actual OS (ubuntu:18.04 for example) -docker run --cap-add CAP_SYS_MODULE --entrypoint bash <(curl -s https://raw.githubusercontent.com/remote-android/redroid-modules/master/deploy/build.sh) +# install kernel modules +sudo bash -c "`curl -s https://raw.githubusercontent.com/remote-android/redroid-modules/master/deploy/build.sh`" -# start a ReDroid instance via docker -docker run -v ~/data:/data -itd -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/redroid +# start ReDroid instance +docker run -v ~/data:/data -itd -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/redroid:10.0.0-latest ## explains: ## -v ~/data:/data -- mount data partition @@ -32,21 +34,21 @@ docker run -v ~/data:/data -itd -p 5900:5900 -p 5555:5555 --rm --memory-swappine ## Start Params required params (already added in image args) - qemu=1 -- androidboot.hardware=goldfish +- androidboot.hardware=redroid display params - redroid.width=720 - redroid.height=1280 -- redroid.density=320 - redroid.fps=15 +- ro.sf.lcd_density=320 GPU accelerating *ReDroid* use mesa3d to accelerate 3D rendering. - qemu.gles.vendor=mesa -- ro.hardware.gralloc=[minigbm|minigbm_intel] +- ro.hardware.gralloc=minigbm you can override system props prefixed with `qemu.` or `ro.`. for example, you can set `ro.secure=0`, then -you can get root adb shell. +you can get root adb shell by default. ## Deployment *ReDroid* support different deploy methods, check [Deploy](./deploy.md) for more details. @@ -57,33 +59,48 @@ you can get root adb shell. - Package Manager ## Native Bridge -It's possible to run Arm Apps in x86 *ReDroid* instance with `libhoudini`, `ARM translater` or `Qemu translater` -check [Native Bridge](./native_bridge.md) for more details. +It's possible to run Arm Apps in x64 *ReDroid* instance with `libhoudini`, `libndk_translator` or `Qemu translater` + +Check [Native Bridge](./native_bridge) for more. ## GMS -It's possible to add GMS (Google Mobile Service) support in *ReDroid* instance via Google packages or `MicroG`. -check [GMS](./gms.md) for more details. +It's possible to add GMS (Google Mobile Service) support in *ReDroid* via Google packages or `MicroG`. + +Check [GMS](./gms.md) for more. ## WebRTC -Compared with RFB (VNC), WebRTC is more versatile (audio / video / camera support...). -*ReDroid* is planning to implement WebRTC protocol. Check [WebRTC](./webrtc.md) for more details. +Compared with `RFB` (VNC), `WebRTC` is more versatile (audio / video / camera / sensors data...). +*ReDroid* is planning to implement `WebRTC` protocol. Check [WebRTC](./webrtc.md) for more. ## Build -1. setup build environment, check [AOSP setup](https://source.android.com/setup/build/initializing#installing-required-packages-ubuntu-1404) -section. Suggest build with [docker](https://android.googlesource.com/platform/build/+/master/tools/docker) -2. `repo init https://github.com/remote-android/platform_manifests.git -b redroid-8.1.0` (you can change to other branches, such as -redroid-9.0.0, redroid-10.0.0) -3. `. build/envsetup.sh && lunch` -4. choose `redroid_x86_64-userdebug` or `redroid_arm64-userdebug` -5. run `m` to build all +Same as AOSP building process. check [AOSP setup](https://source.android.com/setup/build/initializing#installing-required-packages-ubuntu-1404) + +Check [ReDroid build](./build.md) for more. + +## Troubleshooting +- cannot connect to network (cannot `ping`) + - `adb shell boot_completed.redroid.sh` +- VNC screen hang + - try `stop vncserver && start vncserver` + - or reboot *ReDroid* instance `docker restart ...` +- icon in launcher gone + - if switching between GPU / swiftshader (soft), try to clear launcher data or entire data partition +- `fuse` setup failed + - try `modprobe fuse` ## Contributing -Contributing is always welcome (especially the `HAL` part). Please make minimal changes to AOSP code. +Contributing is always welcome (especially the `HAL` part). check [Contributing](./contributing.md) for more ## Workarounds -- SElinux is disabled in *ReDroid*; check [selinuxns POC](http://namei.org/presentations/selinux_namespacing_lca2018.pdf) -- sdcardfs currently not implemented as modules, use `fuse` instead; +- SElinux is disabled in *ReDroid*; possible enabled with [selinuxns POC](http://namei.org/presentations/selinux_namespacing_lca2018.pdf) +- sdcardfs currently not implemented, use `fuse` instead; may need run `modprobe fuse` first in some OS (AmazonLinux2?) - CGroups errors ignored; some cgroups path not same with generic linux, and some (`stune` for example) not supported - `procfs` not fully seperated with host OS; community use `lxcfs` and some cloud vendor ([TencentOS](https://github.com/Tencent/TencentOS-kernel)) enhanced in their own kernel. - vintf verify disabled (since no kernel) +## License +*ReDroid* itself is under [Apache License](https://www.apache.org/licenses/LICENSE-2.0), since *ReDroid* includes +many 3rd party modules, you may need to examine license carefully. + +*ReDroid* kernel modules are under [GPL v2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) + diff --git a/build.md b/build.md new file mode 100644 index 0000000..f5bb48a --- /dev/null +++ b/build.md @@ -0,0 +1,26 @@ +# Build ReDroid + +## Get Source +- `repo init -u git@github.com:remote-android/platform_manifests.git -b [BRANCH] && repo sync -c` +BRANCH could be redroid-8.1.0, redroid-9.0.0, redroid-10.0.0, redroid-11.0.0 ... + +## Build +suggest build with [docker](./docker) + +```bash +# intent changes for redroid-10.0.0 (copyfile hook during repo sync), DO NOT Panic +# [Android Clang/LLVM Toolchain](https://android.googlesource.com/toolchain/llvm_android/) + +project prebuilts/clang/host/linux-x86/ (*** NO BRANCH ***) + -m clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.scudo_minimal-aarch64-android.a + -m clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.scudo_minimal-arm-android.a + -m clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.scudo_minimal-i686-android.a + -m clang-r353983c/lib64/clang/9.0.3/lib/linux/libclang_rt.scudo_minimal-x86_64-android.a +``` + +## Run +1. `export BUILD_OUT=~/redroid_out` +2. create rootfs only image (Dev purpose): `cd $BUILD_OUT && sudo tar --xattrs -c -C root . | docker import -c 'ENTRYPOINT ["/init", "qemu=1", "androidboot.hardware=redroid"]' - redroid-dev` +3. run with rootfs only image: `docker run -v ~/data:/data -itd -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged -v $BUILD_OUT/redroid_x86_64/system:/system -v $BUILD_OUT/redroid_x86_64/vendor:/vendor redroid-dev` +4. create full image: `cd $BUILD_OUT && sudo tar --xattrs -c system vendor -C root --exclude="system" --exclude="vendor" . | docker import -c 'ENTRYPOINT ["/init", "qemu=1", "androidboot.hardware=redroid"]' - redroid` +5. run with full image: `docker run -v ~/data:/data -itd -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid` diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..854139a --- /dev/null +++ b/contributing.md @@ -0,0 +1 @@ +# Contributing diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f9fc65d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:14.04 + +ARG userid +ARG groupid +ARG username + +# COPY apt.conf /etc/apt/apt.conf + +COPY sources.list etc/apt/sources.list + +# gettext python-mako python3-mako used to build mesa3d +RUN apt-get update && apt-get install -y git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip python gettext python-mako python3-mako + +RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo \ + && chmod a+x /usr/local/bin/repo + +RUN groupadd -g $groupid $username \ + && useradd -m -u $userid -g $groupid $username \ + && echo $username >/root/username \ + && echo "$username:$username" | chpasswd && adduser $username sudo + +ENV HOME=/home/$username \ + USER=$username \ + PATH=/src/.repo/repo:/src/prebuilts/jdk/jdk8/linux-x86/bin/:$PATH \ + USE_CCACHE=1 \ + CCACHE_DIR=/src/.ccache + +ENTRYPOINT chroot --userspec=$(cat /root/username):$(cat /root/username) / /bin/bash -i diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..13bbb78 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,12 @@ +# Build ReDroid with docker + +create build image: `docker build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t android-build-trusty .` +run build image: `docker run -it --rm -v $ANDROID_BUILD_TOP:/src android-build-trusty` + +build *ReDroid*: +- `cd /src; . build/envsetup.sh` +- `lunch` +- `m` + +sync build (required) +- `export BUILD_OUT=~/redroid_out && ./sync.sh` (pasword same as `id -un`) diff --git a/docker/apt.conf b/docker/apt.conf new file mode 100644 index 0000000..296f8b5 --- /dev/null +++ b/docker/apt.conf @@ -0,0 +1,3 @@ + +Acquire::https::proxy "http://some-proxy:8080"; +Acquire::https::proxy "https://some-proxy:8080/"; diff --git a/docker/sources.list b/docker/sources.list new file mode 100644 index 0000000..5ceebcb --- /dev/null +++ b/docker/sources.list @@ -0,0 +1,10 @@ +deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse +deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse +deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse +deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse +deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse +deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse diff --git a/gms.md b/gms.md index 582c422..6c076ff 100644 --- a/gms.md +++ b/gms.md @@ -1,3 +1,7 @@ # GMS support in ReDroid -TODO +## Open GApps +[Open GApps](https://opengapps.org/) + +## microG +[microG](https://microg.org/) diff --git a/gpu.md b/gpu.md new file mode 100644 index 0000000..6c65ed0 --- /dev/null +++ b/gpu.md @@ -0,0 +1,5 @@ + +i965 / iris* +AMD Radeon +VMWare vGPU (Nvidia) +Nvidia diff --git a/native_bridge.md b/native_bridge.md deleted file mode 100644 index 287d755..0000000 --- a/native_bridge.md +++ /dev/null @@ -1,2 +0,0 @@ -# Native Support in ReDroid -TODO diff --git a/native_bridge/Dockerfile b/native_bridge/Dockerfile new file mode 100644 index 0000000..ed16a5b --- /dev/null +++ b/native_bridge/Dockerfile @@ -0,0 +1,7 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE + +ADD native-bridge.tar / + +# use factory.prop to override prop +COPY factory.prop /factory/factory.prop diff --git a/native_bridge/README.md b/native_bridge/README.md new file mode 100644 index 0000000..65804eb --- /dev/null +++ b/native_bridge/README.md @@ -0,0 +1,35 @@ +# Native Bridge Support in ReDroid + +There are several choose to support native bridge (typically for arm) in *ReDroid* +- `libndk_translation` from Arm +- `libhoudini` from Intel +- `QEMU` + +Prepare the resource and build the image. +And run `docker build --build-arg BASE_IMAGE= .` + +```bash +# example structure, be careful the file owner and mode + +system/ +├── bin +│   ├── arm +│   └── arm64 +├── etc +│   ├── binfmt_misc +│   └── init +├── lib +│   ├── arm +│   └── libnb.so +└── lib64 + ├── arm64 + └── libnb.so + +# grab libndk_translation from Android 11 Emulator +find /system \( -name 'libndk_translation*' -o -name '*arm*' -o -name 'ndk_translation*' \) | tar -cf native-bridge.tar -T - + +``` + +Example: Patch llibndk_translation in ReDroid 11 + +![Screenshot of ReDroid 11 with libndk_translation](./redroid_11_libndk_translation.png) diff --git a/native_bridge/factory.prop b/native_bridge/factory.prop new file mode 100644 index 0000000..a8e3a24 --- /dev/null +++ b/native_bridge/factory.prop @@ -0,0 +1,10 @@ +ro.product.cpu.abilist=x86_64,arm64-v8a,x86,armeabi-v7a,armeabi +ro.product.cpu.abilist64=x86_64,arm64-v8a +ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi +ro.dalvik.vm.isa.arm=x86 +ro.dalvik.vm.isa.arm64=x86_64 +ro.enable.native.bridge.exec=1 +ro.dalvik.vm.native.bridge=libndk_translation.so + +# other vendor props +ro.ndk_translation.version=0.2.2 diff --git a/native_bridge/redroid_11_libndk_translation.png b/native_bridge/redroid_11_libndk_translation.png new file mode 100644 index 0000000..6ebb44d Binary files /dev/null and b/native_bridge/redroid_11_libndk_translation.png differ diff --git a/zh/README.md b/zh/README.md index 06d4122..0355b05 100644 --- a/zh/README.md +++ b/zh/README.md @@ -1,3 +1,5 @@ +[English](..) | 简体中文 + # ReDroid TODO :)