Replace per-emulator boolean flags with a shared emulator registry - #100
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the 18 parallel
*Installed/*Enabledbooleans (and the fan-out they forced on every caller) with a singleEmulatorenum that carries everything per-emulator: display name, label, prefs keys, package candidates, and how it gets patched.Net +902 / −2244;
MainViewModeldrops from 3029 to ~2300 lines. Adding an emulator is now one enum entry plus its four string resources.Structure
Emulatordescribes each emulator, with two mutually exclusive patch mechanisms:ConfigOverride— RetroArch, Dolphin, PPSSPP. Patched by rewriting their config files (SAF, or the Shizuku user service). Holds the hardcore/patched prefs keys, SAF-uri loader, hardcore detector, patch/revert functions, and the Shizuku wire key.BroadcastOverride— ARMSX1, ARMSX2, Flycast, WatermelonDS, Mupen64Plus, EmuCoreX. Repointed with a host-override broadcast. Holds the receiver class and string resources.Emulator.SHIZUKU_MANAGED/Emulator.BROADCAST_MANAGEDderive from which override is present, so the two sets can't drift out of sync.EmulatorSupportbecomes a collection (List<EmulatorState>) withisInstalled()/isEnabled()/installedCount/hasAnyEnabled, and is whatMainUiStatenow holds instead of the 18 flags.Deduplication
Armsx1CfgPatcher,Armsx2CfgPatcher,FlycastCfgPatcher,Mupen64CfgPatcher,WatermelonDsCfgPatcher,EmuCoreXCfgPatcher) were identical apart from names, receiver class and string resources. Deleted in favour of one registry-drivenBroadcastCfgPatcher.PatchResult/DolphinPatchResult/PpssppPatchResultwere structurally identical — unified intoConfigPatchResultin the newConfigCfgPatcher.setXEnabledmethods collapse tosetEmulatorEnabled(emulator, enabled).startProxy/stopProxy/recoverPatchedCfgIfProxyStopped/BootReceiver/ProxyServicebecome loops over the registry.HomeFragmentinflates its toggle rows fromEmulator.entries, sodialog_emulator_selector.xmlis an empty container instead of nine hardcoded<include>s.Bug fixes
Four issues surfaced while making the fan-out uniform:
restoreHardcore = falseand never reported the pre-patch state, so hardcore stayed off after stopping the proxy — unlike the SAF path, which persists and restores it. The service now detects hardcore before patching, returns it, and the app persists it in the existing*_HARDCORE_WAS_ENABLEDprefs and passes it back on revert.BootReceiverandProxyServiceonly handled ARMSX2 among the six broadcast emulators, so Flycast/Mupen64Plus/EmuCoreX/ARMSX1/WatermelonDS stayed pointed at a dead proxy after a reboot-autostart or a service kill. Both now loop over all of them.patchRetroArchAndPersistlacked the!skippedNotInstalledguard its Dolphin/PPSSPP counterparts had, soretroarch_patched_this_runwas set totrueeven with RetroArch disabled.org.ppsspp.ppsspp, so Gold could overwrite the patched ini on exit. Force-stop is now driven bypackageCandidates.Verification
Debug + release compile,
testDebugUnitTestgreen, including four new cases covering the hardcore round trip (restoreHardcore = truehad no coverage at all before) and the uniqueness of the Shizuku wire keys.On-device:
Not yet exercised at runtime: the non-Shizuku SAF patch/revert path,
BootReceiveron a real reboot, a broadcast emulator confirming receipt of the override, and the PPSSPP Gold force-stop.