Merge "Add class docs for InputMonitor." into qt-dev

This commit is contained in:
Michael Wright
2019-04-12 21:39:51 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 5 deletions

View File

@@ -22,6 +22,13 @@ import android.os.Parcelable;
import android.os.RemoteException;
/**
* An {@code InputMonitor} allows privileged applications and components to monitor streams of
* {@link InputEvent}s without having to be the designated recipient for the event.
*
* For example, focus dispatched events would normally only go to the focused window on the
* targeted display, but an {@code InputMonitor} will also receive a copy of that event if they're
* registered to monitor that type of event on the targeted display.
*
* @hide
*/
public final class InputMonitor implements Parcelable {

View File

@@ -523,11 +523,17 @@ public class InputManagerService extends IInputManager.Stub
}
InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName);
InputMonitorHost host = new InputMonitorHost(inputChannels[0]);
inputChannels[0].setToken(host.asBinder());
nativeRegisterInputMonitor(mPtr, inputChannels[0], displayId, true /*isGestureMonitor*/);
return new InputMonitor(inputChannelName, inputChannels[1], host);
final long ident = Binder.clearCallingIdentity();
try {
InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName);
InputMonitorHost host = new InputMonitorHost(inputChannels[0]);
inputChannels[0].setToken(host.asBinder());
nativeRegisterInputMonitor(mPtr, inputChannels[0], displayId,
true /*isGestureMonitor*/);
return new InputMonitor(inputChannelName, inputChannels[1], host);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
/**