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

Commit 00e9c41d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "InputManagerInternal: Add API to get the last used input device" into main

parents 71875b5f 55a7ccb6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -218,4 +218,13 @@ public abstract class InputManagerInternal {
     * display, external peripherals, fingerprint sensor, etc.
     */
    public abstract void notifyUserActivity();

    /**
     * Get the device ID of the {@link InputDevice} that used most recently.
     *
     * @return the last used input device ID, or
     *     {@link android.os.IInputConstants#INVALID_INPUT_DEVICE_ID} if no device has been used
     *     since boot.
     */
    public abstract int getLastUsedInputDeviceId();
}
+5 −0
Original line number Diff line number Diff line
@@ -3204,6 +3204,11 @@ public class InputManagerService extends IInputManager.Stub
        public void setStylusButtonMotionEventsEnabled(boolean enabled) {
            mNative.setStylusButtonMotionEventsEnabled(enabled);
        }

        @Override
        public int getLastUsedInputDeviceId() {
            return mNative.getLastUsedInputDeviceId();
        }
    }

    @Override
+12 −0
Original line number Diff line number Diff line
@@ -271,6 +271,15 @@ interface NativeInputManagerService {

    void setInputMethodConnectionIsActive(boolean isActive);

    /**
     * Get the device ID of the InputDevice that used most recently.
     *
     * @return the last used input device ID, or
     *     {@link android.os.IInputConstants#INVALID_INPUT_DEVICE_ID} if no device has been used
     *     since boot.
     */
    int getLastUsedInputDeviceId();

    /** The native implementation of InputManagerService methods. */
    class NativeImpl implements NativeInputManagerService {
        /** Pointer to native input manager service object, used by native code. */
@@ -544,5 +553,8 @@ interface NativeInputManagerService {

        @Override
        public native void setInputMethodConnectionIsActive(boolean isActive);

        @Override
        public native int getLastUsedInputDeviceId();
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -2727,6 +2727,11 @@ static void nativeSetInputMethodConnectionIsActive(JNIEnv* env, jobject nativeIm
    im->setInputMethodConnectionIsActive(isActive);
}

static jint nativeGetLastUsedInputDeviceId(JNIEnv* env, jobject nativeImplObj) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
    return static_cast<jint>(im->getInputManager()->getReader().getLastUsedInputDeviceId());
}

// ----------------------------------------------------------------------------

static const JNINativeMethod gInputManagerMethods[] = {
@@ -2835,6 +2840,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
        {"setAccessibilityStickyKeysEnabled", "(Z)V",
         (void*)nativeSetAccessibilityStickyKeysEnabled},
        {"setInputMethodConnectionIsActive", "(Z)V", (void*)nativeSetInputMethodConnectionIsActive},
        {"getLastUsedInputDeviceId", "()I", (void*)nativeGetLastUsedInputDeviceId},
};

#define FIND_CLASS(var, className) \