Search in sources :

Example 6 with InputChannel

use of android.view.InputChannel in project android_frameworks_base by DirtyUnicorns.

the class InputMonitor method updateInputWindowsLw.

/* Updates the cached window information provided to the input dispatcher. */
public void updateInputWindowsLw(boolean force) {
    if (!force && !mUpdateInputWindowsNeeded) {
        return;
    }
    mUpdateInputWindowsNeeded = false;
    if (false)
        Slog.d(TAG_WM, ">>>>>> ENTERED updateInputWindowsLw");
    // Populate the input window list with information about all of the windows that
    // could potentially receive input.
    // As an optimization, we could try to prune the list of windows but this turns
    // out to be difficult because only the native code knows for sure which window
    // currently has touch focus.
    boolean disableWallpaperTouchEvents = false;
    // If there's a drag in flight, provide a pseudowindow to catch drag input
    final boolean inDrag = (mService.mDragState != null);
    if (inDrag) {
        if (DEBUG_DRAG) {
            Log.d(TAG_WM, "Inserting drag window");
        }
        final InputWindowHandle dragWindowHandle = mService.mDragState.mDragWindowHandle;
        if (dragWindowHandle != null) {
            addInputWindowHandleLw(dragWindowHandle);
        } else {
            Slog.w(TAG_WM, "Drag is in progress but there is no " + "drag window handle.");
        }
    }
    final boolean inPositioning = (mService.mTaskPositioner != null);
    if (inPositioning) {
        if (DEBUG_TASK_POSITIONING) {
            Log.d(TAG_WM, "Inserting window handle for repositioning");
        }
        final InputWindowHandle dragWindowHandle = mService.mTaskPositioner.mDragWindowHandle;
        if (dragWindowHandle != null) {
            addInputWindowHandleLw(dragWindowHandle);
        } else {
            Slog.e(TAG_WM, "Repositioning is in progress but there is no drag window handle.");
        }
    }
    boolean addInputConsumerHandle = mService.mInputConsumer != null;
    boolean addWallpaperInputConsumerHandle = mService.mWallpaperInputConsumer != null;
    // Add all windows on the default display.
    final int numDisplays = mService.mDisplayContents.size();
    final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
    for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
        final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
        final WindowList windows = displayContent.getWindowList();
        for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
            final WindowState child = windows.get(winNdx);
            final InputChannel inputChannel = child.mInputChannel;
            final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
            if (inputChannel == null || inputWindowHandle == null || child.mRemoved || child.isAdjustedForMinimizedDock()) {
                // Skip this window because it cannot possibly receive input.
                continue;
            }
            if (addInputConsumerHandle && inputWindowHandle.layer <= mService.mInputConsumer.mWindowHandle.layer) {
                addInputWindowHandleLw(mService.mInputConsumer.mWindowHandle);
                addInputConsumerHandle = false;
            }
            if (addWallpaperInputConsumerHandle) {
                if (child.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER) {
                    // Add the wallpaper input consumer above the first wallpaper window.
                    addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
                    addWallpaperInputConsumerHandle = false;
                }
            }
            final int flags = child.mAttrs.flags;
            final int privateFlags = child.mAttrs.privateFlags;
            final int type = child.mAttrs.type;
            final boolean hasFocus = (child == mInputFocus);
            final boolean isVisible = child.isVisibleLw();
            if ((privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) {
                disableWallpaperTouchEvents = true;
            }
            final boolean hasWallpaper = wallpaperController.isWallpaperTarget(child) && (privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD) == 0 && !disableWallpaperTouchEvents;
            final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);
            // make sure it's been told about the drag
            if (inDrag && isVisible && onDefaultDisplay) {
                mService.mDragState.sendDragStartedIfNeededLw(child);
            }
            addInputWindowHandleLw(inputWindowHandle, child, flags, type, isVisible, hasFocus, hasWallpaper);
        }
    }
    if (addWallpaperInputConsumerHandle) {
        // No wallpaper found, add the wallpaper input consumer at the end.
        addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
    }
    // Send windows to native code.
    mService.mInputManager.setInputWindows(mInputWindowHandles);
    // Clear the list in preparation for the next round.
    clearInputWindowHandlesLw();
    if (false)
        Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw");
}
Also used : InputChannel(android.view.InputChannel) InputWindowHandle(com.android.server.input.InputWindowHandle)

Example 7 with InputChannel

use of android.view.InputChannel in project android_frameworks_base by DirtyUnicorns.

the class DragState method register.

/**
     * @param display The Display that the window being dragged is on.
     */
