Sunday, April 9, 2017

Android O is Breaking Apps that Overlay on top of the Status Bar

The trickle of posts outlining new user-facing features found in Android O is starting to slow down now that users have had weeks to test the software on their device. However, there are many, many changes made under-the-hood that are slowly being uncovered. We posted about one such change just the other day about Nexus and Pixel devices running Android O adopting SDCardFS. But today, we would like to discuss a change that will affect developers of certain apps, particularly those that overlay on top of the status bar. These applications seem to be broken in the Android O Developer Preview, which at first glance you might dismiss as a simple bug, but diving deeper into the reference documentation, this may be an intended change by Google.


Android O Breaks Status Bar Overlays

One of my favorite things about Android is how customizable it is. Users who are rooted or running custom ROMs can theme their system status bars natively with basically no restrictions, but if your device is unrooted you have fewer options available to you. Luckily, there are many applications on the Google Play Store that allow you to change how the status bar looks on a basic level. This is possible thanks to a clever combination of System Overlay Windows to display a custom status bar over the existing one, Notification Listeners to display notifications, and optionally an Accessibility Service to allow for contextually tinting the custom status bar.

The two screenshots above show what my notification bar would look like when using one of the many status bar overlay apps available on the Play Store. These screenshots were taken on an unrooted Huawei Mate 9 running EMUI 5.0. For those of you who aren’t familiar with EMUI, the status bar looks nothing like the above screenshots. Instead, it looks like this:

If you don’t mind the way your stock status bar looks, then apps such as Status or Material Status Bar are godsends. But if, or when your device updates to Android O, these applications may no longer work. Here’s what these same two apps look like on a Google Pixel running the Android O Developer Preview:

Rather than the overlay blocking the original status bar, it looks like the overlay overlaps with the original status bar which results in a huge mess.

Unfortunately, this effectively renders apps such as these useless. And it’s not just your typical status bar theming applications that are affected by this – all apps that require an overlay to be shown on top of the status bar are affected.

Here is a list of some popular apps that may be rendered useless:

And a list of some apps that will work, but can no longer overlay on top of the status bar (restricting previous functionality):

There are many more apps on the Play Store that use some sort of overlay on top of the status bar, but you can already tell that such a change will affect many apps that are used by potentially millions of users. So what’s going on here?


TYPE_SYSTEM_OVERLAY is being Deprecated

With each new iteration of Android, Google both introduces and deprecates (designates as obsolete and to be removed) various features. This time, the feature that is on the chopping block is TYPE_SYSTEM_OVERLAY. To quote the reference page for what this feature offered developers:

TYPE_SYSTEM_OVERLAY

Window type: system overlay windows, which need to be displayed on top of everything else. These windows must not take input focus, or they will interfere with the keyguard. In multiuser systems shows only on the owning user’s window.

In essence, this window type allows an app to draw on top of any element on the screen – including the status bar. However, starting with Android O, this window type has been deprecated. For non-system apps, Google recommends that developers use TYPE_APPLICATION_OVERLAY instead. To quote the reference page for what this new window type does:

TYPE_APPLICATION_OVERLAY

Window type: Application overlay windows are displayed above all activity windows (types between FIRST_APPLICATION_WINDOW and LAST_APPLICATION_WINDOW) but below critical system windows like the status bar or IME.

The system may change the position, size, or visibility of these windows at anytime to reduce visual clutter to the user and also manage resources.

Requires SYSTEM_ALERT_WINDOW permission.

The system will adjust the importance of processes with this window type to reduce the chance of the low-memory-killer killing them.

In multi-user systems shows only on the owning user’s screen.

As you can see, this new window type allows apps to overlay content on top of all other activity windows except “critical system windows like the status bar or IME” (IME refers to the keyboard). This is fine for apps like Facebook Messenger, as the chatheads provided by that app have no purpose sitting on top of the status bar, but this negatively affects most of the apps I mentioned earlier.

Furthermore, there doesn’t appear to be a workaround for developers to use, at this time. One might expect that, in order to avoid this issue on Android O, developers simply build their apps to target SDK 25 (Android 7.1.1). However, as pointed out by the developer of Status on Reddit, Google has replaced TYPE_SYSTEM_OVERLAY with TYPE_APPLICATION_OVERLAY, and the change is independent of the target SDK version. Developers using TYPE_SYSTEM_OVERLAY currently have to use TYPE_APPLICATION_OVERLAY to maintain compatibility, hence, no matter what target SDK version a particular app is based on, it can no longer use TYPE_SYSTEM_OVERLAY on Android O.


What can be done about this?

It’s not exactly clear why Google has made this change, as they haven’t yet provided an official explanation. My guess is it’s an attempt at improving security on Android by preventing unsuspecting users from accidentally installing apps that maliciously block or replace their status bar. Unfortunately, this change catches many perfectly legitimate applications that use TYPE_SYSTEM_OVERLAY in the crossfire.

Developers that utilize this feature have opened bug reports on Android’s Issue Tracker (#260787 and #36574245) to protest the change and ask for an alternative API, but a Googler commented on the tracker with the following statement:

Status: Won’t Fix (Intended Behavior)

We have followed up with the product and engineering team and got suggestion that developers can use SHOW_WHEN_LOCKED activities to show when the device is locked, but it is intentionally no longer possible to show over the lockscreen / over the notification shade

For now, it appears that these developers are out of luck, as developers have pointed out that FLAG_SHOW_WHEN_LOCKED still doesn’t allow windows to be overlaid on top of the status bar. It’s not clear what developers of these apps can do except pray for Google to change things, or raise hell about it.

Since this is just the first Developer Preview for Android O, it’s still possible for Google to change their minds and provide this functionality for apps that don’t target Android O, or for Google to restore TYPE_SYSTEM_OVERLAY. But if things remain the way they are currently, you can kiss these apps goodbye. And that would be a damn shame.


Thanks to Eli Irvin for testing many of these apps for me!

HostGator Web Hosting

0 comments:

Post a Comment