maos: park cast desktop-mode framework patches that bootloop shiba
- Commit
abaeb60e66adaf55e7a32fac4f01ef2758946f27- Author
- Vayun Mathur <[email protected]>
- When
- 2026-09-09 05:12 UTC (2 months ago)
- Parents
483feee
Diff
Android.bp
diff --git a/Android.bp b/Android.bpindex 733c8f9..338ba9c 100644--- a/Android.bp+++ b/Android.bp@@ -204,6 +204,80 @@ android_app_import { }, } +// FindFamily and Share are ordinary user apps, not system components: they replace nothing+// GrapheneOS ships and hold no signature|privileged permission, so neither is `privileged:+// true` and neither needs a privapp-permissions entry. They are preinstalled only so a fresh+// device has them available; everything they use (location, contacts, nearby-device Bluetooth)+// is a runtime permission the user grants, exactly as it would be from a store install.+android_app_import {+ name: "ModernAppsFindFamily",+ apk: "prebuilts/findfamily-release.apk",+ presigned: true,+ preprocessed: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++android_app_import {+ name: "ModernAppsShare",+ apk: "prebuilts/share-release.apk",+ presigned: true,+ preprocessed: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++// Cast is PRIVILEGED: it is a remote display provider, and+// RemoteDisplayProviderWatcher.verifyServiceTrusted only trusts a provider whose app holds+// android.permission.REMOTE_DISPLAY_PROVIDER (signature|privileged). Without that the+// watcher logs and skips the service and Settings' Cast page stays empty. It also needs+// START_ACTIVITIES_FROM_BACKGROUND to reach the screen-capture consent activity from the+// bound service. Both are allowlisted in privapp-permissions-modern-apps.xml.+//+// The TV receiver (com.vayunmathur.cast.tv) is deliberately NOT preinstalled: it targets a+// television, not a phone.+android_app_import {+ name: "ModernAppsCast",+ apk: "prebuilts/cast-release.apk",+ presigned: true,+ preprocessed: true,+ privileged: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}++// LogViewer is PRIVILEGED: it replaces GrapheneOS's app.grapheneos.logviewer (module+// LogViewer, removed from handheld_system.mk) and holds the same permissions it did.+// READ_LOGS, READ_LOGS_FULL, READ_OEM_UNLOCK_STATE and QUERY_USERS are allowlisted in+// privapp-permissions-modern-apps.xml; a missing entry there is a boot failure, not a+// degraded feature. Without READ_LOGS in particular logd filters logcat down to our own+// uid and the log simply looks EMPTY - exit code 0, no error.+//+// It declares two permissions of its own, com.vayunmathur.logviewer.SHOW_LOGCAT+// (signature|privileged) and .SHOW_ERROR_REPORT (signature|preinstalled), which is how+// Settings and the system crash dialog are allowed to open it. There is deliberately no+// launcher entry: both activities are permission-guarded and reached by intent.+//+// frameworks/base/core/java/android/ext/LogViewerApp.java is patched to this package name;+// it is the producer of every error-report intent and addresses them with setPackage().+android_app_import {+ name: "ModernAppsLogViewer",+ apk: "prebuilts/logviewer-release.apk",+ presigned: true,+ preprocessed: true,+ privileged: true,+ product_specific: true,+ dex_preopt: {+ enabled: false,+ },+}+ // Euicc is PRIVILEGED: it is the system eSIM LPA (Local Profile Assistant). It declares the // android.service.euicc.EuiccService and the eSIM management LUI, and drives the eUICC over a // telephony logical channel, so it needs the signature|privileged WRITE_EMBEDDED_SUBSCRIPTIONS /@@ -245,3 +319,78 @@ android_app_import { enabled: false, }, }++// SetupWizard is PRIVILEGED: it is the first-run setup wizard. The platform picks it by+// resolving MAIN against the SETUP_WIZARD and HOME categories, and its intent-filter sits at+// priority 999 so it wins that resolution over the launcher while the device is unprovisioned.+// It sets the system locale, the clock and time zone, and the location master switch, reads+// and clears OEM-unlock state, disables the status bar for the duration of setup, and writes+// DEVICE_PROVISIONED / user_setup_complete to end it - so it needs the signature|privileged+// CHANGE_CONFIGURATION / MANAGE_USER_OEM_UNLOCK_STATE / NETWORK_SETUP_WIZARD /+// READ_PRIVILEGED_PHONE_STATE / READ_OEM_UNLOCK_STATE / REBOOT / SET_TIME / SET_TIME_ZONE /+// STATUS_BAR / WRITE_SECURE_SETTINGS / WRITE_SETTINGS perms, allowlisted in+// privapp-permissions-modern-apps.xml.+//+// It replaces GrapheneOS's SetupWizard2 (app.grapheneos.setupwizard). Both that module and+// AOSP's fallback Provision are dropped by the `overrides` below, which is how GrapheneOS's own+// SetupWizard2 module already drops `Provision` in this tree. Verified mechanism, not a guess:+// soong_app_prebuilt.mk:167 sets PACKAGES.<m>.OVERRIDES for an android_app_import, and+// main.mk:1011-1013 filters overridden modules out of the PRODUCT_PACKAGES-derived list before+// expand-required-modules runs at :1016 (so SetupWizard2's `required:` etc-permissions file+// drops with it, leaving no stale app.grapheneos.setupwizard.xml).+//+// `SetupWizard2` is deliberately LEFT listed in build/make/target/product/handheld_system_ext.mk+// rather than also being deleted there. That line is not redundancy - it is the fallback for+// THIS app going missing. An `overrides` from a module that is not installed does not apply, so+// if the setupwizard prebuilt is ever absent from the image, SetupWizard2 still ships and the+// device still completes setup. Delete that line and the same accident leaves zero activities+// answering SETUP_WIZARD + HOME on an unprovisioned device, which does not boot. Keeping it+// trades a wrong-wizard bug for a brick, in the right direction.+//+// ⚠️ The two must never be separated. With both this app and SetupWizard2 installed, the+// SETUP_WIZARD + HOME resolution is ambiguous; with neither, there is no HOME activity while+// the device is unprovisioned and first boot never completes.+android_app_import {+ name: "ModernAppsSetupWizard",+ apk: "prebuilts/setupwizard-release.apk",+ presigned: true,+ preprocessed: true,+ privileged: true,+ product_specific: true,+ overrides: [+ "Provision",+ "SetupWizard2",+ ],+ dex_preopt: {+ enabled: false,+ },+}++// Updater is PRIVILEGED: it holds REBOOT, ACCESS_CACHE_FILESYSTEM and ALLOCATE_AGGRESSIVE, and+// it drives android.os.UpdateEngine to write an OTA payload into the inactive A/B slot. All+// three are signature|privileged and are allowlisted in privapp-permissions-modern-apps.xml.+//+// `overrides` displaces the GrapheneOS updater outright rather than shipping both. Two update+// clients on one device is not a cosmetic problem: update_engine applies ONE payload at a time+// device-wide, so a second client polling the same server races the first for the slot and the+// loser fails with an error that looks like a corrupt package.+//+// ⚠️ This is the one app whose failure is not self-correcting. If this client is broken and the+// GrapheneOS one is gone, the device cannot update in place and needs a manual flash. It fails+// SAFE only in the sense that `overrides` is conditional on this module existing: a missing+// prebuilt leaves app.seamlessupdate.client in the image. It does NOT protect against ours+// shipping and then not working. Prove an end-to-end update on a real device before trusting it.+android_app_import {+ name: "ModernAppsUpdater",+ apk: "prebuilts/updater-release.apk",+ presigned: true,+ preprocessed: true,+ privileged: true,+ product_specific: true,+ overrides: [+ "Updater",+ ],+ dex_preopt: {+ enabled: false,+ },+}
build-maos.sh
diff --git a/build-maos.sh b/build-maos.shindex a7600e6..6e35a19 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)+APPS=(web camera pdf contacts calculator clock files photos appstore keyboard speech calendar music communicate euicc backup networklocation findfamily share cast setupwizard logviewer updater) # ---- Derived / optional-env config ---- # ONE shared, device-independent key set (see the "Signing keys" note above).@@ -254,8 +254,12 @@ apply_maos_patches() { local spec repo patch for spec in "build/make:platform_build.patch" "vendor/adevtool:adevtool.patch" \ "frameworks/base:frameworks_base.patch" \+ "frameworks/libs/systemui:frameworks_libs_systemui.patch" \+ "build/release:build_release.patch" \ "packages/apps/Settings:settings.patch" \- "packages/apps/SetupWizard2:setupwizard2.patch"; do+ "packages/apps/SetupWizard2:setupwizard2.patch" \+ "external/roboto-fonts:roboto_fonts.patch" \+ "packages/apps/GmsCompat:gmscompat.patch"; do repo="${spec%%:*}"; patch="$TREE/$patches/${spec##*:}" [[ -f "$patch" ]] || die "Missing patch file: $patch" [[ -d "$repo" ]] || die "Missing repo for patch: $repo"
camera/Android.bp
diff --git a/camera/Android.bp b/camera/Android.bpnew file mode 100644index 0000000..a2ef19b--- /dev/null+++ b/camera/Android.bp@@ -0,0 +1,18 @@+// VINTF declaration for the AOSP external (USB/UVC) camera provider.+//+// cameraserver discovers camera providers ONLY through+// ServiceManager::getDeclaredInstances (CameraProviderManager::tryToAddAidlProvidersLocked),+// so shipping the binary without this fragment produces a running service nobody talks to.+//+// This is a standalone fragment rather than a DEVICE_MANIFEST_FILE entry so that nothing in+// the base /vendor/etc/vintf/manifest.xml is modified or reordered. shiba's own vendor+// manifest declares no camera HAL at all - internal/0 comes from the+// com.google.pixel.camera.hal APEX - so this adds an instance and displaces nothing.+//+// soc_specific installs to /vendor/etc/vintf/manifest/, matching adevtool's 39 fragments.+// The installed filename is the src basename, not the module name (vintf_fragment.go).+vintf_fragment {+ name: "maos_vintf_fragment_camera_provider_external",+ src: "android.hardware.camera.provider-V1-external-service.xml",+ soc_specific: true,+}
camera/android.hardware.camera.provider-V1-external-service.xml
diff --git a/camera/android.hardware.camera.provider-V1-external-service.xml b/camera/android.hardware.camera.provider-V1-external-service.xmlnew file mode 100644index 0000000..cf7b21e--- /dev/null+++ b/camera/android.hardware.camera.provider-V1-external-service.xml@@ -0,0 +1,10 @@+<manifest version="1.0" type="device">+ <hal format="aidl">+ <name>android.hardware.camera.provider</name>+ <version>1</version>+ <interface>+ <name>ICameraProvider</name>+ <instance>external/0</instance>+ </interface>+ </hal>+</manifest>
camera/external_camera_config.xml
diff --git a/camera/external_camera_config.xml b/camera/external_camera_config.xmlnew file mode 100644index 0000000..315c6ad--- /dev/null+++ b/camera/external_camera_config.xml@@ -0,0 +1,45 @@+<ExternalCamera>+ <Provider>+ <!-- Ignored /dev/videoN. The id is the numeric suffix of the node name as a+ string (ExternalCameraProvider.cpp deviceAdded/inotify paths), NOT the minor+ number. On shiba 6-11 are the MFC codec nodes (mediacodec:mediadrm, so the+ HAL gets EACCES) and 12 is the JPEG device (labelled hw_jpg_device, which+ hal_camera has no rule for, so it gets an avc denial). Names 0-5 are free,+ which is where a hot-plugged UVC camera lands - and 0-3 are the only nodes+ /vendor/etc/ueventd.rc chowns to system:camera. -->+ <ignore>+ <id>6</id>+ <id>7</id>+ <id>8</id>+ <id>9</id>+ <id>10</id>+ <id>11</id>+ <id>12</id>+ </ignore>+ </Provider>+ <Device>+ <MaxJpegBufferSize bytes="3145728"/>+ <NumVideoBuffers count="4"/>+ <NumStillBuffers count="2"/>+ <!-- Each fpsBound is an inclusive upper-bound FILTER, not a target: any rate the+ camera advertises above it is discarded, and a size whose rates are ALL+ discarded is dropped from the supported-format list entirely+ (ExternalCameraDevice::updateFpsBounds). So a bound that is too low removes+ the resolution rather than slowing it down. The last entry also caps the+ maximum supported size.++ Sizes must strictly increase and fpsBound must strictly decrease+ (ExternalCameraConfig::updateFpsList) - a violation rejects the whole list+ AND abandons the rest of this file, silently reverting to the built-in+ defaults of [email protected] / 1080p@5. Hence 60/45/30 rather than a flat 30: it+ admits 30fps at every size while satisfying the ordering rule.++ 1080p is the cap because MJPEG is decoded in software on the CPU+ (libyuv::MJPGToI420 in ExternalCameraDeviceSession). -->+ <FpsList>+ <Limit width="640" height="480" fpsBound="60.0"/>+ <Limit width="1280" height="720" fpsBound="45.0"/>+ <Limit width="1920" height="1080" fpsBound="30.0"/>+ </FpsList>+ </Device>+</ExternalCamera>
default-permissions-modern-apps.xml
diff --git a/default-permissions-modern-apps.xml b/default-permissions-modern-apps.xmlindex 936e3b7..7ba3116 100644--- a/default-permissions-modern-apps.xml+++ b/default-permissions-modern-apps.xml@@ -15,5 +15,38 @@ <exception package="com.vayunmathur.networklocation"> <permission name="android.permission.ACCESS_FINE_LOCATION" fixed="false" /> <permission name="android.permission.ACCESS_BACKGROUND_LOCATION" fixed="false" />+ <permission name="android.permission.ACCESS_COARSE_LOCATION" fixed="false" />+ <permission name="android.permission.READ_PHONE_STATE" fixed="false" />+ <permission name="android.permission.INTERNET" fixed="false" />+</exception>+ <!-- Cast finds receivers with NsdManager. Android 16's Local Network Protections gate+ that browse on ACCESS_LOCAL_NETWORK, and rather than throwing, the platform+ intercepts it and puts its own NsdPickerActivity in front of the user - so Settings'+ Cast page lists nothing and spins forever while a system "choose a device to+ connect" prompt appears over it. The app cannot ask for this itself: its route list+ is published headlessly by a bound RemoteDisplayProvider service with no UI.+ fixed="false" like the entries above, so the user can still revoke it. -->+ <exception package="com.vayunmathur.cast">+ <permission name="android.permission.ACCESS_LOCAL_NETWORK" fixed="false" />+ <permission name="android.permission.INTERNET" fixed="false" />+ <permission name="android.permission.POST_NOTIFICATIONS" fixed="false" />+</exception>++ <!-- Share discovers peers over mDNS, Wi-Fi Aware and BLE. Every one of these is a+ transport rather than a feature: with any of them missing a peer is simply never+ found, which presents to the user as "nothing here" rather than as an error. -->+ <exception package="com.vayunmathur.share">+ <permission name="android.permission.ACCESS_LOCAL_NETWORK" fixed="false" />+ <permission name="android.permission.NEARBY_WIFI_DEVICES" fixed="false" />+ <permission name="android.permission.BLUETOOTH_ADVERTISE" fixed="false" />+ <permission name="android.permission.BLUETOOTH_SCAN" fixed="false" />+ <permission name="android.permission.INTERNET" fixed="false" />+ <permission name="android.permission.POST_NOTIFICATIONS" fixed="false" />+ </exception>++ <!-- Files reports long copies and deletions through a notification; its actual storage+ access is MANAGE_EXTERNAL_STORAGE, which is an appop and not grantable here. -->+ <exception package="com.vayunmathur.files">+ <permission name="android.permission.POST_NOTIFICATIONS" fixed="false" /> </exception> </exceptions>
modern_apps.mk
diff --git a/modern_apps.mk b/modern_apps.mkindex 105e335..1e17e82 100644--- a/modern_apps.mk+++ b/modern_apps.mk@@ -136,3 +136,30 @@ $(call inherit-product-if-exists, vendor/modern-apps/maos_branding.mk) # removal above, so it was always empty and never fired - which is why a build that # shipped zero MAOS apps still reported success. Removal is now a patch, and a patch # that no longer applies fails loudly in phase_overlay.++# 7. External USB (UVC) camera support, so a webcam is a real system camera visible to every+# camera2 client rather than to one app via UsbManager. Kernel support is already present+# (CONFIG_USB_VIDEO_CLASS=y) and android.hardware.usb.host is already a device feature.+#+# No sepolicy is needed. system/sepolicy/vendor/file_contexts:42 already labels+# /vendor/bin/hw/...-external-service as hal_camera_default_exec, hal_camera_default.te+# gives it a domain via init_daemon_domain, and hal_camera.te:12-13 already allows+# read/write on video_device (which /dev/video[0-9]* is labelled). The extra cameraserver+# rules the AOSP docs mention are for passthrough HIDL mode; this is a binderized AIDL+# daemon in its own domain.+#+# The non-lazy binary is deliberate: the lazy variant is oneshot+disabled and only starts+# on demand, whereas the eager one runs the inotify hotplug thread that notices a camera+# plugged in after boot. Note the lazy module `overrides` this one, so never add both.+PRODUCT_PACKAGES += \+ android.hardware.camera.provider-V1-external-service \+ maos_vintf_fragment_camera_provider_external++# external_camera_config.xml must be at exactly this path - it is hardcoded as+# ExternalCameraConfig::kDefaultCfgPath. The feature file also re-declares+# android.hardware.camera.any, which four already-installed+# /vendor/etc/permissions/android.hardware.camera.*.prebuilt.xml files declare too;+# SystemConfig.addFeature merges duplicates, so that is harmless.+PRODUCT_COPY_FILES += \+ frameworks/native/data/etc/android.hardware.camera.external.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.external.xml \+ vendor/modern-apps/camera/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml
patches/build_release.patch
diff --git a/patches/build_release.patch b/patches/build_release.patchnew file mode 100644index 0000000..e15b919--- /dev/null+++ b/patches/build_release.patch@@ -0,0 +1,12 @@+diff --git a/aconfig/trunk_staging/com.android.server.display.feature.flags/virtual_displays_support_desktop_mode_flag_values.textproto b/aconfig/trunk_staging/com.android.server.display.feature.flags/virtual_displays_support_desktop_mode_flag_values.textproto+new file mode 100755+index 000000000..8ecd4b885+--- /dev/null++++ b/aconfig/trunk_staging/com.android.server.display.feature.flags/virtual_displays_support_desktop_mode_flag_values.textproto+@@ -0,0 +1,6 @@++flag_value {++ package: "com.android.server.display.feature.flags"++ name: "virtual_displays_support_desktop_mode"++ state: ENABLED++ permission: READ_WRITE++}
patches/frameworks_base.patch
diff --git a/patches/frameworks_base.patch b/patches/frameworks_base.patchindex b5ea606..6577c84 100644--- a/patches/frameworks_base.patch+++ b/patches/frameworks_base.patch@@ -1,3 +1,61 @@+diff --git a/core/java/android/ext/KnownSystemPackages.java b/core/java/android/ext/KnownSystemPackages.java+index 839f04c0773b..e962c3bc4f64 100644+--- a/core/java/android/ext/KnownSystemPackages.java++++ b/core/java/android/ext/KnownSystemPackages.java+@@ -37,7 +37,7 @@ public final class KnownSystemPackages {+ mediaProvider = "com.android.providers.media.module";+ permissionController = "com.android.permissioncontroller";+ settings = "com.android.settings";+- setupWizard = "app.grapheneos.setupwizard";++ setupWizard = "com.vayunmathur.setupwizard";+ shell = "com.android.shell";+ systemUi = res.getString(R.string.config_systemUi);+ }+diff --git a/core/java/android/ext/LogViewerApp.java b/core/java/android/ext/LogViewerApp.java+index 0eb6239bc279..fa975ab112b9 100644+--- a/core/java/android/ext/LogViewerApp.java++++ b/core/java/android/ext/LogViewerApp.java+@@ -11,7 +11,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;+ + /** @hide */+ public class LogViewerApp {+- private static final String PACKAGE_NAME = "app.grapheneos.logviewer";++ private static final String PACKAGE_NAME = "com.vayunmathur.logviewer";+ + public static final String ACTION_ERROR_REPORT = PACKAGE_NAME + ".ERROR_REPORT";+ public static final String ACTION_LOGCAT = PACKAGE_NAME + ".LOGCAT";+diff --git a/core/res/res/values/config_ext.xml b/core/res/res/values/config_ext.xml+index 9f66d22bca1a..6dd6906f4e34 100644+--- a/core/res/res/values/config_ext.xml++++ b/core/res/res/values/config_ext.xml+@@ -38,7 +38,13 @@+ <bool name="setting_default_force_app_memtag">false</bool>+ <java-symbol type="bool" name="setting_default_force_app_memtag" />+ +- <string name="config_first_party_app_source_package_name">app.grapheneos.apps</string>++ <!-- MAOS ships Modern Apps Store in place of GrapheneOS Apps, so it is the first-party++ app source here. PackageInstallerSession lets only this package (or shell, or the++ Play Store within version limits) install the Sandboxed Google Play components -++ everything else is refused with "blocked to prevent breaking gmscompat". Leaving++ GrapheneOS's value would name a package this OS does not ship, so nothing could++ install GMS or Vending at all. -->++ <string name="config_first_party_app_source_package_name">com.vayunmathur.appstore</string>+ <java-symbol type="string" name="config_first_party_app_source_package_name" />+ + <!-- Certificate digests for trusted apps that will be allowed to obtain the knownSigner+diff --git a/data/fonts/fallback_order.json b/data/fonts/fallback_order.json+index 2fc3f3e3fc5b..3cac8625cdb5 100644+--- a/data/fonts/fallback_order.json++++ b/data/fonts/fallback_order.json+@@ -1,4 +1,8 @@+ [++ // MAOS: Google Sans Flex backs sans-serif but covers only ~535 codepoints, so++ // Roboto has to absorb everything it lacks. First in the list means Cyrillic and++ // Greek reach Roboto instead of a Noto face, which would look out of place.++ { "id": "roboto-latin" },+ { "lang": "und-Arab" },+ { "lang": "und-Ethi" },+ { "lang": "und-Hebr" }, diff --git a/data/fonts/fonts.xml b/data/fonts/fonts.xml index 8cbc3000c250..a453346df82e 100644 --- a/data/fonts/fonts.xml
patches/frameworks_libs_systemui.patch
diff --git a/patches/frameworks_libs_systemui.patch b/patches/frameworks_libs_systemui.patchnew file mode 100644index 0000000..e69de29
patches/gmscompat.patch
diff --git a/patches/gmscompat.patch b/patches/gmscompat.patchnew file mode 100644index 0000000..36abbe7--- /dev/null+++ b/patches/gmscompat.patch@@ -0,0 +1,13 @@+diff --git a/AndroidManifest.xml b/AndroidManifest.xml+index 676a024..1cb8642 100644+--- a/AndroidManifest.xml++++ b/AndroidManifest.xml+@@ -10,7 +10,7 @@+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />+ <!-- needed to be able to create TempServiceBinding to any package-->+ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />+- <uses-permission android:name="app.grapheneos.logviewer.SHOW_ERROR_REPORT" />++ <uses-permission android:name="com.vayunmathur.logviewer.SHOW_ERROR_REPORT" />+ <!-- needed for config fragments for updating permissions for Android Auto, etc. -->+ <uses-permission android:name="android.permission.UPDATE_AND_INVALIDATE_PERMISSION_STATE" />+
patches/platform_build.patch
diff --git a/patches/platform_build.patch b/patches/platform_build.patchindex 35834fa..3c50145 100644--- a/patches/platform_build.patch+++ b/patches/platform_build.patch@@ -21,10 +21,10 @@ index c54d58ddf6..fe09fa2969 100644 preinstalled-packages-platform-aosp-product.xml \ ThemePicker \ diff --git a/target/product/handheld_product.mk b/target/product/handheld_product.mk-index 2a4602d43b..7fdaddf2ee 100644+index 2a4602d43b..9008973800 100644 --- a/target/product/handheld_product.mk +++ b/target/product/handheld_product.mk-@@ -22,25 +22,28 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/media_product.mk)+@@ -22,25 +22,34 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/media_product.mk) # /product packages PRODUCT_PACKAGES += \@@ -54,9 +54,15 @@ index 2a4602d43b..7fdaddf2ee 100644 + ModernAppsCalendar \ + ModernAppsMusic \ + ModernAppsCommunicate \++ ModernAppsCast \++ ModernAppsFindFamily \++ ModernAppsShare \ + ModernAppsEuicc \ + ModernAppsBackup \ + ModernAppsNetworkLocation \++ ModernAppsSetupWizard \++ ModernAppsLogViewer \++ ModernAppsUpdater \ preinstalled-packages-platform-handheld-product.xml \ SettingsIntelligence \ - SpeechServices \@@ -68,7 +74,7 @@ index 2a4602d43b..7fdaddf2ee 100644 PRODUCT_PACKAGES_DEBUG += \ diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk-index 029bdd6ef3..b9729321b2 100644+index 029bdd6ef3..4eaba4776d 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -48,7 +48,6 @@ PRODUCT_PACKAGES += \@@ -79,7 +85,12 @@ index 029bdd6ef3..b9729321b2 100644 DownloadProviderUi \ EasterEgg \ ExternalStorageProvider \-@@ -62,7 +61,6 @@ PRODUCT_PACKAGES += \+@@ -57,12 +56,10 @@ PRODUCT_PACKAGES += \+ InputDevices \+ KeyChain \+ librs_jni \+- LogViewer \+ ManagedProvisioning \ MmsService \ MtpService \ MusicFX \
patches/roboto_fonts.patch
diff --git a/patches/roboto_fonts.patch b/patches/roboto_fonts.patchnew file mode 100644index 0000000..3a68fbc--- /dev/null+++ b/patches/roboto_fonts.patch@@ -0,0 +1,59 @@+diff --git a/font_config.json b/font_config.json+index 5e46ece..9b44e99 100644+--- a/font_config.json++++ b/font_config.json+@@ -1,10 +1,19 @@+ [+ {++ // MAOS ships Google Sans Flex as the system font. It is a display face with only++ // ~535 codepoints - no Cyrillic, almost no Greek - so it cannot stand alone; the++ // "roboto-latin" fallback below covers everything it is missing. It does carry a++ // full wght axis (1-1000) and a wdth axis (25-151), so both the regular and the++ // condensed family are real instances rather than synthesised ones.++ //++ // supportedAxes stays "wght" because Google Sans Flex has no "ital" axis - it++ // slants via "slnt", which generate_fonts_xml does not accept (font_builder.py++ // allows only "wght" and "wght,ital"). Italic text is therefore synthesised.+ "name": "sans-serif",+ "fonts": [+ {+- "file": "Roboto-Regular.ttf",+- "supportedAxes": "wght,ital",++ "file": "GoogleSansFlex.ttf",++ "supportedAxes": "wght",+ "axes": {+ "wdth": "100"+ }+@@ -13,12 +22,31 @@+ },+ {+ "name": "sans-serif-condensed",++ "fonts": [++ {++ "file": "GoogleSansFlex.ttf",++ "supportedAxes": "wght",++ "axes": {++ "wdth": "75"++ }++ }++ ]++ },++ {++ // Every glyph Google Sans Flex lacks - all Cyrillic, most Greek and Latin Ext-B,++ // most punctuation - resolves here. Registered first in fallback_order.json so it++ // is reached before the Noto faces, which would otherwise pick up Cyrillic and++ // render it in a visibly different design.++ //++ // A fallback family needs an id or a lang that fallback_order.json knows about;++ // FallbackOrder asserts on any family it cannot place.++ "id": "roboto-latin",+ "fonts": [+ {+ "file": "Roboto-Regular.ttf",+ "supportedAxes": "wght,ital",+ "axes": {+- "wdth": "75"++ "wdth": "100"+ }+ }+ ]
patches/settings.patch
diff --git a/patches/settings.patch b/patches/settings.patchindex d7f4bb2..b73a359 100644--- a/patches/settings.patch+++ b/patches/settings.patch@@ -1,3 +1,126 @@+diff --git a/AndroidManifest.xml b/AndroidManifest.xml+index d4e5e0e8670..6ea7e2e8713 100644+--- a/AndroidManifest.xml++++ b/AndroidManifest.xml+@@ -150,7 +150,7 @@+ <uses-permission android:name="android.permission.SATELLITE_COMMUNICATION" />+ <uses-permission android:name="android.permission.READ_SYSTEM_GRAMMATICAL_GENDER" />+ <uses-permission android:name="android.permission.MANAGE_COMPANION_DEVICES" />+- <uses-permission android:name="app.grapheneos.logviewer.SHOW_LOGCAT" />++ <uses-permission android:name="com.vayunmathur.logviewer.SHOW_LOGCAT" />+ <uses-permission android:name="android.permission.CONTROL_SIM_AUTO_PIN_MANAGEMENT" />+ <uses-permission android:name="android.permission.MANAGE_COMPUTER_CONTROL_CONSENT" />+ +diff --git a/res/values-en-rAU/strings.xml b/res/values-en-rAU/strings.xml+index c181c5bc2b2..225af58eee0 100644+--- a/res/values-en-rAU/strings.xml++++ b/res/values-en-rAU/strings.xml+@@ -973,7 +973,7 @@+ <string name="external_display_topology_a11y_display_moved_down" msgid="6028544722984648702">"Display: %1$s moved down"</string>+ <string name="external_display_topology_a11y_display_moved_left" msgid="5308110789317472437">"Display: %1$s moved left"</string>+ <string name="external_display_topology_a11y_display_moved_right" msgid="3802527156765844475">"Display: %1$s moved right"</string>+- <string name="wifi_display_settings_title" msgid="2622548133505158832">"Google Cast"</string>++ <string name="wifi_display_settings_title" msgid="2622548133505158832">"Cast"</string>+ <string name="keywords_wifi_display_settings" msgid="5753883229564422679">"mirror"</string>+ <string name="wifi_display_enable_menu_item" msgid="7391841780777318134">"Enable wireless display"</string>+ <string name="wifi_display_no_devices_found" msgid="7904877793677102805">"No nearby devices were found."</string>+@@ -3775,7 +3775,7 @@+ <string name="keywords_text_cursor_blink_rate" msgid="7682963763334011148">"caret, text caret, text cursor, cursor, blinking, blink interval, blink rate, animation, reduce animation, remove animation"</string>+ <string name="sound_dashboard_summary" msgid="8254699132423665654">"Volume and vibration"</string>+ <string name="media_volume_option_title" msgid="5966569685119475630">"Media volume"</string>+- <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Google Cast volume"</string>++ <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Cast volume"</string>+ <string name="call_volume_option_title" msgid="1461105986437268924">"Call volume"</string>+ <string name="alarm_volume_option_title" msgid="6398641749273697140">"Alarm volume"</string>+ <string name="assistant_volume_option_title" msgid="7206008753384831048">"Assistant volume"</string>+diff --git a/res/values-en-rCA/strings.xml b/res/values-en-rCA/strings.xml+index 22b6f74c23f..0fa0efba534 100644+--- a/res/values-en-rCA/strings.xml++++ b/res/values-en-rCA/strings.xml+@@ -973,7 +973,7 @@+ <string name="external_display_topology_a11y_display_moved_down" msgid="6028544722984648702">"Display: %1$s moved down"</string>+ <string name="external_display_topology_a11y_display_moved_left" msgid="5308110789317472437">"Display: %1$s moved left"</string>+ <string name="external_display_topology_a11y_display_moved_right" msgid="3802527156765844475">"Display: %1$s moved right"</string>+- <string name="wifi_display_settings_title" msgid="2622548133505158832">"Google Cast"</string>++ <string name="wifi_display_settings_title" msgid="2622548133505158832">"Cast"</string>+ <string name="keywords_wifi_display_settings" msgid="5753883229564422679">"mirror"</string>+ <string name="wifi_display_enable_menu_item" msgid="7391841780777318134">"Enable wireless display"</string>+ <string name="wifi_display_no_devices_found" msgid="7904877793677102805">"No nearby devices were found."</string>+@@ -3775,7 +3775,7 @@+ <string name="keywords_text_cursor_blink_rate" msgid="7682963763334011148">"caret, text caret, text cursor, cursor, blinking, blink interval, blink rate, animation, reduce animation, remove animation"</string>+ <string name="sound_dashboard_summary" msgid="8254699132423665654">"Volume and vibration"</string>+ <string name="media_volume_option_title" msgid="5966569685119475630">"Media volume"</string>+- <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Google Cast volume"</string>++ <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Cast volume"</string>+ <string name="call_volume_option_title" msgid="1461105986437268924">"Call volume"</string>+ <string name="alarm_volume_option_title" msgid="6398641749273697140">"Alarm volume"</string>+ <string name="assistant_volume_option_title" msgid="7206008753384831048">"Assistant volume"</string>+diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml+index ffe06a45ad7..3612e93b96b 100644+--- a/res/values-en-rGB/strings.xml++++ b/res/values-en-rGB/strings.xml+@@ -973,7 +973,7 @@+ <string name="external_display_topology_a11y_display_moved_down" msgid="6028544722984648702">"Display: %1$s moved down"</string>+ <string name="external_display_topology_a11y_display_moved_left" msgid="5308110789317472437">"Display: %1$s moved left"</string>+ <string name="external_display_topology_a11y_display_moved_right" msgid="3802527156765844475">"Display: %1$s moved right"</string>+- <string name="wifi_display_settings_title" msgid="2622548133505158832">"Google Cast"</string>++ <string name="wifi_display_settings_title" msgid="2622548133505158832">"Cast"</string>+ <string name="keywords_wifi_display_settings" msgid="5753883229564422679">"mirror"</string>+ <string name="wifi_display_enable_menu_item" msgid="7391841780777318134">"Enable wireless display"</string>+ <string name="wifi_display_no_devices_found" msgid="7904877793677102805">"No nearby devices were found."</string>+@@ -3775,7 +3775,7 @@+ <string name="keywords_text_cursor_blink_rate" msgid="7682963763334011148">"caret, text caret, text cursor, cursor, blinking, blink interval, blink rate, animation, reduce animation, remove animation"</string>+ <string name="sound_dashboard_summary" msgid="8254699132423665654">"Volume and vibration"</string>+ <string name="media_volume_option_title" msgid="5966569685119475630">"Media volume"</string>+- <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Google Cast volume"</string>++ <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Cast volume"</string>+ <string name="call_volume_option_title" msgid="1461105986437268924">"Call volume"</string>+ <string name="alarm_volume_option_title" msgid="6398641749273697140">"Alarm volume"</string>+ <string name="assistant_volume_option_title" msgid="7206008753384831048">"Assistant volume"</string>+diff --git a/res/values-en-rIN/strings.xml b/res/values-en-rIN/strings.xml+index 28a57a30e88..5ab0ed5d081 100644+--- a/res/values-en-rIN/strings.xml++++ b/res/values-en-rIN/strings.xml+@@ -973,7 +973,7 @@+ <string name="external_display_topology_a11y_display_moved_down" msgid="6028544722984648702">"Display: %1$s moved down"</string>+ <string name="external_display_topology_a11y_display_moved_left" msgid="5308110789317472437">"Display: %1$s moved left"</string>+ <string name="external_display_topology_a11y_display_moved_right" msgid="3802527156765844475">"Display: %1$s moved right"</string>+- <string name="wifi_display_settings_title" msgid="2622548133505158832">"Google Cast"</string>++ <string name="wifi_display_settings_title" msgid="2622548133505158832">"Cast"</string>+ <string name="keywords_wifi_display_settings" msgid="5753883229564422679">"mirror"</string>+ <string name="wifi_display_enable_menu_item" msgid="7391841780777318134">"Enable wireless display"</string>+ <string name="wifi_display_no_devices_found" msgid="7904877793677102805">"No nearby devices were found."</string>+@@ -3775,7 +3775,7 @@+ <string name="keywords_text_cursor_blink_rate" msgid="7682963763334011148">"caret, text caret, text cursor, cursor, blinking, blink interval, blink rate, animation, reduce animation, remove animation"</string>+ <string name="sound_dashboard_summary" msgid="8254699132423665654">"Volume and vibration"</string>+ <string name="media_volume_option_title" msgid="5966569685119475630">"Media volume"</string>+- <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Google Cast volume"</string>++ <string name="remote_media_volume_option_title" msgid="7907330631195715350">"Cast volume"</string>+ <string name="call_volume_option_title" msgid="1461105986437268924">"Call volume"</string>+ <string name="alarm_volume_option_title" msgid="6398641749273697140">"Alarm volume"</string>+ <string name="assistant_volume_option_title" msgid="7206008753384831048">"Assistant volume"</string>+diff --git a/res/values/strings.xml b/res/values/strings.xml+index 55de29a749a..9041d8a83e3 100644+--- a/res/values/strings.xml++++ b/res/values/strings.xml+@@ -2283,7 +2283,7 @@+ <string name="external_display_topology_a11y_display_moved_right">Display: %1$s moved right</string>+ + <!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->+- <string name="wifi_display_settings_title">Google Cast</string>++ <string name="wifi_display_settings_title">Cast</string>+ <!-- Wifi Display settings. The keywords of the setting. [CHAR LIMIT=NONE] -->+ <string name="keywords_wifi_display_settings">mirror</string>+ <!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->+@@ -9040,7 +9040,7 @@+ <string name="media_volume_option_title">Media volume</string>+ + <!-- Sound: Title for the option managing remote media volume. [CHAR LIMIT=30] -->+- <string name="remote_media_volume_option_title">Google Cast volume</string>++ <string name="remote_media_volume_option_title">Cast volume</string>+ + <!-- Sound: Title for the option managing call volume. [CHAR LIMIT=30] -->+ <string name="call_volume_option_title">Call volume</string> diff --git a/res/values/strings_app_exploit_protection.xml b/res/values/strings_app_exploit_protection.xml index 59348a1fc82..42111bf22a0 100644 --- a/res/values/strings_app_exploit_protection.xml
patches/wip/README.md
diff --git a/patches/wip/README.md b/patches/wip/README.mdnew file mode 100644index 0000000..46cc388--- /dev/null+++ b/patches/wip/README.md@@ -0,0 +1,39 @@+# Work-in-progress patches (NOT applied by build-maos.sh)++`apply_maos_patches()` in build-maos.sh iterates an explicit `repo:patchfile` list.+Nothing in this directory is on that list, so nothing here is applied automatically.++## cast-desktop-mode-*.patch++The cast desktop-mode framework work. **These bootloop the device** and are parked here+until the fault is found.++Established by bisection on shiba:++| tree state | result |+|---|---|+| all cast patches applied | bootloop (animation, then reset) |+| SystemUI cast patches reverted only | bootloop |+| SystemUI **and** framework cast patches reverted | **boots** |++So the fault is in the framework half — one of `DisplayManager.java`,+`VirtualDisplayConfig.java`, `DisplayDeviceInfo.java`, `LogicalDisplayMapper.java`,+`VirtualDisplayAdapter.java` — not SystemUI.++Two independent features are mixed together in that patch, and they can be re-applied+separately to narrow it further:++1. **Declared display modes** - `VirtualDisplayConfig.setSupportedModes()` plus+ `VirtualDisplayAdapter`'s `mDeclaredModes` / `modeForLocked()` /+ `setUserPreferredDisplayModeLocked()`. Lets the TV's real resolutions appear in+ Settings. Touches only virtual-display code paths.+2. **Connection-pending displays** - `VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING`,+ `DisplayDeviceInfo.FLAG_CONNECTION_PENDING`, and the `LogicalDisplayMapper` branch+ that starts such displays **disabled**. This is the one that touches+ `createNewLogicalDisplayLocked`, which runs for every display at boot including the+ built-in panel, so it is the stronger suspect.++Ruled out already: flag-bit collisions in all three flag namespaces,+`VirtualDisplayConfig` parcel symmetry (write and read orders match), and the+`virtual_displays_support_desktop_mode` aconfig flag (no aconfig storage file differs+between the booting and bootlooping images).
patches/wip/cast-desktop-mode-framework.patch
diff --git a/patches/wip/cast-desktop-mode-framework.patch b/patches/wip/cast-desktop-mode-framework.patchnew file mode 100755index 0000000..5e44916--- /dev/null+++ b/patches/wip/cast-desktop-mode-framework.patch@@ -0,0 +1,424 @@+diff --git a/core/api/system-current.txt b/core/api/system-current.txt+index a21a30f5b415..38bce179e9fc 100644+--- a/core/api/system-current.txt++++ b/core/api/system-current.txt+@@ -6710,6 +6710,7 @@ package android.hardware.display {+ method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public void setBrightnessConfigurationForDisplay(@NonNull android.hardware.display.BrightnessConfiguration, @NonNull String);+ method @Deprecated @RequiresPermission(android.Manifest.permission.CONTROL_DISPLAY_SATURATION) public void setSaturationLevel(float);+ field @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") public static final int VIRTUAL_DISPLAY_FLAG_ALLOWS_CONTENT_MODE_SWITCH = 131072; // 0x20000++ field @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") public static final int VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING = 262144; // 0x40000+ field public static final int VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT = 128; // 0x80+ field public static final int VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED = 65536; // 0x10000+ field public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1024; // 0x400+@@ -6717,6 +6718,7 @@ package android.hardware.display {+ + public final class VirtualDisplayConfig implements android.os.Parcelable {+ method @Nullable public android.view.DisplayCutout getDisplayCutout();++ method @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") @NonNull public java.util.List<android.view.Display.Mode> getSupportedModes();+ method @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") @Nullable public String getUniqueId();+ method public boolean isHomeSupported();+ method @FlaggedApi("com.android.window.flags.vdm_force_app_universal_resizable_api") public boolean isIgnoreActivitySizeRestrictions();+@@ -6726,6 +6728,7 @@ package android.hardware.display {+ method @NonNull public android.hardware.display.VirtualDisplayConfig.Builder setDisplayCutout(@Nullable android.view.DisplayCutout);+ method @NonNull public android.hardware.display.VirtualDisplayConfig.Builder setHomeSupported(boolean);+ method @FlaggedApi("com.android.window.flags.vdm_force_app_universal_resizable_api") @NonNull public android.hardware.display.VirtualDisplayConfig.Builder setIgnoreActivitySizeRestrictions(boolean);++ method @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") @NonNull @RequiresPermission(android.Manifest.permission.ADD_TRUSTED_DISPLAY) public android.hardware.display.VirtualDisplayConfig.Builder setSupportedModes(@NonNull java.util.List<android.view.Display.Mode>);+ method @FlaggedApi("com.android.server.display.feature.flags.virtual_displays_support_desktop_mode") @NonNull @RequiresPermission(android.Manifest.permission.ADD_TRUSTED_DISPLAY) public android.hardware.display.VirtualDisplayConfig.Builder setUniqueId(@Nullable String);+ }+ +diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java+index ce3cfd9fc85d..f2ad0bf8a278 100644+--- a/core/java/android/hardware/display/DisplayManager.java++++ b/core/java/android/hardware/display/DisplayManager.java+@@ -225,6 +225,7 @@ public final class DisplayManager {+ VIRTUAL_DISPLAY_FLAG_OWN_FOCUS,+ VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED,+ VIRTUAL_DISPLAY_FLAG_ALLOWS_CONTENT_MODE_SWITCH,++ VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING,+ })+ @Retention(RetentionPolicy.SOURCE)+ public @interface VirtualDisplayFlag {}+@@ -556,6 +557,27 @@ public final class DisplayManager {+ @SystemApi+ public static final int VIRTUAL_DISPLAY_FLAG_ALLOWS_CONTENT_MODE_SWITCH = 1 << 17;+ ++ /**++ * Virtual display flag: Create the display in the connected-but-disabled state, rather than++ * enabled and composing immediately.++ *++ * <p>A display created this way is reported as a pending connection, the same state a++ * physical display occupies between being plugged in and the user deciding what to do with++ * it. Nothing is composed to it and no activity is placed on it until++ * {@link #enableConnectedDisplay(int)} is called - which is what lets the system ask whether++ * the display should mirror or extend before anything is shown on it.</p>++ *++ * <p>Note that this flag requires {@link #VIRTUAL_DISPLAY_FLAG_TRUSTED}; a display the system++ * would not place activities on has nothing to ask about, so it is ignored otherwise.</p>++ *++ * @see #createVirtualDisplay++ * @hide++ */++ @FlaggedApi(com.android.server++ .display.feature.flags.Flags.FLAG_VIRTUAL_DISPLAYS_SUPPORT_DESKTOP_MODE)++ @SystemApi++ public static final int VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING = 1 << 18;+++ /** @hide */+ @IntDef(prefix = {"MATCH_CONTENT_FRAMERATE_"}, value = {+ MATCH_CONTENT_FRAMERATE_UNKNOWN,+diff --git a/core/java/android/hardware/display/VirtualDisplayConfig.java b/core/java/android/hardware/display/VirtualDisplayConfig.java+index b6fa05f754ac..182b9cbdced3 100644+--- a/core/java/android/hardware/display/VirtualDisplayConfig.java++++ b/core/java/android/hardware/display/VirtualDisplayConfig.java+@@ -40,6 +40,7 @@ import android.view.DisplayCutout;+ import android.view.Surface;+ + import java.util.Collections;++import java.util.List;+ import java.util.Objects;+ import java.util.Set;+ import java.util.concurrent.Executor;+@@ -70,6 +71,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ private final float mDefaultBrightness;+ private final float mDimBrightness;+ private final IBrightnessListener mBrightnessListener;++ private final List<Display.Mode> mSupportedModes;+ + private VirtualDisplayConfig(+ @NonNull String name,+@@ -88,7 +90,8 @@ public final class VirtualDisplayConfig implements Parcelable {+ boolean ignoreActivitySizeRestrictions,+ @FloatRange(from = 0.0f, to = 1.0f) float defaultBrightness,+ @FloatRange(from = 0.0f, to = 1.0f) float dimBrightness,+- IBrightnessListener brightnessListener) {++ IBrightnessListener brightnessListener,++ @NonNull List<Display.Mode> supportedModes) {+ mName = name;+ mWidth = width;+ mHeight = height;+@@ -106,6 +109,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ mDefaultBrightness = defaultBrightness;+ mDimBrightness = dimBrightness;+ mBrightnessListener = brightnessListener;++ mSupportedModes = supportedModes;+ }+ + /**+@@ -203,6 +207,20 @@ public final class VirtualDisplayConfig implements Parcelable {+ return mBrightnessListener;+ }+ ++ /**++ * Returns the modes this display can be shown at, or an empty list when the owner declared++ * none and the display therefore has only the one it was created with.++ *++ * @hide++ */++ @SystemApi++ @NonNull++ @FlaggedApi(com.android.server.display.feature.flags.Flags++ .FLAG_VIRTUAL_DISPLAYS_SUPPORT_DESKTOP_MODE)++ public List<Display.Mode> getSupportedModes() {++ return mSupportedModes == null ? Collections.emptyList() : mSupportedModes;++ }+++ /**+ * Returns the unique identifier for the display. Shouldn't be displayed to the user.+ * @hide+@@ -299,6 +317,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ dest.writeFloat(mDefaultBrightness);+ dest.writeFloat(mDimBrightness);+ dest.writeStrongBinder(mBrightnessListener != null ? mBrightnessListener.asBinder() : null);++ dest.writeTypedList(mSupportedModes);+ }+ + @Override+@@ -329,7 +348,8 @@ public final class VirtualDisplayConfig implements Parcelable {+ && Objects.equals(mDisplayCutout, that.mDisplayCutout)+ && mDefaultBrightness == that.mDefaultBrightness+ && mDimBrightness == that.mDimBrightness+- && Objects.equals(mBrightnessListener, that.mBrightnessListener);++ && Objects.equals(mBrightnessListener, that.mBrightnessListener)++ && Objects.equals(mSupportedModes, that.mSupportedModes);+ }+ + @Override+@@ -339,7 +359,8 @@ public final class VirtualDisplayConfig implements Parcelable {+ mDisplayIdToMirror, mWindowManagerMirroringEnabled, mDisplayCategories,+ mRequestedRefreshRate, mIsHomeSupported, mDisplayCutout,+ mIgnoreActivitySizeRestrictions, mDefaultBrightness, mDimBrightness,+- mBrightnessListener);++ mBrightnessListener,++ mSupportedModes);+ return hashCode;+ }+ +@@ -363,6 +384,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ + " mIgnoreActivitySizeRestrictions=" + mIgnoreActivitySizeRestrictions+ + " mDefaultBrightness=" + mDefaultBrightness+ + " mDimBrightness=" + mDimBrightness++ + " mSupportedModes=" + mSupportedModes+ + ")";+ }+ +@@ -384,6 +406,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ mDefaultBrightness = in.readFloat();+ mDimBrightness = in.readFloat();+ mBrightnessListener = IBrightnessListener.Stub.asInterface(in.readStrongBinder());++ mSupportedModes = in.createTypedArrayList(Display.Mode.CREATOR);+ }+ + /**+@@ -455,6 +478,7 @@ public final class VirtualDisplayConfig implements Parcelable {+ private float mDefaultBrightness = 0.0f;+ private float mDimBrightness = PowerManager.BRIGHTNESS_INVALID;+ private IBrightnessListener mBrightnessListener = null;++ private List<Display.Mode> mSupportedModes = Collections.emptyList();+ + /**+ * Creates a new Builder.+@@ -530,6 +554,29 @@ public final class VirtualDisplayConfig implements Parcelable {+ return this;+ }+ ++ /**++ * Sets the modes this display can be shown at.++ *++ * <p>A virtual display otherwise advertises only the single mode it was created with,++ * which leaves nothing for the connected-display resolution picker to offer. An owner that++ * knows the real sink - a cast receiver that has been told the television's panel modes,++ * say - can declare them here, and the mode with the most pixels becomes the default.</p>++ *++ * <p>Note: honoured only on a trusted display. The modes must all be positive in both++ * dimensions; anything else is dropped.</p>++ *++ * @hide++ */++ @NonNull++ @SystemApi++ @RequiresPermission(Manifest.permission.ADD_TRUSTED_DISPLAY)++ @FlaggedApi(com.android.server.display.feature.flags.Flags++ .FLAG_VIRTUAL_DISPLAYS_SUPPORT_DESKTOP_MODE)++ public Builder setSupportedModes(@NonNull List<Display.Mode> supportedModes) {++ mSupportedModes = supportedModes;++ return this;++ }+++ /**+ * Sets the id of the display that the virtual display should mirror.+ * @hide+@@ -751,7 +798,8 @@ public final class VirtualDisplayConfig implements Parcelable {+ mIgnoreActivitySizeRestrictions,+ mDefaultBrightness,+ mDimBrightness,+- mBrightnessListener);++ mBrightnessListener,++ mSupportedModes);+ }+ }+ }+diff --git a/services/core/java/com/android/server/display/DisplayDeviceInfo.java b/services/core/java/com/android/server/display/DisplayDeviceInfo.java+index a5eb85f87b80..e3f767d2594a 100644+--- a/services/core/java/com/android/server/display/DisplayDeviceInfo.java++++ b/services/core/java/com/android/server/display/DisplayDeviceInfo.java+@@ -204,6 +204,14 @@ final class DisplayDeviceInfo {+ */+ public static final int FLAG_ALLOWS_CONTENT_MODE_SWITCH = 1 << 20;+ ++ /**++ * Flag: The display should be created in the connected-but-disabled state, so that it is++ * offered as a pending connection rather than composing straight away.++ *++ * @see android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING++ */++ public static final int FLAG_CONNECTION_PENDING = 1 << 21;+++ /**+ * Touch attachment: Display does not receive touch.+ */+@@ -820,6 +828,9 @@ final class DisplayDeviceInfo {+ if ((flags & FLAG_STEAL_TOP_FOCUS_DISABLED) != 0) {+ msg.append(", FLAG_STEAL_TOP_FOCUS_DISABLED");+ }++ if ((flags & FLAG_CONNECTION_PENDING) != 0) {++ msg.append(", FLAG_CONNECTION_PENDING");++ }+ return msg.toString();+ }+ }+diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java+index ad113a2513f3..1b6c0f405ca8 100644+--- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java++++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java+@@ -1433,6 +1433,12 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {+ // the display should be disabled as later we will receive a device state update, which+ // will tell us which internal displays should be enabled and which should be disabled.+ display.setEnabledLocked(false);++ } else if ((device.getDisplayDeviceInfoLocked().flags++ & DisplayDeviceInfo.FLAG_CONNECTION_PENDING) != 0) {++ // The owner asked for this display to arrive as a pending connection rather than++ // composing immediately, so that the system can ask what it should be used for++ // first. It stays disabled until enableConnectedDisplay resolves that.++ display.setEnabledLocked(false);+ }+ + mLogicalDisplays.put(displayId, display);+diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java+index 0d4ae75b428f..55006db8a39b 100644+--- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java++++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java+@@ -20,6 +20,7 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ALLOW+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED;+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD;++import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING;+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL;+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_DEVICE_DISPLAY_GROUP;+ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP;+@@ -69,6 +70,8 @@ import com.android.server.display.feature.flags.Flags;+ import com.android.server.display.utils.DebugTransactionDetails;+ + import java.io.PrintWriter;++import java.util.ArrayList;++import java.util.List;+ import java.util.concurrent.atomic.AtomicInteger;+ + /**+@@ -366,6 +369,15 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ private float mCurrentBrightness;+ private final IBrightnessListener mBrightnessListener;+ private final boolean mHasUniqueId;++ /**++ * Every mode the owner declared, each with its own globally unique id.++ *++ * Built once, because {@code createMode} allocates a fresh id on every call and the++ * picker in Settings selects by id - regenerating them on resize would invalidate the++ * user's choice the moment it was applied. Empty when nothing was declared, which is++ * every caller that is not deliberately driving a real external sink.++ */++ private final List<Display.Mode> mDeclaredModes = new ArrayList<>();+ + public VirtualDisplayDevice(IBinder displayToken, IBinder appToken,+ int ownerUid, String ownerPackageName, Surface surface, int flags,+@@ -386,7 +398,13 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ mDimBrightness = virtualDisplayConfig.getDimBrightness();+ mCurrentBrightness = PowerManager.BRIGHTNESS_INVALID;+ mBrightnessListener = virtualDisplayConfig.getBrightnessListener();+- mMode = createMode(mWidth, mHeight, getRefreshRate());++ for (Display.Mode declared : virtualDisplayConfig.getSupportedModes()) {++ if (declared.getPhysicalWidth() > 0 && declared.getPhysicalHeight() > 0) {++ mDeclaredModes.add(createMode(declared.getPhysicalWidth(),++ declared.getPhysicalHeight(), getRefreshRate()));++ }++ }++ mMode = modeForLocked(mWidth, mHeight);+ mSurface = surface;+ mFlags = flags;+ mCallback = callback;+@@ -580,13 +598,70 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ sendTraversalRequestLocked();+ mWidth = width;+ mHeight = height;+- mMode = createMode(width, height, getRefreshRate());++ mMode = modeForLocked(width, height);+ mDensityDpi = densityDpi;+ mInfo = null;+ mPendingChanges |= PENDING_RESIZE;+ }+ }+ ++ /**++ * The declared mode of this size, or a fresh one when the size was never declared.++ *++ * Keeps ids stable across a resize: a display that was created from a declared list must++ * keep reporting those same ids in {@code supportedModes}, or the current mode stops++ * matching anything in the list Settings is showing.++ */++ private Display.Mode modeForLocked(int width, int height) {++ for (Display.Mode declared : mDeclaredModes) {++ if (declared.getPhysicalWidth() == width++ && declared.getPhysicalHeight() == height) {++ return declared;++ }++ }++ return createMode(width, height, getRefreshRate());++ }++++ @Override++ public boolean setUserPreferredDisplayModeLocked(Display.Mode mode) {++ if (mDeclaredModes.isEmpty()) {++ // Nothing was declared, so there is no list to have chosen from and the base++ // class's "not supported" answer is the honest one.++ return super.setUserPreferredDisplayModeLocked(mode);++ }++ if (mode == null) {++ // Back to the default, which is the largest thing the owner said the sink can do.++ Display.Mode largest = defaultModeLocked();++ resizeLocked(largest.getPhysicalWidth(), largest.getPhysicalHeight(), mDensityDpi);++ return true;++ }++ for (Display.Mode declared : mDeclaredModes) {++ if (declared.getPhysicalWidth() == mode.getPhysicalWidth()++ && declared.getPhysicalHeight() == mode.getPhysicalHeight()) {++ // Density is deliberately left alone. It was chosen for the sink rather than++ // derived from the frame, and rescaling it here would resize every element on++ // screen as a side effect of a resolution change.++ resizeLocked(declared.getPhysicalWidth(), declared.getPhysicalHeight(),++ mDensityDpi);++ return true;++ }++ }++ Slog.w(TAG, "Virtual Display: " + mName + " was asked for an undeclared mode " + mode);++ return false;++ }++++ /** The largest declared mode, which is what a display with a sink should default to. */++ private Display.Mode defaultModeLocked() {++ Display.Mode best = mDeclaredModes.get(0);++ for (Display.Mode candidate : mDeclaredModes) {++ long area = (long) candidate.getPhysicalWidth() * candidate.getPhysicalHeight();++ if (area > (long) best.getPhysicalWidth() * best.getPhysicalHeight()) {++ best = candidate;++ }++ }++ return best;++ }+++ public void stopLocked() {+ Slog.d(TAG, "Virtual Display: stopping device " + mName);+ setSurfaceLocked(null);+@@ -602,6 +677,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ pw.println("mDisplayIdToMirror=" + mDisplayIdToMirror);+ pw.println("mWindowManagerMirroring=" + mIsWindowManagerMirroring);+ pw.println("mRequestedRefreshRate=" + mRequestedRefreshRate);++ pw.println("mDeclaredModes=" + mDeclaredModes);+ }+ + @Override+@@ -614,8 +690,11 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ mInfo.height = mHeight;+ mInfo.modeId = mMode.getModeId();+ mInfo.renderFrameRate = mMode.getRefreshRate();+- mInfo.defaultModeId = mMode.getModeId();+- mInfo.supportedModes = new Display.Mode[] { mMode };++ mInfo.defaultModeId = mDeclaredModes.isEmpty()++ ? mMode.getModeId() : defaultModeLocked().getModeId();++ mInfo.supportedModes = mDeclaredModes.isEmpty()++ ? new Display.Mode[] { mMode }++ : mDeclaredModes.toArray(new Display.Mode[0]);+ mInfo.densityDpi = mDensityDpi;+ mInfo.xDpi = mDensityDpi;+ mInfo.yDpi = mDensityDpi;+@@ -631,6 +710,12 @@ public class VirtualDisplayAdapter extends DisplayAdapter {+ if ((mFlags & VIRTUAL_DISPLAY_FLAG_ALLOWS_CONTENT_MODE_SWITCH) != 0) {+ mInfo.flags |= DisplayDeviceInfo.FLAG_ALLOWS_CONTENT_MODE_SWITCH;+ }++ // Trusted only: a display the system will not place activities on has no++ // mirror-or-extend question to ask, so pending would strand it disabled.++ if ((mFlags & VIRTUAL_DISPLAY_FLAG_CONNECTION_PENDING) != 0++ && (mFlags & VIRTUAL_DISPLAY_FLAG_TRUSTED) != 0) {++ mInfo.flags |= DisplayDeviceInfo.FLAG_CONNECTION_PENDING;++ }+ if (mNeverBlank) {+ mInfo.flags |= DisplayDeviceInfo.FLAG_NEVER_BLANK;+ }
patches/wip/cast-desktop-mode-systemui-displaylib.patch
diff --git a/patches/wip/cast-desktop-mode-systemui-displaylib.patch b/patches/wip/cast-desktop-mode-systemui-displaylib.patchnew file mode 100755index 0000000..8fe9a5d--- /dev/null+++ b/patches/wip/cast-desktop-mode-systemui-displaylib.patch@@ -0,0 +1,46 @@+diff --git a/displaylib/src/com/android/app/displaylib/DisplayRepository.kt b/displaylib/src/com/android/app/displaylib/DisplayRepository.kt+index 4617ca3c..cfc04f16 100644+--- a/displaylib/src/com/android/app/displaylib/DisplayRepository.kt++++ b/displaylib/src/com/android/app/displaylib/DisplayRepository.kt+@@ -361,9 +361,7 @@ constructor(+ connectedDisplayIds+ .map { connectedDisplayIds ->+ traceSection("$TAG#filteringExternalDisplays") {+- connectedDisplayIds+- .filter { id -> getDisplayType(id) == Display.TYPE_EXTERNAL }+- .toSet()++ connectedDisplayIds.filter { id -> isExternallyPresented(id) }.toSet()+ }+ }+ .flowOn(backgroundCoroutineDispatcher)+@@ -372,6 +370,30 @@ constructor(+ private fun getDisplayType(displayId: Int): Int? =+ traceSection("$TAG#getDisplayType") { displayManager.getDisplay(displayId)?.type }+ ++ /**++ * Whether this display is shown to the user on something other than the built-in screen, and++ * so is worth asking about when it connects.++ *++ * [Display.TYPE_EXTERNAL] is the physical case. A virtual display counts when it carries++ * `FLAG_ALLOWS_CONTENT_MODE_SWITCH`, which means its owner is driving a real sink - a cast++ * receiver, say - and the display can genuinely be either a mirror or a second desktop. That++ * is exactly the question the connection dialog exists to ask, and without this it was only++ * ever asked about displays with a cable.++ *++ * Deliberately narrow: an ordinary virtual display, of which there are many and most of them++ * invisible, does not carry that flag and is not offered.++ */++ private fun isExternallyPresented(displayId: Int): Boolean =++ traceSection("$TAG#isExternallyPresented") {++ val display = displayManager.getDisplay(displayId) ?: return@traceSection false++ when (display.type) {++ Display.TYPE_EXTERNAL -> true++ Display.TYPE_VIRTUAL ->++ (display.flags and Display.FLAG_ALLOWS_CONTENT_MODE_SWITCH) != 0++ else -> false++ }++ }+++ private fun getDisplayFromDisplayManager(displayId: Int): Display? =+ traceSection("$TAG#getDisplay") { displayManager.getDisplay(displayId) }+
patches/wip/cast-desktop-mode-systemui-interactor.patch
diff --git a/patches/wip/cast-desktop-mode-systemui-interactor.patch b/patches/wip/cast-desktop-mode-systemui-interactor.patchnew file mode 100755index 0000000..b57f659--- /dev/null+++ b/patches/wip/cast-desktop-mode-systemui-interactor.patch@@ -0,0 +1,21 @@+diff --git a/packages/SystemUI/src/com/android/systemui/display/domain/interactor/ConnectedDisplayInteractor.kt b/packages/SystemUI/src/com/android/systemui/display/domain/interactor/ConnectedDisplayInteractor.kt+index 72f92bd65473..42969f418d96 100644+--- a/packages/SystemUI/src/com/android/systemui/display/domain/interactor/ConnectedDisplayInteractor.kt++++ b/packages/SystemUI/src/com/android/systemui/display/domain/interactor/ConnectedDisplayInteractor.kt+@@ -192,7 +192,15 @@ constructor(+ }+ + private fun isExternalDisplay(display: Display): Boolean {+- return display.type == Display.TYPE_EXTERNAL++ if (display.type == Display.TYPE_EXTERNAL) {++ return true++ }++ // A virtual display that can switch content mode is one an owner created for a real sink++ // it is streaming to, so it is external as far as the user is concerned even though no++ // cable is involved. Matches DisplayRepository.isExternallyPresented and Settings'++ // ConnectedDisplayInjector.isVirtualDisplayAllowed.++ return display.type == Display.TYPE_VIRTUAL &&++ (display.flags and Display.FLAG_ALLOWS_CONTENT_MODE_SWITCH) != 0+ }+ + private fun isSecureDisplay(display: Display): Boolean {
privapp-permissions-modern-apps.xml
diff --git a/privapp-permissions-modern-apps.xml b/privapp-permissions-modern-apps.xmlindex d5e84a8..fd0a508 100644--- a/privapp-permissions-modern-apps.xml+++ b/privapp-permissions-modern-apps.xml@@ -43,4 +43,83 @@ <permission name="android.permission.BACKUP" /> <permission name="android.permission.WRITE_SECURE_SETTINGS" /> </privapp-permissions>+ <!-- Cast is PRIVILEGED: it is a remote display provider, which is what puts its receivers in+ Settings' Cast page. RemoteDisplayProviderWatcher.verifyServiceTrusted only trusts a+ provider whose app holds REMOTE_DISPLAY_PROVIDER (signature|privileged); without it the+ watcher logs and skips the service and the page is simply empty.+ START_ACTIVITIES_FROM_BACKGROUND (signature|privileged|vendorPrivileged|oem|verifier|role)+ is needed because selecting a route ends at the screen-capture consent activity, launched+ from a bound service while Settings is in front. CAPTURE_VIDEO_OUTPUT would avoid the+ consent activity entirely but is signature-only, so it is unreachable for a presigned app.+ The package attribute below must byte-match the installed package+ (cast/build.gradle.kts applicationId). With ro.control_privapp_permissions=enforce a+ mismatch is not a warning - the device does not boot.+ The TV receiver (com.vayunmathur.cast.tv) is deliberately absent: it is not preinstalled. -->+ <privapp-permissions package="com.vayunmathur.cast">+ <permission name="android.permission.REMOTE_DISPLAY_PROVIDER" />+ <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />+ <!-- Desktop-mode audio via MediaRecorder.AudioSource.REMOTE_SUBMIX. The+ projection-scoped capture used by screen mirroring is unavailable on that+ path because it deliberately holds no MediaProjection. -->+ <permission name="android.permission.CAPTURE_AUDIO_OUTPUT"/>+</privapp-permissions>++ <!-- SetupWizard is PRIVILEGED: it is the first-run setup wizard, selected by the platform+ as the HOME activity (MAIN + SETUP_WIZARD + HOME at priority 999) while the device is+ unprovisioned. It sets the system locale, the clock, the time zone and the location+ master switch, reads and clears the OEM-unlock state, disables the status bar for the+ duration, and writes DEVICE_PROVISIONED / user_setup_complete to end setup - all of+ which are signature|privileged. It replaces GrapheneOS's SetupWizard2+ (app.grapheneos.setupwizard); that module and AOSP's fallback Provision are both+ dropped by `overrides` on ModernAppsSetupWizard in Android.bp.++ The package attribute below must byte-match the installed package+ (setupwizard/build.gradle.kts applicationId). With+ ro.control_privapp_permissions=enforce a mismatch is not a warning - the device does+ not boot past setup.++ This is GrapheneOS's etc/permissions/app.grapheneos.setupwizard.xml minus+ com.stevesoltys.seedvault.RESTORE_BACKUP, which is gone with Seedvault.+ SET_TIME / SET_TIME_ZONE ARE PENDING REMOVAL AND MUST NOT BE REMOVED YET. Source+ stopped using them when the manual date-and-time step was replaced by the automatic+ clock (a Settings.Global write, covered by WRITE_SECURE_SETTINGS below, not by+ SET_TIME), and the app manifest no longer requests them - but the STAGED PREBUILT+ still does, and this allowlist is matched against the installed APK, not against+ source. Removing them before the prebuilt is rebuilt is the boot-fatal direction.+ Sequence: rebuild + re-stage the APK, confirm with+ analysis/probe_setupwizard_apk_perms.py, then run+ analysis/setupwizard_drop_time_perms.py.+ ACCESS_WIFI_STATE (normal) and app.seamlessupdate.client.OPEN_SECURITY_PREVIEW_SETTINGS+ (declared by the updater, not the platform) are in the app manifest and correctly not+ allowlisted here, matching upstream. -->+ <privapp-permissions package="com.vayunmathur.setupwizard">+ <permission name="android.permission.CHANGE_CONFIGURATION" />+ <permission name="android.permission.MANAGE_USER_OEM_UNLOCK_STATE" />+ <permission name="android.permission.NETWORK_SETUP_WIZARD" />+ <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE" />+ <permission name="android.permission.READ_OEM_UNLOCK_STATE" />+ <permission name="android.permission.REBOOT" />+ <permission name="android.permission.SET_TIME" />+ <permission name="android.permission.SET_TIME_ZONE" />+ <permission name="android.permission.STATUS_BAR" />+ <permission name="android.permission.WRITE_SECURE_SETTINGS" />+ <permission name="android.permission.WRITE_SETTINGS" />+ </privapp-permissions>++ <privapp-permissions package="com.vayunmathur.logviewer">+ <permission name="android.permission.READ_LOGS"/>+ <permission name="android.permission.READ_LOGS_FULL"/>+ <permission name="android.permission.READ_OEM_UNLOCK_STATE"/>+ <permission name="android.permission.QUERY_USERS"/>+ </privapp-permissions>++ <privapp-permissions package="com.vayunmathur.updater">+ <!-- Reboot into the slot update_engine just wrote. -->+ <permission name="android.permission.REBOOT"/>+ <!-- update_engine stages payload metadata under /cache. -->+ <permission name="android.permission.ACCESS_CACHE_FILESYSTEM"/>+ <!-- Evict cached data to make room for a 1-2 GB package. -->+ <permission name="android.permission.ALLOCATE_AGGRESSIVE"/>+ </privapp-permissions>+ </permissions>
rro/MaosFrameworkResRRO/res/values/config.xml
diff --git a/rro/MaosFrameworkResRRO/res/values/config.xml b/rro/MaosFrameworkResRRO/res/values/config.xmlindex 07149a1..0716968 100644--- a/rro/MaosFrameworkResRRO/res/values/config.xml+++ b/rro/MaosFrameworkResRRO/res/values/config.xml@@ -58,5 +58,35 @@ framework default-transport pin (a "package/service" component); Backup holds the signature|privileged BACKUP permission (allowlisted in privapp-permissions-modern-apps.xml) so the BackupManagerService will bind it. -->- <string name="config_backup_transport" translatable="false">com.vayunmathur.backup/.transport.ConfigurableBackupTransportService</string>+ <string name="config_backup_transport" translatable="false">com.vayunmathur.backup/.service.ConfigurableBackupTransportService</string>++ <!-- Automotive projection role -> Modern Apps Cast.++ This is the ONLY route by which cast can hold ADD_TRUSTED_DISPLAY, which is+ `signature|role`. Privileged placement cannot grant it - that covers+ `signature|privileged` only - and cast is presigned with the com.vayunmathur key, so the+ `signature` half never matches. SYSTEM_AUTOMOTIVE_PROJECTION is the role carrying it+ (roles.xml, minSdkVersion 34). Without this pin `createVirtualDisplay` throws+ SecurityException and cast is stuck on MediaProjection screen capture: a consent prompt+ every session, and no system mirror/extend switch.++ WHAT THIS COSTS, stated plainly because it is not free and must not read as if it were.+ `Role.grantAsUser` (role-controller/.../model/Role.java:945-950) calls+ `Permissions.grantAsUser` over the role's WHOLE permission list, so holding the role+ AUTO-GRANTS cast roughly 25 permissions: the microphone, location, nearby-devices and+ notification sets, plus SEND_SMS, RECEIVE_SMS, READ_CONTACTS, READ_CALL_LOG,+ READ_CALENDAR, CALL_PHONE, READ_PHONE_STATE, CREATE_VIRTUAL_DEVICE,+ RECEIVE_SENSITIVE_NOTIFICATIONS and CAPTURE_SECURE_VIDEO_OUTPUT. Not "made grantable" -+ granted. This was weighed against platform-signing the app and chosen deliberately.++ The role name is not a borrowed one: MA Cast is intended to grow automotive projection+ support, so this is the correct role slightly ahead of the feature.++ exclusive="true", so nothing else in MAOS may hold it. systemOnly="true" is satisfied+ because cast is preinstalled. config_systemAutomotiveProjection ships EMPTY in AOSP, so+ there is no existing holder to displace.++ Precedent: config_defaultSms above works the same way - the SMS role auto-grants its+ SMS/Phone/Contacts runtime permissions. -->+ <string name="config_systemAutomotiveProjection" translatable="false">com.vayunmathur.cast</string> </resources>
scripts/collect-apks.sh
diff --git a/scripts/collect-apks.sh b/scripts/collect-apks.shindex 23b21ac..c5f59e5 100755--- a/scripts/collect-apks.sh+++ b/scripts/collect-apks.sh@@ -21,7 +21,13 @@ SRC="${1:?usage: collect-apks.sh <path to Modern-Apps repo, its distribution_apk DEST="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/prebuilts" mkdir -p "$DEST" -APPS=(web camera pdf contacts calculator clock files photos appstore keyboard speech calendar music communicate euicc backup networklocation)+# The app list is the one in build-maos.sh, parsed rather than duplicated. These two+# arrays drifted apart once already (22 vs 18), and the symptom was a Soong failure about+# a missing prebuilt rather than anything pointing back at this script.+BUILD_MAOS="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/build-maos.sh"+[[ -f "$BUILD_MAOS" ]] || { echo "ERROR: cannot find $BUILD_MAOS to read the app list" >&2; exit 1; }+mapfile -t APPS < <(sed -n 's/^APPS=(\(.*\))$/\1/p' "$BUILD_MAOS" | tr ' ' '\n' | grep -v '^$')+[[ "${#APPS[@]}" -gt 0 ]] || { echo "ERROR: could not parse APPS=(...) from $BUILD_MAOS" >&2; exit 1; } find_apk() { local app="$1"
sysconfig-modern-apps.xml
diff --git a/sysconfig-modern-apps.xml b/sysconfig-modern-apps.xmlindex 6fe2df5..58139e5 100644--- a/sysconfig-modern-apps.xml+++ b/sysconfig-modern-apps.xml@@ -9,9 +9,20 @@ - allow-in-power-save exempt from Doze app-standby (runs during idle windows) - allow-in-data-usage-save exempt from Data Saver background-data restrictions - allow-unthrottled-location exempt from the background location throttle++ Backup (com.vayunmathur.backup) is the system app-data backup transport, replacing Seedvault.+ A transport is only bindable if its service is named here: BackupManagerService reads this+ allowlist through SystemConfig.getBackupTransportWhitelist() and refuses to bind anything+ absent from it, so config_backup_transport alone is not enough to select ours. Mirrors+ Seedvault's own allowlist_com.stevesoltys.seedvault.xml, including the Doze exemption its+ file-backup foreground service needs to start from the background. --> <config> <allow-in-power-save package="com.vayunmathur.networklocation" /> <allow-in-data-usage-save package="com.vayunmathur.networklocation" /> <allow-unthrottled-location package="com.vayunmathur.networklocation" />++ <backup-transport-whitelisted-service+ service="com.vayunmathur.backup/.service.ConfigurableBackupTransportService" />+ <allow-in-power-save package="com.vayunmathur.backup" /> </config>