Loading services/core/jni/com_android_server_input_InputManagerService.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "InputManager-JNI" #define ATRACE_TAG ATRACE_TAG_INPUT //#define LOG_NDEBUG 0 // Log debug messages about InputReaderPolicy Loading @@ -36,6 +38,7 @@ #include <utils/Log.h> #include <utils/Looper.h> #include <utils/threads.h> #include <utils/Trace.h> #include <utils/SortedVector.h> #include <input/PointerController.h> Loading Loading @@ -445,16 +448,19 @@ void NativeInputManager::setDisplayViewport(int32_t type, const DisplayViewport& status_t NativeInputManager::registerInputChannel(JNIEnv* /* env */, const sp<InputChannel>& inputChannel, const sp<InputWindowHandle>& inputWindowHandle, bool monitor) { ATRACE_CALL(); return mInputManager->getDispatcher()->registerInputChannel( inputChannel, inputWindowHandle, monitor); } status_t NativeInputManager::unregisterInputChannel(JNIEnv* /* env */, const sp<InputChannel>& inputChannel) { ATRACE_CALL(); return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel); } void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outConfig) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jint virtualKeyQuietTime = env->CallIntMethod(mServiceObj, Loading Loading @@ -528,6 +534,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon } sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t /* deviceId */) { ATRACE_CALL(); AutoMutex _l(mLock); sp<PointerController> controller = mLocked.pointerController.promote(); Loading Loading @@ -560,6 +567,7 @@ void NativeInputManager::ensureSpriteControllerLocked() { } void NativeInputManager::notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) { ATRACE_CALL(); JNIEnv* env = jniEnv(); size_t count = inputDevices.size(); Loading Loading @@ -591,6 +599,7 @@ void NativeInputManager::notifyInputDevicesChanged(const Vector<InputDeviceInfo> sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier) { ATRACE_CALL(); JNIEnv* env = jniEnv(); sp<KeyCharacterMap> result; Loading @@ -616,6 +625,7 @@ sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay( } String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifier) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(identifier.uniqueId.string())); Loading @@ -636,6 +646,7 @@ void NativeInputManager::notifySwitch(nsecs_t when, ALOGD("notifySwitch - when=%lld, switchValues=0x%08x, switchMask=0x%08x, policyFlags=0x%x", when, switchValues, switchMask, policyFlags); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -648,6 +659,7 @@ void NativeInputManager::notifyConfigurationChanged(nsecs_t when) { #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyConfigurationChanged - when=%lld", when); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -660,6 +672,7 @@ nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApp #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyANR"); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading Loading @@ -688,6 +701,7 @@ void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& i #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyInputChannelBroken"); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -703,6 +717,7 @@ void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& i } void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jint keyRepeatTimeout = env->CallIntMethod(mServiceObj, Loading Loading @@ -898,6 +913,7 @@ void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) { TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( JNIEnv *env, jfloatArray matrixArr) { ATRACE_CALL(); ScopedFloatArrayRO matrix(env, matrixArr); assert(matrix.size() == 6); Loading Loading @@ -934,6 +950,7 @@ TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( } bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) { ATRACE_CALL(); jobject inputEventObj; JNIEnv* env = jniEnv(); Loading Loading @@ -967,6 +984,7 @@ bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - Ask the window manager what to do with normal events and trusted injected events. Loading Loading @@ -1003,6 +1021,7 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent, } void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - No special filtering for injected events required at this time. Loading Loading @@ -1048,6 +1067,7 @@ void NativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when, nsecs_t NativeInputManager::interceptKeyBeforeDispatching( const sp<InputWindowHandle>& inputWindowHandle, const KeyEvent* keyEvent, uint32_t policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - Filter normal events and trusted injected events through the window manager policy to Loading Loading @@ -1083,6 +1103,7 @@ nsecs_t NativeInputManager::interceptKeyBeforeDispatching( bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle, const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and do not perform default handling. bool result = false; Loading Loading @@ -1120,12 +1141,14 @@ bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& input } void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType) { ATRACE_CALL(); android_server_PowerManagerService_userActivity(eventTime, eventType); } bool NativeInputManager::checkInjectEventsPermissionNonReentrant( int32_t injectorPid, int32_t injectorUid) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jboolean result = env->CallBooleanMethod(mServiceObj, gServiceClassInfo.checkInjectEventsPermission, injectorPid, injectorUid); Loading @@ -1136,6 +1159,7 @@ bool NativeInputManager::checkInjectEventsPermissionNonReentrant( } void NativeInputManager::loadPointerIcon(SpriteIcon* icon) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalRef<jobject> pointerIconObj(env, env->CallObjectMethod( Loading @@ -1155,6 +1179,7 @@ void NativeInputManager::loadPointerIcon(SpriteIcon* icon) { } void NativeInputManager::loadPointerResources(PointerResources* outResources) { ATRACE_CALL(); JNIEnv* env = jniEnv(); loadSystemIconAsSprite(env, mContextObj, POINTER_ICON_STYLE_SPOT_HOVER, Loading @@ -1167,6 +1192,7 @@ void NativeInputManager::loadPointerResources(PointerResources* outResources) { void NativeInputManager::loadAdditionalMouseResources(std::map<int32_t, SpriteIcon>* outResources, std::map<int32_t, PointerAnimation>* outAnimationResources) { ATRACE_CALL(); JNIEnv* env = jniEnv(); for (int iconId = POINTER_ICON_STYLE_CONTEXT_MENU; iconId <= POINTER_ICON_STYLE_GRABBING; Loading Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #define LOG_TAG "InputManager-JNI" #define ATRACE_TAG ATRACE_TAG_INPUT //#define LOG_NDEBUG 0 // Log debug messages about InputReaderPolicy Loading @@ -36,6 +38,7 @@ #include <utils/Log.h> #include <utils/Looper.h> #include <utils/threads.h> #include <utils/Trace.h> #include <utils/SortedVector.h> #include <input/PointerController.h> Loading Loading @@ -445,16 +448,19 @@ void NativeInputManager::setDisplayViewport(int32_t type, const DisplayViewport& status_t NativeInputManager::registerInputChannel(JNIEnv* /* env */, const sp<InputChannel>& inputChannel, const sp<InputWindowHandle>& inputWindowHandle, bool monitor) { ATRACE_CALL(); return mInputManager->getDispatcher()->registerInputChannel( inputChannel, inputWindowHandle, monitor); } status_t NativeInputManager::unregisterInputChannel(JNIEnv* /* env */, const sp<InputChannel>& inputChannel) { ATRACE_CALL(); return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel); } void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outConfig) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jint virtualKeyQuietTime = env->CallIntMethod(mServiceObj, Loading Loading @@ -528,6 +534,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon } sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t /* deviceId */) { ATRACE_CALL(); AutoMutex _l(mLock); sp<PointerController> controller = mLocked.pointerController.promote(); Loading Loading @@ -560,6 +567,7 @@ void NativeInputManager::ensureSpriteControllerLocked() { } void NativeInputManager::notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) { ATRACE_CALL(); JNIEnv* env = jniEnv(); size_t count = inputDevices.size(); Loading Loading @@ -591,6 +599,7 @@ void NativeInputManager::notifyInputDevicesChanged(const Vector<InputDeviceInfo> sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier) { ATRACE_CALL(); JNIEnv* env = jniEnv(); sp<KeyCharacterMap> result; Loading @@ -616,6 +625,7 @@ sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay( } String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifier) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(identifier.uniqueId.string())); Loading @@ -636,6 +646,7 @@ void NativeInputManager::notifySwitch(nsecs_t when, ALOGD("notifySwitch - when=%lld, switchValues=0x%08x, switchMask=0x%08x, policyFlags=0x%x", when, switchValues, switchMask, policyFlags); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -648,6 +659,7 @@ void NativeInputManager::notifyConfigurationChanged(nsecs_t when) { #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyConfigurationChanged - when=%lld", when); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -660,6 +672,7 @@ nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApp #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyANR"); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading Loading @@ -688,6 +701,7 @@ void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& i #if DEBUG_INPUT_DISPATCHER_POLICY ALOGD("notifyInputChannelBroken"); #endif ATRACE_CALL(); JNIEnv* env = jniEnv(); Loading @@ -703,6 +717,7 @@ void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& i } void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jint keyRepeatTimeout = env->CallIntMethod(mServiceObj, Loading Loading @@ -898,6 +913,7 @@ void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) { TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( JNIEnv *env, jfloatArray matrixArr) { ATRACE_CALL(); ScopedFloatArrayRO matrix(env, matrixArr); assert(matrix.size() == 6); Loading Loading @@ -934,6 +950,7 @@ TouchAffineTransformation NativeInputManager::getTouchAffineTransformation( } bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) { ATRACE_CALL(); jobject inputEventObj; JNIEnv* env = jniEnv(); Loading Loading @@ -967,6 +984,7 @@ bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - Ask the window manager what to do with normal events and trusted injected events. Loading Loading @@ -1003,6 +1021,7 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent, } void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - No special filtering for injected events required at this time. Loading Loading @@ -1048,6 +1067,7 @@ void NativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when, nsecs_t NativeInputManager::interceptKeyBeforeDispatching( const sp<InputWindowHandle>& inputWindowHandle, const KeyEvent* keyEvent, uint32_t policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. // - Filter normal events and trusted injected events through the window manager policy to Loading Loading @@ -1083,6 +1103,7 @@ nsecs_t NativeInputManager::interceptKeyBeforeDispatching( bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle, const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and do not perform default handling. bool result = false; Loading Loading @@ -1120,12 +1141,14 @@ bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& input } void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType) { ATRACE_CALL(); android_server_PowerManagerService_userActivity(eventTime, eventType); } bool NativeInputManager::checkInjectEventsPermissionNonReentrant( int32_t injectorPid, int32_t injectorUid) { ATRACE_CALL(); JNIEnv* env = jniEnv(); jboolean result = env->CallBooleanMethod(mServiceObj, gServiceClassInfo.checkInjectEventsPermission, injectorPid, injectorUid); Loading @@ -1136,6 +1159,7 @@ bool NativeInputManager::checkInjectEventsPermissionNonReentrant( } void NativeInputManager::loadPointerIcon(SpriteIcon* icon) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalRef<jobject> pointerIconObj(env, env->CallObjectMethod( Loading @@ -1155,6 +1179,7 @@ void NativeInputManager::loadPointerIcon(SpriteIcon* icon) { } void NativeInputManager::loadPointerResources(PointerResources* outResources) { ATRACE_CALL(); JNIEnv* env = jniEnv(); loadSystemIconAsSprite(env, mContextObj, POINTER_ICON_STYLE_SPOT_HOVER, Loading @@ -1167,6 +1192,7 @@ void NativeInputManager::loadPointerResources(PointerResources* outResources) { void NativeInputManager::loadAdditionalMouseResources(std::map<int32_t, SpriteIcon>* outResources, std::map<int32_t, PointerAnimation>* outAnimationResources) { ATRACE_CALL(); JNIEnv* env = jniEnv(); for (int iconId = POINTER_ICON_STYLE_CONTEXT_MENU; iconId <= POINTER_ICON_STYLE_GRABBING; Loading