Skip to content

Android Oreo (8.0) Support - #15601

Closed
AndrewJack wants to merge 1 commit into
react:masterfrom
AndrewJack:android-oreo
Closed

Android Oreo (8.0) Support#15601
AndrewJack wants to merge 1 commit into
react:masterfrom
AndrewJack:android-oreo

Conversation

@AndrewJack

@AndrewJackAndrewJack commented Aug 22, 2017

Copy link
Copy Markdown
Contributor

Apps targeting Android 8.0 (API level 26) cannot use TYPE_SYSTEM_OVERLAY and TYPE_SYSTEM_OVERLAY . Targeting 26 will cause the app to crash when in DEV_MODE.

https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt

This PR replaces uses of these overlay flags with the new TYPE_APPLICATION_OVERLAY when running on a device with Android 8.0 or later.

When using TYPE_APPLICATION_OVERLAY it still requires the SYSTEM_ALERT_WINDOW permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAY

Test Plan

https://github.com/AndrewJack/react-native-android-oreo tested here

@facebook-github-botfacebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Aug 22, 2017
@AndrewJack

AndrewJack commented Aug 22, 2017

Copy link
Copy Markdown
ContributorAuthor

Without the changes in this PR you will see the following crash:

FATAL EXCEPTION: main
Process: com.androido, PID: 25946
android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@49e4bdb -- permission denied for window type 2003
at android.view.ViewRootImpl.setView(ViewRootImpl.java:789)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:92)
at android.app.Dialog.show(Dialog.java:330)
at com.facebook.react.devsupport.DevSupportManagerImpl$4.run(DevSupportManagerImpl.java:356)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

@pull-bot

pull-bot commented Aug 22, 2017

Copy link
Copy Markdown

@facebook-github-bot label Core Team

Generated by 🚫 dangerJS

@AndrewJackAndrewJackAug 22, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot use the Android constants because react native doesn't compile to v26 yet, it currently uses v23.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be useful to make this public, if you prefer not to let's just add a /* package */ comment like here for example https://github.com/AndrewJack/react-native/blob/f1cf378cf4ef3e5473fe2ace6d564be897e56a0e/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialog.java#L51

@AndrewJackAndrewJackAug 31, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be public. It's only needed in the devsupport package and I wouldn't like to encourage app developers to use this either.

I'll add /* package */

@janicduplessis

Copy link
Copy Markdown
Contributor

@shergin Looks good to me if you want to ship.

@ide
ide requested a review from sherginSeptember 2, 2017 06:28
@arpit

arpit commented Sep 9, 2017

Copy link
Copy Markdown

Any update on this? Definitely seeing this crash and the patch looks good. The CI failure seems to be unrelated to this code unless I am missing something

@facebook-github-botfacebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Sep 9, 2017
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@janicduplessis

Copy link
Copy Markdown
Contributor

Thanks @AndrewJack for the PR and @shergin for shipping 🎉

ide pushed a commit to expo/react-native that referenced this pull request Sep 14, 2017
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closesreact#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
ide pushed a commit that referenced this pull request Sep 14, 2017
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closes#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
ide pushed a commit to expo/react-native that referenced this pull request Sep 19, 2017
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closesreact#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
gpeal pushed a commit to airbnb/react-native that referenced this pull request Oct 30, 2017
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closesreact#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
gpeal pushed a commit to airbnb/react-native that referenced this pull request Nov 3, 2017
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closesreact#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
@rekha110254

rekha110254 commented Dec 2, 2017

Copy link
Copy Markdown

@AndrewJack@janicduplessis Any update on this?? I'm facing this issue.

FATAL EXCEPTION: main
Process: com.androido, PID: 25946
android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@49e4bdb -- permission denied for window type 2003
at android.view.ViewRootImpl.setView(ViewRootImpl.java:789)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:92)
at android.app.Dialog.show(Dialog.java:330)
at com.facebook.react.devsupport.DevSupportManagerImpl$4.run(DevSupportManagerImpl.java:356)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

@AndrewJack

Copy link
Copy Markdown
ContributorAuthor

@rekha110254 What version are you using? This was only shipped in RN 0.50.

@temitope

Copy link
Copy Markdown

@AndrewJack thanks for this PR, this bug is kicking my project in the shins. I am using RN 0.41 and wondering if there is a recommended way to incorporate this fix outside of 1) upgrading to RN 0.51 and possibly upsetting my other dependencies and 2) manually updating the source files for RN creating an unsupported unique version of the RN codebase just for me :/? Basically I am hoping and wondering if there is a way to just incorporate these changes related to the overlay or do I just need to take the upgrade plunge?
Thanks

@zaplo00

zaplo00 commented Feb 27, 2018

Copy link
Copy Markdown

is navigator.geolocation.getCurrentPosition working in Android 8? Could someone with actual device test it, whether it always returns error 3 (location timeout) or actually works with permission allowed, location services enabled and using both gps and wireless?

@rekha110254

Copy link
Copy Markdown

@AndrewJack RN 0.51.1

dryganets pushed a commit to dryganets/react-native that referenced this pull request Oct 17, 2018
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.
https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt
This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.
When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAYhttps://github.com/AndrewJack/react-native-android-oreo tested here
Closesreact#15601
Reviewed By: achen1
Differential Revision: D5801619
Pulled By: shergin
fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.Import StartedThis pull request has been imported. This does not imply the PR has been approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@AndrewJack@pull-bot@janicduplessis@arpit@facebook-github-bot@rekha110254@temitope@zaplo00@hramos