Modern Apps git

← MAOS.git

maos: onboard emergency app replacing EmergencyInfo

Commit
280e47820288741bf9c6487e07ac133b74b3ce1f
Author
Vayun Mathur <[email protected]>
When
2026-09-27 18:16 UTC (2 months ago)
Parents
3e6b06c

Diff

Android.bp
diff --git a/Android.bp b/Android.bpindex fcf84c3..49c314a 100644--- a/Android.bp+++ b/Android.bp@@ -422,3 +422,26 @@ android_app_import {         enabled: false,     }, }++// Emergency is PRIVILEGED: it replaces AOSP EmergencyInfo (module EmergencyInfo,+// removed from telephony_system_ext.mk via platform_build.patch) and answers the same+// platform contract: the EMERGENCY_ASSISTANCE view, the EDIT_EMERGENCY_INFO (+ legacy+// EDIT_MEDICAL_INFO) editor, the Settings ia.emergency injection, the LAUNCH_EMERGENCY+// SOS alias for SystemUI, and the EmergencyNumberUtils gesture provider. The gesture+// authority is rewired in frameworks_base.patch and the Settings package pins in+// settings.patch. Its signature|privileged perms (CALL_PRIVILEGED / MANAGE_USERS /+// READ_PRIVILEGED_PHONE_STATE / SCHEDULE_EXACT_ALARM /+// START_ACTIVITIES_FROM_BACKGROUND / WRITE_SECURE_SETTINGS) are allowlisted in+// privapp-permissions-modern-apps.xml. Wireless emergency alerts+// (CellBroadcastReceiver) are deliberately NOT replaced and keep shipping stock.+android_app_import {+    name: "ModernAppsEmergency",+    apk: "prebuilts/emergency-release.apk",+    presigned: true,+    preprocessed: true,+    privileged: true,+    product_specific: true,+    dex_preopt: {+        enabled: false,+    },+}
IMPLEMENTATION_README.md
diff --git a/IMPLEMENTATION_README.md b/IMPLEMENTATION_README.mdindex fdc41db..903471d 100755--- a/IMPLEMENTATION_README.md+++ b/IMPLEMENTATION_README.md@@ -32,6 +32,7 @@ repo.) | Communicate | `com.vayunmathur.communicate` | AOSP Dialer **and** Messaging (default dialer + SMS app) | | Euicc | `com.vayunmathur.euicc` | Google's eSIM LPA **EuiccGoogle** (system LPA; Pixel `EuiccSupportPixel` backend kept — see below) | | Backup | `com.vayunmathur.backup` | **Seedvault** (`com.stevesoltys.seedvault`) **and** the GrapheneOS contacts backup transport (`app.grapheneos.backup.contacts`) — system app-data backup transport; see below |+| 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`) | 
build-maos.sh
diff --git a/build-maos.sh b/build-maos.shindex aabc9b6..f6e9476 100755--- a/build-maos.sh+++ b/build-maos.sh@@ -99,7 +99,7 @@ BUILD="$TAG" MANIFEST_URL="https://github.com/GrapheneOS/platform_manifest.git" MAOS_GH="https://github.com/vayun-mathur/"     # overlay repo remote (for the local manifest) MODERN_APPS_GH="vayun-mathur/Modern-Apps"      # source of the prebuilt APKs-APPS=(web camera pdf contacts calculator clock files photos appstore keyboard speech calendar music communicate euicc backup networklocation findfamily share cast setupwizard logviewer updater parentalcontrols screentime)+APPS=(web camera pdf contacts calculator clock files photos appstore keyboard speech calendar music communicate euicc backup networklocation findfamily share cast setupwizard logviewer updater parentalcontrols screentime emergency)  # ---- Derived / optional-env config ---- # ONE shared, device-independent key set (see the "Signing keys" note above).@@ -257,6 +257,7 @@ apply_maos_patches() {                 "frameworks/opt/telephony:frameworks_opt_telephony.patch" \                 "frameworks/libs/systemui:frameworks_libs_systemui.patch" \                 "build/release:build_release.patch" \+                "script:script.patch" \                 "packages/apps/Settings:settings.patch" \                 "packages/apps/SetupWizard2:setupwizard2.patch" \                 "external/roboto-fonts:roboto_fonts.patch" \@@ -369,6 +370,7 @@ phase_overlay() {         -e '\bContacts\b' -e '\bDeskClock\b' -e 'Calculator' -e 'Gallery2' -e 'DocumentsUI' \         -e '\bDialer\b' -e '\bMessaging\b' -e '\bEuiccGoogle\b' \         -e '\bSeedvault\b' -e '\bContactsBackup\b' \+        -e '\bEmergencyInfo\b' \         build/ device/ vendor/ | grep -i 'PRODUCT_PACKAGES' || true     warn "Confirm the names above match the filter-out list in vendor/modern-apps/modern_apps.mk." @@ -434,11 +436,15 @@ 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 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. rm -rf for a clean build (GrapheneOS does the same between devices).-    rm -rf out-    lunch "${DEVICE}-cur-user"+    # time. No rm -rf here: builds are incremental and reuse out/; wipe it manually+    # when you want a clean build (GrapheneOS does rm -rf between devices).+    lunch "${DEVICE}-cur-${VARIANT}"     # Pixel 6 (Tensor G1: bluejay/raven/oriole) has no separate vendor_kernel_boot image;     # every device since the Pixel 6a does. Building vendorkernelbootimage for a Pixel 6 fails.     local boot_targets="vendorbootimage vendorkernelbootimage"@@ -472,6 +478,9 @@ phase_release() {     # empty. Predefine it so decrypt-keys runs non-interactively and takes the plaintext path     # instead of trying to decrypt an already-plaintext key (openssl "asn1 wrong tag" error).     export password=""+    # MAOS_SKIP_OTA=1 skips the OTA zip for faster flash-test releases+    # (see script.patch). Publish path always builds the OTA.+    if [[ -n "${MAOS_SKIP_OTA:-}" ]]; then export SKIP_OTA=1; fi     script/generate-release.sh "$DEVICE" "$BUILD"     log "Release at releases/$BUILD/release-$DEVICE-$BUILD" }
modern_apps.mk
diff --git a/modern_apps.mk b/modern_apps.mkindex 8af54e9..1d279a8 100644--- a/modern_apps.mk+++ b/modern_apps.mk@@ -87,6 +87,21 @@ PRODUCT_SOONG_NAMESPACES += vendor/modern-apps # (Module names are the GrapheneOS build names — re-confirm on your synced tree if a build surprises # you, per the note on the removal list above.) +# NOTE on emergency: Modern Apps Emergency (com.vayunmathur.emergency) is a priv-app+# that replaces AOSP EmergencyInfo (module EmergencyInfo, removed from+# telephony_system_ext.mk via platform_build.patch). It answers the same platform+# actions (EMERGENCY_ASSISTANCE, EDIT_EMERGENCY_INFO + legacy EDIT_MEDICAL_INFO), the+# Settings ia.emergency injection, and the SystemUI SOS gesture via a LAUNCH_EMERGENCY+# alias (config_preferredEmergencySosPackage is empty, so no SystemUI patch is needed).+# Settings finds it through the package pins rewired in settings.patch, and the SOS+# gesture state flows through the gesture authority rewired in frameworks_base.patch.+# Its signature|privileged perms (CALL_PRIVILEGED / MANAGE_USERS /+# READ_PRIVILEGED_PHONE_STATE / SCHEDULE_EXACT_ALARM / START_ACTIVITIES_FROM_BACKGROUND+# / WRITE_SECURE_SETTINGS) are allowlisted in privapp-permissions-modern-apps.xml, and+# it is exempt from Doze in sysconfig-modern-apps.xml so the SOS countdown survives idle.+# Wireless emergency alerts (CellBroadcastReceiver) are deliberately NOT replaced and+# keep shipping stock.+ # 3. framework-res config  # 3. framework-res config (default browser, documents UI, speech recognition service, and the
patches/frameworks_base.patch
diff --git a/patches/frameworks_base.patch b/patches/frameworks_base.patchindex 392c348..32ca99a 100644--- a/patches/frameworks_base.patch+++ b/patches/frameworks_base.patch@@ -706,3 +706,20 @@ index e6fba2fadd1e..94a93f0e83f5 100644              boolean hasInternetPerm = mContext.checkCallingPermission(                      android.Manifest.permission.INTERNET) == PERMISSION_GRANTED;              if (hasInternetPerm) {+diff --git a/packages/SettingsLib/EmergencyNumber/src/com/android/settingslib/emergencynumber/EmergencyNumberUtils.java b/packages/SettingsLib/EmergencyNumber/src/com/android/settingslib/emergencynumber/EmergencyNumberUtils.java+--- a/packages/SettingsLib/EmergencyNumber/src/com/android/settingslib/emergencynumber/EmergencyNumberUtils.java++++ b/packages/SettingsLib/EmergencyNumber/src/com/android/settingslib/emergencynumber/EmergencyNumberUtils.java+@@ -46,9 +46,12 @@+ public class EmergencyNumberUtils {+     private static final String TAG = "EmergencyNumberUtils";+ ++    // MAOS: Modern Apps Emergency (com.vayunmathur.emergency) owns the++    // gesture provider, so SettingsLib must call its authority. The++    // call() method names are unchanged.+     public static final Uri EMERGENCY_NUMBER_OVERRIDE_AUTHORITY = new Uri.Builder().scheme(+             ContentResolver.SCHEME_CONTENT)+-            .authority("com.android.emergency.gesture")++            .authority("com.vayunmathur.emergency.gesture")+             .build();+     public static final String METHOD_NAME_GET_EMERGENCY_NUMBER_OVERRIDE =+             "GET_EMERGENCY_NUMBER_OVERRIDE";
patches/platform_build.patch
diff --git a/patches/platform_build.patch b/patches/platform_build.patchindex 14f011e..e12152a 100644--- a/patches/platform_build.patch+++ b/patches/platform_build.patch@@ -123,3 +123,15 @@ index aa70f46797..0705511932 100644 -    Dialer \      ImsServiceEntitlement \      preinstalled-packages-platform-telephony-product.xml+diff --git a/target/product/telephony_system_ext.mk b/target/product/telephony_system_ext.mk+--- a/target/product/telephony_system_ext.mk++++ b/target/product/telephony_system_ext.mk+@@ -20,7 +20,7 @@+ # /system_ext packages+ PRODUCT_PACKAGES += \+     CarrierConfig \+-    EmergencyInfo \++    ModernAppsEmergency \+     preinstalled-packages-telephony-system-ext.xml \+     preinstalled-packages-gsi-system-ext.xml \+ 
patches/script.patch
diff --git a/patches/script.patch b/patches/script.patchnew file mode 100644index 0000000..37cecec--- /dev/null+++ b/patches/script.patch@@ -0,0 +1,75 @@+diff --git a/generate-release.sh b/generate-release.sh+index 736dfd1..2524ed6 100755+--- a/generate-release.sh++++ b/generate-release.sh+@@ -6,6 +6,30 @@ source "$(dirname ${BASH_SOURCE[0]})/common.sh"+ + [[ $# -eq 2 ]] || user_error "expected two arguments: DEVICE BUILD_NUMBER"+ ++# MAOS: progress reporting. progress_bar TOTAL PATTERN CMD... runs CMD, counts output++# lines matching PATTERN, and redraws a single [####----] N/TOTAL line on stderr while++# passing all output through (nothing hidden).++progress_bar() {++    local total="$1" pattern="$2"; shift 2++    "$@" 2>&1 | awk -v total="$total" -v pat="$pattern" '++        { print > "/dev/stderr"; fflush("/dev/stderr") }++        $0 ~ pat {++            n++; pct = int(50 * n / total); if (pct > 50) pct = 50;++            bar = sprintf("%*s", pct, ""); gsub(/ /, "#", bar);++            pad = sprintf("%*s", 50 - pct, ""); gsub(/ /, "-", pad);++            printf "\r  [MAOS] [%s%s] %d/%d", bar, pad, n, total > "/dev/stderr";++        }++        END { printf "\n" > "/dev/stderr" }'++}++count_signables() {++    unzip -l "$1" 2>/dev/null | grep -cE "\.(apk|apex)$"++}++++# MAOS: stage logging + optional OTA skip. SKIP_OTA=1 skips ota_from_target_files +++# generate-metadata (saves ~15-20 min) for local flash-test builds; the install/factory++# images are unaffected. Default (unset/empty) builds everything as upstream.++stage() { echo ""; echo "===== [generate-release] STAGE $1/4: $2 ($(date -u +%H:%M:%S)) ====="; }+++ chrt -b -p 0 $$+ + DEVICE=$1+@@ -73,7 +97,10 @@ fi+ AVB_PKMD="$KEY_DIR/avb_pkmd.bin"+ AVB_ALGORITHM=SHA256_RSA4096+ +-sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --avb_vbmeta_algorithm $AVB_ALGORITHM \++stage 1 "sign target_files (APK+APEX, RSA-4096)"++_sign_total=$(count_signables "$TARGET_FILES_INPUT")++echo "  [MAOS] signing ~$_sign_total APK/APEX files..."++progress_bar "$_sign_total" "^    signing:" sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --avb_vbmeta_algorithm $AVB_ALGORITHM \+     --extra_apks com.android.adbd.apex="$KEY_DIR/releasekey" \+     --extra_apex_payload_key com.android.adbd.apex="$KEY_DIR/avb.pem" \+     --extra_apks AdServicesApk.apk="$KEY_DIR/releasekey" \+@@ -179,10 +206,16 @@ sign_target_files_apks -o -d "$KEY_DIR" --avb_vbmeta_key "$KEY_DIR/avb.pem" --av+     --extra_apex_payload_key com.google.pixel.camera.hal.apex="$KEY_DIR/avb.pem" \+     $TARGET_FILES_INPUT $TARGET_FILES+ +-ota_from_target_files -k "$KEY_DIR/releasekey" $OTA_ARGS $TARGET_FILES \+-    $DEVICE-ota_update-$BUILD_NUMBER.zip+-script/generate-metadata $DEVICE-ota_update-$BUILD_NUMBER.zip++if [[ -n "${SKIP_OTA:-}" ]]; then++    stage 2 "OTA SKIPPED (SKIP_OTA set) - no ota_update zip, no metadata"++else++    stage 2 "full OTA (block diff, slowest single step)"++    ota_from_target_files -k "$KEY_DIR/releasekey" $OTA_ARGS $TARGET_FILES \++        $DEVICE-ota_update-$BUILD_NUMBER.zip++    script/generate-metadata $DEVICE-ota_update-$BUILD_NUMBER.zip++fi+ ++stage 3 "device images (per-partition + super)"+ img_from_target_files $TARGET_FILES $DEVICE-img-$BUILD_NUMBER.zip+ + source device/common/generate-factory-images-common.sh+@@ -195,6 +228,7 @@ fi+ + # Second arg to optimize-factory-image is the name of outer zip directory.+ # Output zip name defaults to <outer zip dir name>.zip++stage 4 "factory + install zips (super split for flashing)"+ fastboot -S $MAX_DOWNLOAD_SIZE optimize-factory-image $DEVICE-factory-$BUILD_NUMBER.zip $DEVICE-install-$BUILD_NUMBER+ + if [[ -f "$KEY_DIR/id_ed25519" ]]; then
patches/settings.patch
diff --git a/patches/settings.patch b/patches/settings.patchindex b73a359..619d015 100644--- a/patches/settings.patch+++ b/patches/settings.patch@@ -357,3 +357,30 @@ index 4b34ea66db5..d4c383cc0d8 100644 +            Uri.parse("content://com.vayunmathur.networklocation.status/databases")      }  }+diff --git a/res/values/config.xml b/res/values/config.xml+--- a/res/values/config.xml++++ b/res/values/config.xml+@@ -300,9 +300,13 @@+         com.android.contacts+     </string>+ ++    <!-- MAOS: Modern Apps Emergency replaces AOSP EmergencyInfo.++         EmergencyActionContentProvider only takes the SOS call from this++         package, and the preference controllers resolve the edit intent++         against it. -->+     <!-- AOSP Emergency app package name -->+     <string name="config_aosp_emergency_package_name" translatable="false">+-        com.android.emergency++        com.vayunmathur.emergency+     </string>+ +     <!-- AOSP Emergency app intent action -->+@@ -312,7 +316,7 @@+ +     <!-- Emergency app package name -->+     <string name="config_emergency_package_name" translatable="false">+-        com.android.emergency++        com.vayunmathur.emergency+     </string>+ +     <!-- Emergency app intent action -->
privapp-permissions-modern-apps.xml
diff --git a/privapp-permissions-modern-apps.xml b/privapp-permissions-modern-apps.xmlindex fd0a508..efcbee1 100644--- a/privapp-permissions-modern-apps.xml+++ b/privapp-permissions-modern-apps.xml@@ -122,4 +122,21 @@         <permission name="android.permission.ALLOCATE_AGGRESSIVE"/>     </privapp-permissions> +    <!-- Emergency replaces AOSP EmergencyInfo (com.android.emergency). Same six+         signature|privileged perms stock allowlists in+         frameworks/base/data/etc/com.android.emergency.xml: the CALL_PRIVILEGED guard+         on the gesture provider, owner identity (MANAGE_USERS), the privileged half+         of emergency-number lookup (READ_PRIVILEGED_PHONE_STATE), the exact SOS+         countdown alarm (SCHEDULE_EXACT_ALARM), firing the call from the background+         alarm (START_ACTIVITIES_FROM_BACKGROUND), and persisting the SOS gesture+         toggles (WRITE_SECURE_SETTINGS). -->+    <privapp-permissions package="com.vayunmathur.emergency">+        <permission name="android.permission.CALL_PRIVILEGED"/>+        <permission name="android.permission.MANAGE_USERS"/>+        <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>+        <permission name="android.permission.SCHEDULE_EXACT_ALARM"/>+        <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>+        <permission name="android.permission.WRITE_SECURE_SETTINGS"/>+    </privapp-permissions>+ </permissions>
sysconfig-modern-apps.xml
diff --git a/sysconfig-modern-apps.xml b/sysconfig-modern-apps.xmlindex 1a1fdd2..11507d5 100644--- a/sysconfig-modern-apps.xml+++ b/sysconfig-modern-apps.xml@@ -37,4 +37,9 @@     <hidden-api-whitelisted-app package="com.vayunmathur.parentalcontrols" />     <hidden-api-whitelisted-app package="com.vayunmathur.screentime" /> +    <!-- Emergency (com.vayunmathur.emergency) replaces AOSP EmergencyInfo. The SOS+         countdown runs as a foreground service off an exact alarm; exempt it from Doze+         like stock does so the countdown is not killed while the screen is off. -->+    <allow-in-power-save package="com.vayunmathur.emergency" />+ </config>