Loading core/java/android/view/InputWindowHandle.java +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public final class InputWindowHandle { InputConfig.INTERCEPTS_STYLUS, InputConfig.CLONE, InputConfig.SENSITIVE_FOR_PRIVACY, InputConfig.DISPLAY_TOPOLOGY_AWARE, }) public @interface InputConfigFlags {} Loading core/java/android/view/WindowManager.java +20 −1 Original line number Diff line number Diff line Loading @@ -4580,6 +4580,20 @@ public interface WindowManager extends ViewManager { */ public static final int INPUT_FEATURE_SENSITIVE_FOR_PRIVACY = 1 << 3; /** * Input feature used to indicate that this window is display topology aware. * <p> * Using this flag will allow window to receive gestures that can cross display boundaries. * Such windows can receive input event stream containing events with varying displayIds * in the corresponding coordinate space when the cursor crosses display boundary. * <p> * * @hide */ @RequiresPermission(permission.MANAGE_DISPLAYS) public static final int INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE = 1 << 4; /** * An internal annotation for flags that can be specified to {@link #inputFeatures}. * Loading @@ -4592,7 +4606,8 @@ public interface WindowManager extends ViewManager { INPUT_FEATURE_NO_INPUT_CHANNEL, INPUT_FEATURE_DISABLE_USER_ACTIVITY, INPUT_FEATURE_SPY, INPUT_FEATURE_SENSITIVE_FOR_PRIVACY INPUT_FEATURE_SENSITIVE_FOR_PRIVACY, INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE }) public @interface InputFeatureFlags { } Loading Loading @@ -6280,6 +6295,10 @@ public interface WindowManager extends ViewManager { inputFeatures &= ~INPUT_FEATURE_SPY; features.add("INPUT_FEATURE_SPY"); } if ((inputFeatures & INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE) != 0) { inputFeatures &= ~INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; features.add("INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE"); } if (inputFeatures != 0) { features.add(Integer.toHexString(inputFeatures)); } Loading services/core/java/com/android/server/wm/InputConfigAdapter.java +4 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ class InputConfigAdapter { InputConfig.SPY, false /* inverted */), new FlagMapping( LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY, InputConfig.SENSITIVE_FOR_PRIVACY, false /* inverted */) InputConfig.SENSITIVE_FOR_PRIVACY, false /* inverted */), new FlagMapping( LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE, InputConfig.DISPLAY_TOPOLOGY_AWARE, false /* inverted */) }; @InputConfigFlags Loading services/core/java/com/android/server/wm/WindowManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SPY; Loading Loading @@ -9443,6 +9444,16 @@ public class WindowManagerService extends IWindowManager.Stub + "' because it isn't a trusted overlay"); return inputFeatures & ~INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; } if ((inputFeatures & INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE) != 0) { final int permissionResult = mContext.checkPermission( permission.MANAGE_DISPLAYS, callingPid, callingUid); if (permissionResult != PackageManager.PERMISSION_GRANTED) { throw new SecurityException( "Cannot use INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE from '" + windowName + "' because it doesn't the have MANAGE_DISPLAYS permission"); } } return inputFeatures; } Loading services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.Display.FLAG_OWN_FOCUS; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SPY; import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE; Loading Loading @@ -1129,6 +1130,24 @@ public class WindowManagerServiceTests extends WindowTestsBase { argThat(h -> (h.inputConfig & InputConfig.SPY) == InputConfig.SPY)); } @Test public void testGrantInputChannel_sanitizeDisplayTopologyAwareForManageDisplaysPermission() { final Session session = mock(Session.class); final int callingUid = Process.FIRST_APPLICATION_UID; final int callingPid = 1234; final SurfaceControl surfaceControl = mock(SurfaceControl.class); final IBinder window = new Binder(); final InputTransferToken inputTransferToken = mock(InputTransferToken.class); final InputChannel inputChannel = new InputChannel(); assertThrows(SecurityException.class, () -> mWm.grantInputChannel(session, callingUid, callingPid, DEFAULT_DISPLAY, surfaceControl, window, null /* hostInputToken */, 0 /* flags */, PRIVATE_FLAG_TRUSTED_OVERLAY, INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE, TYPE_APPLICATION, null /* windowToken */, inputTransferToken, "TestInputChannel", inputChannel)); } @Test public void testUpdateInputChannel_sanitizeSpyWindowForApplications() { final Session session = mock(Session.class); Loading Loading
core/java/android/view/InputWindowHandle.java +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public final class InputWindowHandle { InputConfig.INTERCEPTS_STYLUS, InputConfig.CLONE, InputConfig.SENSITIVE_FOR_PRIVACY, InputConfig.DISPLAY_TOPOLOGY_AWARE, }) public @interface InputConfigFlags {} Loading
core/java/android/view/WindowManager.java +20 −1 Original line number Diff line number Diff line Loading @@ -4580,6 +4580,20 @@ public interface WindowManager extends ViewManager { */ public static final int INPUT_FEATURE_SENSITIVE_FOR_PRIVACY = 1 << 3; /** * Input feature used to indicate that this window is display topology aware. * <p> * Using this flag will allow window to receive gestures that can cross display boundaries. * Such windows can receive input event stream containing events with varying displayIds * in the corresponding coordinate space when the cursor crosses display boundary. * <p> * * @hide */ @RequiresPermission(permission.MANAGE_DISPLAYS) public static final int INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE = 1 << 4; /** * An internal annotation for flags that can be specified to {@link #inputFeatures}. * Loading @@ -4592,7 +4606,8 @@ public interface WindowManager extends ViewManager { INPUT_FEATURE_NO_INPUT_CHANNEL, INPUT_FEATURE_DISABLE_USER_ACTIVITY, INPUT_FEATURE_SPY, INPUT_FEATURE_SENSITIVE_FOR_PRIVACY INPUT_FEATURE_SENSITIVE_FOR_PRIVACY, INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE }) public @interface InputFeatureFlags { } Loading Loading @@ -6280,6 +6295,10 @@ public interface WindowManager extends ViewManager { inputFeatures &= ~INPUT_FEATURE_SPY; features.add("INPUT_FEATURE_SPY"); } if ((inputFeatures & INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE) != 0) { inputFeatures &= ~INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; features.add("INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE"); } if (inputFeatures != 0) { features.add(Integer.toHexString(inputFeatures)); } Loading
services/core/java/com/android/server/wm/InputConfigAdapter.java +4 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ class InputConfigAdapter { InputConfig.SPY, false /* inverted */), new FlagMapping( LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY, InputConfig.SENSITIVE_FOR_PRIVACY, false /* inverted */) InputConfig.SENSITIVE_FOR_PRIVACY, false /* inverted */), new FlagMapping( LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE, InputConfig.DISPLAY_TOPOLOGY_AWARE, false /* inverted */) }; @InputConfigFlags Loading
services/core/java/com/android/server/wm/WindowManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SPY; Loading Loading @@ -9443,6 +9444,16 @@ public class WindowManagerService extends IWindowManager.Stub + "' because it isn't a trusted overlay"); return inputFeatures & ~INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; } if ((inputFeatures & INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE) != 0) { final int permissionResult = mContext.checkPermission( permission.MANAGE_DISPLAYS, callingPid, callingUid); if (permissionResult != PackageManager.PERMISSION_GRANTED) { throw new SecurityException( "Cannot use INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE from '" + windowName + "' because it doesn't the have MANAGE_DISPLAYS permission"); } } return inputFeatures; } Loading
services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.view.Display.FLAG_OWN_FOCUS; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SENSITIVE_FOR_PRIVACY; import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_SPY; import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE; Loading Loading @@ -1129,6 +1130,24 @@ public class WindowManagerServiceTests extends WindowTestsBase { argThat(h -> (h.inputConfig & InputConfig.SPY) == InputConfig.SPY)); } @Test public void testGrantInputChannel_sanitizeDisplayTopologyAwareForManageDisplaysPermission() { final Session session = mock(Session.class); final int callingUid = Process.FIRST_APPLICATION_UID; final int callingPid = 1234; final SurfaceControl surfaceControl = mock(SurfaceControl.class); final IBinder window = new Binder(); final InputTransferToken inputTransferToken = mock(InputTransferToken.class); final InputChannel inputChannel = new InputChannel(); assertThrows(SecurityException.class, () -> mWm.grantInputChannel(session, callingUid, callingPid, DEFAULT_DISPLAY, surfaceControl, window, null /* hostInputToken */, 0 /* flags */, PRIVATE_FLAG_TRUSTED_OVERLAY, INPUT_FEATURE_DISPLAY_TOPOLOGY_AWARE, TYPE_APPLICATION, null /* windowToken */, inputTransferToken, "TestInputChannel", inputChannel)); } @Test public void testUpdateInputChannel_sanitizeSpyWindowForApplications() { final Session session = mock(Session.class); Loading