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

Commit 14c60531 authored by Vadim Caen's avatar Vadim Caen Committed by Android (Google) Code Review
Browse files

Merge "Prevent callback registration when back flag is disabled"

parents a55e611c aa48dc3c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -800,6 +800,7 @@ package android.content.pm {


  public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
  public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
    method public boolean hasRequestForegroundServiceExemption();
    method public boolean hasRequestForegroundServiceExemption();
    method public boolean isOnBackInvokedCallbackEnabled();
    method public boolean isPrivilegedApp();
    method public boolean isPrivilegedApp();
    method public boolean isSystemApp();
    method public boolean isSystemApp();
    method public void setEnableOnBackInvokedCallback(boolean);
    method public void setEnableOnBackInvokedCallback(boolean);
+0 −2
Original line number Original line Diff line number Diff line
@@ -1482,8 +1482,6 @@ public class Dialog implements DialogInterface, Window.Callback,
    /**
    /**
     * Returns the {@link OnBackInvokedDispatcher} instance associated with the window that this
     * Returns the {@link OnBackInvokedDispatcher} instance associated with the window that this
     * dialog is attached to.
     * dialog is attached to.
     *
     * Returns null if the dialog is not attached to a window with a decor.
     */
     */
    @NonNull
    @NonNull
    public OnBackInvokedDispatcher getOnBackInvokedDispatcher() {
    public OnBackInvokedDispatcher getOnBackInvokedDispatcher() {
+1 −0
Original line number Original line Diff line number Diff line
@@ -2588,6 +2588,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     *
     * @hide
     * @hide
     */
     */
    @TestApi
    public boolean isOnBackInvokedCallbackEnabled() {
    public boolean isOnBackInvokedCallbackEnabled() {
        return ((privateFlagsExt & PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK)) != 0;
        return ((privateFlagsExt & PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK)) != 0;
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -135,6 +135,7 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView;
import android.window.CompatOnBackInvokedCallback;
import android.window.ImeOnBackInvokedDispatcher;
import android.window.ImeOnBackInvokedDispatcher;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import android.window.OnBackInvokedDispatcher;
@@ -366,7 +367,7 @@ public class InputMethodService extends AbstractInputMethodService {
    private RingBuffer<MotionEvent> mPendingEvents;
    private RingBuffer<MotionEvent> mPendingEvents;
    private ImeOnBackInvokedDispatcher mImeDispatcher;
    private ImeOnBackInvokedDispatcher mImeDispatcher;
    private Boolean mBackCallbackRegistered = false;
    private Boolean mBackCallbackRegistered = false;
    private final OnBackInvokedCallback mCompatBackCallback = this::compatHandleBack;
    private final CompatOnBackInvokedCallback mCompatBackCallback = this::compatHandleBack;
    private Runnable mImeSurfaceRemoverRunnable;
    private Runnable mImeSurfaceRemoverRunnable;
    private Runnable mFinishHwRunnable;
    private Runnable mFinishHwRunnable;
    private long mStylusHwSessionsTimeout = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS;
    private long mStylusHwSessionsTimeout = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS;
+5 −10
Original line number Original line Diff line number Diff line
@@ -196,6 +196,7 @@ import android.view.contentcapture.MainContentCaptureSession;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Scroller;
import android.widget.Scroller;
import android.window.ClientWindowFrames;
import android.window.ClientWindowFrames;
import android.window.CompatOnBackInvokedCallback;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import android.window.OnBackInvokedDispatcher;
import android.window.SurfaceSyncer;
import android.window.SurfaceSyncer;
@@ -339,13 +340,12 @@ public final class ViewRootImpl implements ViewParent,
    /**
    /**
     * The top level {@link OnBackInvokedDispatcher}.
     * The top level {@link OnBackInvokedDispatcher}.
     */
     */
    private final WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher =
    private final WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher;
            new WindowOnBackInvokedDispatcher();
    /**
    /**
     * Compatibility {@link OnBackInvokedCallback} that dispatches KEYCODE_BACK events
     * Compatibility {@link OnBackInvokedCallback} that dispatches KEYCODE_BACK events
     * to view root for apps using legacy back behavior.
     * to view root for apps using legacy back behavior.
     */
     */
    private OnBackInvokedCallback mCompatOnBackInvokedCallback;
    private CompatOnBackInvokedCallback mCompatOnBackInvokedCallback;


    /**
    /**
     * Callback for notifying about global configuration changes.
     * Callback for notifying about global configuration changes.
@@ -963,6 +963,8 @@ public final class ViewRootImpl implements ViewParent,
        mFastScrollSoundEffectsEnabled = audioManager.areNavigationRepeatSoundEffectsEnabled();
        mFastScrollSoundEffectsEnabled = audioManager.areNavigationRepeatSoundEffectsEnabled();


        mScrollCaptureRequestTimeout = SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS;
        mScrollCaptureRequestTimeout = SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS;
        mOnBackInvokedDispatcher = new WindowOnBackInvokedDispatcher(
                context.getApplicationInfo().isOnBackInvokedCallbackEnabled());
    }
    }


    public static void addFirstDrawHandler(Runnable callback) {
    public static void addFirstDrawHandler(Runnable callback) {
@@ -10857,13 +10859,6 @@ public final class ViewRootImpl implements ViewParent,
                OnBackInvokedDispatcher.PRIORITY_DEFAULT, mCompatOnBackInvokedCallback);
                OnBackInvokedDispatcher.PRIORITY_DEFAULT, mCompatOnBackInvokedCallback);
    }
    }


    private void unregisterCompatOnBackInvokedCallback() {
        if (mCompatOnBackInvokedCallback != null) {
            mOnBackInvokedDispatcher.unregisterOnBackInvokedCallback(mCompatOnBackInvokedCallback);
            mCompatOnBackInvokedCallback = null;
        }
    }

    @Override
    @Override
    public void setTouchableRegion(Region r) {
    public void setTouchableRegion(Region r) {
        if (r != null) {
        if (r != null) {
Loading