paho.mqtt.android
paho.mqtt.android copied to clipboard
Security Exception in A12
Getting exception: Fatal Exception: java.lang.SecurityException: Caller xxx needs to hold android.permission.SCHEDULE_EXACT_ALARM to set exact alarms.
on line 86 in AlarmPingSender.kt
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextAlarmInMilliseconds, pendingIntent)
Happens on A12 devices only if, Alarms & Reminders permission is turned off. Doc: link
https://github.com/hannesa2/paho.mqtt.android/blob/29ca7ac7503268c8086f8c0a4b3b3dc2f551f133/serviceLibrary/src/main/AndroidManifest.xml#L6
@hannesa2 user can revoke the permission from app settings in Android 12 devices. You'll find "Alarms & reminders" option in App Info.
Please check "Check that your app still has permission" section of this doc.
This is a contribution open source project, and pull request are warmly welcome
Or maybe you give https://github.com/hannesa2/paho.mqtt.android/releases/tag/3.4.0-beta7 a try. It's without this permission and prevent from too much wake up of the device. But needs some more tests
Potential issue fixed with https://github.com/hannesa2/paho.mqtt.android/pull/159. Working fine on local testing, will update if production app stands to expectations.
Please give it a try https://github.com/hannesa2/paho.mqtt.android/releases/tag/3.4.0-beta8
@hannesa2 After adopting this solution, MQTT has been disconnecting every 2 minutes for me. Checking further on what is actually resulting in issue.
@hannesa2 let me know if this makes sense: https://github.com/hannesa2/paho.mqtt.android/pull/293 Meanwhile I am verifying my use-cases, and will update on it.
After adopting this solution, MQTT has been disconnecting every 2 minutes for me
I probably understand why it's disconnecting every 2 minutes. Maybe a simple reconnect is the right solution. What's against this ?
Earlier it was not disconnecting at all even when ideal for >30 minutes. Same behaviour now with handler-looper approach.
Why was it disconnecting? Check starting two lines of PR description: https://github.com/hannesa2/paho.mqtt.android/pull/293
Maybe this will help ? https://github.com/hannesa2/paho.mqtt.android/issues/378#issuecomment-1288913139
Hopefully solved with https://github.com/hannesa2/paho.mqtt.android/releases/tag/4.0 🤞