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

Commit 7ea80e58 authored by Yanye Li's avatar Yanye Li Committed by Android (Google) Code Review
Browse files

Merge "InputManagerInternal: Add API to set power/wakeup node" into main

parents 9126dc19 a59f33bd
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -270,4 +270,18 @@ public abstract class InputManagerInternal {
     * @param scaleFactor the new scale factor to be applied for pointer icons.
     */
    public abstract void setAccessibilityPointerIconScaleFactor(int displayId, float scaleFactor);

    /**
     * Set whether the given input device can wake up the kernel from sleep
     * when it generates input events. By default, usually only internal (built-in)
     * input devices can wake the kernel from sleep. For an external input device
     * that supports remote wakeup to be able to wake the kernel, this must be called
     * after each time the device is connected/added.
     *
     * @param deviceId the device ID of the input device.
     * @param enabled When true, device will be configured to wake up kernel.
     *
     * @return true if setting power wakeup was successful.
     */
    public abstract boolean setKernelWakeEnabled(int deviceId, boolean enabled);
}
+5 −0
Original line number Diff line number Diff line
@@ -3511,6 +3511,11 @@ public class InputManagerService extends IInputManager.Stub
        public void setAccessibilityPointerIconScaleFactor(int displayId, float scaleFactor) {
            InputManagerService.this.setAccessibilityPointerIconScaleFactor(displayId, scaleFactor);
        }

        @Override
        public boolean setKernelWakeEnabled(int deviceId, boolean enabled) {
            return mNative.setKernelWakeEnabled(deviceId, enabled);
        }
    }

    @Override
+14 −0
Original line number Diff line number Diff line
@@ -287,6 +287,17 @@ interface NativeInputManagerService {
     */
    int getLastUsedInputDeviceId();

    /**
     * Set whether the given input device can wake up the kernel from sleep
     * when it generates input events. By default, usually only internal (built-in)
     * input devices can wake the kernel from sleep. For an external input device
     * that supports remote wakeup to be able to wake the kernel, this must be called
     * after each time the device is connected/added.
     *
     * Returns true if setting power wakeup was successful.
     */
    boolean setKernelWakeEnabled(int deviceId, boolean enabled);

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

        @Override
        public native int getLastUsedInputDeviceId();

        @Override
        public native boolean setKernelWakeEnabled(int deviceId, boolean enabled);
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -3056,6 +3056,12 @@ static void nativeSetMouseSwapPrimaryButtonEnabled(JNIEnv* env, jobject nativeIm
    im->setMouseSwapPrimaryButtonEnabled(enabled);
}

static jboolean nativeSetKernelWakeEnabled(JNIEnv* env, jobject nativeImplObj, jint deviceId,
                                      jboolean enabled) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
    return im->getInputManager()->getReader().setKernelWakeEnabled(deviceId, enabled);
}

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

static const JNINativeMethod gInputManagerMethods[] = {
@@ -3172,6 +3178,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
         (void*)nativeSetAccessibilityStickyKeysEnabled},
        {"setInputMethodConnectionIsActive", "(Z)V", (void*)nativeSetInputMethodConnectionIsActive},
        {"getLastUsedInputDeviceId", "()I", (void*)nativeGetLastUsedInputDeviceId},
        {"setKernelWakeEnabled", "(IZ)Z", (void*)nativeSetKernelWakeEnabled},
};

#define FIND_CLASS(var, className) \