Loading services/core/java/com/android/server/input/InputManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ import com.android.internal.policy.KeyInterceptionInfo; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.server.DisplayThread; import com.android.server.IoThread; import com.android.server.LocalServices; import com.android.server.SystemService; import com.android.server.Watchdog; Loading Loading @@ -469,11 +470,13 @@ public class InputManagerService extends IInputManager.Stub static class Injector { private final Context mContext; private final Looper mLooper; private final Looper mIoLooper; private final UEventManager mUEventManager; Injector(Context context, Looper looper, UEventManager uEventManager) { Injector(Context context, Looper looper, Looper ioLooper, UEventManager uEventManager) { mContext = context; mLooper = looper; mIoLooper = ioLooper; mUEventManager = uEventManager; } Loading @@ -485,6 +488,10 @@ public class InputManagerService extends IInputManager.Stub return mLooper; } Looper getIoLooper() { return mIoLooper; } UEventManager getUEventManager() { return mUEventManager; } Loading @@ -505,8 +512,8 @@ public class InputManagerService extends IInputManager.Stub } public InputManagerService(Context context) { this(new Injector(context, DisplayThread.get().getLooper(), new UEventManager() {}), context.getSystemService(PermissionEnforcer.class)); this(new Injector(context, DisplayThread.get().getLooper(), IoThread.get().getLooper(), new UEventManager() {}), context.getSystemService(PermissionEnforcer.class)); } @VisibleForTesting Loading @@ -532,7 +539,7 @@ public class InputManagerService extends IInputManager.Stub mStickyModifierStateController = new StickyModifierStateController(); mInputDataStore = new InputDataStore(); mKeyGestureController = new KeyGestureController(mContext, injector.getLooper(), mInputDataStore); injector.getIoLooper(), mInputDataStore); mKeyboardLedController = new KeyboardLedController(mContext, injector.getLooper(), mNative); mKeyRemapper = new KeyRemapper(mContext, mNative, mDataStore, injector.getLooper()); Loading services/core/java/com/android/server/input/KeyGestureController.java +15 −7 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ final class KeyGestureController { private final Context mContext; private final Handler mHandler; private final Handler mIoHandler; private final int mSystemPid; private final KeyCombinationManager mKeyCombinationManager; private final SettingsObserver mSettingsObserver; Loading Loading @@ -171,9 +172,11 @@ final class KeyGestureController { private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled(); KeyGestureController(Context context, Looper looper, InputDataStore inputDataStore) { KeyGestureController(Context context, Looper looper, Looper ioLooper, InputDataStore inputDataStore) { mContext = context; mHandler = new Handler(looper, this::handleMessage); mIoHandler = new Handler(ioLooper, this::handleIoMessage); mSystemPid = Process.myPid(); mKeyGestureHandlerRecords = new TreeMap<>((p1, p2) -> { if (Objects.equals(p1, p2)) { Loading Loading @@ -458,7 +461,7 @@ final class KeyGestureController { userId = mCurrentUserId; } // Load the system user's input gestures. mHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); } public boolean interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { Loading Loading @@ -1032,7 +1035,7 @@ final class KeyGestureController { synchronized (mUserLock) { mCurrentUserId = userId; } mHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); } @MainThread Loading Loading @@ -1073,6 +1076,12 @@ final class KeyGestureController { AidlKeyGestureEvent event = (AidlKeyGestureEvent) msg.obj; notifyKeyGestureEvent(event); break; } return true; } private boolean handleIoMessage(Message msg) { switch (msg.what) { case MSG_PERSIST_CUSTOM_GESTURES: { final int userId = (Integer) msg.obj; persistInputGestures(userId); Loading @@ -1083,7 +1092,6 @@ final class KeyGestureController { loadInputGestures(userId); break; } } return true; } Loading Loading @@ -1144,7 +1152,7 @@ final class KeyGestureController { final int result = mInputGestureManager.addCustomInputGesture(userId, new InputGestureData(inputGestureData)); if (result == InputManager.CUSTOM_INPUT_GESTURE_RESULT_SUCCESS) { mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } return result; } Loading @@ -1156,7 +1164,7 @@ final class KeyGestureController { final int result = mInputGestureManager.removeCustomInputGesture(userId, new InputGestureData(inputGestureData)); if (result == InputManager.CUSTOM_INPUT_GESTURE_RESULT_SUCCESS) { mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } return result; } Loading @@ -1165,7 +1173,7 @@ final class KeyGestureController { public void removeAllCustomInputGestures(@UserIdInt int userId, @Nullable InputGestureData.Filter filter) { mInputGestureManager.removeAllCustomInputGestures(userId, filter); mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } @BinderThread Loading tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +1 −1 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ class InputManagerServiceTests { testLooper = TestLooper() service = InputManagerService(object : InputManagerService.Injector( context, testLooper.looper, uEventManager) { context, testLooper.looper, testLooper.looper, uEventManager) { override fun getNativeService( service: InputManagerService? ): NativeInputManagerService { Loading tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class KeyGestureControllerTests { private fun setupKeyGestureController() { keyGestureController = KeyGestureController(context, testLooper.looper, inputDataStore) KeyGestureController(context, testLooper.looper, testLooper.looper, inputDataStore) Mockito.`when`(iInputManager.getAppLaunchBookmarks()) .thenReturn(keyGestureController.appLaunchBookmarks) keyGestureController.systemRunning() Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ import com.android.internal.policy.KeyInterceptionInfo; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.server.DisplayThread; import com.android.server.IoThread; import com.android.server.LocalServices; import com.android.server.SystemService; import com.android.server.Watchdog; Loading Loading @@ -469,11 +470,13 @@ public class InputManagerService extends IInputManager.Stub static class Injector { private final Context mContext; private final Looper mLooper; private final Looper mIoLooper; private final UEventManager mUEventManager; Injector(Context context, Looper looper, UEventManager uEventManager) { Injector(Context context, Looper looper, Looper ioLooper, UEventManager uEventManager) { mContext = context; mLooper = looper; mIoLooper = ioLooper; mUEventManager = uEventManager; } Loading @@ -485,6 +488,10 @@ public class InputManagerService extends IInputManager.Stub return mLooper; } Looper getIoLooper() { return mIoLooper; } UEventManager getUEventManager() { return mUEventManager; } Loading @@ -505,8 +512,8 @@ public class InputManagerService extends IInputManager.Stub } public InputManagerService(Context context) { this(new Injector(context, DisplayThread.get().getLooper(), new UEventManager() {}), context.getSystemService(PermissionEnforcer.class)); this(new Injector(context, DisplayThread.get().getLooper(), IoThread.get().getLooper(), new UEventManager() {}), context.getSystemService(PermissionEnforcer.class)); } @VisibleForTesting Loading @@ -532,7 +539,7 @@ public class InputManagerService extends IInputManager.Stub mStickyModifierStateController = new StickyModifierStateController(); mInputDataStore = new InputDataStore(); mKeyGestureController = new KeyGestureController(mContext, injector.getLooper(), mInputDataStore); injector.getIoLooper(), mInputDataStore); mKeyboardLedController = new KeyboardLedController(mContext, injector.getLooper(), mNative); mKeyRemapper = new KeyRemapper(mContext, mNative, mDataStore, injector.getLooper()); Loading
services/core/java/com/android/server/input/KeyGestureController.java +15 −7 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ final class KeyGestureController { private final Context mContext; private final Handler mHandler; private final Handler mIoHandler; private final int mSystemPid; private final KeyCombinationManager mKeyCombinationManager; private final SettingsObserver mSettingsObserver; Loading Loading @@ -171,9 +172,11 @@ final class KeyGestureController { private final boolean mVisibleBackgroundUsersEnabled = isVisibleBackgroundUsersEnabled(); KeyGestureController(Context context, Looper looper, InputDataStore inputDataStore) { KeyGestureController(Context context, Looper looper, Looper ioLooper, InputDataStore inputDataStore) { mContext = context; mHandler = new Handler(looper, this::handleMessage); mIoHandler = new Handler(ioLooper, this::handleIoMessage); mSystemPid = Process.myPid(); mKeyGestureHandlerRecords = new TreeMap<>((p1, p2) -> { if (Objects.equals(p1, p2)) { Loading Loading @@ -458,7 +461,7 @@ final class KeyGestureController { userId = mCurrentUserId; } // Load the system user's input gestures. mHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); } public boolean interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { Loading Loading @@ -1032,7 +1035,7 @@ final class KeyGestureController { synchronized (mUserLock) { mCurrentUserId = userId; } mHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_LOAD_CUSTOM_GESTURES, userId).sendToTarget(); } @MainThread Loading Loading @@ -1073,6 +1076,12 @@ final class KeyGestureController { AidlKeyGestureEvent event = (AidlKeyGestureEvent) msg.obj; notifyKeyGestureEvent(event); break; } return true; } private boolean handleIoMessage(Message msg) { switch (msg.what) { case MSG_PERSIST_CUSTOM_GESTURES: { final int userId = (Integer) msg.obj; persistInputGestures(userId); Loading @@ -1083,7 +1092,6 @@ final class KeyGestureController { loadInputGestures(userId); break; } } return true; } Loading Loading @@ -1144,7 +1152,7 @@ final class KeyGestureController { final int result = mInputGestureManager.addCustomInputGesture(userId, new InputGestureData(inputGestureData)); if (result == InputManager.CUSTOM_INPUT_GESTURE_RESULT_SUCCESS) { mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } return result; } Loading @@ -1156,7 +1164,7 @@ final class KeyGestureController { final int result = mInputGestureManager.removeCustomInputGesture(userId, new InputGestureData(inputGestureData)); if (result == InputManager.CUSTOM_INPUT_GESTURE_RESULT_SUCCESS) { mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } return result; } Loading @@ -1165,7 +1173,7 @@ final class KeyGestureController { public void removeAllCustomInputGestures(@UserIdInt int userId, @Nullable InputGestureData.Filter filter) { mInputGestureManager.removeAllCustomInputGestures(userId, filter); mHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); mIoHandler.obtainMessage(MSG_PERSIST_CUSTOM_GESTURES, userId).sendToTarget(); } @BinderThread Loading
tests/Input/src/com/android/server/input/InputManagerServiceTests.kt +1 −1 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ class InputManagerServiceTests { testLooper = TestLooper() service = InputManagerService(object : InputManagerService.Injector( context, testLooper.looper, uEventManager) { context, testLooper.looper, testLooper.looper, uEventManager) { override fun getNativeService( service: InputManagerService? ): NativeInputManagerService { Loading
tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class KeyGestureControllerTests { private fun setupKeyGestureController() { keyGestureController = KeyGestureController(context, testLooper.looper, inputDataStore) KeyGestureController(context, testLooper.looper, testLooper.looper, inputDataStore) Mockito.`when`(iInputManager.getAppLaunchBookmarks()) .thenReturn(keyGestureController.appLaunchBookmarks) keyGestureController.systemRunning() Loading