Search in sources :

Example 16 with InputChannel

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

the class WindowManagerService method addWindow.

public int addWindow(Session session, IWindow client, int seq, WindowManager.LayoutParams attrs, int viewVisibility, int displayId, Rect outContentInsets, InputChannel outInputChannel) {
    int[] appOp = new int[1];
    int res = mPolicy.checkAddPermission(attrs, appOp);
    if (res != WindowManagerGlobal.ADD_OKAY) {
        return res;
    }
    boolean reportNewConfig = false;
    WindowState attachedWindow = null;
    WindowState win = null;
    long origId;
    final int type = attrs.type;
    synchronized (mWindowMap) {
        if (!mDisplayReady) {
            throw new IllegalStateException("Display has not been initialialized");
        }
        final DisplayContent displayContent = getDisplayContentLocked(displayId);
        if (displayContent == null) {
            return WindowManagerGlobal.ADD_INVALID_DISPLAY;
        }
        if (mWindowMap.containsKey(client.asBinder())) {
            Slog.w(TAG, "Window " + client + " is already added");
            return WindowManagerGlobal.ADD_DUPLICATE_ADD;
        }
        if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
            attachedWindow = windowForClientLocked(null, attrs.token, false);
            if (attachedWindow == null) {
                Slog.w(TAG, "Attempted to add window with token that is not a window: " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
            }
            if (attachedWindow.mAttrs.type >= FIRST_SUB_WINDOW && attachedWindow.mAttrs.type <= LAST_SUB_WINDOW) {
                Slog.w(TAG, "Attempted to add window with token that is a sub-window: " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
            }
        }
        boolean addToken = false;
        WindowToken token = mTokenMap.get(attrs.token);
        if (token == null) {
            if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
                Slog.w(TAG, "Attempted to add application window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
            if (type == TYPE_INPUT_METHOD) {
                Slog.w(TAG, "Attempted to add input method window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
            if (type == TYPE_WALLPAPER) {
                Slog.w(TAG, "Attempted to add wallpaper window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
            if (type == TYPE_DREAM) {
                Slog.w(TAG, "Attempted to add Dream window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
            token = new WindowToken(this, attrs.token, -1, false);
            addToken = true;
        } else if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
            AppWindowToken atoken = token.appWindowToken;
            if (atoken == null) {
                Slog.w(TAG, "Attempted to add window with non-application token " + token + ".  Aborting.");
                return WindowManagerGlobal.ADD_NOT_APP_TOKEN;
            } else if (atoken.removed) {
                Slog.w(TAG, "Attempted to add window with exiting application token " + token + ".  Aborting.");
                return WindowManagerGlobal.ADD_APP_EXITING;
            }
            if (type == TYPE_APPLICATION_STARTING && atoken.firstWindowDrawn) {
                // No need for this guy!
                if (localLOGV)
                    Slog.v(TAG, "**** NO NEED TO START: " + attrs.getTitle());
                return WindowManagerGlobal.ADD_STARTING_NOT_NEEDED;
            }
        } else if (type == TYPE_INPUT_METHOD) {
            if (token.windowType != TYPE_INPUT_METHOD) {
                Slog.w(TAG, "Attempted to add input method window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
        } else if (type == TYPE_WALLPAPER) {
            if (token.windowType != TYPE_WALLPAPER) {
                Slog.w(TAG, "Attempted to add wallpaper window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
        } else if (type == TYPE_DREAM) {
            if (token.windowType != TYPE_DREAM) {
                Slog.w(TAG, "Attempted to add Dream window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
            }
        }
        win = new WindowState(this, session, client, token, attachedWindow, appOp[0], seq, attrs, viewVisibility, displayContent);
        if (win.mDeathRecipient == null) {
            // Client has apparently died, so there is no reason to
            // continue.
            Slog.w(TAG, "Adding window client " + client.asBinder() + " that is dead, aborting.");
            return WindowManagerGlobal.ADD_APP_EXITING;
        }
        mPolicy.adjustWindowParamsLw(win.mAttrs);
        win.setShowToOwnerOnlyLocked(mPolicy.checkShowToOwnerOnly(attrs));
        res = mPolicy.prepareAddWindowLw(win, attrs);
        if (res != WindowManagerGlobal.ADD_OKAY) {
            return res;
        }
        if (outInputChannel != null && (attrs.inputFeatures & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) {
            String name = win.makeInputChannelName();
            InputChannel[] inputChannels = InputChannel.openInputChannelPair(name);
            win.setInputChannel(inputChannels[0]);
            inputChannels[1].transferTo(outInputChannel);
            mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle);
        }
        // From now on, no exceptions or errors allowed!
        res = WindowManagerGlobal.ADD_OKAY;
        origId = Binder.clearCallingIdentity();
        if (addToken) {
            mTokenMap.put(attrs.token, token);
        }
        win.attach();
        mWindowMap.put(client.asBinder(), win);
        if (win.mAppOp != AppOpsManager.OP_NONE) {
            if (mAppOps.startOpNoThrow(win.mAppOp, win.getOwningUid(), win.getOwningPackage()) != AppOpsManager.MODE_ALLOWED) {
                win.setAppOpVisibilityLw(false);
            }
        }
        if (type == TYPE_APPLICATION_STARTING && token.appWindowToken != null) {
            token.appWindowToken.startingWindow = win;
            if (DEBUG_STARTING_WINDOW)
                Slog.v(TAG, "addWindow: " + token.appWindowToken + " startingWindow=" + win);
        }
        boolean imMayMove = true;
        if (type == TYPE_INPUT_METHOD) {
            win.mGivenInsetsPending = true;
            mInputMethodWindow = win;
            addInputMethodWindowToListLocked(win);
            imMayMove = false;
        } else if (type == TYPE_INPUT_METHOD_DIALOG) {
            mInputMethodDialogs.add(win);
            addWindowToListInOrderLocked(win, true);
            adjustInputMethodDialogsLocked();
            imMayMove = false;
        } else {
            addWindowToListInOrderLocked(win, true);
            if (type == TYPE_WALLPAPER) {
                mLastWallpaperTimeoutTime = 0;
                displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            } else if ((attrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
                displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            } else if (mWallpaperTarget != null && mWallpaperTarget.mLayer >= win.mBaseLayer) {
                // If there is currently a wallpaper being shown, and
                // the base layer of the new window is below the current
                // layer of the target window, then adjust the wallpaper.
                // This is to avoid a new window being placed between the
                // wallpaper and its target.
                displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            }
        }
        win.mWinAnimator.mEnterAnimationPending = true;
        if (displayContent.isDefaultDisplay) {
            mPolicy.getContentInsetHintLw(attrs, outContentInsets);
        } else {
            outContentInsets.setEmpty();
        }
        if (mInTouchMode) {
            res |= WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE;
        }
        if (win.mAppToken == null || !win.mAppToken.clientHidden) {
            res |= WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
        }
        mInputMonitor.setUpdateInputWindowsNeededLw();
        boolean focusChanged = false;
        if (win.canReceiveKeys()) {
            focusChanged = updateFocusedWindowLocked(UPDATE_FOCUS_WILL_ASSIGN_LAYERS, false);
            if (focusChanged) {
                imMayMove = false;
            }
        }
        if (imMayMove) {
            moveInputMethodWindowsIfNeededLocked(false);
        }
        assignLayersLocked(displayContent.getWindowList());
        if (focusChanged) {
            finishUpdateFocusedWindowAfterAssignLayersLocked(false);
        }
        mInputMonitor.updateInputWindowsLw(false);
        if (localLOGV)
            Slog.v(TAG, "New client " + client.asBinder() + ": window=" + win);
        if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(false)) {
            reportNewConfig = true;
        }
    }
    if (reportNewConfig) {
        sendNewConfiguration();
    }
    Binder.restoreCallingIdentity(origId);
    return res;
}
Also used : InputChannel(android.view.InputChannel) Point(android.graphics.Point)

Example 17 with InputChannel

use of android.view.InputChannel in project platform_frameworks_base by android.

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)

Example 18 with InputChannel

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

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)

Example 19 with InputChannel

use of android.view.InputChannel in project cornerstone by Onskreen.

the class WindowManagerService method addWindow.

public int addWindow(Session session, IWindow client, int seq, WindowManager.LayoutParams attrs, int viewVisibility, Rect outContentInsets, InputChannel outInputChannel) {
    int res = mPolicy.checkAddPermission(attrs);
    if (res != WindowManagerImpl.ADD_OKAY) {
        return res;
    }
    boolean reportNewConfig = false;
    WindowState attachedWindow = null;
    WindowState win = null;
    long origId;
    synchronized (mWindowMap) {
        if (mDisplay == null) {
            throw new IllegalStateException("Display has not been initialialized");
        }
        if (mWindowMap.containsKey(client.asBinder())) {
            Slog.w(TAG, "Window " + client + " is already added");
            return WindowManagerImpl.ADD_DUPLICATE_ADD;
        }
        if (attrs.type >= FIRST_SUB_WINDOW && attrs.type <= LAST_SUB_WINDOW) {
            attachedWindow = windowForClientLocked(null, attrs.token, false);
            if (attachedWindow == null) {
                Slog.w(TAG, "Attempted to add window with token that is not a window: " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_SUBWINDOW_TOKEN;
            }
            if (attachedWindow.mAttrs.type >= FIRST_SUB_WINDOW && attachedWindow.mAttrs.type <= LAST_SUB_WINDOW) {
                Slog.w(TAG, "Attempted to add window with token that is a sub-window: " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_SUBWINDOW_TOKEN;
            }
        }
        boolean addToken = false;
        WindowToken token = mTokenMap.get(attrs.token);
        if (token == null) {
            if (attrs.type >= FIRST_APPLICATION_WINDOW && attrs.type <= LAST_APPLICATION_WINDOW) {
                Slog.w(TAG, "Attempted to add application window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
            if (attrs.type == TYPE_INPUT_METHOD) {
                Slog.w(TAG, "Attempted to add input method window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
            if (attrs.type == TYPE_WALLPAPER) {
                Slog.w(TAG, "Attempted to add wallpaper window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
            if (attrs.type == TYPE_DREAM) {
                Slog.w(TAG, "Attempted to add Dream window with unknown token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
            token = new WindowToken(this, attrs.token, -1, false);
            addToken = true;
        } else if (attrs.type >= FIRST_APPLICATION_WINDOW && attrs.type <= LAST_APPLICATION_WINDOW) {
            AppWindowToken atoken = token.appWindowToken;
            if (atoken == null) {
                Slog.w(TAG, "Attempted to add window with non-application token " + token + ".  Aborting.");
                return WindowManagerImpl.ADD_NOT_APP_TOKEN;
            } else if (atoken.removed) {
                Slog.w(TAG, "Attempted to add window with exiting application token " + token + ".  Aborting.");
                return WindowManagerImpl.ADD_APP_EXITING;
            }
            if (attrs.type == TYPE_APPLICATION_STARTING && atoken.firstWindowDrawn) {
                // No need for this guy!
                if (localLOGV)
                    Slog.v(TAG, "**** NO NEED TO START: " + attrs.getTitle());
                return WindowManagerImpl.ADD_STARTING_NOT_NEEDED;
            }
        } else if (attrs.type == TYPE_INPUT_METHOD) {
            if (token.windowType != TYPE_INPUT_METHOD) {
                Slog.w(TAG, "Attempted to add input method window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
        } else if (attrs.type == TYPE_WALLPAPER) {
            if (token.windowType != TYPE_WALLPAPER) {
                Slog.w(TAG, "Attempted to add wallpaper window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
        } else if (attrs.type == TYPE_DREAM) {
            if (token.windowType != TYPE_DREAM) {
                Slog.w(TAG, "Attempted to add Dream window with bad token " + attrs.token + ".  Aborting.");
                return WindowManagerImpl.ADD_BAD_APP_TOKEN;
            }
        }
        win = new WindowState(this, session, client, token, attachedWindow, seq, attrs, viewVisibility);
        /**
             * Author: Onskreen
             * Date: 12/01/2011
             *
             * Sets the WindowPanel rect for apptokens.
             */
        if (token.appWindowToken != null) {
            setWindowPanel(token.appWindowToken.groupId);
            //Since the windowstate has not yet been added to mWindows, it
            //must be manually updated here.
            WindowPanel wp = findWindowPanel(token.appWindowToken.groupId);
            if (wp != null) {
                win.mFrame.set(wp.getPos());
            }
        }
        if (win.mDeathRecipient == null) {
            // Client has apparently died, so there is no reason to
            // continue.
            Slog.w(TAG, "Adding window client " + client.asBinder() + " that is dead, aborting.");
            return WindowManagerImpl.ADD_APP_EXITING;
        }
        mPolicy.adjustWindowParamsLw(win.mAttrs);
        res = mPolicy.prepareAddWindowLw(win, attrs);
        if (res != WindowManagerImpl.ADD_OKAY) {
            return res;
        }
        if (outInputChannel != null && (attrs.inputFeatures & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) {
            String name = win.makeInputChannelName();
            InputChannel[] inputChannels = InputChannel.openInputChannelPair(name);
            win.setInputChannel(inputChannels[0]);
            inputChannels[1].transferTo(outInputChannel);
            mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle);
        }
        // From now on, no exceptions or errors allowed!
        res = WindowManagerImpl.ADD_OKAY;
        origId = Binder.clearCallingIdentity();
        if (addToken) {
            mTokenMap.put(attrs.token, token);
        }
        win.attach();
        mWindowMap.put(client.asBinder(), win);
        if (attrs.type == TYPE_APPLICATION_STARTING && token.appWindowToken != null) {
            token.appWindowToken.startingWindow = win;
            if (DEBUG_STARTING_WINDOW)
                Slog.v(TAG, "addWindow: " + token.appWindowToken + " startingWindow=" + win);
        }
        boolean imMayMove = true;
        if (attrs.type == TYPE_INPUT_METHOD) {
            win.mGivenInsetsPending = true;
            mInputMethodWindow = win;
            addInputMethodWindowToListLocked(win);
            imMayMove = false;
        } else if (attrs.type == TYPE_INPUT_METHOD_DIALOG) {
            mInputMethodDialogs.add(win);
            addWindowToListInOrderLocked(win, true);
            adjustInputMethodDialogsLocked();
            imMayMove = false;
        } else {
            addWindowToListInOrderLocked(win, true);
            if (attrs.type == TYPE_WALLPAPER) {
                mLastWallpaperTimeoutTime = 0;
                adjustWallpaperWindowsLocked();
            } else if ((attrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
                adjustWallpaperWindowsLocked();
            }
        }
        win.mWinAnimator.mEnterAnimationPending = true;
        mPolicy.getContentInsetHintLw(attrs, outContentInsets);
        if (mInTouchMode) {
            res |= WindowManagerImpl.ADD_FLAG_IN_TOUCH_MODE;
        }
        if (win.mAppToken == null || !win.mAppToken.clientHidden) {
            res |= WindowManagerImpl.ADD_FLAG_APP_VISIBLE;
        }
        mInputMonitor.setUpdateInputWindowsNeededLw();
        boolean focusChanged = false;
        if (win.canReceiveKeys()) {
            focusChanged = updateFocusedWindowLocked(UPDATE_FOCUS_WILL_ASSIGN_LAYERS, false);
            if (focusChanged) {
                imMayMove = false;
            }
        }
        if (imMayMove) {
            moveInputMethodWindowsIfNeededLocked(false);
        }
        assignLayersLocked();
        if (focusChanged) {
            finishUpdateFocusedWindowAfterAssignLayersLocked(false);
        }
        mInputMonitor.updateInputWindowsLw(false);
        if (localLOGV)
            Slog.v(TAG, "New client " + client.asBinder() + ": window=" + win);
        if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(false)) {
            reportNewConfig = true;
        }
    }
    if (reportNewConfig) {
        sendNewConfiguration();
    }
    Binder.restoreCallingIdentity(origId);
    return res;
}
Also used : InputChannel(android.view.InputChannel) Point(android.graphics.Point)

Example 20 with InputChannel

use of android.view.InputChannel in project cornerstone by Onskreen.

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(WindowManagerService.TAG, ">>>>>> 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.
    final ArrayList<WindowState> windows = mService.mWindows;
    // If there's a drag in flight, provide a pseudowindow to catch drag input
    final boolean inDrag = (mService.mDragState != null);
    if (inDrag) {
        if (WindowManagerService.DEBUG_DRAG) {
            Log.d(WindowManagerService.TAG, "Inserting drag window");
        }
        final InputWindowHandle dragWindowHandle = mService.mDragState.mDragWindowHandle;
        if (dragWindowHandle != null) {
            addInputWindowHandleLw(dragWindowHandle);
        } else {
            Slog.w(WindowManagerService.TAG, "Drag is in progress but there is no " + "drag window handle.");
        }
    }
    final int NFW = mService.mFakeWindows.size();
    for (int i = 0; i < NFW; i++) {
        addInputWindowHandleLw(mService.mFakeWindows.get(i).mWindowHandle);
    }
    final int N = windows.size();
    for (int i = N - 1; i >= 0; i--) {
        final WindowState child = windows.get(i);
        final InputChannel inputChannel = child.mInputChannel;
        final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
        if (inputChannel == null || inputWindowHandle == null || child.mRemoved) {
            // Skip this window because it cannot possibly receive input.
            continue;
        }
        final int flags = child.mAttrs.flags;
        final int type = child.mAttrs.type;
        final boolean hasFocus = (child == mInputFocus);
        final boolean isVisible = child.isVisibleLw();
        final boolean hasWallpaper = (child == mService.mWallpaperTarget) && (type != WindowManager.LayoutParams.TYPE_KEYGUARD);
        // make sure it's been told about the drag
        if (inDrag && isVisible) {
            mService.mDragState.sendDragStartedIfNeededLw(child);
        }
        // Add a window to our list of input windows.
        inputWindowHandle.name = child.toString();
        inputWindowHandle.layoutParamsFlags = flags;
        inputWindowHandle.layoutParamsType = type;
        inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
        inputWindowHandle.visible = isVisible;
        inputWindowHandle.canReceiveKeys = child.canReceiveKeys();
        inputWindowHandle.hasFocus = hasFocus;
        inputWindowHandle.hasWallpaper = hasWallpaper;
        inputWindowHandle.paused = child.mAppToken != null ? child.mAppToken.paused : false;
        inputWindowHandle.layer = child.mLayer;
        inputWindowHandle.ownerPid = child.mSession.mPid;
        inputWindowHandle.ownerUid = child.mSession.mUid;
        inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures;
        final Rect frame = child.mFrame;
        inputWindowHandle.frameLeft = frame.left;
        inputWindowHandle.frameTop = frame.top;
        inputWindowHandle.frameRight = frame.right;
        inputWindowHandle.frameBottom = frame.bottom;
        if (child.mGlobalScale != 1) {
            // If we are scaling the window, input coordinates need
            // to be inversely scaled to map from what is on screen
            // to what is actually being touched in the UI.
            inputWindowHandle.scaleFactor = 1.0f / child.mGlobalScale;
        } else {
            inputWindowHandle.scaleFactor = 1;
        }
        child.getTouchableRegion(inputWindowHandle.touchableRegion);
        addInputWindowHandleLw(inputWindowHandle);
    }
    // Send windows to native code.
    mService.mInputManager.setInputWindows(mInputWindowHandles);
    // Clear the list in preparation for the next round.
    clearInputWindowHandlesLw();
    if (false)
        Slog.d(WindowManagerService.TAG, "<<<<<<< EXITED updateInputWindowsLw");
}
Also used : Rect(android.graphics.Rect) InputChannel(android.view.InputChannel) InputWindowHandle(com.android.server.input.InputWindowHandle)

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