Commit 133d60a
fix(settings): initialise the default-installer flow before init reads it
Opening Settings on an emulator killed the process:
FATAL EXCEPTION: DefaultDispatcher-worker-1
java.lang.NullPointerException: Attempt to invoke interface method
'void kotlinx.coroutines.flow.MutableStateFlow.setValue(java.lang.Object)'
on a null object reference
at SettingViewModel$updateDefaultInstallerStatus$1.invokeSuspend(SettingViewModel.kt:927)
_isDefaultInstaller was declared 480 lines below the init block that starts
the coroutine assigning it. Property initialisers run in declaration order,
so until the constructor reached line 850 the field was genuinely null, and
whichever of the two got there first decided whether the app lived.
Physical devices hid it: resolveActivity is an IPC, slow enough that the
constructor always finished first. An emulator answers fast enough to lose
the race — which is why this only ever showed up there.
Moved next to _shizukuState and _rootState, the other state init touches, with
a note about the ordering so it does not drift back down.
Swept the rest of the app for the same shape: one other flow is declared after
its init block (_selectedLanguage), but init never reaches it.
Verified on the emulator: Settings opens, process survives, zero uncaught
exceptions in logcat.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ebacf39 commit 133d60a
1 file changed
Lines changed: 12 additions & 2 deletions
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
336 | 348 | | |
337 | 349 | | |
338 | 350 | | |
| |||
847 | 859 | | |
848 | 860 | | |
849 | 861 | | |
850 | | - | |
851 | | - | |
852 | 862 | | |
853 | 863 | | |
854 | 864 | | |
| |||
0 commit comments