Merge "Enable privileged apps to set unrestricted gesture exclusion" into tm-qpr-dev
This commit is contained in:
@@ -2366,6 +2366,14 @@ public interface WindowManager extends ViewManager {
|
||||
@RequiresPermission(permission.INTERNAL_SYSTEM_WINDOW)
|
||||
public static final int SYSTEM_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
|
||||
|
||||
/**
|
||||
* Flag to allow this window to have unrestricted gesture exclusion.
|
||||
*
|
||||
* @see View#setSystemGestureExclusionRects(List)
|
||||
* @hide
|
||||
*/
|
||||
public static final int PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION = 0x00000020;
|
||||
|
||||
/**
|
||||
* Never animate position changes of the window.
|
||||
*
|
||||
@@ -2586,6 +2594,7 @@ public interface WindowManager extends ViewManager {
|
||||
PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
|
||||
PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
|
||||
SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
|
||||
PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
|
||||
PRIVATE_FLAG_NO_MOVE_ANIMATION,
|
||||
PRIVATE_FLAG_COMPATIBLE_WINDOW,
|
||||
PRIVATE_FLAG_SYSTEM_ERROR,
|
||||
@@ -2632,6 +2641,10 @@ public interface WindowManager extends ViewManager {
|
||||
mask = SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
|
||||
equals = SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
|
||||
name = "SHOW_FOR_ALL_USERS"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
|
||||
equals = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
|
||||
name = "UNRESTRICTED_GESTURE_EXCLUSION"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = PRIVATE_FLAG_NO_MOVE_ANIMATION,
|
||||
equals = PRIVATE_FLAG_NO_MOVE_ANIMATION,
|
||||
|
||||
@@ -6498,6 +6498,13 @@
|
||||
<permission android:name="android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS"
|
||||
android:protectionLevel="signature|privileged" />
|
||||
|
||||
<!-- Allows an app to set gesture exclusion without restrictions on the vertical extent of the
|
||||
exclusions (see {@link android.view.View#setSystemGestureExclusionRects}).
|
||||
@hide
|
||||
-->
|
||||
<permission android:name="android.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION"
|
||||
android:protectionLevel="signature|privileged|recents" />
|
||||
|
||||
<!-- @SystemApi Allows TV input apps and TV apps to use TIS extension interfaces for
|
||||
domain-specific features.
|
||||
<p>Protection level: signature|privileged|vendorPrivileged
|
||||
|
||||
@@ -67,6 +67,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
|
||||
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
|
||||
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
@@ -5574,11 +5575,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
private static boolean needsGestureExclusionRestrictions(WindowState win,
|
||||
boolean ignoreRequest) {
|
||||
final int type = win.mAttrs.type;
|
||||
final int privateFlags = win.mAttrs.privateFlags;
|
||||
final boolean stickyHideNav =
|
||||
!win.getRequestedVisibility(ITYPE_NAVIGATION_BAR)
|
||||
&& win.mAttrs.insetsFlags.behavior == BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
|
||||
return (!stickyHideNav || ignoreRequest) && type != TYPE_INPUT_METHOD
|
||||
&& type != TYPE_NOTIFICATION_SHADE && win.getActivityType() != ACTIVITY_TYPE_HOME;
|
||||
&& type != TYPE_NOTIFICATION_SHADE && win.getActivityType() != ACTIVITY_TYPE_HOME
|
||||
&& (privateFlags & PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
|
||||
@@ -974,6 +975,10 @@ public class DisplayPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
if (!win.mSession.mCanSetUnrestrictedGestureExclusion) {
|
||||
attrs.privateFlags &= ~PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
}
|
||||
|
||||
// Check if alternate bars positions were updated.
|
||||
if (mStatusBarAlt == win) {
|
||||
mStatusBarAltPosition = getAltBarPosition(attrs);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.server.wm;
|
||||
import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
import static android.Manifest.permission.HIDE_OVERLAY_WINDOWS;
|
||||
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
|
||||
import static android.Manifest.permission.SET_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
import static android.Manifest.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS;
|
||||
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
|
||||
import static android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY;
|
||||
@@ -109,6 +110,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
|
||||
|
||||
final boolean mCanCreateSystemApplicationOverlay;
|
||||
final boolean mCanHideNonSystemOverlayWindows;
|
||||
final boolean mCanSetUnrestrictedGestureExclusion;
|
||||
private AlertWindowNotification mAlertWindowNotification;
|
||||
private boolean mShowingAlertWindowNotificationAllowed;
|
||||
private boolean mClientDead = false;
|
||||
@@ -139,6 +141,9 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
|
||||
mSetsUnrestrictedKeepClearAreas =
|
||||
service.mContext.checkCallingOrSelfPermission(SET_UNRESTRICTED_KEEP_CLEAR_AREAS)
|
||||
== PERMISSION_GRANTED;
|
||||
mCanSetUnrestrictedGestureExclusion =
|
||||
service.mContext.checkCallingOrSelfPermission(SET_UNRESTRICTED_GESTURE_EXCLUSION)
|
||||
== PERMISSION_GRANTED;
|
||||
mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications;
|
||||
mDragDropController = mService.mDragDropController;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -47,8 +47,10 @@ import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
@@ -1402,6 +1404,28 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
win.setHasSurface(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateSystemGestureExclusion_unrestricted() throws Exception {
|
||||
mWm.mConstants.mSystemGestureExcludedByPreQStickyImmersive = true;
|
||||
|
||||
final DisplayContent dc = createNewDisplay();
|
||||
final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "win");
|
||||
win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR;
|
||||
win.getAttrs().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
win.getAttrs().privateFlags |= PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
win.setSystemGestureExclusion(Collections.singletonList(dc.getBounds()));
|
||||
|
||||
performLayout(dc);
|
||||
|
||||
win.setHasSurface(true);
|
||||
|
||||
final Region expected = Region.obtain();
|
||||
expected.set(dc.getBounds());
|
||||
assertEquals(expected, calculateSystemGestureExclusion(dc));
|
||||
|
||||
win.setHasSurface(false);
|
||||
}
|
||||
|
||||
@UseTestDisplay(addWindows = { W_ABOVE_ACTIVITY, W_ACTIVITY})
|
||||
@Test
|
||||
public void testRequestResizeForEmptyFrames() {
|
||||
|
||||
Reference in New Issue
Block a user