Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 717e53a6 authored by Vadim Caen's avatar Vadim Caen
Browse files

Save the OnBackInvokedCallback in WindowState

This CL enable OnBackInvokedCallback to be saved in a WindowState and
queried by the BackNavigationController to be returned when
ATM.startBackNavigation() is called.

The DecorView provides a PendingOnBackInvokedDispatcher that can receive
callback registration before being added to a ViewRootImpl.

Test: atest FrameworksCoreTests:BackNavigationTest
Bug: 131727607
Change-Id: I01528a22ea4a6583a56ade4eab69136d727855d0
parent 35afd765
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -4051,7 +4051,7 @@ package android.app {
    method public int getMaxNumPictureInPictureActions();
    method public final android.media.session.MediaController getMediaController();
    method @NonNull public android.view.MenuInflater getMenuInflater();
    method @Nullable public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method @NonNull public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method public final android.app.Activity getParent();
    method @Nullable public android.content.Intent getParentActivityIntent();
    method public android.content.SharedPreferences getPreferences(int);
@@ -4952,7 +4952,7 @@ package android.app {
    method @NonNull @UiContext public final android.content.Context getContext();
    method @Nullable public android.view.View getCurrentFocus();
    method @NonNull public android.view.LayoutInflater getLayoutInflater();
    method @Nullable public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method @NonNull public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method @Nullable public final android.app.Activity getOwnerActivity();
    method @Nullable public final android.view.SearchEvent getSearchEvent();
    method public final int getVolumeControlStream();
@@ -48944,7 +48944,7 @@ package android.view {
  }
  public interface OnBackInvokedDispatcherOwner {
    method @Nullable public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method @NonNull public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
  }
  public interface OnReceiveContentListener {
@@ -49372,7 +49372,7 @@ package android.view {
    field @NonNull public static final android.os.Parcelable.Creator<android.view.VerifiedMotionEvent> CREATOR;
  }
  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback android.view.OnBackInvokedDispatcherOwner {
  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
    ctor public View(android.content.Context);
    ctor public View(android.content.Context, @Nullable android.util.AttributeSet);
    ctor public View(android.content.Context, @Nullable android.util.AttributeSet, int);
@@ -49576,7 +49576,6 @@ package android.view {
    method @IdRes public int getNextFocusLeftId();
    method @IdRes public int getNextFocusRightId();
    method @IdRes public int getNextFocusUpId();
    method @Nullable public android.view.OnBackInvokedDispatcher getOnBackInvokedDispatcher();
    method public android.view.View.OnFocusChangeListener getOnFocusChangeListener();
    method @ColorInt public int getOutlineAmbientShadowColor();
    method public android.view.ViewOutlineProvider getOutlineProvider();
+1 −1
Original line number Diff line number Diff line
@@ -513,7 +513,7 @@ package android.util {

package android.view {

  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback android.view.OnBackInvokedDispatcherOwner {
  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
    method protected void initializeFadingEdge(android.content.res.TypedArray);
    method protected void initializeScrollbars(android.content.res.TypedArray);
  }
+1 −1
Original line number Diff line number Diff line
@@ -2806,7 +2806,7 @@ package android.view {
    method public void setView(@NonNull android.view.View, @NonNull android.view.WindowManager.LayoutParams);
  }

  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback android.view.OnBackInvokedDispatcherOwner {
  @UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
    method public android.view.View getTooltipView();
    method public boolean isAutofilled();
    method public static boolean isDefaultFocusHighlightEnabled();
+6 −8
Original line number Diff line number Diff line
@@ -8742,17 +8742,15 @@ public class Activity extends ContextThemeWrapper
     * Returns the {@link OnBackInvokedDispatcher} instance associated with the window that this
     * activity is attached to.
     *
     * Returns null if the activity is not attached to a window with a decor.
     * @throws IllegalStateException if this Activity is not visual.
     */
    @Nullable
    @NonNull
    @Override
    public OnBackInvokedDispatcher getOnBackInvokedDispatcher() {
        if (mWindow != null) {
            View decorView = mWindow.getDecorView();
            if (decorView != null) {
                return decorView.getOnBackInvokedDispatcher();
        if (mWindow == null) {
            throw new IllegalStateException("OnBackInvokedDispatcher are not available on "
                    + "non-visual activities");
        }
        }
        return null;
        return ((OnBackInvokedDispatcherOwner) mWindow).getOnBackInvokedDispatcher();
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -1449,15 +1449,9 @@ public class Dialog implements DialogInterface, Window.Callback,
     *
     * Returns null if the dialog is not attached to a window with a decor.
     */
    @Nullable
    @NonNull
    @Override
    public OnBackInvokedDispatcher getOnBackInvokedDispatcher() {
        if (mWindow != null) {
            View decorView = mWindow.getDecorView();
            if (decorView != null) {
                return decorView.getOnBackInvokedDispatcher();
            }
        }
        return null;
        return ((OnBackInvokedDispatcherOwner) mWindow).getOnBackInvokedDispatcher();
    }
}
Loading