Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b388800 authored by Garfield Tan's avatar Garfield Tan
Browse files

Fix 2 input issues.

1) Only register InputConsumer to default display;
2) Only use one input monitor for all displays.

Bug: 112049699
Bug: 112081256
Test: Manual. Launcher stopped crashing. Input works.
Change-Id: I87c5ad3f4c76055f4f164db48af6bd90f1e4339f
parent 2c43c9ef
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -801,7 +801,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        // {@link DisplayContent} ready for use.
        mDisplayReady = true;

        mInputMonitor = new InputMonitor(service, mDisplayId);
        // TODO(b/112081256): Use independent InputMonitor.
        mInputMonitor = isDefaultDisplay ? new InputMonitor(service, mDisplayId)
                : mService.getDefaultDisplayContentLocked().mInputMonitor;
    }

    boolean isReady() {
+2 −1
Original line number Diff line number Diff line
@@ -399,7 +399,8 @@ final class InputMonitor {
            this.inDrag = inDrag;
            wallpaperController = mService.mRoot.mWallpaperController;

            mService.mRoot.getDisplayContent(mDisplayId).forAllWindows(this,
            // TODO(b/112081256): Use independent InputMonitor for each display.
            mService.mRoot/*.getDisplayContent(mDisplayId)*/.forAllWindows(this,
                    true /* traverseTopToBottom */);
            if (mAddWallpaperInputConsumerHandle) {
                // No visible wallpaper found, add the wallpaper input consumer at the end.
+13 −10
Original line number Diff line number Diff line
@@ -6082,23 +6082,26 @@ public class WindowManagerService extends IWindowManager.Stub
    @Override
    public void createInputConsumer(IBinder token, String name, InputChannel inputChannel) {
        synchronized (mWindowMap) {
            mRoot.forAllDisplays(dc -> {
                dc.getInputMonitor().createInputConsumer(token, name, inputChannel,
            // TODO(b/112049699): Fix this for multiple displays. There is only one inputChannel
            // here to accept the return value.
            DisplayContent display = mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);
            if (display != null) {
                display.getInputMonitor().createInputConsumer(token, name, inputChannel,
                        Binder.getCallingPid(), Binder.getCallingUserHandle());
            });
            }
        }
    }

    @Override
    public boolean destroyInputConsumer(String name) {
        synchronized (mWindowMap) {
            AtomicBoolean retValue = new AtomicBoolean(true);
            mRoot.forAllDisplays(dc -> {
                if (!dc.getInputMonitor().destroyInputConsumer(name)) {
                    retValue.set(false);
            // TODO(b/112049699): Fix this for multiple displays. For consistency with
            // createInputConsumer above.
            DisplayContent display = mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);
            if (display != null) {
                return display.getInputMonitor().destroyInputConsumer(name);
            }
            });
            return retValue.get();
            return false;
        }
    }