Merge "DO NOT MERGE: WM: Only allow system to use NO_INPUT_CHANNEL." into pi-dev

This commit is contained in:
Rob Carr
2021-01-26 19:27:19 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 7 deletions

View File

@@ -103,6 +103,13 @@ public final class InputChannel implements Parcelable {
return name != null ? name : "uninitialized";
}
/**
* @hide
*/
public boolean isValid() {
return mPtr != 0;
}
/**
* Disposes the input channel.
* Explicitly releases the reference this object is holding on the input channel.

View File

@@ -745,10 +745,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 {
@@ -838,7 +835,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);

View File

@@ -1348,8 +1348,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);
}