android-rom

IDE

Android Studio

# 必须完整编译一次后

mmm development/tools/idegen/
development/tools/idegen/idegen.sh

# 必须是导入 `android.ipr` 文件而不是 AOSP 目录

VSCode

# env SOONG_GEN_COMPDB=1 SOONG_GEN_COMPDB_DEBUG=1 mka nothing

# 完整编译一次后,进 devcontainer
# 注意要在 docker exec 的 bash 中执行,VSCode Terminal 中会有奇怪的错误
# docker exec -it -w /android-rom/src/LINEAGE_16_0/ <container name> /bin/bash
source build/envsetup.sh 
lunch lineage_x86_64-eng
mka sdk_addon

build lineageos with docker

for bullhead lineage-15.1, --depth=1 reduces ~50GB (~130GB => ~80GB)

lineage-15.1 (8.1.0)

mkdir -p out/lineage-15.1

# 同步和编译,禁用 microg 的 patch
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_INIT_ARGS=--depth=1" \
    -e "BRANCH_NAME=lineage-15.1" \
    -e "DEVICE_LIST=bullhead" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-15.1/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-15.1/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-15.1/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-15.1/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-15.1/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

# 修改代码后,不同步,只编译
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-15.1" \
    -e "DEVICE_LIST=bullhead" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-15.1/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-15.1/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-15.1/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-15.1/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-15.1/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

lineage-16.0 (9.0.0)

mkdir -p out/lineage-16.0

# 同步和编译,禁用 microg 的 patch
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_INIT_ARGS=--depth=1" \
    -e "BRANCH_NAME=lineage-16.0" \
    -e "DEVICE_LIST=dipper" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-16.0/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-16.0/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-16.0/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-16.0/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-16.0/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

# 修改代码后,不同步,只编译
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-16.0" \
    -e "DEVICE_LIST=dipper" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-16.0/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-16.0/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-16.0/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-16.0/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-16.0/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

lineageos-17.1 (10)

mkdir -p out/lineage-17.1

# 同步和编译,禁用 microg 的 patch
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_INIT_ARGS=--depth=1" \
    -e "BRANCH_NAME=lineage-17.1" \
    -e "DEVICE_LIST=dipper" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-17.1/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-17.1/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-17.1/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-17.1/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-17.1/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

# 修改代码后,不同步,只编译
docker run --rm \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-17.1" \
    -e "DEVICE_LIST=dipper" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-17.1/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-17.1/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-17.1/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-17.1/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-17.1/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023

lineageos-18.1 (11)

lineageos-19.1 (12.1)

lineageos-20.0 (13)

avd

docker run --rm \
    -e "VERBOSE=true" \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-16.0" \
    -e "DEVICE_LIST=generic_x86_64" \
    -e "AVD_TARGET=x86_64" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "CLEAN_AFTER_BUILD=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-16.0/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-16.0/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-16.0/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-16.0/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-16.0/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023
# 先去 sdk manager 把对应的 api level 的镜像取消勾选,例如 android-28
mkdir -p ~/Android/Sdk/system-images/android-28/google_apis/x86_64
# 把 out/lineage-16.0/zips/generic_x86_64/sdk_addon/lineage-eng.root-linux-x86-img.zip 解压进去
# 就可以在 AVD 里看到对应的镜像

# # arm on x86_64
# emulator -avd Pixel_6_Pro_API_27 -verbose -engine qemu2 -read-only -qemu -machine virt

# # x86_64 on x86_64
# emulator -avd Pixel_6_Pro_API_28 -verbose
# https://github.com/google/android-emulator-container-scripts
emu-docker list

wget https://dl.google.com/android/repository/emulator-linux_x64-10086546.zip

emu-docker -v create emulator-linux_x64-10086546.zip lineage-eng.root-linux-x86-img.zip --no-metrics

# TODO
#   adb
#   adb root
docker run \
  --rm \
  -e ADBKEY="$(cat ~/.android/adbkey)" \
  --device /dev/kvm \
  --publish 8554:8554/tcp \
  --publish 5555:5555/tcp  \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -e DISPLAY=$DISPLAY \
  us-docker.pkg.dev/android-emulator-268719/images/28-lineage-x64-no-metrics

Youpk

randomize

  • remove cjson
  • non-root DumpDir: /data/local/tmp/ or CacheDir or specfic path
  • skip
  • hide symbols
  • log tag

android-8.0.0_r21

# generate android-8.0.0_r21 from https://github.com/Humenger/Youpk8
# not verified
git clone --depth=1 -b android-8.0.0_r21 https://android.googlesource.com/platform/art android-8.0.0_r21/art
git clone --depth=1 -b android-8.0.0_r21 https://android.googlesource.com/platform/build android-8.0.0_r21/build
git clone --depth=1 -b android-8.0.0_r21 https://android.googlesource.com/platform/frameworks/base android-8.0.0_r21/frameworks/base
git clone --depth=1 -b android-8.0.0_r21 https://android.googlesource.com/platform/frameworks/native android-8.0.0_r21/frameworks/native

