Avoid leaking Activity from OnBackInvokedCallback.

- Remove mTopCallback field
- Cleanup compat and default callbacks
- Remove the callback held by WindowState when the window is removed.

Bug: 218328707
Test: atest packages/apps/Launcher3/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
Test: atest frameworks/base/core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java
Change-Id: I38fd760a617500c874aef10bc8de165880837008
This commit is contained in:
Shan Huang
2022-02-09 17:25:42 +00:00
parent 56fc3f5e5c
commit b533660125
5 changed files with 44 additions and 40 deletions

View File

@@ -10838,6 +10838,7 @@ public final class ViewRootImpl implements ViewParent,
private void unregisterCompatOnBackInvokedCallback() {
if (mCompatOnBackInvokedCallback != null) {
mOnBackInvokedDispatcher.unregisterOnBackInvokedCallback(mCompatOnBackInvokedCallback);
mCompatOnBackInvokedCallback = null;
}
}