maos: scaffold overlay to swap GrapheneOS stock apps with Modern Apps
- Commit
159ab29e61119fe550445756fe933fb911ffb996- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-09 03:56 UTC (3 months ago)
- Parents
- none
Diff
.gitattributes
diff --git a/.gitattributes b/.gitattributesnew file mode 100644index 0000000..4befa4e--- /dev/null+++ b/.gitattributes@@ -0,0 +1,8 @@+# MAOS ships Android/AOSP build files consumed on a Linux build host.+# Force LF so shell shebangs and Soong/Make parsing don't break on CRLF.+* text=auto eol=lf+*.sh text eol=lf+*.bp text eol=lf+*.mk text eol=lf+*.xml text eol=lf+*.md text eol=lf
.gitignore
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..159cb26--- /dev/null+++ b/.gitignore@@ -0,0 +1,3 @@+# Prebuilt APKs are large binaries populated at build time by scripts/collect-apks.sh.+# They are reproducible from the Modern-Apps repo, so we don't commit them.+prebuilts/*.apk
Android.bp
diff --git a/Android.bp b/Android.bpnew file mode 100644index 0000000..ae888d1--- /dev/null+++ b/Android.bp@@ -0,0 +1,106 @@+soong_namespace {+}++// Modern Apps prebuilt userspace apps for MAOS (Modern Apps OS).+//+// Each app ships as an android_app_import so its existing com.vayunmathur signing+// certificate (the README SHA-256 cert) is preserved via `presigned: true`. Do NOT+// port these Gradle/Compose apps to Soong.+//+// APKs live in prebuilts/ and are populated by scripts/collect-apks.sh before a build.++android_app_import {+ name: "ModernAppsWeb",+ apk: "prebuilts/web-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsCamera",+ apk: "prebuilts/camera-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsPdf",+ apk: "prebuilts/pdf-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsContacts",+ apk: "prebuilts/contacts-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsCalculator",+ apk: "prebuilts/calculator-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsClock",+ apk: "prebuilts/clock-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++// Files is PRIVILEGED: in the system build it absorbs DocumentsUI's Storage Access+// Framework role and therefore needs the signature|privileged MANAGE_DOCUMENTS+// permission, allowlisted in privapp-permissions-modern-apps.xml. It installs to+// /product/priv-app. The SAF picker UI itself is implemented in the Files app's+// system build variant (Modern-Apps repo), not here.+android_app_import {+ name: "ModernAppsFiles",+ apk: "prebuilts/files-release.apk",+ presigned: true,+ privileged: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsPhotos",+ apk: "prebuilts/photos-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsStore",+ apk: "prebuilts/appstore-release.apk",+ presigned: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}
README.md
diff --git a/README.md b/README.mdnew file mode 100644index 0000000..2c28537--- /dev/null+++ b/README.md@@ -0,0 +1,84 @@+# MAOS — Modern Apps OS++A GrapheneOS-derived Android OS that ships the [Modern Apps](https://github.com/vayun-mathur)+ecosystem (`com.vayunmathur.*`) in place of the stock GrapheneOS/AOSP userspace apps.++This repository is the **overlay** — the single repo you maintain. It is added to a+GrapheneOS source tree at `vendor/modern-apps/` via a `repo` local manifest. There are+**no long-lived AOSP forks**: additions, removals, and config are all expressed as+overlays. (Full design rationale lives in `GRAPHENEOS_FORK_PLAN.md` in the Modern-Apps+repo.)++## Apps swapped++| Modern App | Package | Replaces |+| --- | --- | --- |+| Web | `com.vayunmathur.web` | Vanadium (browser only; WebView kept) |+| Camera | `com.vayunmathur.camera` | GrapheneOS Camera |+| PDF | `com.vayunmathur.pdf` | PdfViewer |+| Contacts | `com.vayunmathur.contacts` | AOSP Contacts |+| Calculator | `com.vayunmathur.calculator` | AOSP Calculator |+| Clock | `com.vayunmathur.clock` | AOSP DeskClock |+| Files | `com.vayunmathur.files` | **DocumentsUI** (Files also takes over the SAF role — see below) |+| Photos | `com.vayunmathur.photos` | AOSP Gallery |+| App Store | `com.vayunmathur.appstore` | GrapheneOS Apps |++## Layout++```+Android.bp # android_app_import per app (Files: privileged)+modern_apps.mk # PRODUCT_PACKAGES += ours; filter-out stock; overlays; privapp+privapp-permissions-modern-apps.xml # MANAGE_DOCUMENTS for Files+overlay/ # static frameworks/base overlay+ frameworks/base/core/res/res/values/config.xml # config_defaultBrowser, config_documentsUiPackage+prebuilts/ # release APKs (git-ignored; populated by script)+scripts/collect-apks.sh # copies Modern-Apps release APKs into prebuilts/+local_manifest.xml # adds this repo to the GrapheneOS tree+```++## Usage++1. Set up a GrapheneOS build environment and choose a release branch.+2. Before `repo sync`, symlink the local manifest:+ ```bash+ mkdir -p .repo/local_manifests+ ln -s /path/to/MAOS/local_manifest.xml .repo/local_manifests/modern-apps.xml+ repo sync+ ```+ This lands the overlay at `vendor/modern-apps/`.+3. Inherit the product config **last** in your device makefile+ (`device/.../aosp_<device>.mk`):+ ```make+ $(call inherit-product, vendor/modern-apps/modern_apps.mk)+ ```+4. Populate the prebuilt APKs (build them from Modern-Apps first):+ ```bash+ vendor/modern-apps/scripts/collect-apks.sh /path/to/Modern-Apps+ ```+5. Build, sign with your own keys, and rebrand (you cannot ship as "GrapheneOS").++## Notes++- **Vanadium stays installed** as the system WebView provider; only the default *browser*+ role moves to Web (via `config_defaultBrowser`). Our Web app relies on system WebView.+- **Files absorbs DocumentsUI.** DocumentsUI is the system Storage Access Framework (SAF)+ picker (`OPEN_DOCUMENT` / `CREATE_DOCUMENT` / `OPEN_DOCUMENT_TREE` / `GET_CONTENT`), not+ just a file manager. Removing it requires Files to take over that role **in the system+ build only**:+ - `config_documentsUiPackage` is overlaid to `com.vayunmathur.files`.+ - Files ships as a **priv-app** holding `MANAGE_DOCUMENTS` (see the privapp allowlist).+ - The SAF picker UI itself is a **system build variant** of the Files app, implemented in+ the Modern-Apps repo (tracked separately). The plain F-Droid/userspace Files build stays+ an ordinary file manager and must not request `MANAGE_DOCUMENTS`.+- **APKs are `presigned`** so each keeps its `com.vayunmathur` certificate, preserving the+ app-store update chain. The *OS* is signed with your own platform keys.+- **Silent-breakage guard:** `modern_apps.mk` fails the build if any stock module we meant+ to drop is still present in `PRODUCT_PACKAGES` (guards against upstream renames).+- Alternative to `filter-out`: AOSP's `overrides:` field on `android_app_import` also+ removes a named module. We use `filter-out` for a single, explicit removal list.++## OTA++MAOS uses the standard GrapheneOS/AOSP A/B OTA flow (`update_engine` + a forked/overlaid+Updater pointed at your own signed release server). See the OTA section of+`GRAPHENEOS_FORK_PLAN.md`.
local_manifest.xml
diff --git a/local_manifest.xml b/local_manifest.xmlnew file mode 100644index 0000000..5426114--- /dev/null+++ b/local_manifest.xml@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="UTF-8"?>+<!--+ MAOS local manifest.++ Symlink this into your GrapheneOS checkout BEFORE `repo sync`:++ mkdir -p .repo/local_manifests+ ln -s /path/to/MAOS/local_manifest.xml .repo/local_manifests/modern-apps.xml+ repo sync++ This adds the overlay at vendor/modern-apps and (optionally) drops the source of the+ stock apps we replace.+-->+<manifest>+ <remote name="maos-github" fetch="https://github.com/vayun-mathur/" />++ <!-- The overlay repo (this repo) lands at vendor/modern-apps. -->+ <project path="vendor/modern-apps" name="MAOS" remote="maos-github" revision="main" />++ <!--+ OPTIONAL: remove the SOURCE of the stock apps we replace. Not required — modern_apps.mk+ already strips them from PRODUCT_PACKAGES via $(filter-out ...), and leaving the source+ in the tree is harmless. Enable these only if you also want the source gone, and CONFIRM+ each project name against the GrapheneOS manifest for your release tag first (names differ+ across tags). Removing DocumentsUI source is safe because Files takes over its SAF role.++ <remove-project name="platform_packages_apps_Contacts" />+ <remove-project name="platform_packages_apps_DeskClock" />+ <remove-project name="platform_packages_apps_ExactCalculator" />+ <remove-project name="platform_packages_apps_Gallery2" />+ <remove-project name="platform_packages_apps_DocumentsUI" />+ <remove-project name="GrapheneOS/Camera" />+ <remove-project name="GrapheneOS/PdfViewer" />+ <remove-project name="GrapheneOS/Apps" />+ -->+</manifest>
modern_apps.mk
diff --git a/modern_apps.mk b/modern_apps.mknew file mode 100644index 0000000..3c99bd9--- /dev/null+++ b/modern_apps.mk@@ -0,0 +1,60 @@+# MAOS (Modern Apps OS) — product configuration overlay.+#+# Include this from your device product makefile AFTER the base GrapheneOS/AOSP+# product has been inherited, so the $(filter-out ...) below can see and remove the+# stock app modules. Example (in device/.../aosp_<device>.mk):+#+# $(call inherit-product, vendor/modern-apps/modern_apps.mk) # must be LAST+#+# -----------------------------------------------------------------------------------++# 1. Add the Modern Apps prebuilts (defined in Android.bp).+PRODUCT_PACKAGES += \+ ModernAppsWeb \+ ModernAppsCamera \+ ModernAppsPdf \+ ModernAppsContacts \+ ModernAppsCalculator \+ ModernAppsClock \+ ModernAppsFiles \+ ModernAppsPhotos \+ ModernAppsStore++# 2. Remove the stock userspace apps we're replacing.+# There is no PRODUCT_PACKAGES -= operator, so we filter them out. This only works+# if this file is evaluated LAST (see header). Confirm the exact module names in your+# synced tree — they occasionally change between GrapheneOS releases:+# grep -rn --include=*.mk -e 'Camera' -e 'PdfViewer' -e 'DocumentsUI' ...+PRODUCT_PACKAGES := $(filter-out \+ Camera \+ PdfViewer \+ Apps \+ Contacts \+ DeskClock \+ Calculator \+ Gallery2 \+ DocumentsUI, \+ $(PRODUCT_PACKAGES))++# NOTE on the browser (Vanadium): Vanadium provides BOTH the default browser AND the+# system WebView provider. We make Modern Apps Web the default browser via the+# config_defaultBrowser overlay but deliberately KEEP Vanadium installed so WebView+# keeps working (our Web app uses androidx.webkit / system WebView). If you want to+# drop the Vanadium *browser* entirely, identify the browser-only module name in your+# tree and add it to the filter-out list above — do NOT remove the WebView/Trichrome+# modules.++# 3. Static resource overlays: config_defaultBrowser, config_documentsUiPackage,+# WebView allowlist, branding.+PRODUCT_PACKAGE_OVERLAYS += vendor/modern-apps/overlay++# 4. Privileged-permission allowlist so Files (priv-app) may hold MANAGE_DOCUMENTS.+PRODUCT_COPY_FILES += \+ vendor/modern-apps/privapp-permissions-modern-apps.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/privapp-permissions-modern-apps.xml++# 5. Build-time guard: fail the build if any stock app we meant to drop is still in+# PRODUCT_PACKAGES (catches upstream module renames that would silently re-add it).+_maos_leaked := $(filter Camera PdfViewer Apps Contacts DeskClock Calculator Gallery2 DocumentsUI,$(PRODUCT_PACKAGES))+ifneq ($(_maos_leaked),)+$(error MAOS: stock apps still present in PRODUCT_PACKAGES: $(_maos_leaked). Update the filter-out list in vendor/modern-apps/modern_apps.mk)+endif
overlay/frameworks/base/core/res/res/values/config.xml
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xmlnew file mode 100644index 0000000..10a73e5--- /dev/null+++ b/overlay/frameworks/base/core/res/res/values/config.xml@@ -0,0 +1,17 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Static resource overlay for frameworks/base/core/res.+ Pulled in via PRODUCT_PACKAGE_OVERLAYS += vendor/modern-apps/overlay (see modern_apps.mk).+-->+<resources>+ <!-- Default browser role -> Modern Apps Web.+ Vanadium remains installed as the system WebView provider; this only changes+ which app holds the browser role. -->+ <string name="config_defaultBrowser" translatable="false">com.vayunmathur.web</string>++ <!-- Storage Access Framework / documents UI host -> Modern Apps Files.+ Replaces com.android.documentsui. The Files app must ship a system build variant+ that registers the SAF picker intents and holds MANAGE_DOCUMENTS (allowlisted in+ privapp-permissions-modern-apps.xml). -->+ <string name="config_documentsUiPackage" translatable="false">com.vayunmathur.files</string>+</resources>
prebuilts/README.md
diff --git a/prebuilts/README.md b/prebuilts/README.mdnew file mode 100644index 0000000..8f5d7da--- /dev/null+++ b/prebuilts/README.md@@ -0,0 +1,19 @@+# prebuilts/++Modern Apps release APKs are copied here by `scripts/collect-apks.sh` before an AOSP+build. They are intentionally **git-ignored** (large binaries, reproducible from the+Modern-Apps repo).++Expected files:++```+web-release.apk camera-release.apk pdf-release.apk+contacts-release.apk calculator-release.apk clock-release.apk+files-release.apk photos-release.apk appstore-release.apk+```++Populate them with, e.g.:++```+scripts/collect-apks.sh /path/to/Modern-Apps+```
privapp-permissions-modern-apps.xml
diff --git a/privapp-permissions-modern-apps.xml b/privapp-permissions-modern-apps.xmlnew file mode 100644index 0000000..7ce8db3--- /dev/null+++ b/privapp-permissions-modern-apps.xml@@ -0,0 +1,17 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Privileged-permission allowlist for Modern Apps priv-apps.+ Copied to /product/etc/permissions/ by modern_apps.mk. Without this entry the build+ (and boot) rejects a priv-app that requests a signature|privileged permission.+-->+<permissions>+ <!-- Files takes over DocumentsUI's Storage Access Framework role in the system build,+ which requires the signature|privileged MANAGE_DOCUMENTS permission. -->+ <privapp-permissions package="com.vayunmathur.files">+ <permission name="android.permission.MANAGE_DOCUMENTS" />+ </privapp-permissions>++ <!-- NOTE: MANAGE_EXTERNAL_STORAGE (all-files access), if Files needs it, is a special+ app-op permission granted via role/appops, NOT a privapp-permission — do not add+ it here. -->+</permissions>
scripts/collect-apks.sh
diff --git a/scripts/collect-apks.sh b/scripts/collect-apks.shnew file mode 100644index 0000000..6e8b8aa--- /dev/null+++ b/scripts/collect-apks.sh@@ -0,0 +1,58 @@+#!/usr/bin/env bash+#+# collect-apks.sh — populate vendor/modern-apps/prebuilts/ with the Modern Apps+# release APKs before an AOSP build.+#+# The APKs are git-ignored (large binaries, reproducible from the Modern-Apps repo),+# so this must run on the build host before `m`/`make`.+#+# Usage:+# scripts/collect-apks.sh <path>+#+# <path> may be:+# - a Modern-Apps repo root (looks in distribution_apks/ and each module's+# build/outputs/apk/release/)+# - a distribution_apks/ dir (produced by Modern-Apps release.sh)+# - any dir containing *-release.apk files+#+set -euo pipefail++SRC="${1:?usage: collect-apks.sh <path to Modern-Apps repo, its distribution_apks dir, or a dir of *-release.apk>}"+DEST="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/prebuilts"+mkdir -p "$DEST"++APPS=(web camera pdf contacts calculator clock files photos appstore)++find_apk() {+ local app="$1"+ local candidates=(+ "$SRC/${app}-release.apk"+ "$SRC/distribution_apks/${app}-release.apk"+ "$SRC/${app}/build/outputs/apk/release/${app}-release.apk"+ )+ local c+ for c in "${candidates[@]}"; do+ if [[ -f "$c" ]]; then+ printf '%s\n' "$c"+ return 0+ fi+ done+ return 1+}++missing=0+for app in "${APPS[@]}"; do+ if apk="$(find_apk "$app")"; then+ cp -v "$apk" "$DEST/${app}-release.apk"+ else+ echo "ERROR: could not find ${app}-release.apk under $SRC" >&2+ missing=1+ fi+done++if [[ "$missing" -ne 0 ]]; then+ echo "One or more APKs were missing. Build them first (Modern-Apps: ./release.sh or per-module :<app>:assembleRelease)." >&2+ exit 1+fi++echo "Done. Copied ${#APPS[@]} APKs into $DEST"