Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waydroid: initial implementation #114

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let
./flavors/grapheneos
./flavors/lineageos
./flavors/vanilla
./flavors/waydroid
./modules/10
./modules/11
./modules/12
Expand Down
34 changes: 34 additions & 0 deletions flavors/waydroid/anbox.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- Remove replaced Projects -->
<remove-project name="platform/system/libhidl" />
<remove-project name="LineageOS/android_system_libhwbinder" />
<remove-project name="platform/external/libdrm" />
<remove-project name="platform/external/mesa3d" />
<remove-project name="platform/hardware/intel/common/libva" />

<project path="system/libhidl" name="Anbox-halium/android_system_libhidl" />
<project path="system/libhwbinder" name="Anbox-halium/android_system_libhwbinder" />
<project path="external/libdrm" name="Anbox-halium/android_external_libdrm" />
<project path="external/mesa3d" name="Anbox-halium/android_external_mesa3d" />
<project path="hardware/intel/common/libva" name="Anbox-halium/android_hardware_intel_common_libva" />

<!-- Anbox Projects -->
<project path="anbox-patches" name="Anbox-halium/anbox-patches" />
<project path="device/halium/anbox" name="Anbox-halium/android_device_halium_anbox" />
<project path="hardware/anbox/interfaces" name="Anbox-halium/android_hardware_anbox_interfaces" />

<!-- Audio -->
<project path="external/alsa-lib" name="Anbox-halium/android_external_alsa-lib" />
<project path="external/alsa-plugins" name="Anbox-halium/android_external_alsa-plugins" />
<project path="external/libsndfile" name="Anbox-halium/android_external_libsndfile" />
<project path="external/pulseaudio" name="Anbox-halium/android_external_pulseaudio" />

<!-- Display -->
<project path="external/llvm90" name="Anbox-halium/android_external_llvm90" />

<!-- Media -->
<project path="external/ffmpeg" name="Anbox-halium/android_external_ffmpeg" />
<project path="external/stagefright-plugins" name="Anbox-halium/android_external_stagefright-plugins" />

</manifest>
58 changes: 58 additions & 0 deletions flavors/waydroid/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-FileCopyrightText: 2021 Daniel Fullmer
# SPDX-License-Identifier: MIT

{ config, pkgs, lib, ... }:
let
inherit (lib)
mkDefault
mkIf
mkMerge
mkBefore
;
repoDirs = lib.importJSON (./. + "/repo-lineage-17.1.json");
patchMetadata = lib.importJSON ./patch-metadata.json;
in mkIf (config.flavor == "waydroid")
{
buildDateTime = mkDefault 1629060864;

androidVersion = mkDefault 10;
productNamePrefix = "lineage_anbox_";
variant = mkDefault "userdebug";

source.dirs = mkMerge [
repoDirs
(lib.mapAttrs (relpath: patches: {
patches = (builtins.map (p: "${config.source.dirs."anbox-patches".src}/${relpath}/${p}") patches);
}) patchMetadata)
];

envVars.RELEASE_TYPE = mkDefault "EXPERIMENTAL"; # Other options are RELEASE NIGHTLY SNAPSHOT EXPERIMENTAL

# Traceback (most recent call last):
# File "external/mesa3d/src/panfrost/bifrost/bi_printer.c.py", line 203, in <module>
# from mako.template import Template
# ModuleNotFoundError: No module named 'mako'
# TODO: mkBefore here is a hack
envPackages = with pkgs; mkBefore [
(python2.withPackages (p: with p; [ Mako ]))
(python3.withPackages (p: with p; [ Mako ]))
];

build = {
waydroid = config.build.mkAndroid {
name = "robotnix-${config.productName}-${config.buildNumber}";
makeTargets = [ "systemimage" "vendorimage" ];
installPhase = ''
mkdir -p $out

cp -t $out \
$ANDROID_PRODUCT_OUT/android-info.txt \
$ANDROID_PRODUCT_OUT/build_fingerprint.txt \
$ANDROID_PRODUCT_OUT/installed-files.txt

cp --reflink=auto -r $ANDROID_PRODUCT_OUT/system.img $out
cp --reflink=auto -r $ANDROID_PRODUCT_OUT/vendor.img $out
'';
};
};
}
26 changes: 26 additions & 0 deletions flavors/waydroid/extract-patch-metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

import json
import os

from robotnix_common import checkout_git, save


def main() -> None:
data = json.load(open('repo-lineage-17.1.json'))
anbox_patches = data['anbox-patches']
git_info = checkout_git(anbox_patches['url'], anbox_patches['rev'])
topdir = git_info['path']

output = {}
for dirpath, dirs, files in os.walk(topdir):
if any(f.endswith('.patch') for f in files):
if dirpath.startswith(topdir):
dirpath = dirpath[len(topdir)+1:]
output[dirpath] = sorted(files)

save('patch-metadata.json', output)


