KieronQuinn / Smartspacer

Smartspacer is a customisable widget for Android, but with a difference: It can upgrade the built in At a Glance on Pixels - without root!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Smartspacer crashes when Shizuku is unavailable/enhanced mode is off and 'Tap to turn off' (Torch) is clicked

25huizengek1 opened this issue · comments

Description

This is a small inconvenience for when Shizuku is not available for some reason. This theoretically can be seen as a plugin issue, so if I should've reported this in KieronQuinn/SmartspacerPlugins, please let me know. The issue lies in this codebase though, so I think I should be good 😅

Steps to reproduce

  1. Add a torch (reminder) target
  2. Turn on the torch
  3. Navigate to the torch target in Smartspace
  4. Click 'Tap to turn off' in the target
  5. The entire app crashes and the widget restarts

Logs

https://pastebin.com/5WHga8TJ

Possible fix

Normally we wouldn't want this, but it's probably enough if the 'fallback' (workaround?) FlashlightToggleActivity just gets launched (FlashlightReceiver) using the FLAG_ACTIVITY_NEW_TASK Intent flag. That would look something like this:

}.unwrap() ?: run {
    context.startActivity(Intent(context, FlashlightToggleActivity::class.java).apply {
         setFlags(Context.FLAG_ACTIVITY_NEW_TASK)
    })
}

But since I'm not able to test this myself (I can't seem to build without Firebase credentials, for example) I'll leave this to you.

Thank you so much for building such an incredible app, I really appreciate all of your hard work that goes into making this widget.

I mistakenly put ‘complication’ instead of ‘target’, I meant the Torch target, of course.

Fixed in 1.6.4

Excellent bug deduction btw, you were correct in that it needed that flag. I only tested the 'happy path' where the app was already open in the background.