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

Commit e86f6d51 authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "swipe-dismiss: add IDecorViewGestureListener" into main

parents 36960fda 895bf736
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view;

/**
 * Listener for changes to gesture interception detector running at DecorView.
 *
 * {@hide}
 */
oneway interface IDecorViewGestureListener {
    /**
     * Called when a DecorView has started intercepting gesture.
     *
     * @param windowToken Where did this gesture interception result comes from.
     * @param intercepted Whether the gesture interception detector has started interception.
     */
    void onInterceptionChanged(in IBinder windowToken, in boolean intercepted);
}
+15 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.view.IScrollCaptureResponseListener;
import android.view.RemoteAnimationAdapter;
import android.view.IRotationWatcher;
import android.view.ISystemGestureExclusionListener;
import android.view.IDecorViewGestureListener;
import android.view.IWallpaperVisibilityListener;
import android.view.IWindow;
import android.view.IWindowSession;
@@ -1062,4 +1063,18 @@ interface IWindowManager
     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
             + ".permission.ACCESS_SURFACE_FLINGER)")
    boolean replaceContentOnDisplay(int displayId, in SurfaceControl sc);

    /**
     * Registers a DecorView gesture listener for a given display.
     */
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MONITOR_INPUT)")
    void registerDecorViewGestureListener(IDecorViewGestureListener listener, int displayId);

    /**
     * Unregisters a DecorView gesture listener for a given display.
     */
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MONITOR_INPUT)")
    void unregisterDecorViewGestureListener(IDecorViewGestureListener listener, int displayId);
}
+5 −0
Original line number Diff line number Diff line
@@ -283,6 +283,11 @@ interface IWindowSession {
     */
    oneway void reportSystemGestureExclusionChanged(IWindow window, in List<Rect> exclusionRects);

    /**
     * Called when the DecorView gesture interception state has changed.
     */
    oneway void reportDecorViewGestureInterceptionChanged(IWindow window, in boolean intercepted);

    /**
     * Called when the keep-clear areas for this window have changed.
     */
+27 −0
Original line number Diff line number Diff line
@@ -5319,6 +5319,29 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    /**
     * Called from DecorView when gesture interception state has changed.
     *
     * @param intercepted If DecorView is intercepting touch events
     */
    public void updateDecorViewGestureInterception(boolean intercepted) {
        mHandler.sendMessage(
                mHandler.obtainMessage(
                        MSG_DECOR_VIEW_GESTURE_INTERCEPTION,
                        /* arg1= */ intercepted ? 1 : 0,
                        /* arg2= */ 0));
    }

    void decorViewInterceptionChanged(boolean intercepted) {
        if (mView != null) {
            try {
                mWindowSession.reportDecorViewGestureInterceptionChanged(mWindow, intercepted);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Set the root-level system gesture exclusion rects. These are added to those provided by
     * the root's view hierarchy.
@@ -5942,6 +5965,7 @@ public final class ViewRootImpl implements ViewParent,
    private static final int MSG_KEEP_CLEAR_RECTS_CHANGED = 35;
    private static final int MSG_REPORT_KEEP_CLEAR_RECTS = 36;
    private static final int MSG_PAUSED_FOR_SYNC_TIMEOUT = 37;
    private static final int MSG_DECOR_VIEW_GESTURE_INTERCEPTION = 38;

    final class ViewRootHandler extends Handler {
        @Override
@@ -6220,6 +6244,9 @@ public final class ViewRootImpl implements ViewParent,
                case MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED: {
                    systemGestureExclusionChanged();
                }   break;
                case MSG_DECOR_VIEW_GESTURE_INTERCEPTION: {
                    decorViewInterceptionChanged(/* intercepted= */ msg.arg1 == 1);
                }   break;
                case MSG_KEEP_CLEAR_RECTS_CHANGED: {
                    keepClearRectsChanged(/* accessibilityFocusRectChanged= */ msg.arg1 == 1);
                }   break;
+7 −3
Original line number Diff line number Diff line
@@ -584,9 +584,13 @@ public class WindowlessWindowManager implements IWindowSession {
    }

    @Override
    public void reportKeepClearAreasChanged(android.view.IWindow window, List<Rect> restrictedRects,
            List<Rect> unrestrictedRects) {
    }
    public void reportDecorViewGestureInterceptionChanged(IWindow window, boolean intercepted) {}

    @Override
    public void reportKeepClearAreasChanged(
            android.view.IWindow window,
            List<Rect> restrictedRects,
            List<Rect> unrestrictedRects) {}

    @Override
    public void grantInputChannel(int displayId, SurfaceControl surface, IWindow window,
Loading