Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 MaaTouch 在 Android 14 上触控崩溃的问题 #4

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public final class InputManager {
public static final int INJECT_MODE_WAIT_FOR_RESULT = 1;
public static final int INJECT_MODE_WAIT_FOR_FINISH = 2;

private final android.hardware.input.InputManager manager;
private final Object manager;
private Method injectInputEventMethod = null;

public InputManager(android.hardware.input.InputManager manager) {
public InputManager(Object manager) {
this.manager = manager;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.shxyke.MaaTouch.wrappers;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;

Expand Down Expand Up @@ -46,10 +47,15 @@ public DisplayManager getDisplayManager() {
public InputManager getInputManager() {
if (inputManager == null) {
try {
Method getInstanceMethod = android.hardware.input.InputManager.class.getDeclaredMethod("getInstance");
android.hardware.input.InputManager im = (android.hardware.input.InputManager) getInstanceMethod.invoke(null);
Method getInstanceMethod;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
getInstanceMethod = Class.forName("android.hardware.input.InputManagerGlobal").getMethod("getInstance");
} else {
getInstanceMethod = android.hardware.input.InputManager.class.getDeclaredMethod("getInstance");
}
Object im = getInstanceMethod.invoke(null);
inputManager = new InputManager(im);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
throw new AssertionError(e);
}
Expand Down
Loading