diff options
4 files changed, 40 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/input/InputManagerInternal.java b/services/core/java/com/android/server/input/InputManagerInternal.java index c888eef7f5df..e40d855293cd 100644 --- a/services/core/java/com/android/server/input/InputManagerInternal.java +++ b/services/core/java/com/android/server/input/InputManagerInternal.java @@ -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); } diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 98e5319cde30..bea520f9429e 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -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 diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java index 21e8bccd2883..283fdea92b63 100644 --- a/services/core/java/com/android/server/input/NativeInputManagerService.java +++ b/services/core/java/com/android/server/input/NativeInputManagerService.java @@ -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); } } diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 248ed1a58b75..416e60f06c06 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -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) \ |