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

Commit defa0221 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Add InputManager Lifecycle support

Need lifecycle support to listen to user changes in
system server. This is per-requisite for multi-user
support in input manager.

Bug: 362473586
Test: manual
Flag: com.android.hardware.input.input_manager_lifecycle_support
Change-Id: I39b0575c36468bcdddbdb5b95c93c5d8d813bdd1
parent 222c7b1e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -87,6 +87,17 @@ flag {
  bug: "358603902"
}

flag {
    name: "input_manager_lifecycle_support"
    namespace: "input"
    description: "Add support for Lifecycle support in input manager"
    bug: "362473586"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "input_native"
    name: "manage_key_gestures"
+33 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.input;
import static android.Manifest.permission.OVERRIDE_SYSTEM_KEY_BEHAVIOR_IN_FOCUSED_WINDOW;
import static android.content.PermissionChecker.PERMISSION_GRANTED;
import static android.content.PermissionChecker.PID_UNKNOWN;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.provider.DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT;
import static android.view.KeyEvent.KEYCODE_UNKNOWN;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -136,6 +137,7 @@ import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
import com.android.server.DisplayThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.Watchdog;
import com.android.server.input.InputManagerInternal.LidSwitchCallback;
import com.android.server.input.debug.FocusEventDebugView;
@@ -3396,6 +3398,37 @@ public class InputManagerService extends IInputManager.Stub
        }
    }

    /**
     * {@link SystemService} used to publish and manage the lifecycle of {@link InputManagerService}
     */
    public static final class Lifecycle extends SystemService {

        private final InputManagerService mService;

        public Lifecycle(@NonNull Context context) {
            super(context);
            mService = new InputManagerService(context);
        }

        @Override
        public void onStart() {
            publishBinderService(Context.INPUT_SERVICE, mService,
                    /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL);
        }

        @Override
        public void onBootPhase(int phase) {
            // Called on ActivityManager thread.
            if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) {
                mService.systemRunning();
            }
        }

        public InputManagerService getService() {
            return mService;
        }
    }

    private final class LocalService extends InputManagerInternal {
        @Override
        public void setDisplayViewports(List<DisplayViewport> viewports) {
+21 −11
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.system.OsConstants.O_CLOEXEC;
import static android.system.OsConstants.O_RDONLY;
import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.hardware.input.Flags.inputManagerLifecycleSupport;
import static com.android.server.utils.TimingsTraceAndSlog.SYSTEM_SERVER_TIMING_TAG;
import static com.android.tradeinmode.flags.Flags.enableTradeInMode;

@@ -1654,7 +1655,12 @@ public final class SystemServer implements Dumpable {
            t.traceEnd();

            t.traceBegin("StartInputManagerService");
            if (inputManagerLifecycleSupport()) {
                inputManager = mSystemServiceManager.startService(
                        InputManagerService.Lifecycle.class).getService();
            } else {
                inputManager = new InputManagerService(context);
            }
            t.traceEnd();

            t.traceBegin("DeviceStateManagerService");
@@ -1675,8 +1681,10 @@ public final class SystemServer implements Dumpable {
            ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,
                    DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PRIORITY_HIGH
                            | DUMP_FLAG_PROTO);
            if (!inputManagerLifecycleSupport()) {
                ServiceManager.addService(Context.INPUT_SERVICE, inputManager,
                        /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL);
            }
            t.traceEnd();

            t.traceBegin("SetWindowManagerService");
@@ -3350,6 +3358,7 @@ public final class SystemServer implements Dumpable {
                reportWtf("Notifying NetworkTimeService running", e);
            }
            t.traceEnd();
            if (!inputManagerLifecycleSupport()) {
                t.traceBegin("MakeInputManagerServiceReady");
                try {
                    // TODO(BT) Pass parameter to input manager
@@ -3360,6 +3369,7 @@ public final class SystemServer implements Dumpable {
                    reportWtf("Notifying InputManagerService running", e);
                }
                t.traceEnd();
            }
            t.traceBegin("MakeTelephonyRegistryReady");
            try {
                if (telephonyRegistryF != null) {