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

Commit b4142f70 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Android (Google) Code Review
Browse files

Merge "Revert "Add wallpaper input consumer to WindowManagerService"" into nyc-dev

parents 276dcd73 2769e7eb
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -400,14 +400,4 @@ interface IWindowManager
     * @hide
     */
    void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber);

    /**
     * Create the input consumer for wallpaper events.
     */
    void createWallpaperInputConsumer(out InputChannel inputChannel);

    /**
     * Remove the input consumer for wallpaper events.
     */
    void removeWallpaperInputConsumer();
}
+28 −16
Original line number Diff line number Diff line
@@ -16,33 +16,38 @@

package com.android.server.wm;

import android.os.Looper;
import android.os.Process;
import android.view.Display;
import android.view.InputChannel;
import android.view.InputEventReceiver;
import android.view.WindowManager;
import android.view.WindowManagerPolicy;

import com.android.server.input.InputApplicationHandle;
import com.android.server.input.InputWindowHandle;

class InputConsumerImpl {
public final class InputConsumerImpl implements WindowManagerPolicy.InputConsumer {
    final WindowManagerService mService;
    final InputChannel mServerChannel, mClientChannel;
    final InputApplicationHandle mApplicationHandle;
    final InputWindowHandle mWindowHandle;
    final InputEventReceiver mInputEventReceiver;
    final int mWindowLayer;

    InputConsumerImpl(WindowManagerService service, String name, InputChannel inputChannel) {
    public InputConsumerImpl(WindowManagerService service, Looper looper,
            InputEventReceiver.Factory inputEventReceiverFactory) {
        String name = "input consumer";
        mService = service;

        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);

        mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver(
                mClientChannel, looper);

        mApplicationHandle = new InputApplicationHandle(null);
        mApplicationHandle.name = name;
        mApplicationHandle.dispatchingTimeoutNanos =
@@ -52,7 +57,8 @@ class InputConsumerImpl {
        mWindowHandle.name = name;
        mWindowHandle.inputChannel = mServerChannel;
        mWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
        mWindowHandle.layer = getLayerLw(mWindowHandle.layoutParamsType);
        mWindowLayer = getLayerLw(mWindowHandle.layoutParamsType);
        mWindowHandle.layer = mWindowLayer;
        mWindowHandle.layoutParamsFlags = 0;
        mWindowHandle.dispatchingTimeoutNanos =
                WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
@@ -75,15 +81,21 @@ class InputConsumerImpl {
        mWindowHandle.frameBottom = dh;
    }

    @Override
    public void dismiss() {
        synchronized (mService.mWindowMap) {
            if (mService.removeInputConsumer()) {
                mInputEventReceiver.dispose();
                mService.mInputManager.unregisterInputChannel(mServerChannel);
                mClientChannel.dispose();
                mServerChannel.dispose();
            }
        }
    }

    private int getLayerLw(int windowType) {
        return mService.mPolicy.windowTypeToLayerLw(windowType)
                * WindowManagerService.TYPE_LAYER_MULTIPLIER
                + WindowManagerService.TYPE_LAYER_OFFSET;
    }

    void disposeChannelsLw() {
        mService.mInputManager.unregisterInputChannel(mServerChannel);
        mClientChannel.dispose();
        mServerChannel.dispose();
    }
}
+0 −15
Original line number Diff line number Diff line
@@ -282,8 +282,6 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {

        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;
@@ -304,14 +302,6 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
                    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;
@@ -339,11 +329,6 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
            }
        }

        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);

+3 −50
Original line number Diff line number Diff line
@@ -406,11 +406,6 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    InputConsumerImpl mInputConsumer;

    /**
     * The input consumer added to the window manager before all wallpaper windows.
     */
    InputConsumerImpl mWallpaperInputConsumer;

    /**
     * Windows that are being resized.  Used so we can tell the client about
     * the resize after closing the transaction in which we resized the
@@ -9629,37 +9624,13 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private static final class HideNavInputConsumer extends InputConsumerImpl
            implements WindowManagerPolicy.InputConsumer {
        private final InputEventReceiver mInputEventReceiver;

        HideNavInputConsumer(WindowManagerService service, Looper looper,
                             InputEventReceiver.Factory inputEventReceiverFactory) {
            super(service, "input consumer", null);
            mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver(
                    mClientChannel, looper);
        }

        @Override
        public void dismiss() {
            if (mService.removeInputConsumer()) {
                synchronized (mService.mWindowMap) {
                    mInputEventReceiver.dispose();
                    disposeChannelsLw();
                }
            }
        }
    }

    @Override
    public WindowManagerPolicy.InputConsumer addInputConsumer(Looper looper,
    public InputConsumerImpl addInputConsumer(Looper looper,
            InputEventReceiver.Factory inputEventReceiverFactory) {
        synchronized (mWindowMap) {
            HideNavInputConsumer inputConsumerImpl = new HideNavInputConsumer(
                    this, looper, inputEventReceiverFactory);
            mInputConsumer = inputConsumerImpl;
            mInputConsumer = new InputConsumerImpl(this, looper, inputEventReceiverFactory);
            mInputMonitor.updateInputWindowsLw(true);
            return inputConsumerImpl;
            return mInputConsumer;
        }
    }

@@ -9674,24 +9645,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    public void createWallpaperInputConsumer(InputChannel inputChannel) {
        synchronized (mWindowMap) {
            mWallpaperInputConsumer = new InputConsumerImpl(this, "wallpaper input", inputChannel);
            mWallpaperInputConsumer.mWindowHandle.hasWallpaper = true;
            mInputMonitor.updateInputWindowsLw(true);
        }
    }

    public void removeWallpaperInputConsumer() {
        synchronized (mWindowMap) {
            if (mWallpaperInputConsumer != null) {
                mWallpaperInputConsumer.disposeChannelsLw();
                mWallpaperInputConsumer = null;
                mInputMonitor.updateInputWindowsLw(true);
            }
        }
    }

    @Override
    public boolean hasNavigationBar() {
        return mPolicy.hasNavigationBar();
+0 −4
Original line number Diff line number Diff line
@@ -860,10 +860,6 @@ class WindowSurfacePlacer {
            mService.mInputConsumer.layout(dw, dh);
        }

        if (mService.mWallpaperInputConsumer != null) {
            mService.mWallpaperInputConsumer.layout(dw, dh);
        }

        final int N = windows.size();
        int i;