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

Commit 39134b21 authored by Arthur Hung's avatar Arthur Hung
Browse files

Fix WM input limitations on secondary displays (3/4)

One DisplayContent contains one InputMonitor now.
- Change setInputWindow of InputManagerService updated by displayId,
  so Window Handles in InputDispather can be updated by each DisplayContent.
- Only exist one focus in current state, reset it if in removed DisplayContent,
  will be updated by default display or focused display.
- Add displayId parameter for createInputConsumer and destroyInputConsumer,
  so InputConsumer from PIP, RecentApp and Wallpaper can be supported in multi-display.

Bug: 111363643
Test: atest WindowManagerSmokeTest ActivityManagerMultiDisplayTests
Test: atest com.android.server.wm.DisplayContentTests
Test: atest libinput_tests inputflinger_tests
Change-Id: I999c355be1789af5759f00206475d004e10116e3
parent 589ce41d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -159,8 +159,8 @@ Landroid/view/IRemoteAnimationFinishedCallback;->onAnimationFinished()V
Landroid/view/IRemoteAnimationRunner$Stub;-><init>()V
Landroid/view/IRemoteAnimationRunner;->onAnimationCancelled()V
Landroid/view/IRemoteAnimationRunner;->onAnimationStart([Landroid/view/RemoteAnimationTarget;Landroid/view/IRemoteAnimationFinishedCallback;)V
Landroid/view/IWindowManager;->createInputConsumer(Landroid/os/IBinder;Ljava/lang/String;Landroid/view/InputChannel;)V
Landroid/view/IWindowManager;->destroyInputConsumer(Ljava/lang/String;)Z
Landroid/view/IWindowManager;->createInputConsumer(Landroid/os/IBinder;Ljava/lang/String;ILandroid/view/InputChannel;)V
Landroid/view/IWindowManager;->destroyInputConsumer(Ljava/lang/String;I)Z
Landroid/view/IWindowManager;->endProlongedAnimations()V
Landroid/view/IWindowManager;->getStableInsets(ILandroid/graphics/Rect;)V
Landroid/view/IWindowManager;->overridePendingAppTransitionMultiThumbFuture(Landroid/view/IAppTransitionAnimationSpecsFuture;Landroid/os/IRemoteCallback;Z)V
+6 −5
Original line number Diff line number Diff line
@@ -392,15 +392,16 @@ interface IWindowManager
    void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber);

    /**
     * Create an input consumer by name.
     * Create an input consumer by name and display id.
     */
    void createInputConsumer(IBinder token, String name, out InputChannel inputChannel);
    void createInputConsumer(IBinder token, String name, int displayId,
        out InputChannel inputChannel);

    /**
     * Destroy an input consumer by name.  This method will also dispose the input channels
     * associated with that InputConsumer.
     * Destroy an input consumer by name and display id.
     * This method will also dispose the input channels associated with that InputConsumer.
     */
    boolean destroyInputConsumer(String name);
    boolean destroyInputConsumer(String name, int displayId);

    /**
     * Return the touch region for the current IME window, or an empty region if there is none.
+6 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.shared.system;

import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.INPUT_CONSUMER_PIP;
import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;

@@ -146,8 +147,9 @@ public class InputConsumerController {
        if (mInputEventReceiver == null) {
            final InputChannel inputChannel = new InputChannel();
            try {
                mWindowManager.destroyInputConsumer(mName);
                mWindowManager.createInputConsumer(mToken, mName, inputChannel);
                // TODO(b/113087003): Support Picture-in-picture in multi-display.
                mWindowManager.destroyInputConsumer(mName, DEFAULT_DISPLAY);
                mWindowManager.createInputConsumer(mToken, mName, DEFAULT_DISPLAY, inputChannel);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to create input consumer", e);
            }
@@ -164,7 +166,8 @@ public class InputConsumerController {
    public void unregisterInputConsumer() {
        if (mInputEventReceiver != null) {
            try {
                mWindowManager.destroyInputConsumer(mName);
                // TODO(b/113087003): Support Picture-in-picture in multi-display.
                mWindowManager.destroyInputConsumer(mName, DEFAULT_DISPLAY);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to destroy input consumer", e);
            }
+25 −27
Original line number Diff line number Diff line
@@ -17,25 +17,6 @@
package com.android.server.input;

import android.annotation.NonNull;
import android.os.LocaleList;
import android.os.ShellCallback;
import android.util.Log;
import android.view.Display;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.SomeArgs;
import com.android.internal.R;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.Watchdog;
import com.android.server.policy.WindowManagerPolicy;

import org.xmlpull.v1.XmlPullParser;

import android.Manifest;
import android.app.IInputForwarder;
import android.app.Notification;
import android.app.NotificationManager;
@@ -50,8 +31,8 @@ import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.content.res.TypedArray;
@@ -61,10 +42,10 @@ import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayViewport;
import android.hardware.input.IInputDevicesChangedListener;
import android.hardware.input.IInputManager;
import android.hardware.input.ITabletModeChangedListener;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerInternal;
import android.hardware.input.ITabletModeChangedListener;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.TouchCalibration;
import android.os.Binder;
@@ -72,6 +53,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.LocaleList;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
@@ -81,6 +63,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.Xml;
@@ -97,6 +80,23 @@ import android.view.Surface;
import android.view.ViewConfiguration;
import android.widget.Toast;

import com.android.internal.R;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.Watchdog;
import com.android.server.policy.WindowManagerPolicy;

import libcore.io.IoUtils;
import libcore.io.Streams;

import org.xmlpull.v1.XmlPullParser;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
@@ -113,9 +113,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Objects;

import libcore.io.IoUtils;
import libcore.io.Streams;

/*
 * Wraps the C++ InputManager and provides its callbacks.
 */
@@ -212,7 +209,8 @@ public class InputManagerService extends IInputManager.Stub
            int injectorPid, int injectorUid, int syncMode, int timeoutMillis,
            int policyFlags);
    private static native void nativeToggleCapsLock(long ptr, int deviceId);
    private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles);
    private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles,
            int displayId);
    private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen);
    private static native void nativeSetSystemUiVisibility(long ptr, int visibility);
    private static native void nativeSetFocusedApplication(long ptr,
@@ -1467,7 +1465,7 @@ public class InputManagerService extends IInputManager.Stub
    }

    public void setInputWindows(InputWindowHandle[] windowHandles,
            InputWindowHandle focusedWindowHandle) {
            InputWindowHandle focusedWindowHandle, int displayId) {
        final IWindow newFocusedWindow =
            focusedWindowHandle != null ? focusedWindowHandle.clientWindow : null;
        if (mFocusedWindow != newFocusedWindow) {
@@ -1476,7 +1474,7 @@ public class InputManagerService extends IInputManager.Stub
                setPointerCapture(false);
            }
        }
        nativeSetInputWindows(mPtr, windowHandles);
        nativeSetInputWindows(mPtr, windowHandles, displayId);
    }

    public void setFocusedApplication(InputApplicationHandle application) {
+2 −2
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package com.android.server.input;

import android.graphics.Region;
import android.view.InputChannel;
import android.view.IWindow;
import android.view.InputChannel;

/**
 * Functions as a handle for a window that can receive input.
@@ -106,7 +106,7 @@ public final class InputWindowHandle {

    @Override
    public String toString() {
        return new StringBuilder(name)
        return new StringBuilder(name != null ? name : "")
                .append(", layer=").append(layer)
                .append(", frame=[").append(frameLeft).append(",").append(frameTop).append(",")
                        .append(frameRight).append(",").append(frameBottom).append("]")
Loading