summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/input/InputManagerService.java15
-rw-r--r--services/core/java/com/android/server/input/KeyGestureController.java22
-rw-r--r--tests/Input/src/com/android/server/input/InputManagerServiceTests.kt2
-rw-r--r--tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt2
4 files changed, 28 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 0e37238bcb84..c2fecf283a34 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -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;
@@ -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;
}
@@ -485,6 +488,10 @@ public class InputManagerService extends IInputManager.Stub
return mLooper;
}
+ Looper getIoLooper() {
+ return mIoLooper;
+ }
+
UEventManager getUEventManager() {
return mUEventManager;
}
@@ -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
@@ -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());
diff --git a/services/core/java/com/android/server/input/KeyGestureController.java b/services/core/java/com/android/server/input/KeyGestureController.java
index 5770a09e3b92..fba0b0453bfb 100644
--- a/services/core/java/com/android/server/input/KeyGestureController.java
+++ b/services/core/java/com/android/server/input/KeyGestureController.java
@@ -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;
@@ -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)) {
@@ -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) {
@@ -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
@@ -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);
@@ -1083,7 +1092,6 @@ final class KeyGestureController {
loadInputGestures(userId);
break;
}
-
}
return true;
}
@@ -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;
}
@@ -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;
}
@@ -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
diff --git a/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt b/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
index a2f6f0051116..eac426700ec1 100644
--- a/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
+++ b/tests/Input/src/com/android/server/input/InputManagerServiceTests.kt
@@ -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 {
diff --git a/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt b/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
index 88e84966634b..99c5bad7b2b9 100644
--- a/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
+++ b/tests/Input/src/com/android/server/input/KeyGestureControllerTests.kt
@@ -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()