summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author arthurhung <arthurhung@google.com> 2020-05-08 17:20:38 +0800
committer arthurhung <arthurhung@google.com> 2020-05-14 11:59:23 +0800
commitd3f17d7df7ca571265c134a0c72e254108d84b76 (patch)
treef7b3be86373f6423ce77db7bb7f4f5bc9e891682
parent6efab8dbcdf9854ba26cb9b06e8b701be3c781d7 (diff)
Pass window type to the InputWindowHandle of embedded window
A windowless SurfaceControl could grant input via IWindowSession.grantInputChannel, but other window may receive the obscured events because of the type value of input window is always 0. The obscured or partially obscured flag indicates that the window received this motion event is wholly or partially obscured by another visible window above it. We have to filter out the trusted overlap so the motion event could properly dispatch to the view if it is a security sensitive application. Bug: 156063505 Test: enter split window mode and check the motion event Change-Id: I10f63ea131a70ee8cc7d5c4b3e5ca4e5f06fdbad
-rw-r--r--core/java/android/view/IWindowSession.aidl2
-rw-r--r--core/java/android/view/WindowlessWindowManager.java4
-rw-r--r--services/core/java/com/android/server/wm/EmbeddedWindowController.java4
-rw-r--r--services/core/java/com/android/server/wm/Session.java10
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java13
5 files changed, 21 insertions, 12 deletions
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 926d8fc5a368..0410c9024dcb 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -336,7 +336,7 @@ interface IWindowSession {
* an input channel where the client can receive input.
*/
void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
- in IBinder hostInputToken, int flags, out InputChannel outInputChannel);
+ in IBinder hostInputToken, int flags, int type, out InputChannel outInputChannel);
/**
* Update the flags on an input channel associated with a particular surface.
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index cd954c41f469..d20ffb3a6ec1 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -143,7 +143,7 @@ public class WindowlessWindowManager implements IWindowSession {
WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0)) {
try {
mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
- outInputChannel);
+ attrs.type, outInputChannel);
} catch (RemoteException e) {
Log.e(TAG, "Failed to grant input to surface: ", e);
}
@@ -432,7 +432,7 @@ public class WindowlessWindowManager implements IWindowSession {
@Override
public void grantInputChannel(int displayId, SurfaceControl surface, IWindow window,
- IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IBinder hostInputToken, int flags, int type, InputChannel outInputChannel) {
}
@Override
diff --git a/services/core/java/com/android/server/wm/EmbeddedWindowController.java b/services/core/java/com/android/server/wm/EmbeddedWindowController.java
index 9bbd4cd0778a..5a2484735fb9 100644
--- a/services/core/java/com/android/server/wm/EmbeddedWindowController.java
+++ b/services/core/java/com/android/server/wm/EmbeddedWindowController.java
@@ -135,6 +135,7 @@ class EmbeddedWindowController {
final int mOwnerPid;
final WindowManagerService mWmService;
InputChannel mInputChannel;
+ final int mWindowType;
/**
* @param clientToken client token used to clean up the map if the embedding process dies
@@ -146,7 +147,7 @@ class EmbeddedWindowController {
* @param ownerPid calling pid used for anr blaming
*/
EmbeddedWindow(WindowManagerService service, IWindow clientToken,
- WindowState hostWindowState, int ownerUid, int ownerPid) {
+ WindowState hostWindowState, int ownerUid, int ownerPid, int windowType) {
mWmService = service;
mClient = clientToken;
mHostWindowState = hostWindowState;
@@ -154,6 +155,7 @@ class EmbeddedWindowController {
: null;
mOwnerUid = ownerUid;
mOwnerPid = ownerPid;
+ mWindowType = windowType;
}
String getName() {
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index bf20cb907b71..6f5c440c9f83 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -661,17 +661,23 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
@Override
public void grantInputChannel(int displayId, SurfaceControl surface,
- IWindow window, IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IWindow window, IBinder hostInputToken, int flags, int type,
+ InputChannel outInputChannel) {
if (hostInputToken == null && !mCanAddInternalSystemWindow) {
// Callers without INTERNAL_SYSTEM_WINDOW permission cannot grant input channel to
// embedded windows without providing a host window input token
throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
}
+ if (!mCanAddInternalSystemWindow && type != 0) {
+ Slog.w(TAG_WM, "Requires INTERNAL_SYSTEM_WINDOW permission if assign type to"
+ + " input");
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
mService.grantInputChannel(mUid, mPid, displayId, surface, window, hostInputToken,
- flags, outInputChannel);
+ flags, mCanAddInternalSystemWindow ? type : 0, outInputChannel);
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 4c1d6f3b9892..cf1def992590 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -8027,14 +8027,15 @@ public class WindowManagerService extends IWindowManager.Stub
* views.
*/
void grantInputChannel(int callingUid, int callingPid, int displayId, SurfaceControl surface,
- IWindow window, IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IWindow window, IBinder hostInputToken, int flags, int type,
+ InputChannel outInputChannel) {
final InputApplicationHandle applicationHandle;
final String name;
final InputChannel clientChannel;
synchronized (mGlobalLock) {
EmbeddedWindowController.EmbeddedWindow win =
new EmbeddedWindowController.EmbeddedWindow(this, window,
- mInputToWindowMap.get(hostInputToken), callingUid, callingPid);
+ mInputToWindowMap.get(hostInputToken), callingUid, callingPid, type);
clientChannel = win.openInputChannel();
mEmbeddedWindowController.add(clientChannel.getToken(), win);
applicationHandle = win.getApplicationHandle();
@@ -8042,7 +8043,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
updateInputChannel(clientChannel.getToken(), callingUid, callingPid, displayId, surface,
- name, applicationHandle, flags, null /* region */);
+ name, applicationHandle, flags, type, null /* region */);
clientChannel.transferTo(outInputChannel);
clientChannel.dispose();
@@ -8050,7 +8051,7 @@ public class WindowManagerService extends IWindowManager.Stub
private void updateInputChannel(IBinder channelToken, int callingUid, int callingPid,
int displayId, SurfaceControl surface, String name,
- InputApplicationHandle applicationHandle, int flags, Region region) {
+ InputApplicationHandle applicationHandle, int flags, int type, Region region) {
InputWindowHandle h = new InputWindowHandle(applicationHandle, displayId);
h.token = channelToken;
h.name = name;
@@ -8058,7 +8059,7 @@ public class WindowManagerService extends IWindowManager.Stub
final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE
| LayoutParams.FLAG_SLIPPERY);
h.layoutParamsFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | sanitizedFlags;
- h.layoutParamsType = 0;
+ h.layoutParamsType = type;
h.dispatchingTimeoutNanos = DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
h.canReceiveKeys = false;
h.hasFocus = false;
@@ -8105,7 +8106,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
updateInputChannel(channelToken, win.mOwnerUid, win.mOwnerPid, displayId, surface, name,
- applicationHandle, flags, region);
+ applicationHandle, flags, win.mWindowType, region);
}
/** Return whether layer tracing is enabled */