MM2-0 / Kvaesitso

A search-focused Android launcher
https://kvaesitso.mm20.de/
GNU General Public License v3.0
2.33k stars 70 forks source link

Alarm widget under the clock randomly showing up #172

Open Lock-The-Door opened 1 year ago

Lock-The-Door commented 1 year ago

For some reason the next alarm widget keeps showing up under the clock even though my alarm is not within the next 15 minutes.

Lock-The-Door commented 1 year ago

It appears to have some correlation with plugging in my phone, (it switches from the charging widget to the alarm widget after a few seconds)

MM2-0 commented 1 year ago

Some calendar apps interfere with the alarm widget; calendar events/tasks/reminders sometimes appear as alarms. It's a known issue but I haven't found the time yet to investigate why this is happening and how to prevent this.

Lock-The-Door commented 1 year ago

After some digging, the AlarmManager class seems to be used by applications to schedule tasks. It appears that the only way to get a user's clocks is by querying the clock app's api which will unfortunately vary between users. https://stackoverflow.com/a/3147407

MM2-0 commented 1 year ago

I suspected something like that. Thanks, I'll look into that.

which will unfortunately vary between users

If it works on AOSP / LineageOS / Pixel Android, it's good enough for me.

tzugen commented 1 year ago

Yes, there are actually different APIs that apps should use to schedule Tasks (like WorkManager API). The AlarmManager API should only be used by apps actually using alarms.

I would say that this is not a bug of Kvaesito. Maybe somehow it could be made to try to query the stock Clock app for alarms, but then any other alarms, like from any non-stock alarm app would not show up anymore.

I would rather suggest to @Lock-The-Door to raise a bug with the app that misuses this API.

Lock-The-Door commented 1 year ago

The AlarmManager API should only be used by apps actually using alarms.

I would say that this is not a bug of Kvaesito. Maybe somehow it could be made to try to query the stock Clock app for alarms, but then any other alarms, like from any non-stock alarm app would not show up anymore.

While I agree that not every app should be using the AlarmManager, apps that require users to be notified at a precise time such as reminders or calander events are still supposed to use the AlarmManager API. Also, using this API is a common workaround to prevent aggressive systems from killing their app.

I would rather suggest to @Lock-The-Door to raise a bug with the app that misuses this API.

Even if there was no reason to use this API for non-alarm functions, it would be impractical and impossible to ask a large number of other developers, including Google and Samsung, to only use the API for its intended purpose.

Also I found out that a few apps like Home Assistant uses another method to fetch alarms by somehow filtering which app to listen to for alarms.

MM2-0 commented 1 year ago

Google Calendar schedules event notification without it showing up in the calendar widget. Don't know how they do it but there seems to be a way.

What I wonder is, do these false alarms appear in the status bar @Lock-The-Door ?

Afaik, only alarms scheduled using AlarmManager.setAlarmClock should appear in the clock widget but using that method would also make the system show the alarm indicator in the status bar so something isn't right.

Lock-The-Door commented 1 year ago

What I wonder is, do these false alarms appear in the status bar @Lock-The-Door ?

No they do not

Elaborendum commented 2 months ago

In my case I have the Tuta(nota) app installed, I'm pretty sure it uses scheduled tasks to get notifications since it doesn't uses Google's notification services.

JetpackJackson commented 1 month ago

I noticed the other day that a reminder I scheduled on the Google Calendar appeared in the clock area, I guess their reminder system uses that API.