Merge "InputManagerService: Refactor native methods to be testable" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9496cb76fc
@@ -74,7 +74,6 @@ import android.os.InputEventInjectionSync;
|
|||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.MessageQueue;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -112,6 +111,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||||
import com.android.internal.notification.SystemNotificationChannels;
|
import com.android.internal.notification.SystemNotificationChannels;
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
@@ -147,9 +147,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
/*
|
/** The system implementation of {@link IInputManager} that manages input devices. */
|
||||||
* Wraps the C++ InputManager and provides its callbacks.
|
|
||||||
*/
|
|
||||||
public class InputManagerService extends IInputManager.Stub
|
public class InputManagerService extends IInputManager.Stub
|
||||||
implements Watchdog.Monitor {
|
implements Watchdog.Monitor {
|
||||||
static final String TAG = "InputManager";
|
static final String TAG = "InputManager";
|
||||||
@@ -183,8 +181,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
/** TODO(b/169067926): Remove this. */
|
/** TODO(b/169067926): Remove this. */
|
||||||
private static final boolean UNTRUSTED_TOUCHES_TOAST = false;
|
private static final boolean UNTRUSTED_TOUCHES_TOAST = false;
|
||||||
|
|
||||||
// Pointer to native input manager service object.
|
private final NativeInputManagerService mNative;
|
||||||
private final long mPtr;
|
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final InputManagerHandler mHandler;
|
private final InputManagerHandler mHandler;
|
||||||
@@ -299,91 +296,6 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
@GuardedBy("mInputMonitors")
|
@GuardedBy("mInputMonitors")
|
||||||
final Map<IBinder, GestureMonitorSpyWindow> mInputMonitors = new HashMap<>();
|
final Map<IBinder, GestureMonitorSpyWindow> mInputMonitors = new HashMap<>();
|
||||||
|
|
||||||
private static native long nativeInit(InputManagerService service,
|
|
||||||
Context context, MessageQueue messageQueue);
|
|
||||||
private static native void nativeStart(long ptr);
|
|
||||||
private static native void nativeSetDisplayViewports(long ptr,
|
|
||||||
DisplayViewport[] viewports);
|
|
||||||
|
|
||||||
private static native int nativeGetScanCodeState(long ptr,
|
|
||||||
int deviceId, int sourceMask, int scanCode);
|
|
||||||
private static native int nativeGetKeyCodeState(long ptr,
|
|
||||||
int deviceId, int sourceMask, int keyCode);
|
|
||||||
private static native int nativeGetSwitchState(long ptr,
|
|
||||||
int deviceId, int sourceMask, int sw);
|
|
||||||
private static native boolean nativeHasKeys(long ptr,
|
|
||||||
int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists);
|
|
||||||
private static native int nativeGetKeyCodeForKeyLocation(long ptr, int deviceId,
|
|
||||||
int locationKeyCode);
|
|
||||||
private static native InputChannel nativeCreateInputChannel(long ptr, String name);
|
|
||||||
private static native InputChannel nativeCreateInputMonitor(long ptr, int displayId,
|
|
||||||
String name, int pid);
|
|
||||||
private static native void nativeRemoveInputChannel(long ptr, IBinder connectionToken);
|
|
||||||
private static native void nativePilferPointers(long ptr, IBinder token);
|
|
||||||
private static native void nativeSetInputFilterEnabled(long ptr, boolean enable);
|
|
||||||
private static native boolean nativeSetInTouchMode(long ptr, boolean inTouchMode, int pid,
|
|
||||||
int uid, boolean hasPermission);
|
|
||||||
private static native void nativeSetMaximumObscuringOpacityForTouch(long ptr, float opacity);
|
|
||||||
private static native void nativeSetBlockUntrustedTouchesMode(long ptr, int mode);
|
|
||||||
private static native int nativeInjectInputEvent(long ptr, InputEvent event,
|
|
||||||
boolean injectIntoUid, int uid, int syncMode, int timeoutMillis, int policyFlags);
|
|
||||||
private static native VerifiedInputEvent nativeVerifyInputEvent(long ptr, InputEvent event);
|
|
||||||
private static native void nativeToggleCapsLock(long ptr, int deviceId);
|
|
||||||
private static native void nativeDisplayRemoved(long ptr, int displayId);
|
|
||||||
private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen);
|
|
||||||
private static native void nativeSetSystemUiLightsOut(long ptr, boolean lightsOut);
|
|
||||||
private static native void nativeSetFocusedApplication(long ptr,
|
|
||||||
int displayId, InputApplicationHandle application);
|
|
||||||
private static native void nativeSetFocusedDisplay(long ptr, int displayId);
|
|
||||||
private static native boolean nativeTransferTouchFocus(long ptr,
|
|
||||||
IBinder fromChannelToken, IBinder toChannelToken, boolean isDragDrop);
|
|
||||||
private static native boolean nativeTransferTouch(long ptr, IBinder destChannelToken);
|
|
||||||
private static native void nativeSetPointerSpeed(long ptr, int speed);
|
|
||||||
private static native void nativeSetPointerAcceleration(long ptr, float acceleration);
|
|
||||||
private static native void nativeSetShowTouches(long ptr, boolean enabled);
|
|
||||||
private static native void nativeSetInteractive(long ptr, boolean interactive);
|
|
||||||
private static native void nativeReloadCalibration(long ptr);
|
|
||||||
private static native void nativeVibrate(long ptr, int deviceId, long[] pattern,
|
|
||||||
int[] amplitudes, int repeat, int token);
|
|
||||||
private static native void nativeVibrateCombined(long ptr, int deviceId, long[] pattern,
|
|
||||||
SparseArray<int[]> amplitudes, int repeat, int token);
|
|
||||||
private static native void nativeCancelVibrate(long ptr, int deviceId, int token);
|
|
||||||
private static native boolean nativeIsVibrating(long ptr, int deviceId);
|
|
||||||
private static native int[] nativeGetVibratorIds(long ptr, int deviceId);
|
|
||||||
private static native int nativeGetBatteryCapacity(long ptr, int deviceId);
|
|
||||||
private static native int nativeGetBatteryStatus(long ptr, int deviceId);
|
|
||||||
private static native List<Light> nativeGetLights(long ptr, int deviceId);
|
|
||||||
private static native int nativeGetLightPlayerId(long ptr, int deviceId, int lightId);
|
|
||||||
private static native int nativeGetLightColor(long ptr, int deviceId, int lightId);
|
|
||||||
private static native void nativeSetLightPlayerId(long ptr, int deviceId, int lightId,
|
|
||||||
int playerId);
|
|
||||||
private static native void nativeSetLightColor(long ptr, int deviceId, int lightId, int color);
|
|
||||||
private static native void nativeReloadKeyboardLayouts(long ptr);
|
|
||||||
private static native void nativeReloadDeviceAliases(long ptr);
|
|
||||||
private static native String nativeDump(long ptr);
|
|
||||||
private static native void nativeMonitor(long ptr);
|
|
||||||
private static native boolean nativeIsInputDeviceEnabled(long ptr, int deviceId);
|
|
||||||
private static native void nativeEnableInputDevice(long ptr, int deviceId);
|
|
||||||
private static native void nativeDisableInputDevice(long ptr, int deviceId);
|
|
||||||
private static native void nativeSetPointerIconType(long ptr, int iconId);
|
|
||||||
private static native void nativeReloadPointerIcons(long ptr);
|
|
||||||
private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon);
|
|
||||||
private static native void nativeRequestPointerCapture(long ptr, IBinder windowToken,
|
|
||||||
boolean enabled);
|
|
||||||
private static native boolean nativeCanDispatchToDisplay(long ptr, int deviceId, int displayId);
|
|
||||||
private static native void nativeNotifyPortAssociationsChanged(long ptr);
|
|
||||||
private static native void nativeChangeUniqueIdAssociation(long ptr);
|
|
||||||
private static native void nativeNotifyPointerDisplayIdChanged(long ptr);
|
|
||||||
private static native void nativeSetDisplayEligibilityForPointerCapture(long ptr, int displayId,
|
|
||||||
boolean enabled);
|
|
||||||
private static native void nativeSetMotionClassifierEnabled(long ptr, boolean enabled);
|
|
||||||
private static native InputSensorInfo[] nativeGetSensorList(long ptr, int deviceId);
|
|
||||||
private static native boolean nativeFlushSensor(long ptr, int deviceId, int sensorType);
|
|
||||||
private static native boolean nativeEnableSensor(long ptr, int deviceId, int sensorType,
|
|
||||||
int samplingPeriodUs, int maxBatchReportLatencyUs);
|
|
||||||
private static native void nativeDisableSensor(long ptr, int deviceId, int sensorType);
|
|
||||||
private static native void nativeCancelCurrentTouch(long ptr);
|
|
||||||
|
|
||||||
// Maximum number of milliseconds to wait for input event injection.
|
// Maximum number of milliseconds to wait for input event injection.
|
||||||
private static final int INJECTION_TIMEOUT_MILLIS = 30 * 1000;
|
private static final int INJECTION_TIMEOUT_MILLIS = 30 * 1000;
|
||||||
|
|
||||||
@@ -450,18 +362,47 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
/** Whether to use the dev/input/event or uevent subsystem for the audio jack. */
|
/** Whether to use the dev/input/event or uevent subsystem for the audio jack. */
|
||||||
final boolean mUseDevInputEventForAudioJack;
|
final boolean mUseDevInputEventForAudioJack;
|
||||||
|
|
||||||
|
/** Point of injection for test dependencies. */
|
||||||
|
@VisibleForTesting
|
||||||
|
static class Injector {
|
||||||
|
private final Context mContext;
|
||||||
|
private final Looper mLooper;
|
||||||
|
|
||||||
|
Injector(Context context, Looper looper) {
|
||||||
|
mContext = context;
|
||||||
|
mLooper = looper;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context getContext() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
Looper getLooper() {
|
||||||
|
return mLooper;
|
||||||
|
}
|
||||||
|
|
||||||
|
NativeInputManagerService getNativeService(InputManagerService service) {
|
||||||
|
return new NativeInputManagerService.NativeImpl(service, mContext, mLooper.getQueue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public InputManagerService(Context context) {
|
public InputManagerService(Context context) {
|
||||||
this.mContext = context;
|
this(new Injector(context, DisplayThread.get().getLooper()));
|
||||||
this.mHandler = new InputManagerHandler(DisplayThread.get().getLooper());
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
InputManagerService(Injector injector) {
|
||||||
|
mContext = injector.getContext();
|
||||||
|
mHandler = new InputManagerHandler(injector.getLooper());
|
||||||
|
mNative = injector.getNativeService(this);
|
||||||
|
|
||||||
mStaticAssociations = loadStaticInputPortAssociations();
|
mStaticAssociations = loadStaticInputPortAssociations();
|
||||||
mUseDevInputEventForAudioJack =
|
mUseDevInputEventForAudioJack =
|
||||||
context.getResources().getBoolean(R.bool.config_useDevInputEventForAudioJack);
|
mContext.getResources().getBoolean(R.bool.config_useDevInputEventForAudioJack);
|
||||||
Slog.i(TAG, "Initializing input manager, mUseDevInputEventForAudioJack="
|
Slog.i(TAG, "Initializing input manager, mUseDevInputEventForAudioJack="
|
||||||
+ mUseDevInputEventForAudioJack);
|
+ mUseDevInputEventForAudioJack);
|
||||||
mPtr = nativeInit(this, mContext, mHandler.getLooper().getQueue());
|
|
||||||
|
|
||||||
String doubleTouchGestureEnablePath = context.getResources().getString(
|
String doubleTouchGestureEnablePath = mContext.getResources().getString(
|
||||||
R.string.config_doubleTouchGestureEnableFile);
|
R.string.config_doubleTouchGestureEnableFile);
|
||||||
mDoubleTouchGestureEnableFile = TextUtils.isEmpty(doubleTouchGestureEnablePath) ? null :
|
mDoubleTouchGestureEnableFile = TextUtils.isEmpty(doubleTouchGestureEnablePath) ? null :
|
||||||
new File(doubleTouchGestureEnablePath);
|
new File(doubleTouchGestureEnablePath);
|
||||||
@@ -504,9 +445,9 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Slog.i(TAG, "Starting input manager");
|
Slog.i(TAG, "Starting input manager");
|
||||||
nativeStart(mPtr);
|
mNative.start();
|
||||||
|
|
||||||
// Add ourself to the Watchdog monitors.
|
// Add ourselves to the Watchdog monitors.
|
||||||
Watchdog.getInstance().addMonitor(this);
|
Watchdog.getInstance().addMonitor(this);
|
||||||
|
|
||||||
registerPointerSpeedSettingObserver();
|
registerPointerSpeedSettingObserver();
|
||||||
@@ -599,14 +540,14 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "Reloading keyboard layouts.");
|
Slog.d(TAG, "Reloading keyboard layouts.");
|
||||||
}
|
}
|
||||||
nativeReloadKeyboardLayouts(mPtr);
|
mNative.reloadKeyboardLayouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadDeviceAliases() {
|
private void reloadDeviceAliases() {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "Reloading device names.");
|
Slog.d(TAG, "Reloading device names.");
|
||||||
}
|
}
|
||||||
nativeReloadDeviceAliases(mPtr);
|
mNative.reloadDeviceAliases();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDisplayViewportsInternal(List<DisplayViewport> viewports) {
|
private void setDisplayViewportsInternal(List<DisplayViewport> viewports) {
|
||||||
@@ -615,7 +556,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
for (int i = viewports.size() - 1; i >= 0; --i) {
|
for (int i = viewports.size() - 1; i >= 0; --i) {
|
||||||
vArray[i] = viewports.get(i);
|
vArray[i] = viewports.get(i);
|
||||||
}
|
}
|
||||||
nativeSetDisplayViewports(mPtr, vArray);
|
mNative.setDisplayViewports(vArray);
|
||||||
|
|
||||||
if (mOverriddenPointerDisplayId != Display.INVALID_DISPLAY) {
|
if (mOverriddenPointerDisplayId != Display.INVALID_DISPLAY) {
|
||||||
final AdditionalDisplayInputProperties properties =
|
final AdditionalDisplayInputProperties properties =
|
||||||
@@ -642,7 +583,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @return The key state.
|
* @return The key state.
|
||||||
*/
|
*/
|
||||||
public int getKeyCodeState(int deviceId, int sourceMask, int keyCode) {
|
public int getKeyCodeState(int deviceId, int sourceMask, int keyCode) {
|
||||||
return nativeGetKeyCodeState(mPtr, deviceId, sourceMask, keyCode);
|
return mNative.getKeyCodeState(deviceId, sourceMask, keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -655,7 +596,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @return The key state.
|
* @return The key state.
|
||||||
*/
|
*/
|
||||||
public int getScanCodeState(int deviceId, int sourceMask, int scanCode) {
|
public int getScanCodeState(int deviceId, int sourceMask, int scanCode) {
|
||||||
return nativeGetScanCodeState(mPtr, deviceId, sourceMask, scanCode);
|
return mNative.getScanCodeState(deviceId, sourceMask, scanCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -668,7 +609,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @return The switch state.
|
* @return The switch state.
|
||||||
*/
|
*/
|
||||||
public int getSwitchState(int deviceId, int sourceMask, int switchCode) {
|
public int getSwitchState(int deviceId, int sourceMask, int switchCode) {
|
||||||
return nativeGetSwitchState(mPtr, deviceId, sourceMask, switchCode);
|
return mNative.getSwitchState(deviceId, sourceMask, switchCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -691,7 +632,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
throw new IllegalArgumentException("keyExists must be at least as large as keyCodes");
|
throw new IllegalArgumentException("keyExists must be at least as large as keyCodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
return nativeHasKeys(mPtr, deviceId, sourceMask, keyCodes, keyExists);
|
return mNative.hasKeys(deviceId, sourceMask, keyCodes, keyExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -707,7 +648,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
if (locationKeyCode <= KEYCODE_UNKNOWN || locationKeyCode > KeyEvent.getMaxKeyCode()) {
|
if (locationKeyCode <= KEYCODE_UNKNOWN || locationKeyCode > KeyEvent.getMaxKeyCode()) {
|
||||||
return KEYCODE_UNKNOWN;
|
return KEYCODE_UNKNOWN;
|
||||||
}
|
}
|
||||||
return nativeGetKeyCodeForKeyLocation(mPtr, deviceId, locationKeyCode);
|
return mNative.getKeyCodeForKeyLocation(deviceId, locationKeyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -720,7 +661,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
public boolean transferTouch(IBinder destChannelToken) {
|
public boolean transferTouch(IBinder destChannelToken) {
|
||||||
// TODO(b/162194035): Replace this with a SPY window
|
// TODO(b/162194035): Replace this with a SPY window
|
||||||
Objects.requireNonNull(destChannelToken, "destChannelToken must not be null");
|
Objects.requireNonNull(destChannelToken, "destChannelToken must not be null");
|
||||||
return nativeTransferTouch(mPtr, destChannelToken);
|
return mNative.transferTouch(destChannelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -736,7 +677,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
throw new IllegalArgumentException("displayId must >= 0.");
|
throw new IllegalArgumentException("displayId must >= 0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return nativeCreateInputMonitor(mPtr, displayId, inputChannelName, Binder.getCallingPid());
|
return mNative.createInputMonitor(displayId, inputChannelName, Binder.getCallingPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -818,7 +759,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @param name The name of this input channel
|
* @param name The name of this input channel
|
||||||
*/
|
*/
|
||||||
public InputChannel createInputChannel(String name) {
|
public InputChannel createInputChannel(String name) {
|
||||||
return nativeCreateInputChannel(mPtr, name);
|
return mNative.createInputChannel(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -827,7 +768,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
*/
|
*/
|
||||||
public void removeInputChannel(IBinder connectionToken) {
|
public void removeInputChannel(IBinder connectionToken) {
|
||||||
Objects.requireNonNull(connectionToken, "connectionToken must not be null");
|
Objects.requireNonNull(connectionToken, "connectionToken must not be null");
|
||||||
nativeRemoveInputChannel(mPtr, connectionToken);
|
mNative.removeInputChannel(connectionToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -869,7 +810,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeSetInputFilterEnabled(mPtr, filter != null);
|
mNative.setInputFilterEnabled(filter != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,7 +834,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @return {@code true} if the touch mode was successfully changed, {@code false} otherwise
|
* @return {@code true} if the touch mode was successfully changed, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public boolean setInTouchMode(boolean inTouchMode, int pid, int uid, boolean hasPermission) {
|
public boolean setInTouchMode(boolean inTouchMode, int pid, int uid, boolean hasPermission) {
|
||||||
return nativeSetInTouchMode(mPtr, inTouchMode, pid, uid, hasPermission);
|
return mNative.setInTouchMode(inTouchMode, pid, uid, hasPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
@@ -918,7 +859,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
final boolean injectIntoUid = targetUid != Process.INVALID_UID;
|
final boolean injectIntoUid = targetUid != Process.INVALID_UID;
|
||||||
final int result;
|
final int result;
|
||||||
try {
|
try {
|
||||||
result = nativeInjectInputEvent(mPtr, event, injectIntoUid,
|
result = mNative.injectInputEvent(event, injectIntoUid,
|
||||||
targetUid, mode, INJECTION_TIMEOUT_MILLIS,
|
targetUid, mode, INJECTION_TIMEOUT_MILLIS,
|
||||||
WindowManagerPolicy.FLAG_DISABLE_KEY_REPEAT);
|
WindowManagerPolicy.FLAG_DISABLE_KEY_REPEAT);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -962,7 +903,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public VerifiedInputEvent verifyInputEvent(InputEvent event) {
|
public VerifiedInputEvent verifyInputEvent(InputEvent event) {
|
||||||
Objects.requireNonNull(event, "event must not be null");
|
Objects.requireNonNull(event, "event must not be null");
|
||||||
return nativeVerifyInputEvent(mPtr, event);
|
return mNative.verifyInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -985,7 +926,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
// Binder call
|
// Binder call
|
||||||
@Override
|
@Override
|
||||||
public boolean isInputDeviceEnabled(int deviceId) {
|
public boolean isInputDeviceEnabled(int deviceId) {
|
||||||
return nativeIsInputDeviceEnabled(mPtr, deviceId);
|
return mNative.isInputDeviceEnabled(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@@ -995,7 +936,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
"enableInputDevice()")) {
|
"enableInputDevice()")) {
|
||||||
throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission");
|
throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission");
|
||||||
}
|
}
|
||||||
nativeEnableInputDevice(mPtr, deviceId);
|
mNative.enableInputDevice(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@@ -1005,7 +946,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
"disableInputDevice()")) {
|
"disableInputDevice()")) {
|
||||||
throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission");
|
throw new SecurityException("Requires DISABLE_INPUT_DEVICE permission");
|
||||||
}
|
}
|
||||||
nativeDisableInputDevice(mPtr, deviceId);
|
mNative.disableInputDevice(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1251,7 +1192,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
try {
|
try {
|
||||||
if (mDataStore.setTouchCalibration(inputDeviceDescriptor, surfaceRotation,
|
if (mDataStore.setTouchCalibration(inputDeviceDescriptor, surfaceRotation,
|
||||||
calibration)) {
|
calibration)) {
|
||||||
nativeReloadCalibration(mPtr);
|
mNative.reloadCalibration();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
mDataStore.saveIfNeeded();
|
mDataStore.saveIfNeeded();
|
||||||
@@ -1763,11 +1704,11 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFocusedApplication(int displayId, InputApplicationHandle application) {
|
public void setFocusedApplication(int displayId, InputApplicationHandle application) {
|
||||||
nativeSetFocusedApplication(mPtr, displayId, application);
|
mNative.setFocusedApplication(displayId, application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFocusedDisplay(int displayId) {
|
public void setFocusedDisplay(int displayId) {
|
||||||
nativeSetFocusedDisplay(mPtr, displayId);
|
mNative.setFocusedDisplay(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clean up input window handles of the given display. */
|
/** Clean up input window handles of the given display. */
|
||||||
@@ -1777,22 +1718,22 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
mPointerIconDisplayContext = null;
|
mPointerIconDisplayContext = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeDisplayRemoved(mPtr, displayId);
|
mNative.displayRemoved(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestPointerCapture(IBinder inputChannelToken, boolean enabled) {
|
public void requestPointerCapture(IBinder inputChannelToken, boolean enabled) {
|
||||||
Objects.requireNonNull(inputChannelToken, "event must not be null");
|
Objects.requireNonNull(inputChannelToken, "event must not be null");
|
||||||
|
|
||||||
nativeRequestPointerCapture(mPtr, inputChannelToken, enabled);
|
mNative.requestPointerCapture(inputChannelToken, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInputDispatchMode(boolean enabled, boolean frozen) {
|
public void setInputDispatchMode(boolean enabled, boolean frozen) {
|
||||||
nativeSetInputDispatchMode(mPtr, enabled, frozen);
|
mNative.setInputDispatchMode(enabled, frozen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSystemUiLightsOut(boolean lightsOut) {
|
public void setSystemUiLightsOut(boolean lightsOut) {
|
||||||
nativeSetSystemUiLightsOut(mPtr, lightsOut);
|
mNative.setSystemUiLightsOut(lightsOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1811,7 +1752,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
*/
|
*/
|
||||||
public boolean transferTouchFocus(@NonNull InputChannel fromChannel,
|
public boolean transferTouchFocus(@NonNull InputChannel fromChannel,
|
||||||
@NonNull InputChannel toChannel, boolean isDragDrop) {
|
@NonNull InputChannel toChannel, boolean isDragDrop) {
|
||||||
return nativeTransferTouchFocus(mPtr, fromChannel.getToken(), toChannel.getToken(),
|
return mNative.transferTouchFocus(fromChannel.getToken(), toChannel.getToken(),
|
||||||
isDragDrop);
|
isDragDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1832,7 +1773,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
@NonNull IBinder toChannelToken) {
|
@NonNull IBinder toChannelToken) {
|
||||||
Objects.nonNull(fromChannelToken);
|
Objects.nonNull(fromChannelToken);
|
||||||
Objects.nonNull(toChannelToken);
|
Objects.nonNull(toChannelToken);
|
||||||
return nativeTransferTouchFocus(mPtr, fromChannelToken, toChannelToken,
|
return mNative.transferTouchFocus(fromChannelToken, toChannelToken,
|
||||||
false /* isDragDrop */);
|
false /* isDragDrop */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1858,7 +1799,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
private void setPointerSpeedUnchecked(int speed) {
|
private void setPointerSpeedUnchecked(int speed) {
|
||||||
speed = Math.min(Math.max(speed, InputManager.MIN_POINTER_SPEED),
|
speed = Math.min(Math.max(speed, InputManager.MIN_POINTER_SPEED),
|
||||||
InputManager.MAX_POINTER_SPEED);
|
InputManager.MAX_POINTER_SPEED);
|
||||||
nativeSetPointerSpeed(mPtr, speed);
|
mNative.setPointerSpeed(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPointerAcceleration(float acceleration, int displayId) {
|
private void setPointerAcceleration(float acceleration, int displayId) {
|
||||||
@@ -1881,7 +1822,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
@GuardedBy("mAdditionalDisplayInputPropertiesLock")
|
@GuardedBy("mAdditionalDisplayInputPropertiesLock")
|
||||||
private void updatePointerAccelerationLocked(float acceleration) {
|
private void updatePointerAccelerationLocked(float acceleration) {
|
||||||
nativeSetPointerAcceleration(mPtr, acceleration);
|
mNative.setPointerAcceleration(acceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPointerIconVisible(boolean visible, int displayId) {
|
private void setPointerIconVisible(boolean visible, int displayId) {
|
||||||
@@ -1906,12 +1847,12 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
private void updatePointerIconVisibleLocked(boolean visible) {
|
private void updatePointerIconVisibleLocked(boolean visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (mIconType == PointerIcon.TYPE_CUSTOM) {
|
if (mIconType == PointerIcon.TYPE_CUSTOM) {
|
||||||
nativeSetCustomPointerIcon(mPtr, mIcon);
|
mNative.setCustomPointerIcon(mIcon);
|
||||||
} else {
|
} else {
|
||||||
nativeSetPointerIconType(mPtr, mIconType);
|
mNative.setPointerIconType(mIconType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nativeSetPointerIconType(mPtr, PointerIcon.TYPE_NULL);
|
mNative.setPointerIconType(PointerIcon.TYPE_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1938,7 +1879,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
private void updateShowTouchesFromSettings() {
|
private void updateShowTouchesFromSettings() {
|
||||||
int setting = getShowTouchesSetting(0);
|
int setting = getShowTouchesSetting(0);
|
||||||
nativeSetShowTouches(mPtr, setting != 0);
|
mNative.setShowTouches(setting != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerShowTouchesSettingObserver() {
|
private void registerShowTouchesSettingObserver() {
|
||||||
@@ -1957,7 +1898,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
|
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
|
||||||
0, UserHandle.USER_CURRENT);
|
0, UserHandle.USER_CURRENT);
|
||||||
PointerIcon.setUseLargeIcons(accessibilityConfig == 1);
|
PointerIcon.setUseLargeIcons(accessibilityConfig == 1);
|
||||||
nativeReloadPointerIcons(mPtr);
|
mNative.reloadPointerIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerAccessibilityLargePointerSettingObserver() {
|
private void registerAccessibilityLargePointerSettingObserver() {
|
||||||
@@ -1985,7 +1926,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
(enabled ? "Enabling" : "Disabling") + " motion classifier because " + reason
|
(enabled ? "Enabling" : "Disabling") + " motion classifier because " + reason
|
||||||
+ ": feature " + (featureEnabledFlag ? "enabled" : "disabled")
|
+ ": feature " + (featureEnabledFlag ? "enabled" : "disabled")
|
||||||
+ ", long press timeout = " + timeout);
|
+ ", long press timeout = " + timeout);
|
||||||
nativeSetMotionClassifierEnabled(mPtr, enabled);
|
mNative.setMotionClassifierEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerLongPressTimeoutObserver() {
|
private void registerLongPressTimeoutObserver() {
|
||||||
@@ -2013,7 +1954,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
private void updateBlockUntrustedTouchesModeFromSettings() {
|
private void updateBlockUntrustedTouchesModeFromSettings() {
|
||||||
final int mode = InputManager.getInstance().getBlockUntrustedTouchesMode(mContext);
|
final int mode = InputManager.getInstance().getBlockUntrustedTouchesMode(mContext);
|
||||||
nativeSetBlockUntrustedTouchesMode(mPtr, mode);
|
mNative.setBlockUntrustedTouchesMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerMaximumObscuringOpacityForTouchSettingObserver() {
|
private void registerMaximumObscuringOpacityForTouchSettingObserver() {
|
||||||
@@ -2035,7 +1976,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
+ ", it should be >= 0 and <= 1, rejecting update.");
|
+ ", it should be >= 0 and <= 1, rejecting update.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nativeSetMaximumObscuringOpacityForTouch(mPtr, opacity);
|
mNative.setMaximumObscuringOpacityForTouch(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getShowTouchesSetting(int defaultValue) {
|
private int getShowTouchesSetting(int defaultValue) {
|
||||||
@@ -2061,7 +2002,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(b/215597605): trigger MousePositionTracker update
|
// TODO(b/215597605): trigger MousePositionTracker update
|
||||||
nativeNotifyPointerDisplayIdChanged(mPtr);
|
mNative.notifyPointerDisplayIdChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVirtualMousePointerDisplayId() {
|
private int getVirtualMousePointerDisplayId() {
|
||||||
@@ -2071,7 +2012,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDisplayEligibilityForPointerCapture(int displayId, boolean isEligible) {
|
private void setDisplayEligibilityForPointerCapture(int displayId, boolean isEligible) {
|
||||||
nativeSetDisplayEligibilityForPointerCapture(mPtr, displayId, isEligible);
|
mNative.setDisplayEligibilityForPointerCapture(displayId, isEligible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class VibrationInfo {
|
private static class VibrationInfo {
|
||||||
@@ -2170,7 +2111,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
VibratorToken v = getVibratorToken(deviceId, token);
|
VibratorToken v = getVibratorToken(deviceId, token);
|
||||||
synchronized (v) {
|
synchronized (v) {
|
||||||
v.mVibrating = true;
|
v.mVibrating = true;
|
||||||
nativeVibrate(mPtr, deviceId, info.getPattern(), info.getAmplitudes(),
|
mNative.vibrate(deviceId, info.getPattern(), info.getAmplitudes(),
|
||||||
info.getRepeatIndex(), v.mTokenValue);
|
info.getRepeatIndex(), v.mTokenValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2178,13 +2119,13 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
// Binder call
|
// Binder call
|
||||||
@Override
|
@Override
|
||||||
public int[] getVibratorIds(int deviceId) {
|
public int[] getVibratorIds(int deviceId) {
|
||||||
return nativeGetVibratorIds(mPtr, deviceId);
|
return mNative.getVibratorIds(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@Override
|
@Override
|
||||||
public boolean isVibrating(int deviceId) {
|
public boolean isVibrating(int deviceId) {
|
||||||
return nativeIsVibrating(mPtr, deviceId);
|
return mNative.isVibrating(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@@ -2202,7 +2143,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
if (effect instanceof CombinedVibration.Mono) {
|
if (effect instanceof CombinedVibration.Mono) {
|
||||||
CombinedVibration.Mono mono = (CombinedVibration.Mono) effect;
|
CombinedVibration.Mono mono = (CombinedVibration.Mono) effect;
|
||||||
VibrationInfo info = new VibrationInfo(mono.getEffect());
|
VibrationInfo info = new VibrationInfo(mono.getEffect());
|
||||||
nativeVibrate(mPtr, deviceId, info.getPattern(), info.getAmplitudes(),
|
mNative.vibrate(deviceId, info.getPattern(), info.getAmplitudes(),
|
||||||
info.getRepeatIndex(), v.mTokenValue);
|
info.getRepeatIndex(), v.mTokenValue);
|
||||||
} else if (effect instanceof CombinedVibration.Stereo) {
|
} else if (effect instanceof CombinedVibration.Stereo) {
|
||||||
CombinedVibration.Stereo stereo = (CombinedVibration.Stereo) effect;
|
CombinedVibration.Stereo stereo = (CombinedVibration.Stereo) effect;
|
||||||
@@ -2221,7 +2162,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
}
|
}
|
||||||
amplitudes.put(effects.keyAt(i), info.getAmplitudes());
|
amplitudes.put(effects.keyAt(i), info.getAmplitudes());
|
||||||
}
|
}
|
||||||
nativeVibrateCombined(mPtr, deviceId, pattern, amplitudes, repeat,
|
mNative.vibrateCombined(deviceId, pattern, amplitudes, repeat,
|
||||||
v.mTokenValue);
|
v.mTokenValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2252,7 +2193,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
private void cancelVibrateIfNeeded(VibratorToken v) {
|
private void cancelVibrateIfNeeded(VibratorToken v) {
|
||||||
synchronized (v) {
|
synchronized (v) {
|
||||||
if (v.mVibrating) {
|
if (v.mVibrating) {
|
||||||
nativeCancelVibrate(mPtr, v.mDeviceId, v.mTokenValue);
|
mNative.cancelVibrate(v.mDeviceId, v.mTokenValue);
|
||||||
v.mVibrating = false;
|
v.mVibrating = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2348,13 +2289,13 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
// Binder call
|
// Binder call
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryStatus(int deviceId) {
|
public int getBatteryStatus(int deviceId) {
|
||||||
return nativeGetBatteryStatus(mPtr, deviceId);
|
return mNative.getBatteryStatus(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCapacity(int deviceId) {
|
public int getBatteryCapacity(int deviceId) {
|
||||||
return nativeGetBatteryCapacity(mPtr, deviceId);
|
return mNative.getBatteryCapacity(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binder call
|
// Binder call
|
||||||
@@ -2370,10 +2311,10 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
final AdditionalDisplayInputProperties properties =
|
final AdditionalDisplayInputProperties properties =
|
||||||
mAdditionalDisplayInputProperties.get(mOverriddenPointerDisplayId);
|
mAdditionalDisplayInputProperties.get(mOverriddenPointerDisplayId);
|
||||||
if (properties == null || properties.pointerIconVisible) {
|
if (properties == null || properties.pointerIconVisible) {
|
||||||
nativeSetPointerIconType(mPtr, mIconType);
|
mNative.setPointerIconType(mIconType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nativeSetPointerIconType(mPtr, mIconType);
|
mNative.setPointerIconType(mIconType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2391,10 +2332,10 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
if (properties == null || properties.pointerIconVisible) {
|
if (properties == null || properties.pointerIconVisible) {
|
||||||
// Only set the icon if it is not currently hidden; otherwise, it will be set
|
// Only set the icon if it is not currently hidden; otherwise, it will be set
|
||||||
// once it's no longer hidden.
|
// once it's no longer hidden.
|
||||||
nativeSetCustomPointerIcon(mPtr, mIcon);
|
mNative.setCustomPointerIcon(mIcon);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nativeSetCustomPointerIcon(mPtr, mIcon);
|
mNative.setCustomPointerIcon(mIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2418,7 +2359,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
synchronized (mAssociationsLock) {
|
synchronized (mAssociationsLock) {
|
||||||
mRuntimeAssociations.put(inputPort, displayPort);
|
mRuntimeAssociations.put(inputPort, displayPort);
|
||||||
}
|
}
|
||||||
nativeNotifyPortAssociationsChanged(mPtr);
|
mNative.notifyPortAssociationsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2439,7 +2380,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
synchronized (mAssociationsLock) {
|
synchronized (mAssociationsLock) {
|
||||||
mRuntimeAssociations.remove(inputPort);
|
mRuntimeAssociations.remove(inputPort);
|
||||||
}
|
}
|
||||||
nativeNotifyPortAssociationsChanged(mPtr);
|
mNative.notifyPortAssociationsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
@@ -2456,7 +2397,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
synchronized (mAssociationsLock) {
|
synchronized (mAssociationsLock) {
|
||||||
mUniqueIdAssociations.put(inputPort, displayUniqueId);
|
mUniqueIdAssociations.put(inputPort, displayUniqueId);
|
||||||
}
|
}
|
||||||
nativeChangeUniqueIdAssociation(mPtr);
|
mNative.changeUniqueIdAssociation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
@@ -2472,12 +2413,12 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
synchronized (mAssociationsLock) {
|
synchronized (mAssociationsLock) {
|
||||||
mUniqueIdAssociations.remove(inputPort);
|
mUniqueIdAssociations.remove(inputPort);
|
||||||
}
|
}
|
||||||
nativeChangeUniqueIdAssociation(mPtr);
|
mNative.changeUniqueIdAssociation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public InputSensorInfo[] getSensorList(int deviceId) {
|
public InputSensorInfo[] getSensorList(int deviceId) {
|
||||||
return nativeGetSensorList(mPtr, deviceId);
|
return mNative.getSensorList(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
@@ -2538,7 +2479,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
int callingPid = Binder.getCallingPid();
|
int callingPid = Binder.getCallingPid();
|
||||||
SensorEventListenerRecord listener = mSensorEventListeners.get(callingPid);
|
SensorEventListenerRecord listener = mSensorEventListeners.get(callingPid);
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
return nativeFlushSensor(mPtr, deviceId, sensorType);
|
return mNative.flushSensor(deviceId, sensorType);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2548,7 +2489,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
public boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
|
public boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
|
||||||
int maxBatchReportLatencyUs) {
|
int maxBatchReportLatencyUs) {
|
||||||
synchronized (mInputDevicesLock) {
|
synchronized (mInputDevicesLock) {
|
||||||
return nativeEnableSensor(mPtr, deviceId, sensorType, samplingPeriodUs,
|
return mNative.enableSensor(deviceId, sensorType, samplingPeriodUs,
|
||||||
maxBatchReportLatencyUs);
|
maxBatchReportLatencyUs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2556,7 +2497,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void disableSensor(int deviceId, int sensorType) {
|
public void disableSensor(int deviceId, int sensorType) {
|
||||||
synchronized (mInputDevicesLock) {
|
synchronized (mInputDevicesLock) {
|
||||||
nativeDisableSensor(mPtr, deviceId, sensorType);
|
mNative.disableSensor(deviceId, sensorType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2595,7 +2536,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
*/
|
*/
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public List<Light> getLights(int deviceId) {
|
public List<Light> getLights(int deviceId) {
|
||||||
return nativeGetLights(mPtr, deviceId);
|
return mNative.getLights(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2608,11 +2549,11 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
+ "lightState " + lightState);
|
+ "lightState " + lightState);
|
||||||
}
|
}
|
||||||
if (light.getType() == Light.LIGHT_TYPE_PLAYER_ID) {
|
if (light.getType() == Light.LIGHT_TYPE_PLAYER_ID) {
|
||||||
nativeSetLightPlayerId(mPtr, deviceId, light.getId(), lightState.getPlayerId());
|
mNative.setLightPlayerId(deviceId, light.getId(), lightState.getPlayerId());
|
||||||
} else {
|
} else {
|
||||||
// Set ARGB format color to input device light
|
// Set ARGB format color to input device light
|
||||||
// Refer to https://developer.android.com/reference/kotlin/android/graphics/Color
|
// Refer to https://developer.android.com/reference/kotlin/android/graphics/Color
|
||||||
nativeSetLightColor(mPtr, deviceId, light.getId(), lightState.getColor());
|
mNative.setLightColor(deviceId, light.getId(), lightState.getColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2620,7 +2561,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* Set multiple light states with multiple light ids for a specific input device.
|
* Set multiple light states with multiple light ids for a specific input device.
|
||||||
*/
|
*/
|
||||||
private void setLightStatesInternal(int deviceId, int[] lightIds, LightState[] lightStates) {
|
private void setLightStatesInternal(int deviceId, int[] lightIds, LightState[] lightStates) {
|
||||||
final List<Light> lights = nativeGetLights(mPtr, deviceId);
|
final List<Light> lights = mNative.getLights(deviceId);
|
||||||
SparseArray<Light> lightArray = new SparseArray<>();
|
SparseArray<Light> lightArray = new SparseArray<>();
|
||||||
for (int i = 0; i < lights.size(); i++) {
|
for (int i = 0; i < lights.size(); i++) {
|
||||||
lightArray.put(lights.get(i).getId(), lights.get(i));
|
lightArray.put(lights.get(i).getId(), lights.get(i));
|
||||||
@@ -2656,8 +2597,8 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public @Nullable LightState getLightState(int deviceId, int lightId) {
|
public @Nullable LightState getLightState(int deviceId, int lightId) {
|
||||||
synchronized (mLightLock) {
|
synchronized (mLightLock) {
|
||||||
int color = nativeGetLightColor(mPtr, deviceId, lightId);
|
int color = mNative.getLightColor(deviceId, lightId);
|
||||||
int playerId = nativeGetLightPlayerId(mPtr, deviceId, lightId);
|
int playerId = mNative.getLightPlayerId(deviceId, lightId);
|
||||||
|
|
||||||
return new LightState(color, playerId);
|
return new LightState(color, playerId);
|
||||||
}
|
}
|
||||||
@@ -2709,7 +2650,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
throw new SecurityException("Requires MONITOR_INPUT permission");
|
throw new SecurityException("Requires MONITOR_INPUT permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeCancelCurrentTouch(mPtr);
|
mNative.cancelCurrentTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2717,7 +2658,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||||
|
|
||||||
pw.println("INPUT MANAGER (dumpsys input)\n");
|
pw.println("INPUT MANAGER (dumpsys input)\n");
|
||||||
String dumpStr = nativeDump(mPtr);
|
String dumpStr = mNative.dump();
|
||||||
if (dumpStr != null) {
|
if (dumpStr != null) {
|
||||||
pw.println(dumpStr);
|
pw.println(dumpStr);
|
||||||
}
|
}
|
||||||
@@ -2826,7 +2767,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
synchronized (mLidSwitchLock) { /* Test if blocked by lid switch lock. */ }
|
synchronized (mLidSwitchLock) { /* Test if blocked by lid switch lock. */ }
|
||||||
synchronized (mInputMonitors) { /* Test if blocked by input monitor lock. */ }
|
synchronized (mInputMonitors) { /* Test if blocked by input monitor lock. */ }
|
||||||
synchronized (mAdditionalDisplayInputPropertiesLock) { /* Test if blocked by props lock */ }
|
synchronized (mAdditionalDisplayInputPropertiesLock) { /* Test if blocked by props lock */ }
|
||||||
nativeMonitor(mPtr);
|
mNative.monitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Native callback.
|
// Native callback.
|
||||||
@@ -3153,7 +3094,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
* @return True if the device could dispatch to the given display, false otherwise.
|
* @return True if the device could dispatch to the given display, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean canDispatchToDisplay(int deviceId, int displayId) {
|
public boolean canDispatchToDisplay(int deviceId, int displayId) {
|
||||||
return nativeCanDispatchToDisplay(mPtr, deviceId, displayId);
|
return mNative.canDispatchToDisplay(deviceId, displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Native callback.
|
// Native callback.
|
||||||
@@ -3504,7 +3445,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
synchronized (mInputFilterLock) {
|
synchronized (mInputFilterLock) {
|
||||||
if (!mDisconnected) {
|
if (!mDisconnected) {
|
||||||
nativeInjectInputEvent(mPtr, event, false /* injectIntoUid */, -1 /* uid */,
|
mNative.injectInputEvent(event, false /* injectIntoUid */, -1 /* uid */,
|
||||||
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC, 0 /* timeout */,
|
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC, 0 /* timeout */,
|
||||||
policyFlags | WindowManagerPolicy.FLAG_FILTERED);
|
policyFlags | WindowManagerPolicy.FLAG_FILTERED);
|
||||||
}
|
}
|
||||||
@@ -3524,7 +3465,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pilferPointers() {
|
public void pilferPointers() {
|
||||||
nativePilferPointers(mPtr, mInputChannelToken);
|
mNative.pilferPointers(mInputChannelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3702,12 +3643,12 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInteractive(boolean interactive) {
|
public void setInteractive(boolean interactive) {
|
||||||
nativeSetInteractive(mPtr, interactive);
|
mNative.setInteractive(interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggleCapsLock(int deviceId) {
|
public void toggleCapsLock(int deviceId) {
|
||||||
nativeToggleCapsLock(mPtr, deviceId);
|
mNative.toggleCapsLock(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3778,7 +3719,7 @@ public class InputManagerService extends IInputManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pilferPointers(IBinder token) {
|
public void pilferPointers(IBinder token) {
|
||||||
nativePilferPointers(mPtr, token);
|
mNative.pilferPointers(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,389 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.server.input;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.display.DisplayViewport;
|
||||||
|
import android.hardware.input.InputSensorInfo;
|
||||||
|
import android.hardware.lights.Light;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.MessageQueue;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
import android.view.InputApplicationHandle;
|
||||||
|
import android.view.InputChannel;
|
||||||
|
import android.view.InputEvent;
|
||||||
|
import android.view.PointerIcon;
|
||||||
|
import android.view.VerifiedInputEvent;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for the native methods of InputManagerService. We use a public interface so that
|
||||||
|
* this can be mocked for testing by Mockito.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public interface NativeInputManagerService {
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
|
void setDisplayViewports(DisplayViewport[] viewports);
|
||||||
|
|
||||||
|
int getScanCodeState(int deviceId, int sourceMask, int scanCode);
|
||||||
|
|
||||||
|
int getKeyCodeState(int deviceId, int sourceMask, int keyCode);
|
||||||
|
|
||||||
|
int getSwitchState(int deviceId, int sourceMask, int sw);
|
||||||
|
|
||||||
|
boolean hasKeys(int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists);
|
||||||
|
|
||||||
|
int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode);
|
||||||
|
|
||||||
|
InputChannel createInputChannel(String name);
|
||||||
|
|
||||||
|
InputChannel createInputMonitor(int displayId, String name, int pid);
|
||||||
|
|
||||||
|
void removeInputChannel(IBinder connectionToken);
|
||||||
|
|
||||||
|
void pilferPointers(IBinder token);
|
||||||
|
|
||||||
|
void setInputFilterEnabled(boolean enable);
|
||||||
|
|
||||||
|
boolean setInTouchMode(boolean inTouchMode, int pid, int uid, boolean hasPermission);
|
||||||
|
|
||||||
|
void setMaximumObscuringOpacityForTouch(float opacity);
|
||||||
|
|
||||||
|
void setBlockUntrustedTouchesMode(int mode);
|
||||||
|
|
||||||
|
int injectInputEvent(InputEvent event, boolean injectIntoUid, int uid, int syncMode,
|
||||||
|
int timeoutMillis, int policyFlags);
|
||||||
|
|
||||||
|
VerifiedInputEvent verifyInputEvent(InputEvent event);
|
||||||
|
|
||||||
|
void toggleCapsLock(int deviceId);
|
||||||
|
|
||||||
|
void displayRemoved(int displayId);
|
||||||
|
|
||||||
|
void setInputDispatchMode(boolean enabled, boolean frozen);
|
||||||
|
|
||||||
|
void setSystemUiLightsOut(boolean lightsOut);
|
||||||
|
|
||||||
|
void setFocusedApplication(int displayId, InputApplicationHandle application);
|
||||||
|
|
||||||
|
void setFocusedDisplay(int displayId);
|
||||||
|
|
||||||
|
boolean transferTouchFocus(IBinder fromChannelToken, IBinder toChannelToken,
|
||||||
|
boolean isDragDrop);
|
||||||
|
|
||||||
|
boolean transferTouch(IBinder destChannelToken);
|
||||||
|
|
||||||
|
void setPointerSpeed(int speed);
|
||||||
|
|
||||||
|
void setPointerAcceleration(float acceleration);
|
||||||
|
|
||||||
|
void setShowTouches(boolean enabled);
|
||||||
|
|
||||||
|
void setInteractive(boolean interactive);
|
||||||
|
|
||||||
|
void reloadCalibration();
|
||||||
|
|
||||||
|
void vibrate(int deviceId, long[] pattern, int[] amplitudes, int repeat, int token);
|
||||||
|
|
||||||
|
void vibrateCombined(int deviceId, long[] pattern, SparseArray<int[]> amplitudes,
|
||||||
|
int repeat, int token);
|
||||||
|
|
||||||
|
void cancelVibrate(int deviceId, int token);
|
||||||
|
|
||||||
|
boolean isVibrating(int deviceId);
|
||||||
|
|
||||||
|
int[] getVibratorIds(int deviceId);
|
||||||
|
|
||||||
|
int getBatteryCapacity(int deviceId);
|
||||||
|
|
||||||
|
int getBatteryStatus(int deviceId);
|
||||||
|
|
||||||
|
List<Light> getLights(int deviceId);
|
||||||
|
|
||||||
|
int getLightPlayerId(int deviceId, int lightId);
|
||||||
|
|
||||||
|
int getLightColor(int deviceId, int lightId);
|
||||||
|
|
||||||
|
void setLightPlayerId(int deviceId, int lightId, int playerId);
|
||||||
|
|
||||||
|
void setLightColor(int deviceId, int lightId, int color);
|
||||||
|
|
||||||
|
void reloadKeyboardLayouts();
|
||||||
|
|
||||||
|
void reloadDeviceAliases();
|
||||||
|
|
||||||
|
String dump();
|
||||||
|
|
||||||
|
void monitor();
|
||||||
|
|
||||||
|
boolean isInputDeviceEnabled(int deviceId);
|
||||||
|
|
||||||
|
void enableInputDevice(int deviceId);
|
||||||
|
|
||||||
|
void disableInputDevice(int deviceId);
|
||||||
|
|
||||||
|
void setPointerIconType(int iconId);
|
||||||
|
|
||||||
|
void reloadPointerIcons();
|
||||||
|
|
||||||
|
void setCustomPointerIcon(PointerIcon icon);
|
||||||
|
|
||||||
|
void requestPointerCapture(IBinder windowToken, boolean enabled);
|
||||||
|
|
||||||
|
boolean canDispatchToDisplay(int deviceId, int displayId);
|
||||||
|
|
||||||
|
void notifyPortAssociationsChanged();
|
||||||
|
|
||||||
|
void changeUniqueIdAssociation();
|
||||||
|
|
||||||
|
void notifyPointerDisplayIdChanged();
|
||||||
|
|
||||||
|
void setDisplayEligibilityForPointerCapture(int displayId, boolean enabled);
|
||||||
|
|
||||||
|
void setMotionClassifierEnabled(boolean enabled);
|
||||||
|
|
||||||
|
InputSensorInfo[] getSensorList(int deviceId);
|
||||||
|
|
||||||
|
boolean flushSensor(int deviceId, int sensorType);
|
||||||
|
|
||||||
|
boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
|
||||||
|
int maxBatchReportLatencyUs);
|
||||||
|
|
||||||
|
void disableSensor(int deviceId, int sensorType);
|
||||||
|
|
||||||
|
void cancelCurrentTouch();
|
||||||
|
|
||||||
|
/** The native implementation of InputManagerService methods. */
|
||||||
|
class NativeImpl implements NativeInputManagerService {
|
||||||
|
/** Pointer to native input manager service object, used by native code. */
|
||||||
|
@SuppressWarnings({"unused", "FieldCanBeLocal"})
|
||||||
|
private final long mPtr;
|
||||||
|
|
||||||
|
NativeImpl(InputManagerService service, Context context, MessageQueue messageQueue) {
|
||||||
|
mPtr = init(service, context, messageQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private native long init(InputManagerService service, Context context,
|
||||||
|
MessageQueue messageQueue);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void start();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setDisplayViewports(DisplayViewport[] viewports);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getScanCodeState(int deviceId, int sourceMask, int scanCode);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getKeyCodeState(int deviceId, int sourceMask, int keyCode);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getSwitchState(int deviceId, int sourceMask, int sw);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean hasKeys(int deviceId, int sourceMask, int[] keyCodes,
|
||||||
|
boolean[] keyExists);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getKeyCodeForKeyLocation(int deviceId, int locationKeyCode);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native InputChannel createInputChannel(String name);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native InputChannel createInputMonitor(int displayId, String name, int pid);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void removeInputChannel(IBinder connectionToken);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void pilferPointers(IBinder token);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setInputFilterEnabled(boolean enable);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean setInTouchMode(boolean inTouchMode, int pid, int uid,
|
||||||
|
boolean hasPermission);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setMaximumObscuringOpacityForTouch(float opacity);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setBlockUntrustedTouchesMode(int mode);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int injectInputEvent(InputEvent event, boolean injectIntoUid, int uid,
|
||||||
|
int syncMode,
|
||||||
|
int timeoutMillis, int policyFlags);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native VerifiedInputEvent verifyInputEvent(InputEvent event);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void toggleCapsLock(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void displayRemoved(int displayId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setInputDispatchMode(boolean enabled, boolean frozen);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setSystemUiLightsOut(boolean lightsOut);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setFocusedApplication(int displayId, InputApplicationHandle application);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setFocusedDisplay(int displayId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean transferTouchFocus(IBinder fromChannelToken, IBinder toChannelToken,
|
||||||
|
boolean isDragDrop);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean transferTouch(IBinder destChannelToken);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setPointerSpeed(int speed);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setPointerAcceleration(float acceleration);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setShowTouches(boolean enabled);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setInteractive(boolean interactive);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void reloadCalibration();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void vibrate(int deviceId, long[] pattern, int[] amplitudes, int repeat,
|
||||||
|
int token);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void vibrateCombined(int deviceId, long[] pattern,
|
||||||
|
SparseArray<int[]> amplitudes,
|
||||||
|
int repeat, int token);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void cancelVibrate(int deviceId, int token);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean isVibrating(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int[] getVibratorIds(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getBatteryCapacity(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getBatteryStatus(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native List<Light> getLights(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getLightPlayerId(int deviceId, int lightId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native int getLightColor(int deviceId, int lightId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setLightPlayerId(int deviceId, int lightId, int playerId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setLightColor(int deviceId, int lightId, int color);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void reloadKeyboardLayouts();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void reloadDeviceAliases();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native String dump();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void monitor();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean isInputDeviceEnabled(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void enableInputDevice(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void disableInputDevice(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setPointerIconType(int iconId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void reloadPointerIcons();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setCustomPointerIcon(PointerIcon icon);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void requestPointerCapture(IBinder windowToken, boolean enabled);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean canDispatchToDisplay(int deviceId, int displayId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void notifyPortAssociationsChanged();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void changeUniqueIdAssociation();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void notifyPointerDisplayIdChanged();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setDisplayEligibilityForPointerCapture(int displayId, boolean enabled);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void setMotionClassifierEnabled(boolean enabled);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native InputSensorInfo[] getSensorList(int deviceId);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean flushSensor(int deviceId, int sensorType);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native boolean enableSensor(int deviceId, int sensorType, int samplingPeriodUs,
|
||||||
|
int maxBatchReportLatencyUs);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void disableSensor(int deviceId, int sensorType);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public native void cancelCurrentTouch();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,6 +128,11 @@ static struct {
|
|||||||
jmethodID getParentSurfaceForPointers;
|
jmethodID getParentSurfaceForPointers;
|
||||||
} gServiceClassInfo;
|
} gServiceClassInfo;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
jclass clazz;
|
||||||
|
jfieldID mPtr;
|
||||||
|
} gNativeInputManagerServiceImpl;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
jclass clazz;
|
jclass clazz;
|
||||||
} gInputDeviceClassInfo;
|
} gInputDeviceClassInfo;
|
||||||
@@ -259,17 +264,16 @@ public:
|
|||||||
|
|
||||||
void setDisplayViewports(JNIEnv* env, jobjectArray viewportObjArray);
|
void setDisplayViewports(JNIEnv* env, jobjectArray viewportObjArray);
|
||||||
|
|
||||||
base::Result<std::unique_ptr<InputChannel>> createInputChannel(JNIEnv* env,
|
base::Result<std::unique_ptr<InputChannel>> createInputChannel(const std::string& name);
|
||||||
const std::string& name);
|
base::Result<std::unique_ptr<InputChannel>> createInputMonitor(int32_t displayId,
|
||||||
base::Result<std::unique_ptr<InputChannel>> createInputMonitor(JNIEnv* env, int32_t displayId,
|
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
int32_t pid);
|
int32_t pid);
|
||||||
status_t removeInputChannel(JNIEnv* env, const sp<IBinder>& connectionToken);
|
status_t removeInputChannel(const sp<IBinder>& connectionToken);
|
||||||
status_t pilferPointers(const sp<IBinder>& token);
|
status_t pilferPointers(const sp<IBinder>& token);
|
||||||
|
|
||||||
void displayRemoved(JNIEnv* env, int32_t displayId);
|
void displayRemoved(JNIEnv* env, int32_t displayId);
|
||||||
void setFocusedApplication(JNIEnv* env, int32_t displayId, jobject applicationHandleObj);
|
void setFocusedApplication(JNIEnv* env, int32_t displayId, jobject applicationHandleObj);
|
||||||
void setFocusedDisplay(JNIEnv* env, int32_t displayId);
|
void setFocusedDisplay(int32_t displayId);
|
||||||
void setInputDispatchMode(bool enabled, bool frozen);
|
void setInputDispatchMode(bool enabled, bool frozen);
|
||||||
void setSystemUiLightsOut(bool lightsOut);
|
void setSystemUiLightsOut(bool lightsOut);
|
||||||
void setPointerSpeed(int32_t speed);
|
void setPointerSpeed(int32_t speed);
|
||||||
@@ -510,19 +514,18 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO
|
|||||||
}
|
}
|
||||||
|
|
||||||
base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputChannel(
|
base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputChannel(
|
||||||
JNIEnv* /* env */, const std::string& name) {
|
const std::string& name) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
return mInputManager->getDispatcher().createInputChannel(name);
|
return mInputManager->getDispatcher().createInputChannel(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputMonitor(
|
base::Result<std::unique_ptr<InputChannel>> NativeInputManager::createInputMonitor(
|
||||||
JNIEnv* /* env */, int32_t displayId, const std::string& name, int32_t pid) {
|
int32_t displayId, const std::string& name, int32_t pid) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
return mInputManager->getDispatcher().createInputMonitor(displayId, name, pid);
|
return mInputManager->getDispatcher().createInputMonitor(displayId, name, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t NativeInputManager::removeInputChannel(JNIEnv* /* env */,
|
status_t NativeInputManager::removeInputChannel(const sp<IBinder>& connectionToken) {
|
||||||
const sp<IBinder>& connectionToken) {
|
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
return mInputManager->getDispatcher().removeInputChannel(connectionToken);
|
return mInputManager->getDispatcher().removeInputChannel(connectionToken);
|
||||||
}
|
}
|
||||||
@@ -1000,7 +1003,7 @@ void NativeInputManager::setFocusedApplication(JNIEnv* env, int32_t displayId,
|
|||||||
mInputManager->getDispatcher().setFocusedApplication(displayId, applicationHandle);
|
mInputManager->getDispatcher().setFocusedApplication(displayId, applicationHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeInputManager::setFocusedDisplay(JNIEnv* env, int32_t displayId) {
|
void NativeInputManager::setFocusedDisplay(int32_t displayId) {
|
||||||
mInputManager->getDispatcher().setFocusedDisplay(displayId);
|
mInputManager->getDispatcher().setFocusedDisplay(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1490,6 +1493,11 @@ void NativeInputManager::notifyPointerDisplayIdChanged() {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static NativeInputManager* getNativeInputManager(JNIEnv* env, jobject clazz) {
|
||||||
|
return reinterpret_cast<NativeInputManager*>(
|
||||||
|
env->GetLongField(clazz, gNativeInputManagerServiceImpl.mPtr));
|
||||||
|
}
|
||||||
|
|
||||||
static jlong nativeInit(JNIEnv* env, jclass /* clazz */,
|
static jlong nativeInit(JNIEnv* env, jclass /* clazz */,
|
||||||
jobject serviceObj, jobject contextObj, jobject messageQueueObj) {
|
jobject serviceObj, jobject contextObj, jobject messageQueueObj) {
|
||||||
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
|
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
|
||||||
@@ -1504,8 +1512,8 @@ static jlong nativeInit(JNIEnv* env, jclass /* clazz */,
|
|||||||
return reinterpret_cast<jlong>(im);
|
return reinterpret_cast<jlong>(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeStart(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static void nativeStart(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
status_t result = im->getInputManager()->start();
|
status_t result = im->getInputManager()->start();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -1513,39 +1521,39 @@ static void nativeStart(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetDisplayViewports(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static void nativeSetDisplayViewports(JNIEnv* env, jobject nativeImplObj,
|
||||||
jobjectArray viewportObjArray) {
|
jobjectArray viewportObjArray) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->setDisplayViewports(env, viewportObjArray);
|
im->setDisplayViewports(env, viewportObjArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetScanCodeState(JNIEnv* /* env */, jclass /* clazz */,
|
static jint nativeGetScanCodeState(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jlong ptr, jint deviceId, jint sourceMask, jint scanCode) {
|
jint sourceMask, jint scanCode) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
return (jint)im->getInputManager()->getReader().getScanCodeState(deviceId, uint32_t(sourceMask),
|
return (jint)im->getInputManager()->getReader().getScanCodeState(deviceId, uint32_t(sourceMask),
|
||||||
scanCode);
|
scanCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetKeyCodeState(JNIEnv* /* env */, jclass /* clazz */,
|
static jint nativeGetKeyCodeState(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jlong ptr, jint deviceId, jint sourceMask, jint keyCode) {
|
jint sourceMask, jint keyCode) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
return (jint)im->getInputManager()->getReader().getKeyCodeState(deviceId, uint32_t(sourceMask),
|
return (jint)im->getInputManager()->getReader().getKeyCodeState(deviceId, uint32_t(sourceMask),
|
||||||
keyCode);
|
keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetSwitchState(JNIEnv* /* env */, jclass /* clazz */,
|
static jint nativeGetSwitchState(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint sourceMask,
|
||||||
jlong ptr, jint deviceId, jint sourceMask, jint sw) {
|
jint sw) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
return (jint)im->getInputManager()->getReader().getSwitchState(deviceId, uint32_t(sourceMask),
|
return (jint)im->getInputManager()->getReader().getSwitchState(deviceId, uint32_t(sourceMask),
|
||||||
sw);
|
sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeHasKeys(JNIEnv* env, jclass /* clazz */,
|
static jboolean nativeHasKeys(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint sourceMask,
|
||||||
jlong ptr, jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) {
|
jintArray keyCodes, jbooleanArray outFlags) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
int32_t* codes = env->GetIntArrayElements(keyCodes, nullptr);
|
int32_t* codes = env->GetIntArrayElements(keyCodes, nullptr);
|
||||||
uint8_t* flags = env->GetBooleanArrayElements(outFlags, nullptr);
|
uint8_t* flags = env->GetBooleanArrayElements(outFlags, nullptr);
|
||||||
@@ -1567,9 +1575,9 @@ static jboolean nativeHasKeys(JNIEnv* env, jclass /* clazz */,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetKeyCodeForKeyLocation(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jint nativeGetKeyCodeForKeyLocation(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint deviceId, jint locationKeyCode) {
|
jint locationKeyCode) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
return (jint)im->getInputManager()->getReader().getKeyCodeForKeyLocation(deviceId,
|
return (jint)im->getInputManager()->getReader().getKeyCodeForKeyLocation(deviceId,
|
||||||
locationKeyCode);
|
locationKeyCode);
|
||||||
}
|
}
|
||||||
@@ -1582,17 +1590,16 @@ static void handleInputChannelDisposed(JNIEnv* env, jobject /* inputChannelObj *
|
|||||||
ALOGW("Input channel object '%s' was disposed without first being removed with "
|
ALOGW("Input channel object '%s' was disposed without first being removed with "
|
||||||
"the input manager!",
|
"the input manager!",
|
||||||
inputChannel->getName().c_str());
|
inputChannel->getName().c_str());
|
||||||
im->removeInputChannel(env, inputChannel->getConnectionToken());
|
im->removeInputChannel(inputChannel->getConnectionToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject nativeCreateInputChannel(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jobject nativeCreateInputChannel(JNIEnv* env, jobject nativeImplObj, jstring nameObj) {
|
||||||
jstring nameObj) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
ScopedUtfChars nameChars(env, nameObj);
|
ScopedUtfChars nameChars(env, nameObj);
|
||||||
std::string name = nameChars.c_str();
|
std::string name = nameChars.c_str();
|
||||||
|
|
||||||
base::Result<std::unique_ptr<InputChannel>> inputChannel = im->createInputChannel(env, name);
|
base::Result<std::unique_ptr<InputChannel>> inputChannel = im->createInputChannel(name);
|
||||||
|
|
||||||
if (!inputChannel.ok()) {
|
if (!inputChannel.ok()) {
|
||||||
std::string message = inputChannel.error().message();
|
std::string message = inputChannel.error().message();
|
||||||
@@ -1612,9 +1619,9 @@ static jobject nativeCreateInputChannel(JNIEnv* env, jclass /* clazz */, jlong p
|
|||||||
return inputChannelObj;
|
return inputChannelObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint displayId,
|
static jobject nativeCreateInputMonitor(JNIEnv* env, jobject nativeImplObj, jint displayId,
|
||||||
jstring nameObj, jint pid) {
|
jstring nameObj, jint pid) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
if (displayId == ADISPLAY_ID_NONE) {
|
if (displayId == ADISPLAY_ID_NONE) {
|
||||||
std::string message = "InputChannel used as a monitor must be associated with a display";
|
std::string message = "InputChannel used as a monitor must be associated with a display";
|
||||||
@@ -1626,7 +1633,7 @@ static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong p
|
|||||||
std::string name = nameChars.c_str();
|
std::string name = nameChars.c_str();
|
||||||
|
|
||||||
base::Result<std::unique_ptr<InputChannel>> inputChannel =
|
base::Result<std::unique_ptr<InputChannel>> inputChannel =
|
||||||
im->createInputMonitor(env, displayId, name, pid);
|
im->createInputMonitor(displayId, name, pid);
|
||||||
|
|
||||||
if (!inputChannel.ok()) {
|
if (!inputChannel.ok()) {
|
||||||
std::string message = inputChannel.error().message();
|
std::string message = inputChannel.error().message();
|
||||||
@@ -1643,11 +1650,11 @@ static jobject nativeCreateInputMonitor(JNIEnv* env, jclass /* clazz */, jlong p
|
|||||||
return inputChannelObj;
|
return inputChannelObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeRemoveInputChannel(JNIEnv* env, jclass /* clazz */, jlong ptr, jobject tokenObj) {
|
static void nativeRemoveInputChannel(JNIEnv* env, jobject nativeImplObj, jobject tokenObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
sp<IBinder> token = ibinderForJavaObject(env, tokenObj);
|
sp<IBinder> token = ibinderForJavaObject(env, tokenObj);
|
||||||
|
|
||||||
status_t status = im->removeInputChannel(env, token);
|
status_t status = im->removeInputChannel(token);
|
||||||
if (status && status != BAD_VALUE) { // ignore already removed channel
|
if (status && status != BAD_VALUE) { // ignore already removed channel
|
||||||
std::string message;
|
std::string message;
|
||||||
message += StringPrintf("Failed to remove input channel. status=%d", status);
|
message += StringPrintf("Failed to remove input channel. status=%d", status);
|
||||||
@@ -1655,47 +1662,44 @@ static void nativeRemoveInputChannel(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativePilferPointers(JNIEnv* env, jclass /* clazz */, jlong ptr, jobject tokenObj) {
|
static void nativePilferPointers(JNIEnv* env, jobject nativeImplObj, jobject tokenObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
sp<IBinder> token = ibinderForJavaObject(env, tokenObj);
|
sp<IBinder> token = ibinderForJavaObject(env, tokenObj);
|
||||||
im->pilferPointers(token);
|
im->pilferPointers(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetInputFilterEnabled(JNIEnv* /* env */, jclass /* clazz */,
|
static void nativeSetInputFilterEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) {
|
||||||
jlong ptr, jboolean enabled) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getDispatcher().setInputFilterEnabled(enabled);
|
im->getInputManager()->getDispatcher().setInputFilterEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeSetInTouchMode(JNIEnv* /* env */, jclass /* clazz */, jlong ptr,
|
static jboolean nativeSetInTouchMode(JNIEnv* env, jobject nativeImplObj, jboolean inTouchMode,
|
||||||
jboolean inTouchMode, jint pid, jint uid,
|
jint pid, jint uid, jboolean hasPermission) {
|
||||||
jboolean hasPermission) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
return im->getInputManager()->getDispatcher().setInTouchMode(inTouchMode, pid, uid,
|
return im->getInputManager()->getDispatcher().setInTouchMode(inTouchMode, pid, uid,
|
||||||
hasPermission);
|
hasPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetMaximumObscuringOpacityForTouch(JNIEnv* /* env */, jclass /* clazz */,
|
static void nativeSetMaximumObscuringOpacityForTouch(JNIEnv* env, jobject nativeImplObj,
|
||||||
jlong ptr, jfloat opacity) {
|
jfloat opacity) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getDispatcher().setMaximumObscuringOpacityForTouch(opacity);
|
im->getInputManager()->getDispatcher().setMaximumObscuringOpacityForTouch(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetBlockUntrustedTouchesMode(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static void nativeSetBlockUntrustedTouchesMode(JNIEnv* env, jobject nativeImplObj, jint mode) {
|
||||||
jint mode) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getDispatcher().setBlockUntrustedTouchesMode(
|
im->getInputManager()->getDispatcher().setBlockUntrustedTouchesMode(
|
||||||
static_cast<BlockUntrustedTouchesMode>(mode));
|
static_cast<BlockUntrustedTouchesMode>(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeInjectInputEvent(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jint nativeInjectInputEvent(JNIEnv* env, jobject nativeImplObj, jobject inputEventObj,
|
||||||
jobject inputEventObj, jboolean injectIntoUid, jint uid,
|
jboolean injectIntoUid, jint uid, jint syncMode,
|
||||||
jint syncMode, jint timeoutMillis, jint policyFlags) {
|
jint timeoutMillis, jint policyFlags) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
const std::optional<int32_t> targetUid = injectIntoUid ? std::make_optional(uid) : std::nullopt;
|
const std::optional<int32_t> targetUid = injectIntoUid ? std::make_optional(uid) : std::nullopt;
|
||||||
// static_cast is safe because the value was already checked at the Java layer
|
// static_cast is safe because the value was already checked at the Java layer
|
||||||
@@ -1735,9 +1739,8 @@ static jint nativeInjectInputEvent(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject nativeVerifyInputEvent(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jobject nativeVerifyInputEvent(JNIEnv* env, jobject nativeImplObj, jobject inputEventObj) {
|
||||||
jobject inputEventObj) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
if (env->IsInstanceOf(inputEventObj, gKeyEventClassInfo.clazz)) {
|
if (env->IsInstanceOf(inputEventObj, gKeyEventClassInfo.clazz)) {
|
||||||
KeyEvent keyEvent;
|
KeyEvent keyEvent;
|
||||||
@@ -1778,56 +1781,53 @@ static jobject nativeVerifyInputEvent(JNIEnv* env, jclass /* clazz */, jlong ptr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeToggleCapsLock(JNIEnv* env, jclass /* clazz */,
|
static void nativeToggleCapsLock(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
jlong ptr, jint deviceId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getReader().toggleCapsLockState(deviceId);
|
im->getInputManager()->getReader().toggleCapsLockState(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDisplayRemoved(JNIEnv* env, jclass /* clazz */, jlong ptr, jint displayId) {
|
static void nativeDisplayRemoved(JNIEnv* env, jobject nativeImplObj, jint displayId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->displayRemoved(env, displayId);
|
im->displayRemoved(env, displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetFocusedApplication(JNIEnv* env, jclass /* clazz */,
|
static void nativeSetFocusedApplication(JNIEnv* env, jobject nativeImplObj, jint displayId,
|
||||||
jlong ptr, jint displayId, jobject applicationHandleObj) {
|
jobject applicationHandleObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->setFocusedApplication(env, displayId, applicationHandleObj);
|
im->setFocusedApplication(env, displayId, applicationHandleObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetFocusedDisplay(JNIEnv* env, jclass /* clazz */,
|
static void nativeSetFocusedDisplay(JNIEnv* env, jobject nativeImplObj, jint displayId) {
|
||||||
jlong ptr, jint displayId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setFocusedDisplay(env, displayId);
|
im->setFocusedDisplay(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeRequestPointerCapture(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static void nativeRequestPointerCapture(JNIEnv* env, jobject nativeImplObj, jobject tokenObj,
|
||||||
jobject tokenObj, jboolean enabled) {
|
jboolean enabled) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
sp<IBinder> windowToken = ibinderForJavaObject(env, tokenObj);
|
sp<IBinder> windowToken = ibinderForJavaObject(env, tokenObj);
|
||||||
|
|
||||||
im->requestPointerCapture(windowToken, enabled);
|
im->requestPointerCapture(windowToken, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetInputDispatchMode(JNIEnv* /* env */,
|
static void nativeSetInputDispatchMode(JNIEnv* env, jobject nativeImplObj, jboolean enabled,
|
||||||
jclass /* clazz */, jlong ptr, jboolean enabled, jboolean frozen) {
|
jboolean frozen) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->setInputDispatchMode(enabled, frozen);
|
im->setInputDispatchMode(enabled, frozen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetSystemUiLightsOut(JNIEnv* /* env */, jclass /* clazz */, jlong ptr,
|
static void nativeSetSystemUiLightsOut(JNIEnv* env, jobject nativeImplObj, jboolean lightsOut) {
|
||||||
jboolean lightsOut) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setSystemUiLightsOut(lightsOut);
|
im->setSystemUiLightsOut(lightsOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeTransferTouchFocus(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jboolean nativeTransferTouchFocus(JNIEnv* env, jobject nativeImplObj,
|
||||||
jobject fromChannelTokenObj, jobject toChannelTokenObj,
|
jobject fromChannelTokenObj, jobject toChannelTokenObj,
|
||||||
jboolean isDragDrop) {
|
jboolean isDragDrop) {
|
||||||
if (fromChannelTokenObj == nullptr || toChannelTokenObj == nullptr) {
|
if (fromChannelTokenObj == nullptr || toChannelTokenObj == nullptr) {
|
||||||
@@ -1837,7 +1837,7 @@ static jboolean nativeTransferTouchFocus(JNIEnv* env, jclass /* clazz */, jlong
|
|||||||
sp<IBinder> fromChannelToken = ibinderForJavaObject(env, fromChannelTokenObj);
|
sp<IBinder> fromChannelToken = ibinderForJavaObject(env, fromChannelTokenObj);
|
||||||
sp<IBinder> toChannelToken = ibinderForJavaObject(env, toChannelTokenObj);
|
sp<IBinder> toChannelToken = ibinderForJavaObject(env, toChannelTokenObj);
|
||||||
|
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
if (im->getInputManager()->getDispatcher().transferTouchFocus(fromChannelToken, toChannelToken,
|
if (im->getInputManager()->getDispatcher().transferTouchFocus(fromChannelToken, toChannelToken,
|
||||||
isDragDrop)) {
|
isDragDrop)) {
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
@@ -1846,11 +1846,11 @@ static jboolean nativeTransferTouchFocus(JNIEnv* env, jclass /* clazz */, jlong
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeTransferTouch(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jboolean nativeTransferTouch(JNIEnv* env, jobject nativeImplObj,
|
||||||
jobject destChannelTokenObj) {
|
jobject destChannelTokenObj) {
|
||||||
sp<IBinder> destChannelToken = ibinderForJavaObject(env, destChannelTokenObj);
|
sp<IBinder> destChannelToken = ibinderForJavaObject(env, destChannelTokenObj);
|
||||||
|
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
if (im->getInputManager()->getDispatcher().transferTouch(destChannelToken)) {
|
if (im->getInputManager()->getDispatcher().transferTouch(destChannelToken)) {
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
} else {
|
} else {
|
||||||
@@ -1858,42 +1858,39 @@ static jboolean nativeTransferTouch(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetPointerSpeed(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint speed) {
|
static void nativeSetPointerSpeed(JNIEnv* env, jobject nativeImplObj, jint speed) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->setPointerSpeed(speed);
|
im->setPointerSpeed(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetPointerAcceleration(JNIEnv* /* env */, jclass /* clazz */, jlong ptr,
|
static void nativeSetPointerAcceleration(JNIEnv* env, jobject nativeImplObj, jfloat acceleration) {
|
||||||
jfloat acceleration) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setPointerAcceleration(acceleration);
|
im->setPointerAcceleration(acceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetShowTouches(JNIEnv* /* env */,
|
static void nativeSetShowTouches(JNIEnv* env, jobject nativeImplObj, jboolean enabled) {
|
||||||
jclass /* clazz */, jlong ptr, jboolean enabled) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setShowTouches(enabled);
|
im->setShowTouches(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetInteractive(JNIEnv* env,
|
static void nativeSetInteractive(JNIEnv* env, jobject nativeImplObj, jboolean interactive) {
|
||||||
jclass clazz, jlong ptr, jboolean interactive) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setInteractive(interactive);
|
im->setInteractive(interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeReloadCalibration(JNIEnv* env, jclass clazz, jlong ptr) {
|
static void nativeReloadCalibration(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->reloadCalibration();
|
im->reloadCalibration();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeVibrate(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static void nativeVibrate(JNIEnv* env, jobject nativeImplObj, jint deviceId, jlongArray patternObj,
|
||||||
jlongArray patternObj, jintArray amplitudesObj, jint repeat, jint token) {
|
jintArray amplitudesObj, jint repeat, jint token) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
size_t patternSize = env->GetArrayLength(patternObj);
|
size_t patternSize = env->GetArrayLength(patternObj);
|
||||||
if (patternSize > MAX_VIBRATE_PATTERN_SIZE) {
|
if (patternSize > MAX_VIBRATE_PATTERN_SIZE) {
|
||||||
@@ -1926,10 +1923,10 @@ static void nativeVibrate(JNIEnv* env, jclass /* clazz */, jlong ptr, jint devic
|
|||||||
im->getInputManager()->getReader().vibrate(deviceId, sequence, repeat, token);
|
im->getInputManager()->getReader().vibrate(deviceId, sequence, repeat, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeVibrateCombined(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static void nativeVibrateCombined(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jlongArray patternObj, jobject amplitudesObj, jint repeat,
|
jlongArray patternObj, jobject amplitudesObj, jint repeat,
|
||||||
jint token) {
|
jint token) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
size_t patternSize = env->GetArrayLength(patternObj);
|
size_t patternSize = env->GetArrayLength(patternObj);
|
||||||
|
|
||||||
@@ -1976,21 +1973,20 @@ static void nativeVibrateCombined(JNIEnv* env, jclass /* clazz */, jlong ptr, ji
|
|||||||
im->getInputManager()->getReader().vibrate(deviceId, sequence, repeat, token);
|
im->getInputManager()->getReader().vibrate(deviceId, sequence, repeat, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeCancelVibrate(JNIEnv* /* env */,
|
static void nativeCancelVibrate(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint token) {
|
||||||
jclass /* clazz */, jlong ptr, jint deviceId, jint token) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getReader().cancelVibrate(deviceId, token);
|
im->getInputManager()->getReader().cancelVibrate(deviceId, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nativeIsVibrating(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint deviceId) {
|
static bool nativeIsVibrating(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
return im->getInputManager()->getReader().isVibrating(deviceId);
|
return im->getInputManager()->getReader().isVibrating(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jintArray nativeGetVibratorIds(JNIEnv* env, jclass clazz, jlong ptr, jint deviceId) {
|
static jintArray nativeGetVibratorIds(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
std::vector<int32_t> vibrators = im->getInputManager()->getReader().getVibratorIds(deviceId);
|
std::vector<int32_t> vibrators = im->getInputManager()->getReader().getVibratorIds(deviceId);
|
||||||
|
|
||||||
jintArray vibIdArray = env->NewIntArray(vibrators.size());
|
jintArray vibIdArray = env->NewIntArray(vibrators.size());
|
||||||
@@ -2000,8 +1996,8 @@ static jintArray nativeGetVibratorIds(JNIEnv* env, jclass clazz, jlong ptr, jint
|
|||||||
return vibIdArray;
|
return vibIdArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject nativeGetLights(JNIEnv* env, jclass clazz, jlong ptr, jint deviceId) {
|
static jobject nativeGetLights(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
jobject jLights = env->NewObject(gArrayListClassInfo.clazz, gArrayListClassInfo.constructor);
|
jobject jLights = env->NewObject(gArrayListClassInfo.clazz, gArrayListClassInfo.constructor);
|
||||||
|
|
||||||
std::vector<InputDeviceLightInfo> lights =
|
std::vector<InputDeviceLightInfo> lights =
|
||||||
@@ -2045,9 +2041,9 @@ static jobject nativeGetLights(JNIEnv* env, jclass clazz, jlong ptr, jint device
|
|||||||
return jLights;
|
return jLights;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetLightPlayerId(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static jint nativeGetLightPlayerId(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint lightId) {
|
jint lightId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
std::optional<int32_t> ret =
|
std::optional<int32_t> ret =
|
||||||
im->getInputManager()->getReader().getLightPlayerId(deviceId, lightId);
|
im->getInputManager()->getReader().getLightPlayerId(deviceId, lightId);
|
||||||
@@ -2055,54 +2051,51 @@ static jint nativeGetLightPlayerId(JNIEnv* env, jclass /* clazz */, jlong ptr, j
|
|||||||
return static_cast<jint>(ret.value_or(0));
|
return static_cast<jint>(ret.value_or(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetLightColor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static jint nativeGetLightColor(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint lightId) {
|
||||||
jint lightId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
std::optional<int32_t> ret =
|
std::optional<int32_t> ret =
|
||||||
im->getInputManager()->getReader().getLightColor(deviceId, lightId);
|
im->getInputManager()->getReader().getLightColor(deviceId, lightId);
|
||||||
return static_cast<jint>(ret.value_or(0));
|
return static_cast<jint>(ret.value_or(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetLightPlayerId(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static void nativeSetLightPlayerId(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint lightId,
|
||||||
jint lightId, jint playerId) {
|
jint playerId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getReader().setLightPlayerId(deviceId, lightId, playerId);
|
im->getInputManager()->getReader().setLightPlayerId(deviceId, lightId, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetLightColor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static void nativeSetLightColor(JNIEnv* env, jobject nativeImplObj, jint deviceId, jint lightId,
|
||||||
jint lightId, jint color) {
|
jint color) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getReader().setLightColor(deviceId, lightId, color);
|
im->getInputManager()->getReader().setLightColor(deviceId, lightId, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetBatteryCapacity(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId) {
|
static jint nativeGetBatteryCapacity(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
std::optional<int32_t> ret = im->getInputManager()->getReader().getBatteryCapacity(deviceId);
|
std::optional<int32_t> ret = im->getInputManager()->getReader().getBatteryCapacity(deviceId);
|
||||||
return static_cast<jint>(ret.value_or(android::os::IInputConstants::INVALID_BATTERY_CAPACITY));
|
return static_cast<jint>(ret.value_or(android::os::IInputConstants::INVALID_BATTERY_CAPACITY));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeGetBatteryStatus(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId) {
|
static jint nativeGetBatteryStatus(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
std::optional<int32_t> ret = im->getInputManager()->getReader().getBatteryStatus(deviceId);
|
std::optional<int32_t> ret = im->getInputManager()->getReader().getBatteryStatus(deviceId);
|
||||||
return static_cast<jint>(ret.value_or(BATTERY_STATUS_UNKNOWN));
|
return static_cast<jint>(ret.value_or(BATTERY_STATUS_UNKNOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeReloadKeyboardLayouts(JNIEnv* /* env */,
|
static void nativeReloadKeyboardLayouts(JNIEnv* env, jobject nativeImplObj) {
|
||||||
jclass /* clazz */, jlong ptr) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getReader().requestRefreshConfiguration(
|
im->getInputManager()->getReader().requestRefreshConfiguration(
|
||||||
InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS);
|
InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeReloadDeviceAliases(JNIEnv* /* env */,
|
static void nativeReloadDeviceAliases(JNIEnv* env, jobject nativeImplObj) {
|
||||||
jclass /* clazz */, jlong ptr) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->getInputManager()->getReader().requestRefreshConfiguration(
|
im->getInputManager()->getReader().requestRefreshConfiguration(
|
||||||
InputReaderConfiguration::CHANGE_DEVICE_ALIAS);
|
InputReaderConfiguration::CHANGE_DEVICE_ALIAS);
|
||||||
@@ -2117,58 +2110,54 @@ static std::string dumpInputProperties() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jstring nativeDump(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static jstring nativeDump(JNIEnv* env, jobject nativeImplObj) {
|
||||||
std::string dump = dumpInputProperties();
|
std::string dump = dumpInputProperties();
|
||||||
|
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->dump(dump);
|
im->dump(dump);
|
||||||
|
|
||||||
return env->NewStringUTF(dump.c_str());
|
return env->NewStringUTF(dump.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeMonitor(JNIEnv* /* env */, jclass /* clazz */, jlong ptr) {
|
static void nativeMonitor(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getReader().monitor();
|
im->getInputManager()->getReader().monitor();
|
||||||
im->getInputManager()->getDispatcher().monitor();
|
im->getInputManager()->getDispatcher().monitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeIsInputDeviceEnabled(JNIEnv* env /* env */,
|
static jboolean nativeIsInputDeviceEnabled(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
jclass /* clazz */, jlong ptr, jint deviceId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
return im->getInputManager()->getReader().isInputDeviceEnabled(deviceId);
|
return im->getInputManager()->getReader().isInputDeviceEnabled(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeEnableInputDevice(JNIEnv* /* env */,
|
static void nativeEnableInputDevice(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
jclass /* clazz */, jlong ptr, jint deviceId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setInputDeviceEnabled(deviceId, true);
|
im->setInputDeviceEnabled(deviceId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDisableInputDevice(JNIEnv* /* env */,
|
static void nativeDisableInputDevice(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
jclass /* clazz */, jlong ptr, jint deviceId) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setInputDeviceEnabled(deviceId, false);
|
im->setInputDeviceEnabled(deviceId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetPointerIconType(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint iconId) {
|
static void nativeSetPointerIconType(JNIEnv* env, jobject nativeImplObj, jint iconId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->setPointerIconType(iconId);
|
im->setPointerIconType(iconId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeReloadPointerIcons(JNIEnv* /* env */, jclass /* clazz */, jlong ptr) {
|
static void nativeReloadPointerIcons(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->reloadPointerIcons();
|
im->reloadPointerIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetCustomPointerIcon(JNIEnv* env, jclass /* clazz */,
|
static void nativeSetCustomPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject iconObj) {
|
||||||
jlong ptr, jobject iconObj) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
PointerIcon pointerIcon;
|
PointerIcon pointerIcon;
|
||||||
status_t result = android_view_PointerIcon_getLoadedIcon(env, iconObj, &pointerIcon);
|
status_t result = android_view_PointerIcon_getLoadedIcon(env, iconObj, &pointerIcon);
|
||||||
@@ -2182,40 +2171,38 @@ static void nativeSetCustomPointerIcon(JNIEnv* env, jclass /* clazz */,
|
|||||||
im->setCustomPointerIcon(spriteIcon);
|
im->setCustomPointerIcon(spriteIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint deviceId, jint displayId) {
|
jint displayId) {
|
||||||
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
return im->getInputManager()->getReader().canDispatchToDisplay(deviceId, displayId);
|
return im->getInputManager()->getReader().canDispatchToDisplay(deviceId, displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeNotifyPortAssociationsChanged(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static void nativeNotifyPortAssociationsChanged(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->getInputManager()->getReader().requestRefreshConfiguration(
|
im->getInputManager()->getReader().requestRefreshConfiguration(
|
||||||
InputReaderConfiguration::CHANGE_DISPLAY_INFO);
|
InputReaderConfiguration::CHANGE_DISPLAY_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeNotifyPointerDisplayIdChanged(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static void nativeNotifyPointerDisplayIdChanged(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->notifyPointerDisplayIdChanged();
|
im->notifyPointerDisplayIdChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetDisplayEligibilityForPointerCapture(JNIEnv* env, jclass /* clazz */, jlong ptr,
|
static void nativeSetDisplayEligibilityForPointerCapture(JNIEnv* env, jobject nativeImplObj,
|
||||||
jint displayId, jboolean isEligible) {
|
jint displayId, jboolean isEligible) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->getInputManager()->getDispatcher().setDisplayEligibilityForPointerCapture(displayId,
|
im->getInputManager()->getDispatcher().setDisplayEligibilityForPointerCapture(displayId,
|
||||||
isEligible);
|
isEligible);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeChangeUniqueIdAssociation(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static void nativeChangeUniqueIdAssociation(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->getInputManager()->getReader().requestRefreshConfiguration(
|
im->getInputManager()->getReader().requestRefreshConfiguration(
|
||||||
InputReaderConfiguration::CHANGE_DISPLAY_INFO);
|
InputReaderConfiguration::CHANGE_DISPLAY_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetMotionClassifierEnabled(JNIEnv* /* env */, jclass /* clazz */, jlong ptr,
|
static void nativeSetMotionClassifierEnabled(JNIEnv* env, jobject nativeImplObj, jboolean enabled) {
|
||||||
jboolean enabled) {
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
|
||||||
|
|
||||||
im->setMotionClassifierEnabled(enabled);
|
im->setMotionClassifierEnabled(enabled);
|
||||||
}
|
}
|
||||||
@@ -2251,8 +2238,8 @@ static jobject createInputSensorInfo(JNIEnv* env, jstring name, jstring vendor,
|
|||||||
return sensorInfo;
|
return sensorInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobjectArray nativeGetSensorList(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId) {
|
static jobjectArray nativeGetSensorList(JNIEnv* env, jobject nativeImplObj, jint deviceId) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
std::vector<InputDeviceSensorInfo> sensors =
|
std::vector<InputDeviceSensorInfo> sensors =
|
||||||
im->getInputManager()->getReader().getSensors(deviceId);
|
im->getInputManager()->getReader().getSensors(deviceId);
|
||||||
|
|
||||||
@@ -2281,10 +2268,10 @@ static jobjectArray nativeGetSensorList(JNIEnv* env, jclass /* clazz */, jlong p
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeEnableSensor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static jboolean nativeEnableSensor(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint sensorType, jint samplingPeriodUs,
|
jint sensorType, jint samplingPeriodUs,
|
||||||
jint maxBatchReportLatencyUs) {
|
jint maxBatchReportLatencyUs) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
return im->getInputManager()
|
return im->getInputManager()
|
||||||
->getReader()
|
->getReader()
|
||||||
@@ -2293,18 +2280,18 @@ static jboolean nativeEnableSensor(JNIEnv* env, jclass /* clazz */, jlong ptr, j
|
|||||||
std::chrono::microseconds(maxBatchReportLatencyUs));
|
std::chrono::microseconds(maxBatchReportLatencyUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDisableSensor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static void nativeDisableSensor(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint sensorType) {
|
jint sensorType) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getReader().disableSensor(deviceId,
|
im->getInputManager()->getReader().disableSensor(deviceId,
|
||||||
static_cast<InputDeviceSensorType>(
|
static_cast<InputDeviceSensorType>(
|
||||||
sensorType));
|
sensorType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeFlushSensor(JNIEnv* env, jclass /* clazz */, jlong ptr, jint deviceId,
|
static jboolean nativeFlushSensor(JNIEnv* env, jobject nativeImplObj, jint deviceId,
|
||||||
jint sensorType) {
|
jint sensorType) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
|
|
||||||
im->getInputManager()->getReader().flushSensor(deviceId,
|
im->getInputManager()->getReader().flushSensor(deviceId,
|
||||||
static_cast<InputDeviceSensorType>(sensorType));
|
static_cast<InputDeviceSensorType>(sensorType));
|
||||||
@@ -2313,8 +2300,8 @@ static jboolean nativeFlushSensor(JNIEnv* env, jclass /* clazz */, jlong ptr, ji
|
|||||||
sensorType));
|
sensorType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeCancelCurrentTouch(JNIEnv* env, jclass /* clazz */, jlong ptr) {
|
static void nativeCancelCurrentTouch(JNIEnv* env, jobject nativeImplObj) {
|
||||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||||
im->getInputManager()->getDispatcher().cancelCurrentTouch();
|
im->getInputManager()->getDispatcher().cancelCurrentTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2322,87 +2309,84 @@ static void nativeCancelCurrentTouch(JNIEnv* env, jclass /* clazz */, jlong ptr)
|
|||||||
|
|
||||||
static const JNINativeMethod gInputManagerMethods[] = {
|
static const JNINativeMethod gInputManagerMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{"nativeInit",
|
{"init",
|
||||||
"(Lcom/android/server/input/InputManagerService;Landroid/content/Context;Landroid/os/"
|
"(Lcom/android/server/input/InputManagerService;Landroid/content/Context;Landroid/os/"
|
||||||
"MessageQueue;)J",
|
"MessageQueue;)J",
|
||||||
(void*)nativeInit},
|
(void*)nativeInit},
|
||||||
{"nativeStart", "(J)V", (void*)nativeStart},
|
{"start", "()V", (void*)nativeStart},
|
||||||
{"nativeSetDisplayViewports", "(J[Landroid/hardware/display/DisplayViewport;)V",
|
{"setDisplayViewports", "([Landroid/hardware/display/DisplayViewport;)V",
|
||||||
(void*)nativeSetDisplayViewports},
|
(void*)nativeSetDisplayViewports},
|
||||||
{"nativeGetScanCodeState", "(JIII)I", (void*)nativeGetScanCodeState},
|
{"getScanCodeState", "(III)I", (void*)nativeGetScanCodeState},
|
||||||
{"nativeGetKeyCodeState", "(JIII)I", (void*)nativeGetKeyCodeState},
|
{"getKeyCodeState", "(III)I", (void*)nativeGetKeyCodeState},
|
||||||
{"nativeGetSwitchState", "(JIII)I", (void*)nativeGetSwitchState},
|
{"getSwitchState", "(III)I", (void*)nativeGetSwitchState},
|
||||||
{"nativeHasKeys", "(JII[I[Z)Z", (void*)nativeHasKeys},
|
{"hasKeys", "(II[I[Z)Z", (void*)nativeHasKeys},
|
||||||
{"nativeGetKeyCodeForKeyLocation", "(JII)I", (void*)nativeGetKeyCodeForKeyLocation},
|
{"getKeyCodeForKeyLocation", "(II)I", (void*)nativeGetKeyCodeForKeyLocation},
|
||||||
{"nativeCreateInputChannel", "(JLjava/lang/String;)Landroid/view/InputChannel;",
|
{"createInputChannel", "(Ljava/lang/String;)Landroid/view/InputChannel;",
|
||||||
(void*)nativeCreateInputChannel},
|
(void*)nativeCreateInputChannel},
|
||||||
{"nativeCreateInputMonitor", "(JILjava/lang/String;I)Landroid/view/InputChannel;",
|
{"createInputMonitor", "(ILjava/lang/String;I)Landroid/view/InputChannel;",
|
||||||
(void*)nativeCreateInputMonitor},
|
(void*)nativeCreateInputMonitor},
|
||||||
{"nativeRemoveInputChannel", "(JLandroid/os/IBinder;)V", (void*)nativeRemoveInputChannel},
|
{"removeInputChannel", "(Landroid/os/IBinder;)V", (void*)nativeRemoveInputChannel},
|
||||||
{"nativePilferPointers", "(JLandroid/os/IBinder;)V", (void*)nativePilferPointers},
|
{"pilferPointers", "(Landroid/os/IBinder;)V", (void*)nativePilferPointers},
|
||||||
{"nativeSetInputFilterEnabled", "(JZ)V", (void*)nativeSetInputFilterEnabled},
|
{"setInputFilterEnabled", "(Z)V", (void*)nativeSetInputFilterEnabled},
|
||||||
{"nativeSetInTouchMode", "(JZIIZ)Z", (void*)nativeSetInTouchMode},
|
{"setInTouchMode", "(ZIIZ)Z", (void*)nativeSetInTouchMode},
|
||||||
{"nativeSetMaximumObscuringOpacityForTouch", "(JF)V",
|
{"setMaximumObscuringOpacityForTouch", "(F)V",
|
||||||
(void*)nativeSetMaximumObscuringOpacityForTouch},
|
(void*)nativeSetMaximumObscuringOpacityForTouch},
|
||||||
{"nativeSetBlockUntrustedTouchesMode", "(JI)V", (void*)nativeSetBlockUntrustedTouchesMode},
|
{"setBlockUntrustedTouchesMode", "(I)V", (void*)nativeSetBlockUntrustedTouchesMode},
|
||||||
{"nativeInjectInputEvent", "(JLandroid/view/InputEvent;ZIIII)I",
|
{"injectInputEvent", "(Landroid/view/InputEvent;ZIIII)I", (void*)nativeInjectInputEvent},
|
||||||
(void*)nativeInjectInputEvent},
|
{"verifyInputEvent", "(Landroid/view/InputEvent;)Landroid/view/VerifiedInputEvent;",
|
||||||
{"nativeVerifyInputEvent", "(JLandroid/view/InputEvent;)Landroid/view/VerifiedInputEvent;",
|
|
||||||
(void*)nativeVerifyInputEvent},
|
(void*)nativeVerifyInputEvent},
|
||||||
{"nativeToggleCapsLock", "(JI)V", (void*)nativeToggleCapsLock},
|
{"toggleCapsLock", "(I)V", (void*)nativeToggleCapsLock},
|
||||||
{"nativeDisplayRemoved", "(JI)V", (void*)nativeDisplayRemoved},
|
{"displayRemoved", "(I)V", (void*)nativeDisplayRemoved},
|
||||||
{"nativeSetFocusedApplication", "(JILandroid/view/InputApplicationHandle;)V",
|
{"setFocusedApplication", "(ILandroid/view/InputApplicationHandle;)V",
|
||||||
(void*)nativeSetFocusedApplication},
|
(void*)nativeSetFocusedApplication},
|
||||||
{"nativeSetFocusedDisplay", "(JI)V", (void*)nativeSetFocusedDisplay},
|
{"setFocusedDisplay", "(I)V", (void*)nativeSetFocusedDisplay},
|
||||||
{"nativeRequestPointerCapture", "(JLandroid/os/IBinder;Z)V",
|
{"requestPointerCapture", "(Landroid/os/IBinder;Z)V", (void*)nativeRequestPointerCapture},
|
||||||
(void*)nativeRequestPointerCapture},
|
{"setInputDispatchMode", "(ZZ)V", (void*)nativeSetInputDispatchMode},
|
||||||
{"nativeSetInputDispatchMode", "(JZZ)V", (void*)nativeSetInputDispatchMode},
|
{"setSystemUiLightsOut", "(Z)V", (void*)nativeSetSystemUiLightsOut},
|
||||||
{"nativeSetSystemUiLightsOut", "(JZ)V", (void*)nativeSetSystemUiLightsOut},
|
{"transferTouchFocus", "(Landroid/os/IBinder;Landroid/os/IBinder;Z)Z",
|
||||||
{"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;Z)Z",
|
|
||||||
(void*)nativeTransferTouchFocus},
|
(void*)nativeTransferTouchFocus},
|
||||||
{"nativeTransferTouch", "(JLandroid/os/IBinder;)Z", (void*)nativeTransferTouch},
|
{"transferTouch", "(Landroid/os/IBinder;)Z", (void*)nativeTransferTouch},
|
||||||
{"nativeSetPointerSpeed", "(JI)V", (void*)nativeSetPointerSpeed},
|
{"setPointerSpeed", "(I)V", (void*)nativeSetPointerSpeed},
|
||||||
{"nativeSetPointerAcceleration", "(JF)V", (void*)nativeSetPointerAcceleration},
|
{"setPointerAcceleration", "(F)V", (void*)nativeSetPointerAcceleration},
|
||||||
{"nativeSetShowTouches", "(JZ)V", (void*)nativeSetShowTouches},
|
{"setShowTouches", "(Z)V", (void*)nativeSetShowTouches},
|
||||||
{"nativeSetInteractive", "(JZ)V", (void*)nativeSetInteractive},
|
{"setInteractive", "(Z)V", (void*)nativeSetInteractive},
|
||||||
{"nativeReloadCalibration", "(J)V", (void*)nativeReloadCalibration},
|
{"reloadCalibration", "()V", (void*)nativeReloadCalibration},
|
||||||
{"nativeVibrate", "(JI[J[III)V", (void*)nativeVibrate},
|
{"vibrate", "(I[J[III)V", (void*)nativeVibrate},
|
||||||
{"nativeVibrateCombined", "(JI[JLandroid/util/SparseArray;II)V",
|
{"vibrateCombined", "(I[JLandroid/util/SparseArray;II)V", (void*)nativeVibrateCombined},
|
||||||
(void*)nativeVibrateCombined},
|
{"cancelVibrate", "(II)V", (void*)nativeCancelVibrate},
|
||||||
{"nativeCancelVibrate", "(JII)V", (void*)nativeCancelVibrate},
|
{"isVibrating", "(I)Z", (void*)nativeIsVibrating},
|
||||||
{"nativeIsVibrating", "(JI)Z", (void*)nativeIsVibrating},
|
{"getVibratorIds", "(I)[I", (void*)nativeGetVibratorIds},
|
||||||
{"nativeGetVibratorIds", "(JI)[I", (void*)nativeGetVibratorIds},
|
{"getLights", "(I)Ljava/util/List;", (void*)nativeGetLights},
|
||||||
{"nativeGetLights", "(JI)Ljava/util/List;", (void*)nativeGetLights},
|
{"getLightPlayerId", "(II)I", (void*)nativeGetLightPlayerId},
|
||||||
{"nativeGetLightPlayerId", "(JII)I", (void*)nativeGetLightPlayerId},
|
{"getLightColor", "(II)I", (void*)nativeGetLightColor},
|
||||||
{"nativeGetLightColor", "(JII)I", (void*)nativeGetLightColor},
|
{"setLightPlayerId", "(III)V", (void*)nativeSetLightPlayerId},
|
||||||
{"nativeSetLightPlayerId", "(JIII)V", (void*)nativeSetLightPlayerId},
|
{"setLightColor", "(III)V", (void*)nativeSetLightColor},
|
||||||
{"nativeSetLightColor", "(JIII)V", (void*)nativeSetLightColor},
|
{"getBatteryCapacity", "(I)I", (void*)nativeGetBatteryCapacity},
|
||||||
{"nativeGetBatteryCapacity", "(JI)I", (void*)nativeGetBatteryCapacity},
|
{"getBatteryStatus", "(I)I", (void*)nativeGetBatteryStatus},
|
||||||
{"nativeGetBatteryStatus", "(JI)I", (void*)nativeGetBatteryStatus},
|
{"reloadKeyboardLayouts", "()V", (void*)nativeReloadKeyboardLayouts},
|
||||||
{"nativeReloadKeyboardLayouts", "(J)V", (void*)nativeReloadKeyboardLayouts},
|
{"reloadDeviceAliases", "()V", (void*)nativeReloadDeviceAliases},
|
||||||
{"nativeReloadDeviceAliases", "(J)V", (void*)nativeReloadDeviceAliases},
|
{"dump", "()Ljava/lang/String;", (void*)nativeDump},
|
||||||
{"nativeDump", "(J)Ljava/lang/String;", (void*)nativeDump},
|
{"monitor", "()V", (void*)nativeMonitor},
|
||||||
{"nativeMonitor", "(J)V", (void*)nativeMonitor},
|
{"isInputDeviceEnabled", "(I)Z", (void*)nativeIsInputDeviceEnabled},
|
||||||
{"nativeIsInputDeviceEnabled", "(JI)Z", (void*)nativeIsInputDeviceEnabled},
|
{"enableInputDevice", "(I)V", (void*)nativeEnableInputDevice},
|
||||||
{"nativeEnableInputDevice", "(JI)V", (void*)nativeEnableInputDevice},
|
{"disableInputDevice", "(I)V", (void*)nativeDisableInputDevice},
|
||||||
{"nativeDisableInputDevice", "(JI)V", (void*)nativeDisableInputDevice},
|
{"setPointerIconType", "(I)V", (void*)nativeSetPointerIconType},
|
||||||
{"nativeSetPointerIconType", "(JI)V", (void*)nativeSetPointerIconType},
|
{"reloadPointerIcons", "()V", (void*)nativeReloadPointerIcons},
|
||||||
{"nativeReloadPointerIcons", "(J)V", (void*)nativeReloadPointerIcons},
|
{"setCustomPointerIcon", "(Landroid/view/PointerIcon;)V",
|
||||||
{"nativeSetCustomPointerIcon", "(JLandroid/view/PointerIcon;)V",
|
|
||||||
(void*)nativeSetCustomPointerIcon},
|
(void*)nativeSetCustomPointerIcon},
|
||||||
{"nativeCanDispatchToDisplay", "(JII)Z", (void*)nativeCanDispatchToDisplay},
|
{"canDispatchToDisplay", "(II)Z", (void*)nativeCanDispatchToDisplay},
|
||||||
{"nativeNotifyPortAssociationsChanged", "(J)V", (void*)nativeNotifyPortAssociationsChanged},
|
{"notifyPortAssociationsChanged", "()V", (void*)nativeNotifyPortAssociationsChanged},
|
||||||
{"nativeChangeUniqueIdAssociation", "(J)V", (void*)nativeChangeUniqueIdAssociation},
|
{"changeUniqueIdAssociation", "()V", (void*)nativeChangeUniqueIdAssociation},
|
||||||
{"nativeNotifyPointerDisplayIdChanged", "(J)V", (void*)nativeNotifyPointerDisplayIdChanged},
|
{"notifyPointerDisplayIdChanged", "()V", (void*)nativeNotifyPointerDisplayIdChanged},
|
||||||
{"nativeSetDisplayEligibilityForPointerCapture", "(JIZ)V",
|
{"setDisplayEligibilityForPointerCapture", "(IZ)V",
|
||||||
(void*)nativeSetDisplayEligibilityForPointerCapture},
|
(void*)nativeSetDisplayEligibilityForPointerCapture},
|
||||||
{"nativeSetMotionClassifierEnabled", "(JZ)V", (void*)nativeSetMotionClassifierEnabled},
|
{"setMotionClassifierEnabled", "(Z)V", (void*)nativeSetMotionClassifierEnabled},
|
||||||
{"nativeGetSensorList", "(JI)[Landroid/hardware/input/InputSensorInfo;",
|
{"getSensorList", "(I)[Landroid/hardware/input/InputSensorInfo;",
|
||||||
(void*)nativeGetSensorList},
|
(void*)nativeGetSensorList},
|
||||||
{"nativeEnableSensor", "(JIIII)Z", (void*)nativeEnableSensor},
|
{"enableSensor", "(IIII)Z", (void*)nativeEnableSensor},
|
||||||
{"nativeDisableSensor", "(JII)V", (void*)nativeDisableSensor},
|
{"disableSensor", "(II)V", (void*)nativeDisableSensor},
|
||||||
{"nativeFlushSensor", "(JII)Z", (void*)nativeFlushSensor},
|
{"flushSensor", "(II)Z", (void*)nativeFlushSensor},
|
||||||
{"nativeCancelCurrentTouch", "(J)V", (void*)nativeCancelCurrentTouch},
|
{"cancelCurrentTouch", "()V", (void*)nativeCancelCurrentTouch},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FIND_CLASS(var, className) \
|
#define FIND_CLASS(var, className) \
|
||||||
@@ -2422,11 +2406,21 @@ static const JNINativeMethod gInputManagerMethods[] = {
|
|||||||
LOG_FATAL_IF(! (var), "Unable to find field " fieldName);
|
LOG_FATAL_IF(! (var), "Unable to find field " fieldName);
|
||||||
|
|
||||||
int register_android_server_InputManager(JNIEnv* env) {
|
int register_android_server_InputManager(JNIEnv* env) {
|
||||||
int res = jniRegisterNativeMethods(env, "com/android/server/input/InputManagerService",
|
int res = jniRegisterNativeMethods(env,
|
||||||
gInputManagerMethods, NELEM(gInputManagerMethods));
|
"com/android/server/input/"
|
||||||
(void) res; // Faked use when LOG_NDEBUG.
|
"NativeInputManagerService$NativeImpl",
|
||||||
|
gInputManagerMethods, NELEM(gInputManagerMethods));
|
||||||
|
(void)res; // Faked use when LOG_NDEBUG.
|
||||||
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
|
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
|
||||||
|
|
||||||
|
FIND_CLASS(gNativeInputManagerServiceImpl.clazz,
|
||||||
|
"com/android/server/input/"
|
||||||
|
"NativeInputManagerService$NativeImpl");
|
||||||
|
gNativeInputManagerServiceImpl.clazz =
|
||||||
|
jclass(env->NewGlobalRef(gNativeInputManagerServiceImpl.clazz));
|
||||||
|
gNativeInputManagerServiceImpl.mPtr =
|
||||||
|
env->GetFieldID(gNativeInputManagerServiceImpl.clazz, "mPtr", "J");
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
|
||||||
jclass clazz;
|
jclass clazz;
|
||||||
|
|||||||
Reference in New Issue
Block a user