Repository navigation
Conversation
A full backup or restore starts the process with a plain Application, so OpenCodeApplication.onCreate never runs and MainActivity's first dependency read threw. MainActivity now ends that process and Android starts it again normally. Reproduced with bmgr backupnow on an API 36 emulator; scripts/check.sh passes. Fixes #343
This branch has not been deployed
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.
Opening OpenCode while Android was backing up or restoring its data crashed the app at start, with
IllegalStateException: AppContext is installed by OpenCodeApplication.onCreate before first use. For a full (Auto Backup) backup or restore, Android starts the process in restricted mode with a plainApplication, soOpenCodeApplication.onCreatenever runs. When the app is opened during that time,MainActivitystarts in that same process and its firstdependency()read throws. Ondevthat read is inTranscriptCachePersistence. The sample stack in #343 comes from an older build and goes throughmigrateBeforeRestore. NowMainActivityends that process when it isn't running underOpenCodeApplication, and Android starts the activity again in a normal process.I reproduced it on an API 36 emulator on
dev: I ranbmgr backupnowwith the local transport and about 22 MB infiles/, then launchedMainActivityas soon as the backup process appeared. Logcat showedStart proc … for backup {android/FullBackupAgent}and then the crash. With the fix, the same steps start the activity in a new process (for top-activity) and the app opens normally. The new Robolectric test fails without the guard and also without thekillProcesscall.scripts/check.shpasses.I didn't test a real restore (a new phone or Smart Switch), but it goes through the same restricted mode. Ending the process cancels that backup or restore. The crash did that too, and Android tries again later. This PR only guards
MainActivity, which is the only entry point in the Play reports. The other exported activities (share, Ask OpenCode, widget configuration, system actions, background call) could hit the same thing and aren't covered here. Nothing visible changes.Fixes #343