Saturday, February 23, 2019

Working on A2DP Connect2

I finally got around to dusting off the aging A2DP Connect2 widget and getting it updated to work on newer devices better.  I have not yet pushed an update to the Play Store but I am putting signed APKs as I progress here.  I also have the Github page for it here.  I have it compiled for API 19 through the current API 28 (Pie).  I cannot test it in emulators though so I have only tested on Android 7 and Android 8 right now.

The most requested issue, which is posted on the issues list, is to have an indication of the connection state.  I have that somewhat working.  I say somewhat since there is not an interface to get this.  In Android you are supposed to use a background process to listen for Bluetooth connection changes.  These are called Broadcast receivers.  You register your receiver with filters to call back to your service when the connection changes.  In the response, it will tell you details such as profiles that connected and of course the current connection state.  This is how A2DP Volume does it.  There is another back door approach that involves using reflection to access methods that are not exposed.  To do that you must bind to a service that accesses an IADL.  A2DP Volume and A2DP Connect2 use this to make the connect/disconnect happen.  It's tricky and undocumented, and risky as they can change Android and break this with no warning. This happened back when Jelly Bean came out and the Bluetooth stack was replaced.  I have made several attempts at using this method to get connection state but there are incompatibilities between widgets and binding services that I have not yet been successful. 

Update: After hours of trying and failing, it finally seems to work.  Opt in to the beta testers to get the test apk: https://play.google.com/apps/testing/a2dp.connect2Let me know your feedback.

Update 3/9/2019: In order to make the icon change based on connection state, I needed to have a foreground service running which means having a notification icon active.  I thought that was too much for a simple widget.  So, I added a simple call from A2DP Volume (which already has the service running) to run an update service in A2DP Connect2 and update the icon when the state of the Bluetooth connection changes.  This will be in version 2.12.12.5 of A2DP Volume. 

Friday, February 8, 2019

Recent updates to A2DP Volume

I have been busy this winter finally getting around to fixing a bunch of broken stuff on A2DP Volume and making changes required to comply with Play Store policy changes.  You can see the log of updates on Github.  Here are some highlights:


  • Removed a bunch of really old and unusable Pandora integration.
  • Fixed the custom intent maker to actually work
  • Fixed many issues around registering and unregistering broadcast receivers.  This was the root cause of the notification reader reading messages twice.  I also added a simple check to prevent the same message from being read twice.
  • Fixed the media playback when using voice call stream.  It works on Spotify now but not necessarily all players.  
  • Updated the minimum SDK (Android version) to 23 (or Android 6.0) and the target SDK to 28 (Android 9.0).  This is far more work than it sounds as this requires many things to be re-implemented as older methods are deprecated.  Play Store now requires the target SDK be 26 or higher.
  • Many additional robustness improvements.
  • Added many log file entries so people can use LogCat and see what is going on.
  • Removed the SMS reader to comply with new Play Store policy.  Now you have to use the notification reader to read SMS messages.  This also removed a bunch of permissions including not just SMS but also contacts access.  
  • Added a shortcut from the preferences menu to set up your notifications and removed the internal app preferences for notifications.  Basically Android now gives the user much more control over notifications so now you just use the configurations in Android for this.  I added a wiki about this here.
  • I removed the ability for A2DP Volume to set the media volume in Android 9 and up since Android 9 already has this built in to the OS.  However, I got bad reviews and complaints about removing it so I added it back but made the default to not set media volume.  It really is no longer needed and it may actually fight with the OS if you use it but I guess folks will need to learn that themselves.  It is interesting that it took until Android 9 to finally implement this, making the feature this app was named for obsolete. Now I really should change the name.
  • I made many improvements to the way the media volume before a device connects is captured.  This ensures that an adjusted media volume is not captured instead.  
  • I added an additional check to open the notification access permissions settings in Android so users can enable A2DP Volume notification access to make it work.  This was not very obvious and nobody seems to read the manuals so I hope this helps.  Many bad reviews claiming the reader did not work.