Repository navigation
Conversation
|
Hi @chocky335! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Fixes #58407. On Android 13 to 15, an app that sets
android:enableOnBackInvokedCallback="true"receives Back throughOnBackInvokedDispatcher, andReactActivityregisters itsOnBackPressedCallbackonly when the device also runs API 36, soBackHandlernever sees the press and Back closes the app.ReactActivity.onCreatenow registers the callback on API 33+ when the app targets SDK 36, the condition #51096 describes.Review focus: apps that target SDK 35 or lower and opt in are still not covered, because Android has no public API to read the opt-in. Dropping the
targetSdkVersioncondition would register the callback on every API 33+ device. Without the opt-in, Android keeps sending Back toonBackPressed()there, so the callback would stay unused.Changelog:
[ANDROID] [FIXED] - Fix
BackHandlernot receivinghardwareBackPresson Android 13 to 15 when the app targets SDK 36 and setsandroid:enableOnBackInvokedCallback="true"Test Plan:
ReactActivityBackCallbackTestat sdk 33, 34 and 35. Onmainthe 6 targetSdk 36 cases fail: no callback is registered and a back press never reachesReactActivityDelegate.onBackPressed(). With this change all 8 cases pass. Robolectric 4.15 on JDK 17 has no sdk 36, so API 36+ was checked on a device.:packages:react-native:ReactAndroid:testDebugUnitTest: 903 tests, 0 failures.yarn format-check-javaandyarn format-check-kotlinpass.hardwareBackPress receivedis never logged. After, each of 3 presses logs it, the counter shows 3 and the app stays open.