fix(android): Ringtone/Vibration stopping on auto lock #792
+41
−12
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.
Description
When an incoming call notification was presented in a form of a heads-up notification, if the device auto locked when ringing, the ringtone/vibration stopped even though the fullscreen intent was presented.
Many different solutions were attempted to fix this:
After some other solutions were attempted, here is the final one:
Instead of trying to avoid the auto lock, we decided to keep the ringtone/vibration on when the phone auto locks and presents the fullscreen intent activity. To do this, we had to avoid stopping it during 200ms after the fullscreen intent is presented since the plugin is already stopped by the ACTION_SCREEN_OFF intent. This is a bit hackish but there is unfortunately no way to distinguish between an auto lock and a manual press on the power button of the device.
The only downside of the fix is that if a heads-up notification is presented and the user press on the power button, he will need to press it once again when being presented with the fullscreen intent to stop the ringtone/vibration. Still, the press on the power button when the phone is locked will stop the ringtone/vibration.