Oreo (API 26) - drawOverlay + draw over status bar
Asked Answered
S

3

16

In android oreo, I can't use WindowManager.LayoutParams.TYPE_SYSTEM_ERROR anymore and must use WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY instead. The drawback is, that this mode does not draw over the statusbar.

Is there anyway to achieve the old behaviour and be able to draw over the statusbar as well? I've a sidebar app and until now, I allowed the user to have trigger areas on top of the screen as well, which does not work anymore now, because the status bar is overlapping the touchable region on top now...

I'm interested in ANY solution, even if it's only for some devices, like rooted devices for example... As I think there is not normal solution for this problem because the android system does not allow this anymore as stated in the docs (https://developer.android.com/about/versions/oreo/android-8.0-changes.html#o-apps). Still, this does not necessary mean that there is no alternative solution...

Stocktonontees answered 1/9, 2017 at 7:33 Comment(0)
T
1

The docs says that the flag is deprecated for non-system apps. Have you tried making the app a system app?

This constant was deprecated in API level 26. for non-system apps.

Here is how with ES File Explorer:

Configure ES File Explorer by doing the following steps:
    Launch ES File Explorer.
    Select Menu and choose Settings.
    Under Settings, enable the options for Up to root and Root Explorer. A message will appear, requiring you to confirm your action. You will also need to confirm Superuser access.
    Enable Mount File System.
    Go back to the app’s main menu.
Get a copy of the APK (Android Package) of the app that you want to save as a system file by doing the following steps (skip to step 3 if you already have the app’s APK file):
    Install an app from the Google Play Store. For this guide, we will be using the app BioRhythms as an example.
    Launch ES File Explorer and navigate to /data/app.
    Locate the APK file that you want to install as a system app. If you don’t know the APK’s filename, simply go to the Google Play Store link of your chosen app. View the link and take note of the words after “?id=”. This will be your APK’s filename. For instance, the BioRhythms app link is https://play.google.com/store/apps/details?id=app.biorhythms. The BioRhythms’ APK is app.biorhythms-1.apk.
Create a backup of the chosen APK by copying it to the phone’s SD Card.
After creating a backup, long tap on the APK file and a menu will appear. Choose Cut. A blue arrow will appear at the bottom of the screen.
Go back to the main menu and navigate to /system/app/.
Drag the little arrow at the bottom of the screen. It will bring up the icon of the APK file.
Tap the APK file and it will be transferred to /system/app/.
Find the APK file in /system/app/. Press and hold it and a menu will appear.
Select Properties on the menu. The dialog properties will show up.
Tap Change and it will show the permissions dialog box.
Check the boxes for the following permissions in the dialog box:
    User: Read and Write
    Group: Read
    Other: Read
Select OK once the required settings have been made.
Reboot your device.
Throng answered 31/10, 2017 at 0:29 Comment(5)
This would require root permissions as /system/app is protected. (as well as mount -o remount, rw[...]) Furthermore I am not convinced Google identifies a system app by file location. Otherwise Samsung / HTC etc would be able to use this as well, yet the above statement sounds like they want to "unify" the behavior and present the lock screen unmodified to the user. (There are obvious security implications as well) Depending on root permissions is not practicable for a production app in the Android ecosystem.Straitjacket
I am not convinced Google identifies a system app by file location Actually it's true to some extent. There are signature permissions that are granted only to apps signed with the same signature as the system. There are privileged permissions which are granted to apps in /system/priv-app (since KitKat). system permissions are an old version of privileged permissions, these are granted to apps in /system/app (until KitKat). One of the reasons system is write protected is so that the user or an app can't just grant privileged permissions easily.Watters
I understand this is not viable for the massive production apps but he asked for any way including root devices and adb, meaning this is likely a company internal app.Throng
Thanks for the answer. As far as I know, system apps must be signed with the same key the system is signed with and that's no solution for me. If I can only have this function for root users, this would be fine for me, but system signature is too much and not worth the effort... Still this seems to be the best answer and the only one with a concrete solution (workaround), so I'll accept it as the best optionStocktonontees
@Stocktonontees As far as I know, the signature is only needed if you don't want to use root. See here #37586755Throng
W
3

Unfortunately, this is no longer possible...

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

and there is only solution for this that you set your target sdk as 25

Woodnote answered 30/10, 2017 at 6:28 Comment(0)
T
1

The docs says that the flag is deprecated for non-system apps. Have you tried making the app a system app?

This constant was deprecated in API level 26. for non-system apps.

Here is how with ES File Explorer:

Configure ES File Explorer by doing the following steps:
    Launch ES File Explorer.
    Select Menu and choose Settings.
    Under Settings, enable the options for Up to root and Root Explorer. A message will appear, requiring you to confirm your action. You will also need to confirm Superuser access.
    Enable Mount File System.
    Go back to the app’s main menu.
Get a copy of the APK (Android Package) of the app that you want to save as a system file by doing the following steps (skip to step 3 if you already have the app’s APK file):
    Install an app from the Google Play Store. For this guide, we will be using the app BioRhythms as an example.
    Launch ES File Explorer and navigate to /data/app.
    Locate the APK file that you want to install as a system app. If you don’t know the APK’s filename, simply go to the Google Play Store link of your chosen app. View the link and take note of the words after “?id=”. This will be your APK’s filename. For instance, the BioRhythms app link is https://play.google.com/store/apps/details?id=app.biorhythms. The BioRhythms’ APK is app.biorhythms-1.apk.
Create a backup of the chosen APK by copying it to the phone’s SD Card.
After creating a backup, long tap on the APK file and a menu will appear. Choose Cut. A blue arrow will appear at the bottom of the screen.
Go back to the main menu and navigate to /system/app/.
Drag the little arrow at the bottom of the screen. It will bring up the icon of the APK file.
Tap the APK file and it will be transferred to /system/app/.
Find the APK file in /system/app/. Press and hold it and a menu will appear.
Select Properties on the menu. The dialog properties will show up.
Tap Change and it will show the permissions dialog box.
Check the boxes for the following permissions in the dialog box:
    User: Read and Write
    Group: Read
    Other: Read
Select OK once the required settings have been made.
Reboot your device.
Throng answered 31/10, 2017 at 0:29 Comment(5)
This would require root permissions as /system/app is protected. (as well as mount -o remount, rw[...]) Furthermore I am not convinced Google identifies a system app by file location. Otherwise Samsung / HTC etc would be able to use this as well, yet the above statement sounds like they want to "unify" the behavior and present the lock screen unmodified to the user. (There are obvious security implications as well) Depending on root permissions is not practicable for a production app in the Android ecosystem.Straitjacket
I am not convinced Google identifies a system app by file location Actually it's true to some extent. There are signature permissions that are granted only to apps signed with the same signature as the system. There are privileged permissions which are granted to apps in /system/priv-app (since KitKat). system permissions are an old version of privileged permissions, these are granted to apps in /system/app (until KitKat). One of the reasons system is write protected is so that the user or an app can't just grant privileged permissions easily.Watters
I understand this is not viable for the massive production apps but he asked for any way including root devices and adb, meaning this is likely a company internal app.Throng
Thanks for the answer. As far as I know, system apps must be signed with the same key the system is signed with and that's no solution for me. If I can only have this function for root users, this would be fine for me, but system signature is too much and not worth the effort... Still this seems to be the best answer and the only one with a concrete solution (workaround), so I'll accept it as the best optionStocktonontees
@Stocktonontees As far as I know, the signature is only needed if you don't want to use root. See here #37586755Throng
P
0

I m afraid you cant do that in android oreo as google stopped support for that to draw over notification line till date. May be in future they might think to implement that too as many developers are protesting against that.

For more details visit links below:

https://www.androidauthority.com/android-o-draw-over-system-763178/

https://www.reddit.com/r/Android/comments/64ffk1/android_o_is_breaking_apps_that_overlay_on_top_of/

Picket answered 30/10, 2017 at 12:45 Comment(1)
This question is specifically about whether there still is a possibility/workaround despite the changes described in the articles you linked. They don't answer the question.Michael

© 2022 - 2024 — McMap. All rights reserved.