void register(Display display) {
    if (DEBUG_DRAG)
        Slog.d(TAG_WM, "registering drag input channel");
    if (mClientChannel != null) {
        Slog.e(TAG_WM, "Duplicate register of drag input channel");
    } else {
        mDisplayContent = mService.getDisplayContentLocked(display.getDisplayId());
        InputChannel[] channels = InputChannel.openInputChannelPair("drag");
        mServerChannel = channels[0];
        mClientChannel = channels[1];
        mService.mInputManager.registerInputChannel(mServerChannel, null);
        mInputEventReceiver = mService.new DragInputEventReceiver(mClientChannel, mService.mH.getLooper());
        mDragApplicationHandle = new InputApplicationHandle(null);
        mDragApplicationHandle.name = "drag";
        mDragApplicationHandle.dispatchingTimeoutNanos = WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
        mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null, display.getDisplayId());
        mDragWindowHandle.name = "drag";
        mDragWindowHandle.inputChannel = mServerChannel;
        mDragWindowHandle.layer = getDragLayerLw();
        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;
        Point p = new Point();
        display.getRealSize(p);
        mDragWindowHandle.frameRight = p.x;
        mDragWindowHandle.frameBottom = p.y;
        // Pause rotations before a drag.
        if (DEBUG_ORIENTATION) {
            Slog.d(TAG_WM, "Pausing rotation during drag");
        }
        mService.pauseRotationLocked();
    }
}
Also used : InputApplicationHandle(com.android.server.input.InputApplicationHandle) DragInputEventReceiver(com.android.server.wm.WindowManagerService.DragInputEventReceiver) InputChannel(android.view.InputChannel) Point(android.graphics.Point) InputWindowHandle(com.android.server.input.InputWindowHandle)

Example 8 with InputChannel

use of android.view.InputChannel in project android_frameworks_base by DirtyUnicorns.

the class TvInputManagerService method createSessionInternalLocked.

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();
}
Also used : InputChannel(android.view.InputChannel) ITvInputSessionCallback(android.media.tv.ITvInputSessionCallback) RemoteException(android.os.RemoteException) ITvInputSessionCallback(android.media.tv.ITvInputSessionCallback)

Example 9 with InputChannel

use of android.view.InputChannel in project android_frameworks_base by AOSPA.

the class InputMethodManagerService method handleMessage.

