summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Carr <racarr@google.com>2020-12-11 12:59:08 -0800
committerAnis Assi <anisassi@google.com>2021-02-05 10:36:16 -0800
commit7d142d2a2244aa86e796523dd36456c8b77336df (patch)
tree7c174978c69fddbca89a99faf919d6abc852e7cf
parent496aeb507fd5dd12b55b960ff4d6c48d32bde996 (diff)
downloadbase-7d142d2a2244aa86e796523dd36456c8b77336df.tar.gz
DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL.
NO_INPUT_CHANNEL is a hidden WM flag that allows creation of a window without an input channel. Unfortunately in releases prior to Android R this would allow creation of a Window which will not be known to the InputDispatcher at all. This means that the logic generating FLAG_OBSCURED will work and a window will be able to overlay another window without the overlayed window being notified. In Android R and later this isn't a problem as the InputDispatcher is informed of all windows, input channel or not. For past Android releases, this patch disables NO_INPUT_CHANNEL for use outside of the WM. Bug: 152064592 Test: Existing tests pass Change-Id: I7e1f45cba139eab92e7df88d1e052baba0ae2cc6 (cherry picked from commit 9661bf7a40d33470bcd35f15758ab71c7c635c63)
-rw-r--r--core/java/android/view/InputChannel.java7
-rw-r--r--core/java/android/view/ViewRootImpl.java7
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java9
3 files changed, 16 insertions, 7 deletions
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index de195ae524c8..6223bc10222c 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -104,6 +104,13 @@ public final class InputChannel implements Parcelable {
}
/**
+ * @hide
+ */
+ public boolean isValid() {
+ return mPtr != 0;
+ }
+
+ /**
* Disposes the input channel.
* Explicitly releases the reference this object is holding on the input channel.
* When all references are released, the input channel will be closed.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 3f1ea34c37ab..51d6c09fcc77 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -713,10 +713,7 @@ public final class ViewRootImpl implements ViewParent,
// manager, to make sure we do the relayout before receiving
// any other events from the system.
requestLayout();
- if ((mWindowAttributes.inputFeatures
- & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) {
- mInputChannel = new InputChannel();
- }
+ mInputChannel = new InputChannel();
mForceDecorViewVisibility = (mWindowAttributes.privateFlags
& PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY) != 0;
try {
@@ -805,7 +802,7 @@ public final class ViewRootImpl implements ViewParent,
mInputQueueCallback =
((RootViewSurfaceTaker)view).willYouTakeTheInputQueue();
}
- if (mInputChannel != null) {
+ if (mInputChannel.isValid()) {
if (mInputQueueCallback != null) {
mInputQueue = new InputQueue();
mInputQueueCallback.onInputQueueCreated(mInputQueue);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index c0e56688bf8a..756af3cad50e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1413,8 +1413,13 @@ public class WindowManagerService extends IWindowManager.Stub
return res;
}
- final boolean openInputChannels = (outInputChannel != null
- && (attrs.inputFeatures & INPUT_FEATURE_NO_INPUT_CHANNEL) == 0);
+ boolean openInputChannels = (outInputChannel != null
+ && (attrs.inputFeatures & INPUT_FEATURE_NO_INPUT_CHANNEL) == 0);
+ if (callingUid != SYSTEM_UID) {
+ Slog.e(TAG_WM,
+ "App trying to use insecure INPUT_FEATURE_NO_INPUT_CHANNEL flag. Ignoring");
+ openInputChannels = true;
+ }
if (openInputChannels) {
win.openInputChannel(outInputChannel);
}