Java Code Examples for android.view.InputChannel#openInputChannelPair()

The following examples show how to use android.view.InputChannel#openInputChannelPair() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TvInputManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void createSessionInternalLocked(ITvInputService service, IBinder sessionToken,
        int userId) {
    UserState userState = getOrCreateUserStateLocked(userId);
    SessionState sessionState = userState.sessionStateMap.get(sessionToken);
    if (DEBUG) {
        Slog.d(TAG, "createSessionInternalLocked(inputId=" + sessionState.inputId + ")");
    }
    InputChannel[] channels = InputChannel.openInputChannelPair(sessionToken.toString());

    // Set up a callback to send the session token.
    ITvInputSessionCallback callback = new SessionCallback(sessionState, channels);

    // Create a session. When failed, send a null token immediately.
    try {
        if (sessionState.isRecordingSession) {
            service.createRecordingSession(callback, sessionState.inputId);
        } else {
            service.createSession(channels[1], callback, sessionState.inputId);
        }
    } catch (RemoteException e) {
        Slog.e(TAG, "error in createSession", e);
        removeSessionStateLocked(sessionToken, userId);
        sendSessionTokenToClientLocked(sessionState.client, sessionState.inputId, null,
                null, sessionState.seq);
    }
    channels[1].dispose();
}
 
Example 2
Source File: InputManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an input channel that will receive all input from the input dispatcher.
 * @param inputChannelName The input channel name.
 * @return The input channel.
 */
public InputChannel monitorInput(String inputChannelName) {
    if (inputChannelName == null) {
        throw new IllegalArgumentException("inputChannelName must not be null.");
    }

    InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName);
    nativeRegisterInputChannel(mPtr, inputChannels[0], null, true);
    inputChannels[0].dispose(); // don't need to retain the Java object reference
    return inputChannels[1];
}
 
Example 3
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 5 votes vote down vote up
void requestClientSessionLocked(ClientState cs) {
    if (!cs.sessionRequested) {
        if (DEBUG) Slog.v(TAG, "Creating new session for client " + cs);
        InputChannel[] channels = InputChannel.openInputChannelPair(cs.toString());
        cs.sessionRequested = true;
        executeOrSendMessage(mCurMethod, mCaller.obtainMessageOOO(
                MSG_CREATE_SESSION, mCurMethod, channels[1],
                new MethodCallback(this, mCurMethod, channels[0])));
    }
}
 
Example 4
Source File: InputConsumerImpl.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
InputConsumerImpl(WindowManagerService service, IBinder token, String name,
        InputChannel inputChannel, int clientPid, UserHandle clientUser) {
    mService = service;
    mToken = token;
    mName = name;
    mClientPid = clientPid;
    mClientUser = clientUser;

    InputChannel[] channels = InputChannel.openInputChannelPair(name);
    mServerChannel = channels[0];
    if (inputChannel != null) {
        channels[1].transferTo(inputChannel);
        channels[1].dispose();
        mClientChannel = inputChannel;
    } else {
        mClientChannel = channels[1];
    }
    mService.mInputManager.registerInputChannel(mServerChannel, null);

    mApplicationHandle = new InputApplicationHandle(null);
    mApplicationHandle.name = name;
    mApplicationHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

    mWindowHandle = new InputWindowHandle(mApplicationHandle, null, null,
            Display.DEFAULT_DISPLAY);
    mWindowHandle.name = name;
    mWindowHandle.inputChannel = mServerChannel;
    mWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
    mWindowHandle.layer = getLayerLw(mWindowHandle.layoutParamsType);
    mWindowHandle.layoutParamsFlags = 0;
    mWindowHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mWindowHandle.visible = true;
    mWindowHandle.canReceiveKeys = false;
    mWindowHandle.hasFocus = false;
    mWindowHandle.hasWallpaper = false;
    mWindowHandle.paused = false;
    mWindowHandle.ownerPid = Process.myPid();
    mWindowHandle.ownerUid = Process.myUid();
    mWindowHandle.inputFeatures = 0;
    mWindowHandle.scaleFactor = 1.0f;
}
 
Example 5
Source File: TaskPositioner.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * @param display The Display that the window being dragged is on.
 */
