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

Commit cca4bab2 authored by Vadim Caen's avatar Vadim Caen Committed by Automerger Merge Worker
Browse files

Merge changes from topic "presubmit-am-b87ddd3bbf2947f1aa639cddcee6ecb8" into tm-dev am: 09f7f6f6

parents 043307a2 09f7f6f6
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -8399,6 +8399,7 @@ public final class ViewRootImpl implements ViewParent,
                return;
                return;
            }
            }
            mRemoved = true;
            mRemoved = true;
            mOnBackInvokedDispatcher.detachFromWindow();
            if (mAdded) {
            if (mAdded) {
                dispatchDetachedFromWindow();
                dispatchDetachedFromWindow();
            }
            }
@@ -8433,8 +8434,6 @@ public final class ViewRootImpl implements ViewParent,


            mAdded = false;
            mAdded = false;
        }
        }
        unregisterCompatOnBackInvokedCallback();
        mOnBackInvokedDispatcher.detachFromWindow();
        WindowManagerGlobal.getInstance().doRemoveView(this);
        WindowManagerGlobal.getInstance().doRemoveView(this);
    }
    }


+8 −3
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.compat.CompatChanges;
import android.app.compat.CompatChanges;
import android.content.Context;
import android.content.Context;
import android.os.Debug;
import android.os.Handler;
import android.os.Handler;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.SystemProperties;
@@ -35,11 +36,11 @@ import java.util.TreeMap;


/**
/**
 * Provides window based implementation of {@link OnBackInvokedDispatcher}.
 * Provides window based implementation of {@link OnBackInvokedDispatcher}.
 *
 * <p>
 * Callbacks with higher priorities receive back dispatching first.
 * Callbacks with higher priorities receive back dispatching first.
 * Within the same priority, callbacks receive back dispatching in the reverse order
 * Within the same priority, callbacks receive back dispatching in the reverse order
 * in which they are added.
 * in which they are added.
 *
 * <p>
 * When the top priority callback is updated, the new callback is propagated to the Window Manager
 * When the top priority callback is updated, the new callback is propagated to the Window Manager
 * if the window the instance is associated with has been attached. It is allowed to register /
 * if the window the instance is associated with has been attached. It is allowed to register /
 * unregister {@link OnBackInvokedCallback}s before the window is attached, although
 * unregister {@link OnBackInvokedCallback}s before the window is attached, although
@@ -166,6 +167,10 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
                mWindowSession.setOnBackInvokedCallback(
                mWindowSession.setOnBackInvokedCallback(
                        mWindow, new OnBackInvokedCallbackWrapper(callback), priority);
                        mWindow, new OnBackInvokedCallbackWrapper(callback), priority);
            }
            }
            if (DEBUG && callback == null) {
                Log.d(TAG, TextUtils.formatSimple("setTopOnBackInvokedCallback(null) Callers:%s",
                        Debug.getCallers(5, "  ")));
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to set OnBackInvokedCallback to WM. Error: " + e);
            Log.e(TAG, "Failed to set OnBackInvokedCallback to WM. Error: " + e);
        }
        }
@@ -243,7 +248,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {


    /**
    /**
     * Returns if the legacy back behavior should be used.
     * Returns if the legacy back behavior should be used.
     *
     * <p>
     * Legacy back behavior dispatches KEYCODE_BACK instead of invoking the application registered
     * Legacy back behavior dispatches KEYCODE_BACK instead of invoking the application registered
     * {@link OnBackInvokedCallback}.
     * {@link OnBackInvokedCallback}.
     */
     */
+3 −3
Original line number Original line Diff line number Diff line
@@ -940,12 +940,12 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    public void setOnBackInvokedCallback(
    public void setOnBackInvokedCallback(
            IWindow window,
            IWindow window,
            IOnBackInvokedCallback onBackInvokedCallback,
            IOnBackInvokedCallback onBackInvokedCallback,
            @OnBackInvokedDispatcher.Priority int priority) throws RemoteException {
            @OnBackInvokedDispatcher.Priority int priority) {
        synchronized (mService.mGlobalLock) {
        synchronized (mService.mGlobalLock) {
            WindowState windowState = mService.windowForClientLocked(this, window, true);
            WindowState windowState = mService.windowForClientLocked(this, window, false);
            if (windowState == null) {
            if (windowState == null) {
                Slog.e(TAG_WM,
                Slog.e(TAG_WM,
                        "setOnBackInvokedCallback(): Can't find window state for package:"
                        "setOnBackInvokedCallback(): No window state for package:"
                                + mPackageName);
                                + mPackageName);
            } else {
            } else {
                windowState.setOnBackInvokedCallback(onBackInvokedCallback, priority);
                windowState.setOnBackInvokedCallback(onBackInvokedCallback, priority);