Loading packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java +0 −3 Original line number Diff line number Diff line Loading @@ -239,7 +239,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayAddSystemDecorations(int displayId) { CommandQueue.Callbacks.super.onDisplayAddSystemDecorations(displayId); mEdgeBackGestureHandler.onDisplayAddSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading @@ -254,7 +253,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayRemoved(int displayId) { CommandQueue.Callbacks.super.onDisplayRemoved(displayId); mEdgeBackGestureHandler.onDisplayRemoveSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading @@ -269,7 +267,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayRemoveSystemDecorations(int displayId) { CommandQueue.Callbacks.super.onDisplayRemoveSystemDecorations(displayId); mEdgeBackGestureHandler.onDisplayRemoveSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +23 −94 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static android.view.MotionEvent.TOOL_TYPE_FINGER; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION; import static com.android.systemui.Flags.edgebackGestureHandlerGetRunningTasksBackground; import static com.android.window.flags.Flags.enableMultidisplayTrackpadBackGesture; import static com.android.systemui.Flags.predictiveBackDelayWmTransition; import static com.android.systemui.classifier.Classifier.BACK_GESTURE; import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe; Loading Loading @@ -116,8 +115,6 @@ import kotlinx.coroutines.Job; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Optional; Loading Loading @@ -282,7 +279,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack private boolean mIsTrackpadThreeFingerSwipe; private boolean mIsButtonForcedVisible; private final Map<Integer, InputMonitorResource> mInputMonitorResources = new HashMap<>(); private InputMonitorCompat mInputMonitor; private InputChannelCompat.InputEventReceiver mInputEventReceiver; private NavigationEdgeBackPlugin mEdgeBackPlugin; private BackAnimation mBackAnimation; Loading Loading @@ -667,44 +665,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack mIsNavBarShownTransiently = isTransient; } /** * Called when a new display gets connected * * @param displayId The id associated with the connected display. */ public void onDisplayAddSystemDecorations(int displayId) { if (enableMultidisplayTrackpadBackGesture() && mIsEnabled) { mUiThreadContext.runWithScissors(() -> { removeAndDisposeInputMonitorResource(displayId); mInputMonitorResources.put(displayId, new InputMonitorResource(displayId)); }); } } /** * Called when a display gets disconnected * * @param displayId The id associated with the disconnected display. */ public void onDisplayRemoveSystemDecorations(int displayId) { if (enableMultidisplayTrackpadBackGesture()) { mUiThreadContext.runWithScissors(() -> removeAndDisposeInputMonitorResource(displayId)); } } private void removeAndDisposeInputMonitorResource(int displayId) { InputMonitorResource inputMonitor = mInputMonitorResources.remove(displayId); if (inputMonitor != null) { inputMonitor.dispose(); } private void disposeInputChannel() { if (mInputEventReceiver != null) { mInputEventReceiver.dispose(); mInputEventReceiver = null; } private void disposeInputChannels() { Iterator<Map.Entry<Integer, InputMonitorResource>> iterator = mInputMonitorResources.entrySet().iterator(); while (iterator.hasNext()) { iterator.next().getValue().dispose(); iterator.remove(); if (mInputMonitor != null) { mInputMonitor.dispose(); mInputMonitor = null; } } Loading @@ -723,7 +691,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack return; } mIsEnabled = isEnabled; disposeInputChannels(); disposeInputChannel(); if (mEdgeBackPlugin != null) { mEdgeBackPlugin.onDestroy(); Loading Loading @@ -778,8 +746,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } // Register input event receiver mInputMonitorResources.put(mDisplayId, new InputMonitorResource(mDisplayId)); //TODO(b/382774299): Register input monitor on connected displays (if any) mInputMonitor = new InputMonitorCompat("edge-swipe", mDisplayId); mInputEventReceiver = mInputMonitor.getInputReceiver(mUiThreadContext.getLooper(), mUiThreadContext.getChoreographer(), this::onInputEvent); // Add a nav bar panel window resetEdgeBackPlugin(); Loading Loading @@ -981,10 +950,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack return true; } private boolean isValidTrackpadBackGesture(int displayId) { if (enableMultidisplayTrackpadBackGesture() && displayId != mDisplayId) { //TODO(b/382774299): Handle exclude regions on connected displays return true; private boolean isValidTrackpadBackGesture(boolean isTrackpadEvent) { if (!isTrackpadEvent) { return false; } // for trackpad gestures, unless the whole screen is excluded region, 3-finger swipe // gestures are allowed even if the cursor is in the excluded region. Loading @@ -1001,15 +969,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack private boolean isWithinTouchRegion(MotionEvent ev) { // If the point is inside the PiP or Nav bar overlay excluded bounds, then ignore the back // gesture. Also ignore (for now) if it's not on the main display. // TODO(b/382130680): Implement back gesture handling on connected displays // gesture int x = (int) ev.getX(); int y = (int) ev.getY(); final boolean isInsidePip = mIsInPip && mPipExcludedBounds.contains(x, y); final boolean isInDesktopExcludeRegion = desktopExcludeRegionContains(x, y) && isEdgeResizePermitted(ev); if (isInsidePip || isInDesktopExcludeRegion || mNavBarOverlayExcludedBounds.contains(x, y) || ev.getDisplayId() != mDisplayId) { || mNavBarOverlayExcludedBounds.contains(x, y)) { return false; } Loading Loading @@ -1109,11 +1076,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack // Verify if this is in within the touch region and we aren't in immersive mode, and // either the bouncer is showing or the notification panel is hidden InputMonitorResource inputMonitorResource = mInputMonitorResources.get(ev.getDisplayId()); if (inputMonitorResource != null) { inputMonitorResource.mInputEventReceiver.setBatchingEnabled(false); } mInputEventReceiver.setBatchingEnabled(false); if (mIsTrackpadThreeFingerSwipe) { // Since trackpad gestures don't have zones, this will be determined later by the // direction of the gesture. {@code mIsOnLeftEdge} is set to false to begin with. Loading @@ -1136,7 +1099,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack boolean trackpadGesturesEnabled = (mSysUiFlags & SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED) == 0; mAllowGesture = isBackAllowedCommon && trackpadGesturesEnabled && isValidTrackpadBackGesture(ev.getDisplayId()); && isValidTrackpadBackGesture(true /* isTrackpadEvent */); } else { mAllowGesture = isBackAllowedCommon && !mUsingThreeButtonNav && isWithinInsets && isWithinTouchRegion(ev) && !isButtonPressFromTrackpad(ev); Loading Loading @@ -1247,14 +1210,12 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } private void pilferPointers() { //TODO(b/382774299): Pilfer pointers on the correct display InputMonitorResource inputMonitorResource = mInputMonitorResources.get(mDisplayId); if (inputMonitorResource != null) { if (mInputMonitor != null) { // Capture inputs inputMonitorResource.mInputMonitorCompat.pilferPointers(); mInputMonitor.pilferPointers(); // Notify FalsingManager that an intentional gesture has occurred. mFalsingManager.isFalseTouch(BACK_GESTURE); inputMonitorResource.mInputEventReceiver.setBatchingEnabled(true); mInputEventReceiver.setBatchingEnabled(true); } } Loading Loading @@ -1383,11 +1344,6 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack if (mEdgeBackPlugin != null) { mEdgeBackPlugin.dump(pw); } pw.println(" mInputMonitorResources=" + mInputMonitorResources); for (Map.Entry<Integer, InputMonitorResource> inputMonitorResource : mInputMonitorResources.entrySet()) { inputMonitorResource.getValue().dump("\t", pw); } } private void updateTopActivityPackageName() { Loading Loading @@ -1420,33 +1376,6 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } } private class InputMonitorResource { private final int mDisplayId; private final InputMonitorCompat mInputMonitorCompat; private final InputChannelCompat.InputEventReceiver mInputEventReceiver; private InputMonitorResource(int displayId) { this.mDisplayId = displayId; mInputMonitorCompat = new InputMonitorCompat("edge-swipe", displayId); mInputEventReceiver = mInputMonitorCompat.getInputReceiver(mUiThreadContext.getLooper(), mUiThreadContext.getChoreographer(), EdgeBackGestureHandler.this::onInputEvent); } public void dispose() { mInputEventReceiver.dispose(); mInputMonitorCompat.dispose(); } public void dump(String prefix, PrintWriter writer) { writer.println(prefix + this); } @Override public String toString() { return "InputMonitorResource (displayId=" + mDisplayId + ")"; } } private static class LogArray extends ArrayDeque<String> { private final int mLength; Loading Loading
packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java +0 −3 Original line number Diff line number Diff line Loading @@ -239,7 +239,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayAddSystemDecorations(int displayId) { CommandQueue.Callbacks.super.onDisplayAddSystemDecorations(displayId); mEdgeBackGestureHandler.onDisplayAddSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading @@ -254,7 +253,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayRemoved(int displayId) { CommandQueue.Callbacks.super.onDisplayRemoved(displayId); mEdgeBackGestureHandler.onDisplayRemoveSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading @@ -269,7 +267,6 @@ public class TaskbarDelegate implements CommandQueue.Callbacks, @Override public void onDisplayRemoveSystemDecorations(int displayId) { CommandQueue.Callbacks.super.onDisplayRemoveSystemDecorations(displayId); mEdgeBackGestureHandler.onDisplayRemoveSystemDecorations(displayId); if (mLauncherProxyService.getProxy() == null) { return; } Loading
packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +23 −94 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static android.view.MotionEvent.TOOL_TYPE_FINGER; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION; import static com.android.systemui.Flags.edgebackGestureHandlerGetRunningTasksBackground; import static com.android.window.flags.Flags.enableMultidisplayTrackpadBackGesture; import static com.android.systemui.Flags.predictiveBackDelayWmTransition; import static com.android.systemui.classifier.Classifier.BACK_GESTURE; import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe; Loading Loading @@ -116,8 +115,6 @@ import kotlinx.coroutines.Job; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Optional; Loading Loading @@ -282,7 +279,8 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack private boolean mIsTrackpadThreeFingerSwipe; private boolean mIsButtonForcedVisible; private final Map<Integer, InputMonitorResource> mInputMonitorResources = new HashMap<>(); private InputMonitorCompat mInputMonitor; private InputChannelCompat.InputEventReceiver mInputEventReceiver; private NavigationEdgeBackPlugin mEdgeBackPlugin; private BackAnimation mBackAnimation; Loading Loading @@ -667,44 +665,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack mIsNavBarShownTransiently = isTransient; } /** * Called when a new display gets connected * * @param displayId The id associated with the connected display. */ public void onDisplayAddSystemDecorations(int displayId) { if (enableMultidisplayTrackpadBackGesture() && mIsEnabled) { mUiThreadContext.runWithScissors(() -> { removeAndDisposeInputMonitorResource(displayId); mInputMonitorResources.put(displayId, new InputMonitorResource(displayId)); }); } } /** * Called when a display gets disconnected * * @param displayId The id associated with the disconnected display. */ public void onDisplayRemoveSystemDecorations(int displayId) { if (enableMultidisplayTrackpadBackGesture()) { mUiThreadContext.runWithScissors(() -> removeAndDisposeInputMonitorResource(displayId)); } } private void removeAndDisposeInputMonitorResource(int displayId) { InputMonitorResource inputMonitor = mInputMonitorResources.remove(displayId); if (inputMonitor != null) { inputMonitor.dispose(); } private void disposeInputChannel() { if (mInputEventReceiver != null) { mInputEventReceiver.dispose(); mInputEventReceiver = null; } private void disposeInputChannels() { Iterator<Map.Entry<Integer, InputMonitorResource>> iterator = mInputMonitorResources.entrySet().iterator(); while (iterator.hasNext()) { iterator.next().getValue().dispose(); iterator.remove(); if (mInputMonitor != null) { mInputMonitor.dispose(); mInputMonitor = null; } } Loading @@ -723,7 +691,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack return; } mIsEnabled = isEnabled; disposeInputChannels(); disposeInputChannel(); if (mEdgeBackPlugin != null) { mEdgeBackPlugin.onDestroy(); Loading Loading @@ -778,8 +746,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } // Register input event receiver mInputMonitorResources.put(mDisplayId, new InputMonitorResource(mDisplayId)); //TODO(b/382774299): Register input monitor on connected displays (if any) mInputMonitor = new InputMonitorCompat("edge-swipe", mDisplayId); mInputEventReceiver = mInputMonitor.getInputReceiver(mUiThreadContext.getLooper(), mUiThreadContext.getChoreographer(), this::onInputEvent); // Add a nav bar panel window resetEdgeBackPlugin(); Loading Loading @@ -981,10 +950,9 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack return true; } private boolean isValidTrackpadBackGesture(int displayId) { if (enableMultidisplayTrackpadBackGesture() && displayId != mDisplayId) { //TODO(b/382774299): Handle exclude regions on connected displays return true; private boolean isValidTrackpadBackGesture(boolean isTrackpadEvent) { if (!isTrackpadEvent) { return false; } // for trackpad gestures, unless the whole screen is excluded region, 3-finger swipe // gestures are allowed even if the cursor is in the excluded region. Loading @@ -1001,15 +969,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack private boolean isWithinTouchRegion(MotionEvent ev) { // If the point is inside the PiP or Nav bar overlay excluded bounds, then ignore the back // gesture. Also ignore (for now) if it's not on the main display. // TODO(b/382130680): Implement back gesture handling on connected displays // gesture int x = (int) ev.getX(); int y = (int) ev.getY(); final boolean isInsidePip = mIsInPip && mPipExcludedBounds.contains(x, y); final boolean isInDesktopExcludeRegion = desktopExcludeRegionContains(x, y) && isEdgeResizePermitted(ev); if (isInsidePip || isInDesktopExcludeRegion || mNavBarOverlayExcludedBounds.contains(x, y) || ev.getDisplayId() != mDisplayId) { || mNavBarOverlayExcludedBounds.contains(x, y)) { return false; } Loading Loading @@ -1109,11 +1076,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack // Verify if this is in within the touch region and we aren't in immersive mode, and // either the bouncer is showing or the notification panel is hidden InputMonitorResource inputMonitorResource = mInputMonitorResources.get(ev.getDisplayId()); if (inputMonitorResource != null) { inputMonitorResource.mInputEventReceiver.setBatchingEnabled(false); } mInputEventReceiver.setBatchingEnabled(false); if (mIsTrackpadThreeFingerSwipe) { // Since trackpad gestures don't have zones, this will be determined later by the // direction of the gesture. {@code mIsOnLeftEdge} is set to false to begin with. Loading @@ -1136,7 +1099,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack boolean trackpadGesturesEnabled = (mSysUiFlags & SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED) == 0; mAllowGesture = isBackAllowedCommon && trackpadGesturesEnabled && isValidTrackpadBackGesture(ev.getDisplayId()); && isValidTrackpadBackGesture(true /* isTrackpadEvent */); } else { mAllowGesture = isBackAllowedCommon && !mUsingThreeButtonNav && isWithinInsets && isWithinTouchRegion(ev) && !isButtonPressFromTrackpad(ev); Loading Loading @@ -1247,14 +1210,12 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } private void pilferPointers() { //TODO(b/382774299): Pilfer pointers on the correct display InputMonitorResource inputMonitorResource = mInputMonitorResources.get(mDisplayId); if (inputMonitorResource != null) { if (mInputMonitor != null) { // Capture inputs inputMonitorResource.mInputMonitorCompat.pilferPointers(); mInputMonitor.pilferPointers(); // Notify FalsingManager that an intentional gesture has occurred. mFalsingManager.isFalseTouch(BACK_GESTURE); inputMonitorResource.mInputEventReceiver.setBatchingEnabled(true); mInputEventReceiver.setBatchingEnabled(true); } } Loading Loading @@ -1383,11 +1344,6 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack if (mEdgeBackPlugin != null) { mEdgeBackPlugin.dump(pw); } pw.println(" mInputMonitorResources=" + mInputMonitorResources); for (Map.Entry<Integer, InputMonitorResource> inputMonitorResource : mInputMonitorResources.entrySet()) { inputMonitorResource.getValue().dump("\t", pw); } } private void updateTopActivityPackageName() { Loading Loading @@ -1420,33 +1376,6 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack } } private class InputMonitorResource { private final int mDisplayId; private final InputMonitorCompat mInputMonitorCompat; private final InputChannelCompat.InputEventReceiver mInputEventReceiver; private InputMonitorResource(int displayId) { this.mDisplayId = displayId; mInputMonitorCompat = new InputMonitorCompat("edge-swipe", displayId); mInputEventReceiver = mInputMonitorCompat.getInputReceiver(mUiThreadContext.getLooper(), mUiThreadContext.getChoreographer(), EdgeBackGestureHandler.this::onInputEvent); } public void dispose() { mInputEventReceiver.dispose(); mInputMonitorCompat.dispose(); } public void dump(String prefix, PrintWriter writer) { writer.println(prefix + this); } @Override public String toString() { return "InputMonitorResource (displayId=" + mDisplayId + ")"; } } private static class LogArray extends ArrayDeque<String> { private final int mLength; Loading