Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background executionmay become unreliable if SD Maid was triggered while being backed up by "Auto Backup" #1274

Open
d4rken opened this issue Jul 5, 2024 · 0 comments
Labels
bug Something isn't working as expected c: Scheduler

Comments

@d4rken
Copy link
Member

d4rken commented Jul 5, 2024

If SD Maid is launched while being backed up through Android's automatic backup tooling, then SD Maid may crash because when being launched while being backed up, the provided context is not our own app context, i.e. subclassed Application class, but a RestrictedContext provided by the system.

There are two issues due to this:

SD Maid will crash, because we are trying to do dependency injection and getting:

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:4780)
  at android.app.ActivityThread.-$$Nest$mhandleReceiver
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2435)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loopOnce (Looper.java:232)
  at android.os.Looper.loop (Looper.java:317)
  at android.app.ActivityThread.main (ActivityThread.java:8699)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:886)
Caused by java.lang.IllegalArgumentException: Hilt BroadcastReceiver must be attached to an @AndroidEntryPoint Application. Found: class android.app.Application
  at dagger.hilt.android.internal.managers.BroadcastReceiverComponentManager.generatedComponent (BroadcastReceiverComponentManager.java)
  at eu.darken.sdmse.scheduler.core.SchedulerRestoreReceiver.onReceive (SchedulerRestoreReceiver.java)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:4771)

and up to Android 13 there was/is a bug that if we crash while being backed up, subsequent app launches still get the restricted context.

Potential solution would be to disable the auto backup and code a custom backup provider, but this is a lot of extra work. According to Google Play this is currently still a quite rare crash so we could also just ignore it 🤔

Also see

@d4rken d4rken added bug Something isn't working as expected c: Scheduler labels Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected c: Scheduler
Projects
None yet
Development

No branches or pull requests

1 participant