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

Prevent crash on alarms going off with a different user active #886

Merged
merged 1 commit into from
May 29, 2019

Conversation

davidgyoung
Copy link
Member

This attempts to fix #876, which reports a SecurityException crash when a library Alarm goes off after somebody switched users on the phone. The fix is to detect the user switch and cancel the alarm.

Testing this on the Google Pixel 3a, I start the reference app (with a foreground service enabled), then switch to the Guest User. I see that the logs show the alarm gets cancelled:

05-29 13:44:14.588  3760  3760 W CycledLeScanner: User switch detected.  Cancelling alarm to prevent potential crash.
05-29 13:44:14.588  3760  3760 D CycledLeScanner: cancel wakeup alarm: PendingIntent{b0fb482: android.os.BinderProxy@d3ba793}
05-29 13:44:14.600  3760  3760 D CycledLeScanner: Set a wakeup alarm to go off in 9223372035236175056 ms: PendingIntent{b0fb482: android.os.BinderProxy@d3ba793}

As a side note, this test showed some fascinating things about how the library behaves after user switching, at lest on a Pixel 3a with Android 9.0 and the library running with a foreground service:

  1. The library keeps running after the user switch, and I see logs coming from the foreground service started by an app from the primary user.
  2. Bluetooth is switched off automatically after the user switch happens (I guess this is the Pixel 3a default behavior?) so beacon detections stop.
  3. When switching back to the primary user, bluetooth comes back on like before, and detections resume as if nothing happened.

Maybe the above is expected behavior, but I was shocked to see that all work! I figured I'd note it for the record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CycledLeScanner crashes on setWakeUpAlarm
1 participant