Merge "Transfer the actual dispatcher when the window is preserved" into tm-dev am: a147b66f61
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18601925 Change-Id: Ia862d7710d2c5891a33d399d17e67842f4cbe963 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -90,7 +90,11 @@ public class ProxyOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mCallbacks.add(Pair.create(callback, priority));
|
mCallbacks.add(Pair.create(callback, priority));
|
||||||
if (mActualDispatcher != null) {
|
if (mActualDispatcher != null) {
|
||||||
mActualDispatcher.registerOnBackInvokedCallback(priority, callback);
|
if (priority <= PRIORITY_SYSTEM) {
|
||||||
|
mActualDispatcher.registerSystemOnBackInvokedCallback(callback);
|
||||||
|
} else {
|
||||||
|
mActualDispatcher.registerOnBackInvokedCallback(priority, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +175,16 @@ public class ProxyOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearCallbacksOnDispatcher();
|
clearCallbacksOnDispatcher();
|
||||||
mActualDispatcher = actualDispatcher;
|
if (actualDispatcher instanceof ProxyOnBackInvokedDispatcher) {
|
||||||
|
// We don't want to nest ProxyDispatchers, so if we are given on, we unwrap its
|
||||||
|
// actual dispatcher.
|
||||||
|
// This can happen when an Activity is recreated but the Window is preserved (e.g.
|
||||||
|
// when going from split-screen back to single screen)
|
||||||
|
mActualDispatcher =
|
||||||
|
((ProxyOnBackInvokedDispatcher) actualDispatcher).mActualDispatcher;
|
||||||
|
} else {
|
||||||
|
mActualDispatcher = actualDispatcher;
|
||||||
|
}
|
||||||
transferCallbacksToDispatcher();
|
transferCallbacksToDispatcher();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
|
|
||||||
boolean mDecorFitsSystemWindows = true;
|
boolean mDecorFitsSystemWindows = true;
|
||||||
|
|
||||||
private ProxyOnBackInvokedDispatcher mProxyOnBackInvokedDispatcher =
|
private final ProxyOnBackInvokedDispatcher mProxyOnBackInvokedDispatcher =
|
||||||
new ProxyOnBackInvokedDispatcher();
|
new ProxyOnBackInvokedDispatcher();
|
||||||
|
|
||||||
static class WindowManagerHolder {
|
static class WindowManagerHolder {
|
||||||
@@ -378,6 +378,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
// window, as we'll be skipping the addView in handleResumeActivity(), and
|
// window, as we'll be skipping the addView in handleResumeActivity(), and
|
||||||
// the token will not be updated as for a new window.
|
// the token will not be updated as for a new window.
|
||||||
getAttributes().token = preservedWindow.getAttributes().token;
|
getAttributes().token = preservedWindow.getAttributes().token;
|
||||||
|
mProxyOnBackInvokedDispatcher.setActualDispatcher(
|
||||||
|
preservedWindow.getOnBackInvokedDispatcher());
|
||||||
}
|
}
|
||||||
// Even though the device doesn't support picture-in-picture mode,
|
// Even though the device doesn't support picture-in-picture mode,
|
||||||
// an user can force using it through developer options.
|
// an user can force using it through developer options.
|
||||||
|
|||||||
Reference in New Issue
Block a user