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

Rest Timer does not vibrate when complete #145

Closed
sdriv3r opened this issue Jul 4, 2020 · 5 comments · Fixed by #163
Closed

Rest Timer does not vibrate when complete #145

sdriv3r opened this issue Jul 4, 2020 · 5 comments · Fixed by #163
Assignees
Labels

Comments

@sdriv3r
Copy link
Contributor

sdriv3r commented Jul 4, 2020

Describe your issue
I have the rest timer turned on for my programs. One thing I have noticed on my phone is that when the countdown reaches 0, it does not vibrate my phone. This only happens when my screen is off. If I leave my screen on, the vibration does work.

I am only reproducing this on my phone (Samsung Galaxy S9+, latest updates). I tried on my tablet (Samsung Tab A 8) and it works fine there, with the screen off or on.

To Reproduce
Steps to reproduce the behavior:

  1. Create a program and add exercises that use the rest timer.
  2. Go to "Workout" and start a program.
  3. Press the checkmark to finish a set and pop the rest timer up.
  4. Turn off screen and wait to see if it vibrates.

Expected behavior
At the end of the countdown, phone should always vibrate.

Smartphone (please complete the following information):

  • Device: Samsung Galaxy s9+
  • OS: Android 10

Additional context
As stated above, only reproduces on my phone and not my tablet. Did not look into why that is the case yet.

@brodeurlv
Copy link
Owner

Yes, there is a weird behavior with the vibration and I realized that this is not always reproductible. On my phone, sometimes is works, sometimes it doesn't. I haven't investigated that much anyway but if you find something, let me know.
Thanks.

@sdriv3r
Copy link
Contributor Author

sdriv3r commented Jul 6, 2020

Hey @brodeurlv,

I looked into this quickly but I'm having issues debugging on my phone (I have the playstore version installed on there and I don't feel like wiping my data to use from AndroidStudio) but I did find something that might be the reason that it works only sometimes. In CountdownDialogbox.java, in the registerAlarm method line 78, we use "set" for the alarmManager. Per android docs:
"Beginning in API 19, the trigger time passed to this method is treated as inexact: the alarm will not be delivered before this time, but may be deferred and delivered some time later..."

Reason I think this might be the problem is because I noticed on my phone that sometimes it vibrates when it's supposed to and gives me 3 zaps(restTime -2), sometimes its late and only gives me a single zap, and sometimes it doesn't happen.

It looks like the better method to use on alarmManager would be setExact: https://developer.android.com/reference/android/app/AlarmManager#setExact(int,%20long,%20android.app.PendingIntent)

Are you set up and have the time to verify this?

@brodeurlv
Copy link
Owner

Hi @sdriv3r , I gave it a try but I'm not sure it is changing anything.
One of the test I do is that I launch a countdown, then I turn off my screen and I wait, and nothing happens. It is supposed to Wakeup as I use ELAPSED_REALTIME_WAKEUP, but it doesn't work. I wonder if it is not due to the fact that it is launched from a dialog.
It will need deeper investigation.

@brodeurlv
Copy link
Owner

Hi @sdriv3r ,

I have the playstore version installed on there and I don't feel like wiping my data to use from AndroidStudio

FYI, with the recent commit from @ironjan , you can have a debug and a release app on the same device. So you should be able to debug this issue more easily on your device.
Cheers

@sdriv3r
Copy link
Contributor Author

sdriv3r commented Jul 19, 2020

Hi @brodeurlv ,
Problem is when the vibrate gets called in the AlarmReceiver class. I added a "AudioAttribute" to the vibrate and I am able to get it vibrating every time. Both "USAGE_ALARM" and "USAGE_NOTIFICATION" seem to do the job. Reading the doc i'm not sure which one is more appropriate...
https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ALARM

I kind of feel like Notification is a better choice and that Alarm seems a little too "aggressive", but the effect seems the same for our usage.

Will submit a pull request in a little bit.

Cheers

sdriv3r added a commit to sdriv3r/fastnfitness that referenced this issue Jul 19, 2020
Added an AudioAttribute with "USAGE_NOTIFICATION" to the vibration. It now seems to vibrate always, even with the screen off.
brodeurlv added a commit that referenced this issue Jul 25, 2020
@brodeurlv brodeurlv added the bug label Jul 25, 2020
@brodeurlv brodeurlv linked a pull request Jul 25, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants