Find My Phone plugin API refresh
This is an update to the FindMyPhone plugin, attempting to make use of newer APIs to more correctly manage audio playback on newer Android releases. Highlights:
21. (To access more recent APIs w/o lots of legacy fallback. If that's a problem and support for pre-Android 5 devices is still necessary, let me know and I'll look into removing the version bump and adding version gating to the code involving
WAKE_LOCKto permissions requested in manifest file.
AudioAttributesto replace deprecated
- Request & manage audio focus, on Android 26+
- Prevent screen / CPU sleep during playback (using
I'll be honest, I wrote this code working off of API docs and code samples, but I'm not supremely confident that it's all correct. It compiles with no problems, and I built and installed it as an APK on my Android 7 phone, where it worked just the same as the version installed from Google Play. However, running on Android 7 means that most of the newer APIs (including Audio Focus) aren't accessed, and I don't have a newer device to test on. (Trying to run the app in an emulator failed, network-connectivity wise... I ended up with my desktop trying to pair with itself.)
So, I'm submitting this in case it might be useful, at least as a starting point, to help improve Find My Phone's reliability on newer Android (9 / 10) releases. But I would be surprised if it doesn't need at least some cleanup. It certainly needs testing on newer devices, something I'm unable to do myself.