Verified
Status Update
Comments
sa...@google.com <sa...@google.com> #2
ot...@google.com <ot...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit e465976de8f05f0d1db49b4e2887c9f3cd4beab5
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 17 17:07:42 2021
Add OnBackPressedDispatcher observer before NavController observer
If you add a OnBackPressed callback with the NavBackStackEntry as the
lifecycle owner, if the Activity Lifecycle is STOPPED and STARTED again, the navController callback and NavBackStackEntry callback are readded to the Activity Lifecycle in the wrong order. This means that the new callback will not properly intercept onBackPressed() calls from the system, they will instead be intercepted by NavController.
If an OnBackPressedDispatcher is set, we should remove and readd the
NavController observer after we add the callback to the dispatcher.
RelNote: "OnBackPressedCallbacks added to a dispatcher with the
NavBackStackEntry as the LifecycleOwner now properly intercept back
after the Activity Lifecycle is STOPPED, then STARTED"
Test: NavControllerTest
Bug: 182284739
Change-Id: I6acf78848546160eaea7ed700ef8875664a125d0
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
https://android-review.googlesource.com/1643646
Branch: androidx-main
commit e465976de8f05f0d1db49b4e2887c9f3cd4beab5
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 17 17:07:42 2021
Add OnBackPressedDispatcher observer before NavController observer
If you add a OnBackPressed callback with the NavBackStackEntry as the
lifecycle owner, if the Activity Lifecycle is STOPPED and STARTED again, the navController callback and NavBackStackEntry callback are readded to the Activity Lifecycle in the wrong order. This means that the new callback will not properly intercept onBackPressed() calls from the system, they will instead be intercepted by NavController.
If an OnBackPressedDispatcher is set, we should remove and readd the
NavController observer after we add the callback to the dispatcher.
RelNote: "OnBackPressedCallbacks added to a dispatcher with the
NavBackStackEntry as the LifecycleOwner now properly intercept back
after the Activity Lifecycle is STOPPED, then STARTED"
Test: NavControllerTest
Bug: 182284739
Change-Id: I6acf78848546160eaea7ed700ef8875664a125d0
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
Description
My understanding is that jniCreateFileDescriptor() (https://android.googlesource.com/platform/libnativehelper/+/master/JNIHelp.cpp ) may return NULL if out-of-memory occurs and then `fd' is leaked. This might also happen in other places where jniCreateFileDescriptor() is called.
I have never encountered this in the field, but I happened to notice this in the code because Android O changed ParcelFileDescriptor.openInternal() to call android.system.Os.open() which ends up calling Linux_open(). Previously, ParcelFileDescriptor.openInternal() used to call android_os_Parcel_openFileDescriptor() which didn't have this (theoretical) issue.
This was formerly reported as https://issuetracker.google.com/issues/65423997