if __name__ == '__main__':
main()
98 changes: 98 additions & 0 deletions flavors/waydroid/patch-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"bionic": [
"0001-hybris-don-t-fail-because-of-fsetxattr.patch",
"0002-anbox-add-vendor_extra-lib-folders-to-default-librar.patch"
],
"build/soong": [
"0001-anbox-do-not-fail-on-VNDK-ABI-mismatch.patch"
],
"external/wayland-protocols": [
"0001-stable-Add-xdg-shell.patch"
],
"frameworks/av": [
"0001-libcameraservice-Use-listByInterface.patch",
"0002-media-xmlparser-Add-host-dirs-to-search-path.patch",
"0003-mediacodec-Use-vendor_extra-seccomp-minijail.patch",
"0004-media-Add-host-media_profiles-search-paths.patch",
"0005-drm-Fix-drm-on-older-vendors.patch",
"0006-codec2-Fix-media-on-older-vendors.patch",
"0007-SW-encode-Fix-output-buffer-size.patch",
"0007-apex-Add-vendor_extra-to-ld-search-paths.patch",
"0008-Change-max-width-and-height-supported-by-H.263-decod.patch",
"0009-FLACExtractor-Add-more-sample-rates-support.patch",
"0010-Don-t-use-YV12-color-format-for-video-decoding.patch",
"0011-Allow-screenrecord-usage-on-Android-x86.patch",
"0012-media-enable-dithering-for-RGB565-conversion.patch",
"0013-nuplayer-skip-bad-SAR-values.patch",
"0014-stagefright-Add-support-for-loading-a-custom-OMXPlug.patch",
"0015-stagefright-allow-multiple-custom-OMXPlugins.patch",
"0016-libstagefright-Extended-media-support-via-FFMPEG.patch",
"0017-Add-paths-and-system-libraries-for-swcodec-APEX.patch",
"0018-Setup-FFMPEG-audio-mpeg-L2-codec-correctly.patch"
],
"frameworks/base": [
"0001-anbox-disable-SELinux-parts.patch",
"0002-anbox-disable-suspend-control.patch",
"0003-temp-anbox-neutralize-sound-pool-audio-sample-loadi.patch",
"0004-anbox-core-jni-start-thread-pool-for-host-hwbinder-w.patch",
"0005-fwb-Don-t-check-vintf-compatibility.patch",
"0006-Prevent-the-system-from-entering-a-sleep-state.patch",
"0007-core-Add-support-for-MicroG.patch",
"0008-AndroidManifest-add-a-permission-group-for-signature.patch",
"0009-Zygote-Disable-seccomp.patch"
],
"frameworks/native": [
"0001-anbox-installd-run-without-SELinux.patch",
"0002-halium-disable-SELinux-checks-in-ServiceManager.patch",
"0003-halium-never-set-FLAT_BINDER_FLAG_TXN_SECURITY_CTX-f.patch",
"0004-Hack-EventHub-until-it-works-with-our-fake-evdev-eve.patch",
"0005-surfaceflinger-Provide-layer-names-and-stuffs.patch",
"0006-EventHub-Add-wayland-inputs-support.patch",
"0007-inputflinger-add-absolute-event-support-for-cursor.patch",
"0008-RenderEngine-support-non-RGBA_8888-format.patch",
"0009-libEGL-select-pixel-format-by-EGL_NATIVE_VISUAL_ID.patch"
],
"hardware/libhardware": [
"0001-anbox-add-vendor_extra-lib-hw-to-HAL-search-path.patch",
"0002-libhardware-Don-t-check-for-ro.hardware.patch"
],
"packages/apps/PermissionController": [
"0001-Utils-add-FAKE_PACKAGE_SIGNATURE-to-platform-permiss.patch"
],
"packages/apps/Settings": [
"0001-Settings-Disable-double_tap_sleep_gesture-by-default.patch"
],
"system/core": [
"0001-anbox-init-start-inside-LXC-container-without-SELinu.patch",
"0002-anbox-init-modify-mount_all-to-skip-mounts-and-trigg.patch",
"0003-anbox-healthd-adjust-backup-service-name-to-avoid-co.patch",
"0004-temp-anbox-temporary-disable-adbd.patch",
"0005-anbox-add-vendor_extra-path-as-a-clone-of-vendor-ent.patch",
"0006-libsync-Add-sw_sync-symbols-to-map.patch",
"0007-sdcard-Bring-back-fuse.patch",
"0008-sdcard-Add-full-mount-directory.patch"
],
"system/hardware/interfaces": [
"0001-suspend-Set-mUseSuspendCounter-to-true.patch"
],
"system/hwservicemanager": [
"0001-halium-disable-SELinux-parts.patch"
],
"system/netd": [
"0001-netd-Fix-networking.patch"
],
"system/nfc": [
"0001-nfc-Add-host-search-paths.patch"
],
"system/security": [
"0001-keystore-Supress-SELinux-errors.patch"
],
"system/tools/hidl": [
"0001-anbox-Allow-host_hwbinder-to-be-used-for-HALs.patch"
],
"system/vold": [
"0001-vold-Fix-fuse-sdcard.patch",
"0002-vold-Drop-selinux-checks-on-prepare_subdirs.patch",
"0003-Revert-Remove-waitpid-on-UnMount.patch"
]
}
Loading