Fix Accessibility Menu Window breaking gesture exclusion API
The gesture exclusion region set by the Accessibility Menu Window counts towards the global exclusion limit. With a few menu items, there is no gesture exclusion margin left to be used by apps.
To fix this, the PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION flag is set on the Accessibility Menu Window. This ensures that the exclusion region is not counted towards the global limit.
Additionally, this fixes the problem that the Accessibility Menu Window itself runs out of exclusion margin when it has many menu items. In that case, it's easy to trigger the back gesture when the intention is to drag the window.
Bug: 378425927
Test: Manual, i.e. verified that app's exclusion regions are unaffected by the presence of the Accessibility Menu. Also verified that dragging the Accessibility Menu never triggers the back gesture.
Flag: EXEMPT bugfix
Change-Id: I8f4171b92acfdeffd0e1bc383587320e15c9ef71
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
index 45952ea..3eadf3b 100644
--- a/data/etc/com.android.systemui.xml
+++ b/data/etc/com.android.systemui.xml
@@ -95,5 +95,6 @@
<permission name="android.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND" />
<permission name="android.permission.OVERRIDE_SYSTEM_KEY_BEHAVIOR_IN_FOCUSED_WINDOW"/>
<permission name="android.permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE" />
+ <permission name="android.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION" />
</privapp-permissions>
</permissions>
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index b53198d..e5e8418 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -392,6 +392,9 @@
<!-- To be able to decipher default applications for certain roles in shortcut helper -->
<uses-permission android:name="android.permission.MANAGE_DEFAULT_APPLICATIONS" />
+ <!-- To be able to set unrestricted system gesture exclusion rects -->
+ <uses-permission android:name="android.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION"/>
+
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
index e7470a3..102efcf 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
@@ -17,6 +17,7 @@
package com.android.systemui.accessibility.floatingmenu;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
import android.content.Context;
@@ -90,9 +91,11 @@
WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
+ params.setTitle("FloatingMenu");
params.receiveInsetsIgnoringZOrder = true;
params.privateFlags |=
- PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION | SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
+ PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION | SYSTEM_FLAG_SHOW_FOR_ALL_USERS
+ | PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
params.windowAnimations = android.R.style.Animation_Translucent;
// Insets are configured to allow the menu to display over navigation and system bars.
params.setFitInsetsTypes(0);