Changes for Android 6 - Marshmallow

Android 6.0 has brought some pretty major changes to android which affect Light Flow. Some are positive changes whereas others may limit features users are accustomed to.

Here are some of the benefits:

App permission control
  • The app now doesn't grant lots of permissions at startup. Permissions are requested for the user to select when they want to use a specific feature. For example, contact access if using contact specific notifications. This is great for letting the user control what the app has access to.
Better support for camera flash
  • Camera flash should work across all Android 6.0 phones are Google added standard access to the camera flash whereas previously every phone was different and many undocumented.
Automatic backup of app settings
  • The app settings should now get automatically backed up and restored if reinstalling
* Note the above new features are available in Light Flow version 3.60.0 upwards


And here's a few changes in how things work that may limit functionality:


Doze mode
Android 6.0 has a new feature to help improve phone battery usage called Doze mode. It's a system wide feature that places many parts of android into a sleeping state to help preserve the battery. When in this mode apps don't run and their operations will be limited.

During this time there's only really two things that are guaranteed ways to make apps work:
  • Alarm apps where a user alarm is set will wake a few minutes before the alarm time
  • Apps which send messages via Google Cloud Messenger as high priority will wake the phone for a few seconds to place up notifications.
Because of these limitations, during this period Light Flow can't run code that'll cycle the led or perform repeating notification sounds and vibrations. Using Google Cloud messenger wouldn't be practical for the purpose of Light Flow as every few seconds the phone would need to be getting data from servers which would do exactly the opposite of what Doze mode is intended for. 

Your phone will typically enter doze mode if the following criteria are met:
  • not plugged in (ie it's running on battery)
  • has not been switched on for an hour
  • has not moved recently.
This does mean that if you leave your phone on your desk all day not on charge after approx 1 hour the led cycling may stop.

If you have your phone in your pocket and get it out the sensors will detect the movement and also bring the phone out of doze mode.

Although android has a new battery optimization option for apps in the phone settings these settings don't change the behavior of doze mode so the above limitations are not possible to change with any system settings.

Persistent notifications
Previous versions of Light Flow have targeted an omission in Android's API which allowed a notification to get created to control the LED without a notification. Since android 4.3 in the system logs there's been warnings that future versions of Android will cause apps to crash using this method.

Android 6 preview 1 and 2 had this warning, but Preview 3 and the official release changed to crashing apps.

Therefore light flow now needs a persistent notification (but only when the notification bar is pulled down). Without it the app would crash (using the previous method) or loose control of the notification led when other app tried to control it and wouldn't be able to regain control.

In versions of Light Flow prior to version 3.60.0 even in Android 6 you wouldn't need this notification. This is because the when creating an app you select a "target" version of Android. Versions prior to 3.60.0 targeted android 5.1, version 3.60.0 upwards target android 6. Android won't crash apps targeting older versions to try and keep apps from crashing.

The app has to target android 6 to use new great features like permission controls, auto backup and any new feature that'll come in future versions of android.

I've raised a feature request with Google to improve LED control in future versions. It can be "starred" here https://code.google.com/p/android/issues/detail?id=190997

One advantage of having the persistent notification is that it can be combined with having the app run in the foreground which means it's less likely to miss notifications and be less effected by side effects of doze mode and battery optimizations.

Sounds not playing or cut short if you have the switch screen on option enabled
If in Light Flow for an notification you set a "volume control method" of "android standard" then the sound will only play if you have the screen switched off. That's because previously light flow could create a notification and set a sound without an additional icon in the notification bar. As this isn't possible now (it's required for notifications to play sounds, similar to the priority of showing the LED as described above) then it's not possible to do cleanly.

Using a volume control method of "Light flow controlled notification volume" should fix this.

Vibrations not triggering when the screen is on
In light flow->settings->labs, there's a "Notification vibration" option. If this is on and the screen is on then the vibration may not play due to the same reasons as the sound not playing described above.

Having this option switched off in Android 6 is recommended.


 
Copyright Reactle Ltd