void register(DisplayContent displayContent) {
    final Display display = displayContent.getDisplay();

    if (DEBUG_TASK_POSITIONING) {
        Slog.d(TAG, "Registering task positioner");
    }

    if (mClientChannel != null) {
        Slog.e(TAG, "Task positioner already registered");
        return;
    }

    mDisplay = display;
    mDisplay.getMetrics(mDisplayMetrics);
    final InputChannel[] channels = InputChannel.openInputChannelPair(TAG);
    mServerChannel = channels[0];
    mClientChannel = channels[1];
    mService.mInputManager.registerInputChannel(mServerChannel, null);

    mInputEventReceiver = new WindowPositionerEventReceiver(
            mClientChannel, mService.mAnimationHandler.getLooper(),
            mService.mAnimator.getChoreographer());

    mDragApplicationHandle = new InputApplicationHandle(null);
    mDragApplicationHandle.name = TAG;
    mDragApplicationHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

    mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null, null,
            mDisplay.getDisplayId());
    mDragWindowHandle.name = TAG;
    mDragWindowHandle.inputChannel = mServerChannel;
    mDragWindowHandle.layer = mService.getDragLayerLocked();
    mDragWindowHandle.layoutParamsFlags = 0;
    mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
    mDragWindowHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mDragWindowHandle.visible = true;
    mDragWindowHandle.canReceiveKeys = false;
    mDragWindowHandle.hasFocus = true;
    mDragWindowHandle.hasWallpaper = false;
    mDragWindowHandle.paused = false;
    mDragWindowHandle.ownerPid = Process.myPid();
    mDragWindowHandle.ownerUid = Process.myUid();
    mDragWindowHandle.inputFeatures = 0;
    mDragWindowHandle.scaleFactor = 1.0f;

    // The drag window cannot receive new touches.
    mDragWindowHandle.touchableRegion.setEmpty();

    // The drag window covers the entire display
    mDragWindowHandle.frameLeft = 0;
    mDragWindowHandle.frameTop = 0;
    final Point p = new Point();
    mDisplay.getRealSize(p);
    mDragWindowHandle.frameRight = p.x;
    mDragWindowHandle.frameBottom = p.y;

    // Pause rotations before a drag.
    if (DEBUG_ORIENTATION) {
        Slog.d(TAG, "Pausing rotation during re-position");
    }
    mService.pauseRotationLocked();

    mSideMargin = dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
    mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, mDisplayMetrics);
    mMinVisibleHeight = dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, mDisplayMetrics);
    mDisplay.getRealSize(mMaxVisibleSize);

    mDragEnded = false;
}
 
Example 6
Source File: DragState.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
InputInterceptor(Display display) {
    InputChannel[] channels = InputChannel.openInputChannelPair("drag");
    mServerChannel = channels[0];
    mClientChannel = channels[1];
    mService.mInputManager.registerInputChannel(mServerChannel, null);
    mInputEventReceiver = new DragInputEventReceiver(mClientChannel,
            mService.mH.getLooper(), mDragDropController);

    mDragApplicationHandle = new InputApplicationHandle(null);
    mDragApplicationHandle.name = "drag";
    mDragApplicationHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

    mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null, null,
            display.getDisplayId());
    mDragWindowHandle.name = "drag";
    mDragWindowHandle.inputChannel = mServerChannel;
    mDragWindowHandle.layer = getDragLayerLocked();
    mDragWindowHandle.layoutParamsFlags = 0;
    mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
    mDragWindowHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mDragWindowHandle.visible = true;
    mDragWindowHandle.canReceiveKeys = false;
    mDragWindowHandle.hasFocus = true;
    mDragWindowHandle.hasWallpaper = false;
    mDragWindowHandle.paused = false;
    mDragWindowHandle.ownerPid = Process.myPid();
    mDragWindowHandle.ownerUid = Process.myUid();
    mDragWindowHandle.inputFeatures = 0;
    mDragWindowHandle.scaleFactor = 1.0f;

    // The drag window cannot receive new touches.
    mDragWindowHandle.touchableRegion.setEmpty();

    // The drag window covers the entire display
    mDragWindowHandle.frameLeft = 0;
    mDragWindowHandle.frameTop = 0;
    mDragWindowHandle.frameRight = mDisplaySize.x;
    mDragWindowHandle.frameBottom = mDisplaySize.y;

    // Pause rotations before a drag.
    if (DEBUG_ORIENTATION) {
        Slog.d(TAG_WM, "Pausing rotation during drag");
    }
    mService.pauseRotationLocked();
}