Modern Apps git

← MAOS.git

maos: apply total-review fixes F-01 to F-09

Commit
ca7361e7ba480abf92594911517d10a5c1dcb635
Author
Vayun Mathur <[email protected]>
When
2026-11-21 15:58 UTC (14 days ago)
Parents
796d562
F-02: default lunch variant to user (MAOS_BUILD_VARIANT=userdebug opts in).
F-05: keys/generate-keys.sh now generates the same 9 keys (+ id_ed25519)
as build-maos.sh phase_keys; fix stale 9-APKs counts to 28.
F-04: remove dead GrapheneOS-Updater wiring (overlay config, phase_overlay
sed, standalone ota/*.sh pair, empty origin/); the live MA Updater reads
ro.maos.ota.server. Rewrite updater/README.md and ota/README.md for the
live pipeline.
F-08: canonical overlay remote is GitHub (what build-maos.sh phase_sync
generates); local_manifest.xml now matches it.
F-09: runbook tag 2026080500 -> 2026110700, keystore path and build-number
docs aligned with the script; IMPLEMENTATION_README app table completed
to 28 apps and layout updated (RRO under rro/); prebuilts/README lists
all 28 APKs; ro.maos.version comment no longer claims a sync with the
OTA build number.
F-01: allowlist START_ACTIVITIES_FROM_BACKGROUND and SCHEDULE_EXACT_ALARM
for com.vayunmathur.emergency, verified against the staged prebuilt via
aapt2 dump permissions (prebuilts/emergency-release.apk requests both).
F-03: add docs/endpoints.md liveness checklist with probe commands; all
rows marked UNVERIFIED (no results fabricated).

No full OS build run (per instructions); bash -n and XML parses pass.

Diff

Android.bp
diff --git a/Android.bp b/Android.bpindex 415bf99..39509bb 100644--- a/Android.bp+++ b/Android.bp@@ -497,8 +497,9 @@ android_app_import { // // PRIVILEGED: it declares signature|privileged perms - CALL_PRIVILEGED (place the emergency // call), WRITE_SECURE_SETTINGS (the gesture provider EMERGENCY_GESTURE_* writes),-// READ_PRIVILEGED_PHONE_STATE (emergency-number lookup) and MANAGE_USERS (owner card) --// allowlisted in privapp-permissions-modern-apps.xml. Its Health Connect medical reads and+// READ_PRIVILEGED_PHONE_STATE (emergency-number lookup), MANAGE_USERS (owner card),+// START_ACTIVITIES_FROM_BACKGROUND (SOS background alarm) and SCHEDULE_EXACT_ALARM+// (SOS countdown) - allowlisted in privapp-permissions-modern-apps.xml. Its Health Connect medical reads and // contacts access are default-granted (fixed) in default-permissions-modern-apps.xml so an // emergency needs no manual permission setup. android_app_import {
IMPLEMENTATION_README.md
diff --git a/IMPLEMENTATION_README.md b/IMPLEMENTATION_README.mdindex 61f29c3..dd82abc 100755--- a/IMPLEMENTATION_README.md+++ b/IMPLEMENTATION_README.md@@ -35,23 +35,30 @@ repo.) | Emergency | `com.vayunmathur.emergency` | AOSP EmergencyInfo (medical info + contacts + SOS countdown; wireless alerts stay stock CellBroadcast) | | Parental Controls | `com.vayunmathur.parentalcontrols` | n/a (new; AOSP has no supervision app) — system supervision app: bedtime + app limits via the SYSTEM_SUPERVISION role (pinned by `config_systemSupervision`) | | Screen Time | `com.vayunmathur.screentime` | n/a (new; AOSP has no wellbeing app) — self-managed screen time: dashboard, timers, focus, wind-down via the SYSTEM_WELLBEING role (pinned by `config_systemWellbeing`) |+| Auto | `com.vayunmathur.auto` | n/a (new) — SYSTEM_AUTOMOTIVE_PROJECTION role holder (Android Auto projection) |+| Network Location | `com.vayunmathur.networklocation` | GrapheneOS NetworkLocation — network location provider + offline geocoder |+| Find Family | `com.vayunmathur.findfamily` | n/a (new) — family location sharing (ordinary user app, preinstalled) |+| Share | `com.vayunmathur.share` | n/a (new) — AirDrop-compatible sharing (privileged for the Mosey/AWDL HAL) |+| Cast | `com.vayunmathur.cast` | n/a (new) — Cast / remote-display provider |+| Setup Wizard | `com.vayunmathur.setupwizard` | GrapheneOS SetupWizard2 (first-run setup; see Android.bp warning) |+| Log Viewer | `com.vayunmathur.logviewer` | GrapheneOS LogViewer (error-report viewer, no launcher entry) |+| Updater | `com.vayunmathur.updater` | GrapheneOS Updater (`overrides`) — polls `ro.maos.ota.server`; see `updater/` |+| Health | `com.vayunmathur.health` | n/a (new) — health metrics/medications (ordinary user app, preinstalled) |  ## Layout  ``` Android.bp                            # android_app_import per app (Files: privileged)-modern_apps.mk                        # PRODUCT_PACKAGES += ours; filter-out stock; overlays; privapp; branding+modern_apps.mk                        # product config: app membership notes, RRO, privapp; branding maos_branding.mk                      # PRODUCT_* + ro.maos.* identity (inherited by modern_apps.mk)-privapp-permissions-modern-apps.xml   # MANAGE_DOCUMENTS for Files-overlay/                              # static overlays-  frameworks/base/.../config.xml       #   config_defaultBrowser, config_documentsUiPackage-  packages/apps/Updater/.../config.xml #   OTA server URL (verify resource name)+privapp-permissions-modern-apps.xml   # signature|privileged allowlists for the 12 priv-apps+rro/MaosFrameworkResRRO/              # static platform-signed framework-res RRO (config_* pins) prebuilts/                            # release APKs (git-ignored; populated by script) scripts/collect-apks.sh              # copies Modern-Apps release APKs into prebuilts/ keys/generate-keys.sh                # generates the OS key set (offline; never committed)-ota/                                 # build-ota.sh + publish-ota.sh (+ README)+ota/                                 # OTA flow notes (pipeline lives in build-maos.sh) installer/                           # prepare-factory.sh + sparse_split.py for the web installer-updater/                             # how to point the Updater at ota.maproj.org+updater/                             # MA Updater: server URL via ro.maos.ota.server docs/BUILD_RUNBOOK.md                # end-to-end Linux build/sign/OTA/publish local_manifest.xml                    # adds this repo to the GrapheneOS tree ```@@ -174,9 +181,9 @@ files, and the server with `cargo test` using a generated fixture chain. MAOS uses the standard A/B OTA flow (`update_engine`) with updates served from **`https://ota.maproj.org`**, a **Cloudflare R2 bucket** exposed via a custom domain. The build host uploads signed OTA zips + channel metadata straight to R2-(`ota/publish-ota.sh`), and devices download directly from R2 — no GitHub Release and no-server proxy, since the payloads are multi-GB. Build/publish scripts are in-[`ota/`](ota/README.md); pointing the Updater at the server is covered in+(the `publish` phase of `build-maos.sh`), and devices download directly from R2 — no GitHub+Release and no server proxy, since the payloads are multi-GB. The OTA flow is documented in+[`ota/`](ota/README.md); how the MA Updater finds the server is covered in [`updater/`](updater/README.md). Full design rationale is in `GRAPHENEOS_FORK_PLAN.md` (Modern-Apps repo). 
build-maos.sh
diff --git a/build-maos.sh b/build-maos.shindex 8124908..9562018 100755--- a/build-maos.sh+++ b/build-maos.sh@@ -48,8 +48,10 @@ # # ── Optional environment ──────────────────────────────────────────────────────────────── #   MAOS_KEYS_FILE=$HOME/maos-keys/maos.keys.tar.gz.scrypt   encrypted key blob (shared, outside the tree)-#   MODERN_APPS_SRC=<path>         Modern-Apps checkout/dir with release APKs; if unset, the 9+#   MODERN_APPS_SRC=<path>         Modern-Apps checkout/dir with release APKs; if unset, the 28 #                                  APKs are downloaded from the Modern-Apps GitHub release+#   MAOS_BUILD_VARIANT=<variant>   lunch build variant (default: user; set to userdebug+#                                  explicitly for debuggable builds) #   MAOS_RELEASE_JOBS=<n>          how many devices to sign/package (release) in parallel (default 4). #   MAOS_PUBLISH_JOBS=<n>          how many devices to upload (publish) in parallel (default 4). #   MAOS_BUILD_NUMBER=<n>          pin the build number (default: today's UTC date + "00").@@ -420,10 +422,9 @@ phase_overlay() {         log "MAOS inherit already present in $mk"     fi -    log "Pointing the Updater at ota.maproj.org"-    local cfg="packages/apps/Updater/res/values/config.xml"-    [[ -f "$cfg" ]] && sed -i 's#https://releases.grapheneos.org#https://ota.maproj.org#g' "$cfg" \-        || warn "Updater config.xml not found; set the URL manually if OFFICIAL_BUILD is used."+    # No Updater URL wiring here: the MA Updater app (ModernAppsUpdater, which+    # overrides the GrapheneOS Updater in Android.bp) reads ro.maos.ota.server+    # from maos_branding.mk. The GrapheneOS Updater is displaced, not configured. }  phase_keys() {@@ -463,10 +464,10 @@ phase_build() {     log "Building MAOS for $DEVICE (tag $TAG, build $BUILD)"     cd "$TREE"; source build/envsetup.sh     export OFFICIAL_BUILD=true-    # Build variant for lunch <device>-cur-<variant>. Default userdebug while-    # bootloop-bisecting (adbd as root from init,Disabled-verity-tolerant logging);-    # set MAOS_BUILD_VARIANT=user for production/shippable release builds.-    VARIANT="${MAOS_BUILD_VARIANT:-userdebug}"+    # Build variant for lunch <device>-cur-<variant>. Defaults to the shippable+    # `user` variant; set MAOS_BUILD_VARIANT=userdebug explicitly for debugging+    # (adbd as root from init, disabled-verity-tolerant logging).+    VARIANT="${MAOS_BUILD_VARIANT:-user}"     # Build in the DEFAULT out/. soong's siso/product config is anchored to it (a custom     # OUT_DIR breaks '@config//main.star' loading during bootstrap), so builds run one at a     # time. No rm -rf here: builds are incremental and reuse out/; wipe it manually
docs/BUILD_RUNBOOK.md
diff --git a/docs/BUILD_RUNBOOK.md b/docs/BUILD_RUNBOOK.mdindex 67499c3..b9d2dbd 100644--- a/docs/BUILD_RUNBOOK.md+++ b/docs/BUILD_RUNBOOK.md@@ -1,7 +1,7 @@ # MAOS build runbook — Pixel 7 Pro (cheetah)  Build and publish MAOS for the **Pixel 7 Pro (`cheetah`)** on GrapheneOS base tag-**`2026080500`** from a Windows machine. The whole pipeline (install deps, sync source,+**`2026110700`** from a Windows machine. The whole pipeline (install deps, sync source, extract vendor files, apply the MAOS overlay, generate/use signing keys, build, sign, and publish OTA + web-installer artifacts) is automated by **`build-maos.sh`**. This runbook is just the three things you do by hand: **set up WSL2**, **create the encrypted keystore**,@@ -98,14 +98,17 @@ export R2_SECRET_ACCESS_KEY='<r2 token secret>' Optional:  ```bash-# export MODERN_APPS_SRC=/path/to/Modern-Apps   # else the 9 APKs are downloaded from GitHub+# export MODERN_APPS_SRC=/path/to/Modern-Apps   # else the 28 APKs are downloaded from GitHub+# export MAOS_BUILD_VARIANT=userdebug          # debuggable build (default: user) ```  Device, tag, and OTA channel are **command-line flags** on the script (not env vars),-defaulting to `cheetah` / `2026080500` / `stable`. The AOSP checkout (`~/maos`), the R2-bucket (`maos`), and the release build number (always the GrapheneOS tag) are fixed.+defaulting to `cheetah` / `2026110700` / `stable`. The AOSP checkout (`~/maos`) and the R2+bucket (`maos`) are fixed; the release build number defaults to today's UTC date + `00`+(override with `MAOS_BUILD_NUMBER`). The build variant defaults to `user`; set+`MAOS_BUILD_VARIANT=userdebug` only for debugging. -The keystore is written to `~/maos-keys/<device>.keys.tar.gz.scrypt` (scrypt + AES-256,+The keystore is written to `~/maos-keys/maos.keys.tar.gz.scrypt` (scrypt + AES-256, encrypted with your passphrase). **Back that file up and keep the passphrase safe** — losing either permanently breaks OTA/verified boot for every installed device. @@ -117,9 +120,9 @@ Run the pipeline. The first run generates the signing keys and encrypts them int keystore automatically (the `keys` phase), then builds, signs, and publishes:  ```bash-~/MAOS/build-maos.sh all                       # Pixel 7 Pro (cheetah), tag 2026080500+~/MAOS/build-maos.sh all                       # Pixel 7 Pro (cheetah), tag 2026110700 # other devices/tags/channels via flags:-# ~/MAOS/build-maos.sh -d panther -t 2026080500 -c beta all+# ~/MAOS/build-maos.sh -d panther -t 2026110700 -c beta all ```  Phases run in order: `deps → sync → vendor → overlay → keys → build → release → publish`.@@ -143,6 +146,11 @@ from `https://ma.vayunmathur.com/os/install`.  ## 6. Test the release +Before publishing, run the endpoint liveness probes in+[`endpoints.md`](endpoints.md) (SUPL/PSDS/Private-DNS have no standard-mode+fallback in Settings, so a missing maproj service is ship-blocking) and+record the results there.+ - **Web installer:** open `https://ma.vayunmathur.com/os/install` in Chrome/Edge with the   Pixel 7 Pro in bootloader mode; it auto-detects "Pixel 7 Pro (cheetah)", then   Unlock → Download → Flash → Lock.
docs/endpoints.md
diff --git a/docs/endpoints.md b/docs/endpoints.mdnew file mode 100644index 0000000..c081d56--- /dev/null+++ b/docs/endpoints.md@@ -0,0 +1,32 @@+# MAOS migrated endpoints — liveness checklist++MAOS repoints several platform services from Google/GrapheneOS endpoints to+maproj.org infrastructure (see the patches under `../patches/`). The OS-side+configuration is in-tree; whether the **servers** actually exist and behave is+asserted in patch comments and commit messages, not evidenced anywhere. This+file is the evidence checklist: run the probes before a publish, and record+the date + result here. Until a row says otherwise, treat it as unverified.++**Status of every row below: UNVERIFIED** (no probe results recorded yet —+do not read a row's presence here as proof the service is up).++| # | Service | Endpoint the OS uses | In-repo evidence (config only) | Probe | Last verified |+|---|---------|----------------------|--------------------------------|-------|---------------|+| 1 | SUPL (assisted GNSS) | `supl.maproj.org:7275` (TLS) | `patches/frameworks_base_gnss_servers.patch` (comment says a TLS proxy "will run" there); `settings.patch` removes the standard SUPL mode, so if this is down the only fallback is Off | `openssl s_client -connect supl.maproj.org:7275 -brief </dev/null` — expect a TLS handshake, not a reset/timeout | UNVERIFIED |+| 2 | PSDS (predicted satellite data) | `https://static.maproj.org/psds/<type>…` | `patches/frameworks_base_gnss_servers.patch` assumes the mirror layout `psds/<type><original path>`; standard PSDS mode removed in Settings | `curl -sS -o /dev/null -w '%{http_code}\n' https://static.maproj.org/psds/broadcom/` (adjust `<type>`/path per device logs) — expect 200 on a real file, not the SPA/index fallback | UNVERIFIED |+| 3 | Private DNS probe (wildcard DNS) | `*-dnsotls-ds.dnscheck.maproj.org` | `patches/networkstack_private_dns_probe.patch` requires a wildcard A/AAAA record for `dnscheck.maproj.org` | `dig +short random123-dnsotls-ds.dnscheck.maproj.org` (any random label) — expect an answer for arbitrary labels | UNVERIFIED |+| 4 | Captive portal / connectivity check | `https://maproj.org/generate_204` | `patches/networkstack_captive_portal.patch`; RRO `config_httpsTimeUrls` also points here | `curl -sS -o /dev/null -w '%{http_code}\n' https://maproj.org/generate_204` — expect 204 with an empty body | UNVERIFIED |+| 5 | Certificate Transparency log list | `https://static.maproj.org/android/certificate_transparency/` | `patches/packages_modules_Connectivity_certificate_transparency.patch` | `curl -sSI https://static.maproj.org/android/certificate_transparency/log_list.json` (confirm the exact path against the patch) — expect 200 | UNVERIFIED |+| 6 | Remote Key Provisioning | `https://rkp.maproj.org/v1…` (proxy → Google upstream) | `patches/frameworks_base_remote_key_provisioning.patch` | `curl -sS -o /dev/null -w '%{http_code}\n' https://rkp.maproj.org/` — expect an RKP-path response (4xx on a bare path is fine; connection failure is not); full check needs a device attestation fetch | UNVERIFIED |+| 7 | Widevine provisioning | `https://wv.maproj.org…` (proxy → googleapis upstream) | `patches/frameworks_base_widevine_provisioning.patch` | `curl -sS -o /dev/null -w '%{http_code}\n' https://wv.maproj.org/` — expect a service response, not a connection failure; full check needs a device provisioning request | UNVERIFIED |+| 8 | Device attestation | `https://api.maproj.org/attest/v1…` | `patches/packages_apps_Settings_maos_attestation.patch`; one-shot, user-triggered | `curl -sS -o /dev/null -w '%{http_code}\n' https://api.maproj.org/attest/v1` — expect an API response (4xx on a bare GET is fine); full check is the Settings Verify flow on a device | UNVERIFIED |+| 9 | OTA metadata | `https://ota.maproj.org/<device>-stable` | `maos_branding.mk` (`ro.maos.ota.server`); `build-maos.sh` publish phase | `curl -sS https://ota.maproj.org/cheetah-stable` — expect the current build's metadata line after a publish | UNVERIFIED |++## How to record a verification++Replace the row's `UNVERIFIED` with `YYYY-MM-DD — <result>` (e.g.+`2026-11-21 — 204 OK`). If a probe fails, leave the failure text in the cell —+a recorded failure is more useful than a silent pass. Re-run the whole table+before each publish; rows 1–3 are ship-blocking because Settings offers no+standard-mode fallback for SUPL/PSDS, and Private DNS validation depends on+the wildcard record.
installer/prepare-factory.sh
diff --git a/installer/prepare-factory.sh b/installer/prepare-factory.shindex 433ab9e..11ba956 100755--- a/installer/prepare-factory.sh+++ b/installer/prepare-factory.sh@@ -27,7 +27,7 @@ #   installer/prepare-factory.sh -d cheetah -b 2026081000 -f <device>-install-<build>.zip \ #       [-P plan.json] [-m 104857600] [-O out/maos-factory] [-B maos] [--no-upload] #-# R2 upload reuses the same env as ota/publish-ota.sh:+# R2 upload reuses the same env as build-maos.sh's publish phase: #   R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, and R2_ACCOUNT_ID (or R2_ENDPOINT). # set -euo pipefail@@ -188,7 +188,7 @@ if [[ "$UPLOAD" -eq 0 ]]; then     exit 0 fi -# ---- Upload to R2 (mirrors ota/publish-ota.sh) ----+# ---- Upload to R2 (mirrors build-maos.sh phase_publish) ---- command -v aws >/dev/null || { echo "aws CLI (v2) required to upload" >&2; exit 1; } : "${R2_ACCESS_KEY_ID:?set R2_ACCESS_KEY_ID}" : "${R2_SECRET_ACCESS_KEY:?set R2_SECRET_ACCESS_KEY}"
keys/generate-keys.sh
diff --git a/keys/generate-keys.sh b/keys/generate-keys.shindex 883c251..bc6b7c1 100755--- a/keys/generate-keys.sh+++ b/keys/generate-keys.sh@@ -2,7 +2,7 @@ # # generate-keys.sh — create the MAOS signing key set on the (offline) build host. #-# These are the OS keys, entirely separate from the app signing keys: the 9 Modern+# These are the OS keys, entirely separate from the app signing keys: the 28 Modern # Apps ship `presigned` and keep their own com.vayunmathur certificate, so app updates # via the app store keep working. Do NOT reuse an app key here, and do NOT reuse these # for apps (a platform-signed app would be massively over-privileged).@@ -30,7 +30,8 @@ cd "$OUT" # The AOSP APK-signing key set. releasekey also signs the OTA payloads. # platform/shared/media are classic; networkstack (A10+), sdk_sandbox (A14+) and # bluetooth (A13+) are required by newer platforms — generating extras is harmless.-KEYS=(releasekey platform shared media networkstack sdk_sandbox bluetooth)+# Keep this list in sync with the key set generated by build-maos.sh phase_keys.+KEYS=(releasekey platform shared media networkstack bluetooth sdk_sandbox gmscompat_lib nfc)  for k in "${KEYS[@]}"; do     if [[ -f "$k.pk8" ]]; then@@ -55,13 +56,22 @@ else     echo "skip avb.pem (already exists)" fi -chmod 600 ./*.pk8 ./*.pem 2>/dev/null || true+# SSH keypair included in the encrypted key blob by build-maos.sh phase_keys.+if [[ ! -f id_ed25519 ]]; then+    echo "generating id_ed25519 ..."+    ssh-keygen -t ed25519 -N "" -f id_ed25519 >/dev/null+else+    echo "skip id_ed25519 (already exists)"+fi++chmod 600 ./*.pk8 ./*.pem id_ed25519 2>/dev/null || true  cat <<EOF  Done. Key set written to: $OUT   APK/OTA keys : ${KEYS[*]} (.pk8 + .x509.pem each)   AVB          : avb.pem (private) + avb_pkmd.bin (public metadata)+  SSH          : id_ed25519 (+ .pub)  Next:   * Keep this directory OFFLINE and backed up. Losing releasekey/avb bricks OTA updates
local_manifest.xml
diff --git a/local_manifest.xml b/local_manifest.xmlindex 098c4f3..4fa0b6a 100644--- a/local_manifest.xml+++ b/local_manifest.xml@@ -10,16 +10,19 @@    This adds the overlay at vendor/modern-apps and (optionally) drops the source of the   stock apps we replace.++  Canonical remote: GitHub (github.com/vayun-mathur), matching the manifest that+  build-maos.sh phase_sync generates. Keep the two in sync. --> <manifest>-  <remote name="maos" fetch="https://git.maproj.org/" />+  <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.git" remote="maos" revision="main" />+  <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+    OPTIONAL: remove the SOURCE of the stock apps we replace. Not required — app+    membership/removal is applied by patches/platform_build.patch, 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.
maos_branding.mk
diff --git a/maos_branding.mk b/maos_branding.mkindex 2f44930..4412d74 100644--- a/maos_branding.mk+++ b/maos_branding.mk@@ -1,9 +1,9 @@ # MAOS branding — inherited from modern_apps.mk. # # You cannot ship as "GrapheneOS"; this rebrands the build as MAOS (Modern Apps OS).-# Full de-branding also requires overlaying the Settings "About phone" strings and-# swapping boot logos/wallpapers — those live under overlay/ and are called out in-# docs/BUILD_RUNBOOK.md. This file covers the build.prop-level identity.+# Full de-branding also requires the Settings "About phone" strings and boot+# artwork (bootanimation/ here; see docs/BUILD_RUNBOOK.md). This file covers the+# build.prop-level identity. # # NOTE: changing brand/fingerprint means the build no longer matches GrapheneOS's # attestation/OTA identity — expected for a fork. Because MAOS is self-signed, Play@@ -13,7 +13,9 @@ PRODUCT_BRAND := MAOS PRODUCT_MANUFACTURER := MAOS  # Marketing/version identity surfaced to our own apps (e.g. the Updater) and About.-# Keep MAOS_VERSION in sync with the OTA build number used by ota/build-ota.sh.+# MAOS_VERSION is an independent marketing version — it is NOT the OTA build number+# (build-maos.sh pins that separately as BUILD_NUMBER, a date-based value), so there+# is nothing to keep in sync here; bump this only for a deliberate version change. MAOS_VERSION ?= 1 MAOS_CHANNEL ?= stable 
modern_apps.mk
diff --git a/modern_apps.mk b/modern_apps.mkindex 1d279a8..659a23a 100644--- a/modern_apps.mk+++ b/modern_apps.mk@@ -115,9 +115,8 @@ PRODUCT_SOONG_NAMESPACES += vendor/modern-apps #    always-on at boot. See vendor/modern-apps/rro/MaosFrameworkResRRO/. PRODUCT_PACKAGES += MaosFrameworkResRRO -#    The overlay/ dir now only carries the GrapheneOS Updater OTA-URL overlay (no framework-res-#    overlay here, so no auto-generated framework-res RRO is produced).-PRODUCT_PACKAGE_OVERLAYS += vendor/modern-apps/overlay+#    There is no PRODUCT_PACKAGE_OVERLAYS entry here: framework-res config ships via the+#    explicit RRO above, so no auto-generated framework-res RRO is produced.  # 3b. Default-permission grant so the Speech recognizer/TTS gets RECORD_AUDIO headlessly. PRODUCT_COPY_FILES += \
ota/README.md
diff --git a/ota/README.md b/ota/README.mdindex 27fd830..117b44b 100644--- a/ota/README.md+++ b/ota/README.md@@ -1,71 +1,62 @@ # MAOS OTA -How over-the-air updates flow, and the scripts that produce them.+How over-the-air updates flow. There are no standalone OTA scripts in this+directory: building and publishing OTAs is the `release` and `publish` phases+of `../build-maos.sh`.  ## Pipeline  ```-signed target-files ──build-ota.sh──▶ full + incremental OTA zips + channel metadata-        │                                          │-        │                                          ▼-        │                               publish-ota.sh ──▶ Cloudflare R2 bucket-        │                                                          │-        ▼                                                          ▼-  (kept for next                              ota.maproj.org  (R2 custom domain,-   incremental)                               serves objects directly)-                                                                   │-                                                                   ▼-                                                        Updater on device+build-maos.sh build ──▶ target-files ──release──▶ signed OTA zip + factory image+                                                      │+                                                 publish (per device)+                                                      ▼+                                          Cloudflare R2 bucket `maos`+                                                      │+                                          ota.maproj.org (custom domain)+                                                      │+                                                      ▼+                                            MA Updater on device ``` -- **`build-ota.sh`** turns a *signed* target-files zip into `DEVICE-ota_update-BUILD.zip`-  (full), optionally `DEVICE-incremental-OLD-NEW.zip`, and a `DEVICE-CHANNEL` metadata-  file. Signed with your `releasekey`.-- **`publish-ota.sh`** uploads those to a **Cloudflare R2** bucket (S3-compatible, via the-  `aws` CLI). Zips go up first; the channel-metadata pointer goes up last.-- **`ota.maproj.org`** is that R2 bucket exposed via a Cloudflare custom domain, so-  an object keyed `<file>` is served at `https://ota.maproj.org/<file>`. Devices-  download straight from R2 — **no GitHub Release and no `location_share_server` proxy are-  involved** (R2 handles the multi-GB payloads that GitHub Releases / the server's disk-  can't).-- The **Updater** app polls `https://ota.maproj.org/<device>-<channel>` then-  downloads the referenced zip (see `../updater/README.md`).+- **`release`** signs the staged target-files with the MAOS key set and+  generates the factory image + full OTA zip (`script/generate-release.sh`+  in the AOSP tree).+- **`publish`** uploads the OTA zip first with an immutable cache header,+  then the `<device>-<channel>` metadata file with `no-store`, so a device+  polling mid-publish never sees metadata referencing a zip that isn't+  there yet. It also prepares/uploads the web-installer factory artifacts+  via `../installer/prepare-factory.sh`.+- **`ota.maproj.org`** is the R2 bucket `maos` exposed via a Cloudflare+  custom domain: an object keyed `<file>` is served at+  `https://ota.maproj.org/<file>`. Devices download straight from R2 — no+  GitHub Release and no server proxy are involved.+- The **MA Updater** app polls `https://ota.maproj.org/<device>-<channel>`+  (from `ro.maos.ota.server`; see `../updater/README.md`).  ## Credentials (never commit) -`publish-ota.sh` reads R2 credentials from the environment:+The `publish` phase reads R2 credentials from the environment:  | Var | Meaning | | --- | --- |+| `R2_ACCOUNT_ID` | Cloudflare account id (builds the R2 endpoint) | | `R2_ACCESS_KEY_ID` | R2 API token access key id | | `R2_SECRET_ACCESS_KEY` | R2 API token secret |-| `R2_ACCOUNT_ID` | Cloudflare account id (builds the endpoint), **or** |-| `R2_ENDPOINT` | full endpoint URL (overrides `R2_ACCOUNT_ID`) |-| `R2_BUCKET` | bucket name (default `maos-ota`; or pass `-b`) | -The endpoint defaults to `https://<R2_ACCOUNT_ID>.r2.cloudflarestorage.com`. Create the-API token in the Cloudflare dashboard (R2 → Manage API Tokens) with **Object Read & Write**-on the target bucket.+The bucket is fixed to `maos` in `build-maos.sh`. Create the API token in+the Cloudflare dashboard (R2 → Manage API Tokens) with **Object Read &+Write** on that bucket.  ## Cloudflare setup (one-time) -1. Create the R2 bucket (e.g. `maos-ota`).-2. Attach the custom domain `ota.maproj.org` to it (R2 → Settings → Custom Domains).-   Cloudflare provisions TLS automatically.-3. The object `Cache-Control` headers set by `publish-ota.sh` (immutable zips, `no-store`-   metadata) are honored by Cloudflare's cache. If you add a Cache Rule, make sure it does-   **not** cache the `*-<channel>` metadata objects, or devices will see stale builds.+1. Create the R2 bucket `maos`.+2. Attach the custom domain `ota.maproj.org` to it (R2 → Settings → Custom+   Domains). Cloudflare provisions TLS automatically.+3. Add a bucket CORS policy so the installer page (`ma.vayunmathur.com`)+   can fetch factory images (see `../docs/BUILD_RUNBOOK.md`).+4. Add a Cache Rule that bypasses cache for the channel-metadata files+   (paths not ending in `.zip`) so devices never see a stale build pointer. -## Keep every release's signed target-files--Incrementals diff the previous signed target-files against the new one. Archive each-release's `signed-*.zip` so you can pass it as `-p` next time. Without it you can still-ship a full OTA, just not a delta.--## Metadata format--`build-ota.sh` writes `BUILD TIMESTAMP CHANNEL` (one line). This must match whatever your-Updater version parses — confirm against the pinned source and adjust both sides together-if needed.--See `../docs/BUILD_RUNBOOK.md` for the full build → sign → OTA → publish sequence.+See `../docs/BUILD_RUNBOOK.md` for the full build → sign → OTA → publish+sequence.
ota/build-ota.sh
diff --git a/ota/build-ota.sh b/ota/build-ota.shdeleted file mode 100755index c6315d6..0000000--- a/ota/build-ota.sh+++ /dev/null@@ -1,83 +0,0 @@-#!/usr/bin/env bash-#-# build-ota.sh — generate signed OTA package(s) + channel metadata from a SIGNED-# target-files zip.-#-# Prerequisite: you already produced a signed target-files with your MAOS keys, e.g.-#-#   sign_target_files_apks -o -d "$KEYSDIR" \-#     out/target/product/$DEVICE/obj/PACKAGING/target_files_intermediates/*-target_files-*.zip \-#     signed-$DEVICE-$BUILD.zip-#-# (see docs/BUILD_RUNBOOK.md). This script turns that into a full OTA, an optional-# incremental OTA, and the tiny channel-metadata file the Updater polls.-#-# Run inside the AOSP tree after `source build/envsetup.sh` so ota_from_target_files is-# on PATH (else it's at build/make/tools/releasetools/ota_from_target_files).-#-set -euo pipefail--DEVICE="" ; CHANNEL="stable" ; BUILD="" ; SIGNED_TF="" ; PREV_TF="" ; OLD_BUILD=""-KEYSDIR="" ; OUTDIR="out/maos-ota"--usage() {-    cat >&2 <<EOF-usage: build-ota.sh -d DEVICE -b BUILD -t SIGNED_TF -k KEYSDIR [options]-  -d DEVICE       device codename (e.g. shusky)-  -b BUILD        build number for the new build (e.g. 2026080900)-  -t SIGNED_TF    signed target-files zip for the new build-  -k KEYSDIR      dir holding releasekey.{pk8,x509.pem} (OTA signing key)-  -c CHANNEL      release channel (default: stable)-  -p PREV_TF      previous signed target-files (to also build an incremental)-  -o OLD_BUILD    previous build number (required with -p; used in the file name)-  -O OUTDIR       output dir (default: out/maos-ota)-EOF-    exit 2-}--while getopts "d:b:t:k:c:p:o:O:h" opt; do-    case "$opt" in-        d) DEVICE="$OPTARG" ;;-        b) BUILD="$OPTARG" ;;-        t) SIGNED_TF="$OPTARG" ;;-        k) KEYSDIR="$OPTARG" ;;-        c) CHANNEL="$OPTARG" ;;-        p) PREV_TF="$OPTARG" ;;-        o) OLD_BUILD="$OPTARG" ;;-        O) OUTDIR="$OPTARG" ;;-        *) usage ;;-    esac-done--[[ -n "$DEVICE" && -n "$BUILD" && -n "$SIGNED_TF" && -n "$KEYSDIR" ]] || usage-[[ -f "$SIGNED_TF" ]] || { echo "signed target-files not found: $SIGNED_TF" >&2; exit 1; }-[[ -f "$KEYSDIR/releasekey.pk8" ]] || { echo "releasekey not found in $KEYSDIR" >&2; exit 1; }-if [[ -n "$PREV_TF" && -z "$OLD_BUILD" ]]; then echo "-p requires -o OLD_BUILD" >&2; exit 1; fi--OTA_TOOL="ota_from_target_files"-command -v "$OTA_TOOL" >/dev/null || \-    OTA_TOOL="${ANDROID_BUILD_TOP:?source build/envsetup.sh}/build/make/tools/releasetools/ota_from_target_files"--mkdir -p "$OUTDIR"--FULL="$OUTDIR/$DEVICE-ota_update-$BUILD.zip"-echo ">> full OTA -> $FULL"-"$OTA_TOOL" -k "$KEYSDIR/releasekey" "$SIGNED_TF" "$FULL"--if [[ -n "$PREV_TF" ]]; then-    [[ -f "$PREV_TF" ]] || { echo "previous target-files not found: $PREV_TF" >&2; exit 1; }-    INC="$OUTDIR/$DEVICE-incremental-$OLD_BUILD-$BUILD.zip"-    echo ">> incremental OTA ($OLD_BUILD -> $BUILD) -> $INC"-    "$OTA_TOOL" -k "$KEYSDIR/releasekey" -i "$PREV_TF" "$SIGNED_TF" "$INC"-fi--# Channel metadata polled by the Updater at-#   https://ota.maproj.org/$DEVICE-$CHANNEL-# Format: "BUILD TIMESTAMP CHANNEL". Keep this in sync with what your Updater fork-# parses (see updater/README.md).-META="$OUTDIR/$DEVICE-$CHANNEL"-printf '%s %s %s\n' "$BUILD" "$(date +%s)" "$CHANNEL" > "$META"-echo ">> metadata -> $META ($(cat "$META"))"--echo-echo "Artifacts in $OUTDIR — publish with ota/publish-ota.sh"
ota/publish-ota.sh
diff --git a/ota/publish-ota.sh b/ota/publish-ota.shdeleted file mode 100755index 071d3ec..0000000--- a/ota/publish-ota.sh+++ /dev/null@@ -1,100 +0,0 @@-#!/usr/bin/env bash-#-# publish-ota.sh — upload OTA artifacts to Cloudflare R2.-#-# `ota.maproj.org` is an R2 bucket served directly via a Cloudflare custom-# domain, so devices download straight from R2 — there is no GitHub Release and no-# server proxy in the loop. An object stored at key `<file>` is served at-# `https://ota.maproj.org/<file>`, which is exactly what the Updater polls.-#-# Upload order matters: the signed zips go up FIRST and the channel-metadata pointer-# goes up LAST, so a device polling mid-publish never sees metadata referencing a zip-# that isn't there yet.-#-# R2 is S3-compatible, so this uses the standard `aws` CLI pointed at the R2 endpoint.-# Credentials come from the environment (never commit them):-#-#   R2_ACCESS_KEY_ID       R2 API token access key id-#   R2_SECRET_ACCESS_KEY   R2 API token secret-#   R2_ACCOUNT_ID          Cloudflare account id (used to build the endpoint), OR-#   R2_ENDPOINT            full endpoint URL (overrides R2_ACCOUNT_ID)-#   R2_BUCKET              bucket name (default: maos, or pass -b)-#-# Requires: awscli v2.-#-set -euo pipefail--BUCKET="${R2_BUCKET:-maos}"-OUTDIR="out/maos-ota"--usage() {-    cat >&2 <<EOF-usage: publish-ota.sh [-b BUCKET] [-O OUTDIR]-  -b BUCKET   R2 bucket name (default: $R2_BUCKET or maos)-  -O OUTDIR   dir containing the artifacts from build-ota.sh (default: out/maos-ota)--Required env: R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, and either R2_ACCOUNT_ID or-R2_ENDPOINT. See the header of this file.-EOF-    exit 2-}--while getopts "b:O:h" opt; do-    case "$opt" in-        b) BUCKET="$OPTARG" ;;-        O) OUTDIR="$OPTARG" ;;-        *) usage ;;-    esac-done--command -v aws >/dev/null || { echo "aws CLI (v2) not found" >&2; exit 1; }-: "${R2_ACCESS_KEY_ID:?set R2_ACCESS_KEY_ID}"-: "${R2_SECRET_ACCESS_KEY:?set R2_SECRET_ACCESS_KEY}"--ENDPOINT="${R2_ENDPOINT:-}"-if [[ -z "$ENDPOINT" ]]; then-    : "${R2_ACCOUNT_ID:?set R2_ACCOUNT_ID or R2_ENDPOINT}"-    ENDPOINT="https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com"-fi--# Map R2 creds to the AWS SDK's variables for this process only.-export AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID"-export AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY"-# R2 ignores region but the SDK requires one; "auto" is the documented value.-export AWS_DEFAULT_REGION="auto"-# aws-cli v2 adds trailing/streaming integrity checksums that break R2 multipart-# uploads (which is every multi-GB OTA). Only send checksums when the API requires-# them, matching Cloudflare's own R2 guidance.-export AWS_REQUEST_CHECKSUM_CALCULATION="when_required"-export AWS_RESPONSE_CHECKSUM_VALIDATION="when_required"--s3() { aws s3 --endpoint-url "$ENDPOINT" "$@"; }--put() {-    # put <local> <key> <content-type> <cache-control>-    local src="$1" key="$2" ctype="$3" cache="$4"-    echo ">> $key  ($(du -h "$src" | cut -f1), $ctype)"-    s3 cp "$src" "s3://$BUCKET/$key" \-        --content-type "$ctype" \-        --cache-control "$cache" \-        --only-show-errors-}--shopt -s nullglob-ZIPS=("$OUTDIR"/*.zip)-METAS=("$OUTDIR"/*-stable "$OUTDIR"/*-beta "$OUTDIR"/*-alpha)-[[ ${#ZIPS[@]} -gt 0 || ${#METAS[@]} -gt 0 ]] || { echo "no artifacts in $OUTDIR" >&2; exit 1; }--echo ">> R2 endpoint: $ENDPOINT   bucket: $BUCKET"--# 1) Immutable payloads first. Named per-build, so they can be cached forever.-for z in "${ZIPS[@]}"; do-    put "$z" "$(basename "$z")" "application/zip" "public, max-age=31536000, immutable"-done--# 2) Mutable channel pointer(s) last, uncacheable so a new build is seen promptly.-for m in "${METAS[@]}"; do-    put "$m" "$(basename "$m")" "text/plain; charset=utf-8" "no-store, must-revalidate"-done--echo ">> done. Served at https://ota.maproj.org/<file>"
overlay/packages/apps/Updater/res/values/config.xml
diff --git a/overlay/packages/apps/Updater/res/values/config.xml b/overlay/packages/apps/Updater/res/values/config.xmldeleted file mode 100644index 82112bf..0000000--- a/overlay/packages/apps/Updater/res/values/config.xml+++ /dev/null@@ -1,19 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!---  Overlay for the GrapheneOS Updater's OTA server URL.--  !!! VERIFY THE RESOURCE NAME against your pinned Updater source before relying on this.-  Overlays only replace a resource that already exists with the SAME name; if the name is-  wrong this file does nothing (and does not fail the build). Find the real name with:--      grep -rn "releases.grapheneos.org" packages/apps/Updater/--  If the URL lives in code / BuildConfig instead of resources, overlaying can't help —-  fork the Updater and change it there (see updater/README.md).--  This overlay is wired in via PRODUCT_PACKAGE_OVERLAYS (vendor/modern-apps/overlay).--->-<resources>-    <!-- Common GrapheneOS name is "url"; adjust to match your source if different. -->-    <string name="url" translatable="false">https://ota.maproj.org</string>-</resources>
prebuilts/README.md
diff --git a/prebuilts/README.md b/prebuilts/README.mdindex 8f5d7da..7d26ada 100644--- a/prebuilts/README.md+++ b/prebuilts/README.md@@ -4,12 +4,19 @@ Modern Apps release APKs are copied here by `scripts/collect-apks.sh` before an build. They are intentionally **git-ignored** (large binaries, reproducible from the Modern-Apps repo). -Expected files:+Expected files (28, matching the APPS list in `build-maos.sh`):  ```-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+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+keyboard-release.apk    speech-release.apk    calendar-release.apk+music-release.apk    communicate-release.apk    auto-release.apk+euicc-release.apk    backup-release.apk    networklocation-release.apk+findfamily-release.apk    share-release.apk    cast-release.apk+setupwizard-release.apk    logviewer-release.apk    updater-release.apk+parentalcontrols-release.apk    screentime-release.apk    health-release.apk+emergency-release.apk ```  Populate them with, e.g.:
privapp-permissions-modern-apps.xml
diff --git a/privapp-permissions-modern-apps.xml b/privapp-permissions-modern-apps.xmlindex d987e43..31266b0 100644--- a/privapp-permissions-modern-apps.xml+++ b/privapp-permissions-modern-apps.xml@@ -182,13 +182,19 @@          EmergencyInfo. It needs these signature|privileged perms: CALL_PRIVILEGED places the          emergency call, WRITE_SECURE_SETTINGS lets the gesture provider persist the          EMERGENCY_GESTURE_* Settings.Secure keys, READ_PRIVILEGED_PHONE_STATE is the privileged-         half of the emergency-number lookup, and MANAGE_USERS reads the owner name/photo for the-         card. All degrade gracefully if absent, but the app is privileged so they are granted. -->+         half of the emergency-number lookup, MANAGE_USERS reads the owner name/photo for the+         card, START_ACTIVITIES_FROM_BACKGROUND lets the SOS receiver fire the call broadcast+         from the background alarm, and SCHEDULE_EXACT_ALARM drives the SOS countdown alarm.+         Verified against the staged prebuilt (aapt2 dump permissions on+         prebuilts/emergency-release.apk), which requests exactly these plus the four above.+         All degrade gracefully if absent, but the app is privileged so they are granted. -->     <privapp-permissions package="com.vayunmathur.emergency">         <permission name="android.permission.CALL_PRIVILEGED" />         <permission name="android.permission.WRITE_SECURE_SETTINGS" />         <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE" />         <permission name="android.permission.MANAGE_USERS" />+        <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />+        <permission name="android.permission.SCHEDULE_EXACT_ALARM" />     </privapp-permissions>  </permissions>
updater/README.md
diff --git a/updater/README.md b/updater/README.mdindex 57ab364..ff092ac 100644--- a/updater/README.md+++ b/updater/README.md@@ -1,55 +1,26 @@-# Updater configuration (MAOS)+# Updater (MAOS) -MAOS reuses the GrapheneOS Updater app but points it at our own OTA server,-`https://ota.maproj.org` — a **Cloudflare R2 bucket** exposed via a custom domain,-which serves the signed OTA zips + channel metadata directly (uploaded by-`ota/publish-ota.sh`; see `../ota/README.md`).+MAOS ships the first-party **MA Updater** app (`com.vayunmathur.updater`,+module `ModernAppsUpdater` in `../Android.bp`). It **replaces** the GrapheneOS+Updater outright via `overrides: ["Updater"]` — the GrapheneOS app is displaced,+not configured. There is no overlay, fork, or URL patch for the stock Updater;+do not re-add one. -## What the Updater fetches+## How the MA Updater finds the server -For device `$DEVICE` on channel `$CHANNEL` (e.g. `stable`), it requests:+The app reads the `ro.maos.ota.server` system property, set to+`https://ota.maproj.org` in `../maos_branding.mk`, and falls back to that same+URL when the property is empty (Modern-Apps `updater/.../SystemBuild.kt`). -- **Metadata:** `GET https://ota.maproj.org/$DEVICE-$CHANNEL`-- **Full OTA:** `GET https://ota.maproj.org/$DEVICE-ota_update-$BUILD.zip`-- **Incremental:** `GET https://ota.maproj.org/$DEVICE-incremental-$OLD-$NEW.zip`--Those filenames are produced by `ota/build-ota.sh` and uploaded to the release by-`ota/publish-ota.sh`. The metadata line format is defined there and must match whatever-your Updater version parses (GrapheneOS uses a short space-separated line —-`BUILD TIMESTAMP CHANNEL` in our `build-ota.sh`).--## Two things to change in the Updater--1. **Server URL.** GrapheneOS hardcodes `https://releases.grapheneos.org`. Find it and-   replace it with `https://ota.maproj.org`:--   ```bash-   grep -rn "releases.grapheneos.org" packages/apps/Updater/-   ```+For device `$DEVICE` on channel `$CHANNEL` (e.g. `stable`), it polls: -   If it resolves to a **string resource**, prefer overlaying it (no fork) — see-   `overlay/` below. If it's a `const`/`BuildConfig` value in code, you need a small-   fork of `packages/apps/Updater` (pull it in via the local manifest; see the main-   fork plan's "fallback: when a real fork is unavoidable").--2. **Certificate pinning.** GrapheneOS pins its server's certificate. `ota.maproj.org`-   uses a Cloudflare-managed certificate (and Cloudflare may rotate it), so either remove the-   pin or pin to the Cloudflare/issuer cert. Check the Updater's `network_security_config` /-   any `CertificatePinner`:--   ```bash-   grep -rn "pin-set\|CertificatePinner\|network_security_config" packages/apps/Updater/-   ```--## Overlay (preferred, if the URL is a resource)--`overlay/packages/apps/Updater/res/values/config.xml` in this repo overlays the server-URL. **Verify the string name** against your pinned Updater source before relying on it-— an overlay with the wrong resource name silently does nothing (it won't fail the-build). Update the name to match, then confirm the built Updater points at-`ota.maproj.org`.+- **Metadata:** `GET https://ota.maproj.org/$DEVICE-$CHANNEL`+- **Payload:** the OTA zip referenced by that metadata, applied to the+  inactive A/B slot via `update_engine` after local signature verification. -## Channels+## Publishing -`build-ota.sh` publishes per-channel metadata (`$DEVICE-stable`, `$DEVICE-beta`, ...).-Keep the channel names the Updater offers in sync with the ones you publish.+`build-maos.sh`'s `publish` phase uploads the release OTA zip first+(immutable cache) and the `$DEVICE-$CHANNEL` metadata last (`no-store`) to+the R2 bucket `maos`, which `ota.maproj.org` serves. See `../ota/README.md`.+Keep the channel names the app offers in sync with the ones published.