@Override
public boolean handleMessage(Message msg) {
    SomeArgs args;
    switch(msg.what) {
        case MSG_SHOW_IM_SUBTYPE_PICKER:
            final boolean showAuxSubtypes;
            switch(msg.arg1) {
                case InputMethodManager.SHOW_IM_PICKER_MODE_AUTO:
                    // This is undocumented so far, but IMM#showInputMethodPicker() has been
                    // implemented so that auxiliary subtypes will be excluded when the soft
                    // keyboard is invisible.
                    showAuxSubtypes = mInputShown;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = true;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = false;
                    break;
                default:
                    Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1);
                    return false;
            }
            showInputMethodMenu(showAuxSubtypes);
            return true;
        case MSG_SHOW_IM_SUBTYPE_ENABLER:
            showInputMethodAndSubtypeEnabler((String) msg.obj);
            return true;
        case MSG_SHOW_IM_CONFIG:
            showConfigureInputMethods();
            return true;
        case MSG_UNBIND_INPUT:
            try {
                ((IInputMethod) msg.obj).unbindInput();
            } catch (RemoteException e) {
            // There is nothing interesting about the method dying.
            }
            return true;
        case MSG_BIND_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                ((IInputMethod) args.arg1).bindInput((InputBinding) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_SHOW_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".showSoftInput(" + msg.arg1 + ", " + args.arg2 + ")");
                ((IInputMethod) args.arg1).showSoftInput(msg.arg1, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".hideSoftInput(0, " + args.arg2 + ")");
                ((IInputMethod) args.arg1).hideSoftInput(0, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_CURRENT_INPUT_METHOD:
            synchronized (mMethodMap) {
                hideCurrentInputLocked(0, null);
            }
            return true;
        case MSG_ATTACH_TOKEN:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Sending attach of token: " + args.arg2);
                ((IInputMethod) args.arg1).attachToken((IBinder) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_CREATE_SESSION:
            {
                args = (SomeArgs) msg.obj;
                IInputMethod method = (IInputMethod) args.arg1;
                InputChannel channel = (InputChannel) args.arg2;
                try {
                    method.createSession(channel, (IInputSessionCallback) args.arg3);
                } catch (RemoteException e) {
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (channel != null && Binder.isProxy(method)) {
                        channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_START_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.startInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_RESTART_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.restartInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_UNBIND_CLIENT:
            try {
                ((IInputMethodClient) msg.obj).onUnbindMethod(msg.arg1, msg.arg2);
            } catch (RemoteException e) {
            // There is nothing interesting about the last client dying.
            }
            return true;
        case MSG_BIND_CLIENT:
            {
                args = (SomeArgs) msg.obj;
                IInputMethodClient client = (IInputMethodClient) args.arg1;
                InputBindResult res = (InputBindResult) args.arg2;
                try {
                    client.onBindMethod(res);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Client died receiving input method " + args.arg2);
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (res.channel != null && Binder.isProxy(client)) {
                        res.channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_SET_ACTIVE:
            try {
                ((ClientState) msg.obj).client.setActive(msg.arg1 != 0);
            } catch (RemoteException e) {
                Slog.w(TAG, "Got RemoteException sending setActive(false) notification to pid " + ((ClientState) msg.obj).pid + " uid " + ((ClientState) msg.obj).uid);
            }
            return true;
        case MSG_SET_INTERACTIVE:
            handleSetInteractive(msg.arg1 != 0);
            return true;
        case MSG_SWITCH_IME:
            handleSwitchInputMethod(msg.arg1 != 0);
            return true;
        case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER:
            {
                final int sequenceNumber = msg.arg1;
                final ClientState clientState = (ClientState) msg.obj;
                try {
                    clientState.client.setUserActionNotificationSequenceNumber(sequenceNumber);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Got RemoteException sending " + "setUserActionNotificationSequenceNumber(" + sequenceNumber + ") notification to pid " + clientState.pid + " uid " + clientState.uid);
                }
                return true;
            }
        // --------------------------------------------------------------
        case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
            mHardKeyboardListener.handleHardKeyboardStatusChange(msg.arg1 == 1);
            return true;
        case MSG_SYSTEM_UNLOCK_USER:
            final int userId = msg.arg1;
            onUnlockUser(userId);
            return true;
    }
    return false;
}
Also used : IInputSessionCallback(com.android.internal.view.IInputSessionCallback) InputBindResult(com.android.internal.view.InputBindResult) IInputContext(com.android.internal.view.IInputContext) IInputMethod(com.android.internal.view.IInputMethod) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethodClient(com.android.internal.view.IInputMethodClient) InputChannel(android.view.InputChannel) RemoteException(android.os.RemoteException)

Example 10 with InputChannel

use of android.view.InputChannel in project android_frameworks_base by ResurrectionRemix.

the class TvInputService method onBind.

@Override
public final IBinder onBind(Intent intent) {
    return new ITvInputService.Stub() {

        @Override
        public void registerCallback(ITvInputServiceCallback cb) {
            if (cb != null) {
                mCallbacks.register(cb);
            }
        }

        @Override
        public void unregisterCallback(ITvInputServiceCallback cb) {
            if (cb != null) {
                mCallbacks.unregister(cb);
            }
        }

        @Override
        public void createSession(InputChannel channel, ITvInputSessionCallback cb, String inputId) {
            if (channel == null) {
                Log.w(TAG, "Creating session without input channel");
            }
            if (cb == null) {
                return;
            }
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = channel;
            args.arg2 = cb;
            args.arg3 = inputId;
            mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION, args).sendToTarget();
        }

        @Override
        public void createRecordingSession(ITvInputSessionCallback cb, String inputId) {
            if (cb == null) {
                return;
            }
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = cb;
            args.arg2 = inputId;
            mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_RECORDING_SESSION, args).sendToTarget();
        }

        @Override
        public void notifyHardwareAdded(TvInputHardwareInfo hardwareInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HARDWARE_INPUT, hardwareInfo).sendToTarget();
        }

        @Override
        public void notifyHardwareRemoved(TvInputHardwareInfo hardwareInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HARDWARE_INPUT, hardwareInfo).sendToTarget();
        }

        @Override
        public void notifyHdmiDeviceAdded(HdmiDeviceInfo deviceInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HDMI_INPUT, deviceInfo).sendToTarget();
        }

        @Override
        public void notifyHdmiDeviceRemoved(HdmiDeviceInfo deviceInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HDMI_INPUT, deviceInfo).sendToTarget();
        }
    };
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) SomeArgs(com.android.internal.os.SomeArgs) InputChannel(android.view.InputChannel)

Aggregations

InputChannel (android.view.InputChannel)32 InputWindowHandle (com.android.server.input.InputWindowHandle)15 Point (android.graphics.Point)11 SomeArgs (com.android.internal.os.SomeArgs)11 RemoteException (android.os.RemoteException)10 InputApplicationHandle (com.android.server.input.InputApplicationHandle)9 IInputMethod (com.android.internal.view.IInputMethod)6 IInputMethodClient (com.android.internal.view.IInputMethodClient)6 IInputSessionCallback (com.android.internal.view.IInputSessionCallback)6 InputBindResult (com.android.internal.view.InputBindResult)6 HdmiDeviceInfo (android.hardware.hdmi.HdmiDeviceInfo)5 EditorInfo (android.view.inputmethod.EditorInfo)5 IInputContext (com.android.internal.view.IInputContext)5 DragInputEventReceiver (com.android.server.wm.WindowManagerService.DragInputEventReceiver)5 ITvInputSessionCallback (android.media.tv.ITvInputSessionCallback)4 Rect (android.graphics.Rect)1