Custom Anbox installation files & patches, including patched Android OS image file.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

129 lines
4.7 KiB

# NOTE NOTE NOTE
# This is a very rough shell script file. Untested, and not intended to run in a single run. Just tells chronological order of necessary commands to compile Android OS on an Arch Linux system.
# Ref: https://gist.github.com/ssz66666/8422d46eae83ce7240f5547d129bf29c
# Ref: https://github.com/anbox/anbox/blob/master/docs/build-android.md
##################
# Required: aosp-devel packages
# https://aur.archlinux.org/packages/aosp-devel/
WORKDIR="${PWD}/aosp"
rm -rf ${WORKDIR}/out/*
ln -s /usr/bin/python2 ./python
export PATH=$PWD:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
cd ${WORKDIR}
# This takes A LOT of time, since ~280GiB must be downloaded.
# Full Android source code with all commit histories etc. This is not a shallow copy.
# TODO this manifest file contains old Android version tag. Should be replaced with android-9.0.0_r57 or newer
# For available versions, see i.e.: https://android.googlesource.com/platform/frameworks/support
repo init -u https://github.com/anbox/platform_manifests.git -b anbox
repo sync -j6
sudo pacman -S repo
# Check all deps of AUR pkg aosp-devel are installed (/home/fincer/ssd/arch_linux_programs/aosp-devel)
cd /media/a2ee7134-4f0e-4aa7-a12e-ee2b949fbb0b/
# Not merged, as of 6th June 2020
# Audio timing fix:
# https://github.com/anbox/anbox/pull/1034
cp -f ./patch_audio01_timing.patch aosp/vendor/patch_audio01_timing.patch
cp -f ./patch_audio02_pass-messenger.patch aosp/vendor/patch_audio02_pass-messenger.patch
cp -f ./patch_initcgroups.patch aosp/patch_initcgroups.patch
# Disable foreground/background activity checks and functionality of built-in Gallery apps for Desktop use
# Comment onPause and onResume functions and related parts
# This helps when using multiple apps simultaneosly and playing a video/music track. Originally,
# playback pauses which is not a wanted feature in desktop Android. In this patch, we disable all relevant code
# parts which cause this pause.
cp -f ./patch_gallery2_no-activity-checks.patch aosp/patch_gallery2_no-activity-checks.patch
cd ${WORKDIR}/vendor/anbox
patch -Np1 -i ../patch_audio01_timing.patch
patch -Np1 -i ../patch_audio02_pass-messenger.patch
cd ${WORKDIR}
# We don't have several cgroups in native Linux. Avoid unnecessary kernel errors.
# Disabled 'schedtune' cgroup as it targets Android ARM devices. Reason for it is to
# add more efficient CPU usage. However, native Linux kernel does not populate
# cgroup subsystem 'schedtune', and we see complaints about that in dmesg output.
# This image has modified /init.rc file with commented out lines related to schedtune
# Additional cgroups have been also commented out in the same file to avoid kernel complaints
# 'Need name or subsystem set'
patch -Np1 -i ./patch_initcgroups.patch
# Already merged, as of 6th June 2020
# Server side decoration fix:
# https://github.com/anbox/anbox/pull/1415
#ln -s patch_serversidedecoration.patch aosp/vendor/patch_serversidedecoration.patch
patch -Np1 -i ./patch_gallery2_no-activity-checks.patch
archlinux-java set java-8-openjdk
cd ${WORKDIR}/
. build/envsetup.sh
lunch anbox_x86_64-userdebug
# Disable JACK
sed -i -r 's/(ANDROID_COMPILE_WITH_JACK := )true/\1false/' ${WORKDIR}/build/core/combo/javac.mk
#export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx2G"
# RUN THIS IN SEPARATE SHELL!
# Jack server must be run during compilation process
#while true; do
# sleep 2
# if [ -f aosp/out/host/linux-x86/bin/jack-admin ]; then
# aosp/out/host/linux-x86/bin/jack-admin start-server
# break
# fi
#done
LC_ALL=C make -j$(nproc --ignore 1)
# Takes ~3 hours to compile with 11 CPU cores
if [[ $? -eq 0 ]]; then
rm -f $HOME/.jack-settings
rm -rf $HOME/.jack-server
fi
cd $WORKDIR/vendor/anbox/
scripts/create-package.sh ${PWD}/../../out/target/product/x86_64/ramdisk.img ${PWD}/../../out/target/product/x86_64/system.img
# Image will locate at aosp/vendor/anbox/android.img
# To compile a single element (e.g. a modified system app), use the following (example)
# cd aosp
# source build/envsetup.sh
# mmma packages/apps/Gallery2/
# For more information:
# https://elinux.org/Android_Build_System
# ----------
# Copy all parts from aosp/out/target/product/x86_64/system/ into unsquashed android.img using rsync
# Correct ownership of the copied files (chown ...) and squash the files into a new android.img file
# Stop Anbox container & session managers by issuing
# sudo systemctl stop anbox-container-manager (stops user session manager automatically)
# Copy the new image file into /var/lib/anbox/android.img
# Restart Anbox container & session managers by issuing
# sudo systemctl start anbox-container-manager.service && sleep 3 && systemctl --user start anbox-session-manager