DO NOT MERGE Prevent back navigation not working after activity re-created am: 338e956022
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21166958 Change-Id: I1329869eea34cf8f88c38adb397da9c63e7dbb2a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -8632,6 +8632,8 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|
|
||||||
mInsetsController.dump(prefix, writer);
|
mInsetsController.dump(prefix, writer);
|
||||||
|
|
||||||
|
mOnBackInvokedDispatcher.dump(prefix, writer);
|
||||||
|
|
||||||
writer.println(prefix + "View Hierarchy:");
|
writer.println(prefix + "View Hierarchy:");
|
||||||
dumpViewHierarchy(innerPrefix, writer, mView);
|
dumpViewHierarchy(innerPrefix, writer, mView);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,6 +211,12 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
|
|||||||
IOnBackInvokedCallback getIOnBackInvokedCallback() {
|
IOnBackInvokedCallback getIOnBackInvokedCallback() {
|
||||||
return mIOnBackInvokedCallback;
|
return mIOnBackInvokedCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ImeCallback=ImeOnBackInvokedCallback@" + mId
|
||||||
|
+ " Callback=" + mIOnBackInvokedCallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -179,16 +179,7 @@ public class ProxyOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearCallbacksOnDispatcher();
|
clearCallbacksOnDispatcher();
|
||||||
if (actualDispatcher instanceof ProxyOnBackInvokedDispatcher) {
|
mActualDispatcher = actualDispatcher;
|
||||||
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.util.Log;
|
|||||||
import android.view.IWindow;
|
import android.view.IWindow;
|
||||||
import android.view.IWindowSession;
|
import android.view.IWindowSession;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -221,6 +222,26 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private static final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
|
private static final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump information about this WindowOnBackInvokedDispatcher
|
||||||
|
* @param prefix the prefix that will be prepended to each line of the produced output
|
||||||
|
* @param writer the writer that will receive the resulting text
|
||||||
|
*/
|
||||||
|
public void dump(String prefix, PrintWriter writer) {
|
||||||
|
String innerPrefix = prefix + " ";
|
||||||
|
writer.println(prefix + "WindowOnBackDispatcher:");
|
||||||
|
if (mAllCallbacks.isEmpty()) {
|
||||||
|
writer.println(prefix + "<None>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.println(innerPrefix + "Top Callback: " + getTopCallback());
|
||||||
|
writer.println(innerPrefix + "Callbacks: ");
|
||||||
|
mAllCallbacks.forEach((callback, priority) -> {
|
||||||
|
writer.println(innerPrefix + " Callback: " + callback + " Priority=" + priority);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
|
static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub {
|
||||||
private final WeakReference<OnBackInvokedCallback> mCallback;
|
private final WeakReference<OnBackInvokedCallback> mCallback;
|
||||||
|
|
||||||
|
|||||||
@@ -379,8 +379,12 @@ 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(
|
final ViewRootImpl viewRoot = mDecor.getViewRootImpl();
|
||||||
preservedWindow.getOnBackInvokedDispatcher());
|
if (viewRoot != null) {
|
||||||
|
// Clear the old callbacks and attach to the new window.
|
||||||
|
viewRoot.getOnBackInvokedDispatcher().clear();
|
||||||
|
onViewRootImplSet(viewRoot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 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