git clone --depth=1 https://github.com/Humenger/Youpk8
rsync -a Youpk8/android-8.0.0_r21/art/ android-8.0.0_r21/art
mv Youpk8/android-8.0.0_r21/build/make/core/tasks/check_boot_jars/package_whitelist.txt android-8.0.0_r21/build/core/tasks/check_boot_jars/package_whitelist.txt
rsync -a Youpk8/android-8.0.0_r21/frameworks/base/ android-8.0.0_r21/frameworks/base
rsync -a Youpk8/android-8.0.0_r21/frameworks/native/ android-8.0.0_r21/frameworks/native

mkdir -p youpk/android-8.0.0_r21
find android-8.0.0_r21 -name .git | xargs -L 1 dirname | xargs -I '{}' bash -c 'git -C "{}" config user.email "example@android.com" && git -C "{}" config user.name android && git -C "{}" add . && git -C "{}" commit -m diff && git -C "{}" diff HEAD~1 > youpk/android-8.0.0_r21/$(basename "{}").patch'

lineageos-15.1 (8.1.0)

verified

# 假设已经正常编译过一次,在 out/lineage-15.1

chmod +x "$(pwd)/userscripts/lineageos-15.1/before.sh" && \
chmod +x "$(pwd)/youpk/lineageos-15.1/build.patch.sh" && \
docker run --rm \
    -e "UNPACK_RAND=false" \
    -e "UNPACK_CONFIG_FILE=miui.config" \
    -e "UNPACK_LOG_TAG=woowoo" \
    -e "UNPACK_OUTPUT_DIR=oowoow" \
    -e "UNPACK_JAVA_CLASS=com.android.miui.pushd.Pusher" \
    -e "UNPACK_UNPACKER_LOWER=milink" \
    -e "UNPACK_UNPACKER_UPPER=Milink" \
    -e "UNPACK_UNPACK_NATIVE=jump" \
    -e "UNPACK_UNPACK=printk" \
    -e "UNPACK_CJSON=mipush" \
    -e "UNPACK_isFakeInvoke=a" \
    -e "UNPACK_afterInstructionExecute=b" \
    -e "UNPACK_beforeInstructionExecute=c" \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-15.1" \
    -e "DEVICE_LIST=bullhead" \
    -e "SIGN_BUILDS=false" \
    -e "BUILD_TYPE=eng" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -e "USERSCRIPTS_FAIL=true" \
    -v "$(pwd)/userscripts/lineageos-15.1:/home/ubuntu/userscripts:ro" \
    -v "$(pwd)/youpk/lineageos-15.1:/home/ubuntu/patch:ro" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-15.1/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-15.1/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-15.1/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-15.1/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-15.1/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023-non-root

lineageos-16.0 (9)

# 假设已经正常编译过一次,在 out/lineage-16.0

chmod +x "$(pwd)/userscripts/lineageos-16.0/before.sh" && \
chmod +x "$(pwd)/youpk/lineageos-16.0/build.patch.sh" && \
docker run --rm \
    -e "UNPACK_RAND=false" \
    -e "UNPACK_CONFIG_FILE=miui.config" \
    -e "UNPACK_LOG_TAG=woowoo" \
    -e "UNPACK_OUTPUT_DIR=oowoow" \
    -e "UNPACK_JAVA_CLASS=com.android.miui.pushd.Pusher" \
    -e "UNPACK_UNPACKER_LOWER=milink" \
    -e "UNPACK_UNPACKER_UPPER=Milink" \
    -e "UNPACK_UNPACK_NATIVE=jump" \
    -e "UNPACK_UNPACK=printk" \
    -e "UNPACK_CJSON=mipush" \
    -e "UNPACK_isFakeInvoke=a" \
    -e "UNPACK_afterInstructionExecute=b" \
    -e "UNPACK_beforeInstructionExecute=c" \
    -e "VERBOSE=true" \
    -e "REPO_SYNC=false" \
    -e "REPO_INIT=false" \
    -e "UPDATE_PROPRIETARY=false" \
    -e "ENABLE_GIT_RESET=false" \
    -e "ENABLE_GIT_CLEAN=false" \
    -e "BRANCH_NAME=lineage-16.0" \
    -e "DEVICE_LIST=generic_x86_64" \
    -e "AVD_TARGET=x86_64" \
    -e "BUILD_TYPE=eng" \
    -e "SIGN_BUILDS=false" \
    -e "SIGNATURE_SPOOFING=no" \
    -e "WITH_GMS=false" \
    -e "USE_PYTHON2=true" \
    -e "USE_GCC9=true" \
    -e "USERSCRIPTS_FAIL=true" \
    -v "$(pwd)/userscripts/lineageos-16.0:/home/ubuntu/userscripts:ro" \
    -v "$(pwd)/youpk/lineageos-16.0:/home/ubuntu/patch:ro" \
    -v "$(pwd)/src:/android-rom/src" \
    -v "$(pwd)/out/lineage-16.0/zips:/android-rom/zips" \
    -v "$(pwd)/out/lineage-16.0/logs:/android-rom/logs" \
    -v "$(pwd)/out/lineage-16.0/cache:/android-rom/ccache" \
    -v "$(pwd)/out/lineage-16.0/keys:/android-rom/keys" \
    -v "$(pwd)/out/lineage-16.0/manifests:/android-rom/local_manifests" \
    ghcr.io/hellodword/docker-lineage-cicd:dev2023-non-root

lineageos-16.0 (9.0.0)

lineageos-17.1 (10)

lineageos-18.1 (11)

lineageos-19.1 (12.1)

lineageos-20.0 (13)


reproducible