From 320270ae65e35346b7cd5857551f152e2b3c0c4c Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:02:59 +0530 Subject: [PATCH 01/10] fix(branding): adapt lyrics watermark removal to new upstream header layout --- fc/branding/apply.py | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/fc/branding/apply.py b/fc/branding/apply.py index a5b2ee533a6..87e38255aec 100644 --- a/fc/branding/apply.py +++ b/fc/branding/apply.py @@ -39,17 +39,37 @@ def xml_text(value, path): value) def lyrics_card(value, path): - # Remove the ENTIRE watermark block and its bottom gutter, not merely the word. - start, end = " // ── Brand ─", "\n bitmap\n" - if value.count(start) != 1 or value.count(end) != 1: - raise SystemExit("Lyrics card footer changed; refusing unsafe patch") - head, tail = value.split(start, 1) - watermark, rest = tail.split(end, 1) - if "drawLogo(" not in watermark or "canvas.drawText(BRAND" not in watermark: - raise SystemExit("Lyrics card watermark changed; refusing unsafe patch") - value = head + " // No brand, icon or watermark in shared lyrics images.\n" + end + rest - return replace_once(value, "private const val BRAND_BAND = 132f", - "private const val BRAND_BAND = 0f", path) + """Remove the visible logo/watermark; support both reviewed upstream layouts. + + Zenith 2026-11-22 moved the mark from a footer band to the upper-right + header. Do not remove any panel/lyrics/song-drawing code. + """ + marker = " // ── Brand ─" + if value.count(marker) != 1: + raise SystemExit("Lyrics brand section changed; review patch before releasing") + if "private const val BRAND_BAND = 132f" in value: + # Older layout: brand sits below panel and has a dedicated height band. + end = "\n bitmap\n" + if value.count(end) != 1: + raise SystemExit("Legacy lyrics footer layout changed; refusing patch") + head, tail = value.split(marker, 1) + removed, rest = tail.split(end, 1) + if "drawLogo(" not in removed or "canvas.drawText(BRAND" not in removed: + raise SystemExit("Legacy lyrics logo did not match reviewed layout") + value = head + " // No visual watermark on shared lyrics.\\n" + end + rest + return replace_once(value, "private const val BRAND_BAND = 132f", + "private const val BRAND_BAND = 0f", path) + # New layout: brand is a conditional header before the lyrics passage. + end = " // ── The passage ─" + if value.count(end) != 1: + raise SystemExit("New lyrics passage anchor changed; refusing patch") + head, tail = value.split(marker, 1) + removed, rest = tail.split(end, 1) + required = ("if (showLogo)", "drawLogo(canvas, context,", "canvas.drawText(BRAND") + if not all(token in removed for token in required): + raise SystemExit("New lyrics header logo did not match reviewed layout") + return head + " // No visual watermark on shared lyrics.\n" + end + rest + def home(value, path): old = """ Wordmark( From e934cc9395db28f0d051276bda63d51f05a55e90 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:06 +0530 Subject: [PATCH 02/10] fix(spatial): preserve explicit global ON mode across app restarts --- fc/spatial-audio/apply.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fc/spatial-audio/apply.py b/fc/spatial-audio/apply.py index e214362402d..9a693a8b437 100644 --- a/fc/spatial-audio/apply.py +++ b/fc/spatial-audio/apply.py @@ -139,11 +139,7 @@ def copy_asset(name: str, destination: str) -> None: " } else {\n" " SpatialAudioMode.OFF\n" " }\n" - " if (spatialAudioMode.value == SpatialAudioMode.ON) {\n" - " spatialAudioMode.value = SpatialAudioMode.AUTO\n" - " prefs.edit().putString(KEY_SPATIAL_AUDIO_MODE, SpatialAudioMode.AUTO.name).apply()\n" - " }\n" - " spatialAudio.value = spatialAudioMode.value != SpatialAudioMode.OFF\n" + " spatialAudio.value = spatialAudioMode.value != SpatialAudioMode.OFF\n" " spatialAudioByTrack.value = readSpatialAudioByTrack()\n" " spatialAudioRecords.value = readSpatialAudioRecords()\n" " spatialAudioTrackPreferences.value = readSpatialAudioTrackPreferences()\n" From b65c624989bba9f180a76d34e4e3ea558319c350 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:20 +0530 Subject: [PATCH 03/10] feat(audio): explicit force headphone surround software mode in Settings --- fc/spatial-audio/headphone-force/apply.py | 68 +++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 fc/spatial-audio/headphone-force/apply.py diff --git a/fc/spatial-audio/headphone-force/apply.py b/fc/spatial-audio/headphone-force/apply.py new file mode 100644 index 00000000000..488db331797 --- /dev/null +++ b/fc/spatial-audio/headphone-force/apply.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +"""Build-only UI for explicit software headphone surround. + +Not an Atmos decoder or an Atmos entitlement. Uses existing SpatialAudioMode.ON +to bypass Auto learning only; keep device codec, JOC, speaker, bit-perfect and DSP +safety checks in the existing service. +""" +from pathlib import Path +ROOT = Path(__file__).resolve().parents[3] +UI = ROOT / "app/src/main/java/com/music/zenith/ui/screens/SettingsSheet.kt" + +def once(source: str, before: str, after: str) -> str: + matches = source.count(before) + if matches != 1: + raise SystemExit(f"Headphone surround UI changed upstream: expected one anchor, got {matches}") + return source.replace(before, after, 1) + +def patch(value: str) -> str: + # The permanent spatial-audio adapter has already installed this mode. + value = once( + value, + " val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n", + " val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n" + " val headphoneSurroundMode by AppSettings.spatialAudioMode.collectAsStateWithLifecycle()\n", + ) + added = ''' // Software headphone surround: a manual override of Auto learning. + // This is deliberately NOT an attempt to unlock Dolby Atmos decoding. + val forceHeadphoneSurround = headphoneSurroundMode == com.music.zenith.playback.SpatialAudioMode.ON + row("Force headphone surround", "stereo", "headphones", "spatial audio") { + BypassedByBitPerfect(bitPerfectReady) { + SettingsRow( + icon = SfIcons.SurroundSound, + title = "Force headphone surround", + subtitle = "Software stereo widening, not Dolby Atmos. Bypassed on phone speakers, Atmos tracks and incompatible outputs.", + trailing = { + IosSwitch( + checked = forceHeadphoneSurround, + onCheckedChange = { force -> + AppSettings.setSpatialAudioMode( + if (force) com.music.zenith.playback.SpatialAudioMode.ON + else com.music.zenith.playback.SpatialAudioMode.AUTO, + ) + }, + ) + }, + onClick = { + AppSettings.setSpatialAudioMode( + if (forceHeadphoneSurround) com.music.zenith.playback.SpatialAudioMode.AUTO + else com.music.zenith.playback.SpatialAudioMode.ON, + ) + }, + ) + } + } +''' + return once( + value, + " val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n", + added + " val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n", + ) + +if __name__ == "__main__": + if not UI.is_file(): + raise SystemExit("Expected Settings UI missing; refusing unsafe integration") + before = UI.read_text(encoding="utf-8") + after = patch(before) + UI.write_text(after, encoding="utf-8") + print("Headphone surround: optional manual stereo override added; Dolby decoder gate untouched") From ec39ce5bff399874645e9e70164a9d9aea119469 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:36 +0530 Subject: [PATCH 04/10] ci: integrate safe manual headphone spatial control with release gates --- .github/workflows/fc-sync-release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/fc-sync-release.yml b/.github/workflows/fc-sync-release.yml index 6890846c882..ae57218523d 100644 --- a/.github/workflows/fc-sync-release.yml +++ b/.github/workflows/fc-sync-release.yml @@ -304,6 +304,13 @@ jobs: set -euo pipefail python3 fc/spatial-audio/refinement/apply.py echo "enabled=$(sed -n 's/^enabled=//p' fc/spatial-audio/refinement/config.properties)" >> "$GITHUB_OUTPUT" + - name: Enable optional software headphone surround control + if: steps.decision.outputs.should_release == 'true' + run: | + set -euo pipefail + python3 -m py_compile fc/spatial-audio/headphone-force/apply.py + python3 -m unittest discover -s fc/spatial-audio/headphone-force -p 'test_*.py' + python3 fc/spatial-audio/headphone-force/apply.py - name: Fill missing Android locale fallbacks for this build if: steps.decision.outputs.should_release == 'true' run: | From 4134d95f8fdbe729a71647154f4c21f0c0e4c67a Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:38 +0530 Subject: [PATCH 05/10] ci: integrate safe manual headphone spatial control with release gates --- .github/workflows/fc-spatial-quality-verify.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/fc-spatial-quality-verify.yml b/.github/workflows/fc-spatial-quality-verify.yml index 09caed289bb..5d5a5b15b21 100644 --- a/.github/workflows/fc-spatial-quality-verify.yml +++ b/.github/workflows/fc-spatial-quality-verify.yml @@ -8,6 +8,7 @@ on: - 'fc/spatial-audio/apply.py' - 'fc/spatial-audio/source-commit' - 'fc/spatial-audio/refinement/**' + - 'fc/spatial-audio/headphone-force/**' - 'fc/branding/**' - 'canvas-web/public/index.html' - 'canvas-web/public/api/tg-webhook.js' @@ -109,6 +110,9 @@ jobs: python3 fc/spatial-audio/apply.py python3 fc/spatial-audio/experimental/apply.py python3 fc/spatial-audio/refinement/apply.py + python3 -m py_compile fc/spatial-audio/headphone-force/apply.py + python3 -m unittest discover -s fc/spatial-audio/headphone-force -p 'test_*.py' + python3 fc/spatial-audio/headphone-force/apply.py python3 -m py_compile fc/branding/apply.py fc/branding/makeover.py fc/branding/glass_once.py python3 -m unittest discover -s fc/branding -p 'test_*.py' python3 fc/branding/apply.py From 241738d622b4b421ac0754d45b89d01eeaacccf3 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:48 +0530 Subject: [PATCH 06/10] test(audio): verify manual headphone surround remains non-Dolby and fail-closed --- .../headphone-force/test_apply.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 fc/spatial-audio/headphone-force/test_apply.py diff --git a/fc/spatial-audio/headphone-force/test_apply.py b/fc/spatial-audio/headphone-force/test_apply.py new file mode 100644 index 00000000000..cbe666982e2 --- /dev/null +++ b/fc/spatial-audio/headphone-force/test_apply.py @@ -0,0 +1,29 @@ +"""Regression tests for safe, explicitly labeled headphone surround.""" +import importlib.util +import unittest +from pathlib import Path + +spec = importlib.util.spec_from_file_location("headphone_force", Path(__file__).with_name("apply.py")) +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) + +class HeadphoneForceTests(unittest.TestCase): + def test_settings_only_adds_software_mode(self): + sample = ( + " val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n" + " val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n" + ) + altered = module.patch(sample) + self.assertIn("Force headphone surround", altered) + self.assertIn("not Dolby Atmos", altered) + self.assertIn("SpatialAudioMode.ON", altered) + self.assertIn("SpatialAudioMode.AUTO", altered) + self.assertNotIn("DeviceCodecs.forced", altered) + self.assertNotIn("setDolbyAtmos", altered) + + def test_missing_upstream_anchor_aborts(self): + with self.assertRaises(SystemExit): + module.patch("unrecognized layout") + +if __name__ == "__main__": + unittest.main() From a0876324fe90d1c011ee93e88a5a6b42db29a7fe Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:03:55 +0530 Subject: [PATCH 07/10] test(audio): force mode overrides learning but not Atmos, DSP or speaker safety --- fc/spatial-audio/SpatialAudioLearningTest.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fc/spatial-audio/SpatialAudioLearningTest.kt b/fc/spatial-audio/SpatialAudioLearningTest.kt index cedc1823d66..077ef918bea 100644 --- a/fc/spatial-audio/SpatialAudioLearningTest.kt +++ b/fc/spatial-audio/SpatialAudioLearningTest.kt @@ -163,6 +163,23 @@ class SpatialAudioLearningTest { assertEquals(SpatialAudioDecisionReason.DSP_UNAVAILABLE, decide(mode = SpatialAudioMode.ON, dsp = false).reason) } + @Test + fun headphoneForceOverridesAutoLearningButNeverAudioSafety() { + val negative = listOf( + example("one", SpatialAudioFeedback.OFF), + example("two", SpatialAudioFeedback.OFF), + example("three", SpatialAudioFeedback.OFF), + example("four", SpatialAudioFeedback.OFF), + ) + assertFalse(decide(mode = SpatialAudioMode.AUTO, examples = negative).enabled) + val forced = decide(mode = SpatialAudioMode.ON, examples = negative) + assertTrue(forced.enabled) + assertEquals(SpatialAudioDecisionReason.GLOBAL_ON, forced.reason) + assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, speaker = true).enabled) + assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, atmos = true).enabled) + assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, dsp = false).enabled) + } + @Test fun disablingLearningStopsProfilingButKeepsEffectOn() { assertTrue(decide(learning = false).enabled) From e621cbd8601d6f0eb8335eb82b000dacd1745844 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:04:03 +0530 Subject: [PATCH 08/10] chore(release): bump UI revision to publish headphone surround control --- fc/branding/config.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fc/branding/config.properties b/fc/branding/config.properties index bdb88e0daa8..7087c0a03f8 100644 --- a/fc/branding/config.properties +++ b/fc/branding/config.properties @@ -2,7 +2,7 @@ # Keep package name, signing certificate, account/storage IDs and internal APIs unchanged. # Increase brandingRevision whenever visible branding or identity assets change. enabled=true -brandingRevision=3 +brandingRevision=4 # One-release touch-elasticity trial. CI changes this to false after a signed # APK has been verified, before committing release metadata to main. # Future upstream updates will not re-apply the experimental patch. From 531677623df406e9e05617d336c71ed7a28033ea Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:04:15 +0530 Subject: [PATCH 09/10] docs: explain headphone software surround and preserve Dolby capability warnings --- fc/spatial-audio/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fc/spatial-audio/README.md b/fc/spatial-audio/README.md index bd198986cd3..fa289acf770 100644 --- a/fc/spatial-audio/README.md +++ b/fc/spatial-audio/README.md @@ -20,6 +20,11 @@ generated application edits before committing the upstream sync. (“Auto · On” or “Auto · Off”), not as a third toggle. - Phone speaker is blocked by default. Dolby Atmos and unavailable DSP are hard bypasses. Profiles are capped at 400 records and excluded from settings export. +- **Force headphone surround** is an opt-in software stereo mode in Settings. + It sets the persistent global spatial policy to On instead of Auto, overriding + learned Auto decisions only. Disabling it returns to Auto; the overall spatial + switch still provides Off. The option never enables an unsupported E-AC-3/JOC + decoder, Dolby processing, phone speakers by default, or bit-perfect DSP. - Only explicit per-track On/Off choices train the learner. Metadata, likes, scrobbles and playlists are not treated as preference evidence. From a9d8c7e412039b4721b420295931f10c2de17873 Mon Sep 17 00:00:00 2001 From: Batmancpu Date: Sun, 22 Nov 2026 17:04:18 +0530 Subject: [PATCH 10/10] docs: explain headphone software surround and preserve Dolby capability warnings --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6ade9f0b424..56896585a15 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ It inherits a capable music experience from [Zenith](https://github.com/rezapran > [!IMPORTANT] > **Spatial Audio here means stereo soundstage processing**—not Dolby Atmos, object-based surround or personalized HRTF binaural rendering. The experimental limiter checks sample peaks, **not true peaks**. Automated tests establish behavior and numerical safety; they do not prove a subjective sound-quality improvement on every device. +### Headphone surround, even without Dolby hardware + +If your phone lacks an E-AC-3/Atmos decoder, the Dolby Atmos switch may remain unavailable. **Settings → Force headphone surround** gives you the existing *software stereo-widening* engine without requiring Dolby hardware. This bypasses only the spatial learner's Auto decision; it still respects speaker, DSP, actual Atmos-stream and bit-perfect safety gates. It is **not Dolby Atmos**, and does not turn a stereo mix into discrete object-based surround. + ## What makes brrMusic different | Focus | What we've built or configured |