Add tracing to InputManagerService
Test: Took systrace, looked at results
Change-Id: I787275ec6881f53b7e9910ee81ffb2ff427c71e0
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 41f86c9..59a174e 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -16,6 +16,8 @@
#define LOG_TAG "InputManager-JNI"
+#define ATRACE_TAG ATRACE_TAG_INPUT
+
//#define LOG_NDEBUG 0
// Log debug messages about InputReaderPolicy
@@ -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>
@@ -445,16 +448,19 @@
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,
@@ -528,6 +534,7 @@
}
sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t /* deviceId */) {
+ ATRACE_CALL();
AutoMutex _l(mLock);
sp<PointerController> controller = mLocked.pointerController.promote();
@@ -560,6 +567,7 @@
}
void NativeInputManager::notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
size_t count = inputDevices.size();
@@ -591,6 +599,7 @@
sp<KeyCharacterMap> NativeInputManager::getKeyboardLayoutOverlay(
const InputDeviceIdentifier& identifier) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
sp<KeyCharacterMap> result;
@@ -616,6 +625,7 @@
}
String8 NativeInputManager::getDeviceAlias(const InputDeviceIdentifier& identifier) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(identifier.uniqueId.string()));
@@ -636,6 +646,7 @@
ALOGD("notifySwitch - when=%lld, switchValues=0x%08x, switchMask=0x%08x, policyFlags=0x%x",
when, switchValues, switchMask, policyFlags);
#endif
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
@@ -648,6 +659,7 @@
#if DEBUG_INPUT_DISPATCHER_POLICY
ALOGD("notifyConfigurationChanged - when=%lld", when);
#endif
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
@@ -660,6 +672,7 @@
#if DEBUG_INPUT_DISPATCHER_POLICY
ALOGD("notifyANR");
#endif
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
@@ -688,6 +701,7 @@
#if DEBUG_INPUT_DISPATCHER_POLICY
ALOGD("notifyInputChannelBroken");
#endif
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
@@ -703,6 +717,7 @@
}
void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
jint keyRepeatTimeout = env->CallIntMethod(mServiceObj,
@@ -898,6 +913,7 @@
TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
JNIEnv *env, jfloatArray matrixArr) {
+ ATRACE_CALL();
ScopedFloatArrayRO matrix(env, matrixArr);
assert(matrix.size() == 6);
@@ -934,6 +950,7 @@
}
bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) {
+ ATRACE_CALL();
jobject inputEventObj;
JNIEnv* env = jniEnv();
@@ -967,6 +984,7 @@
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.
@@ -1003,6 +1021,7 @@
}
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.
@@ -1048,6 +1067,7 @@
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
@@ -1083,6 +1103,7 @@
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;
@@ -1120,12 +1141,14 @@
}
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);
@@ -1136,6 +1159,7 @@
}
void NativeInputManager::loadPointerIcon(SpriteIcon* icon) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
ScopedLocalRef<jobject> pointerIconObj(env, env->CallObjectMethod(
@@ -1155,6 +1179,7 @@
}
void NativeInputManager::loadPointerResources(PointerResources* outResources) {
+ ATRACE_CALL();
JNIEnv* env = jniEnv();
loadSystemIconAsSprite(env, mContextObj, POINTER_ICON_STYLE_SPOT_HOVER,
@@ -1167,6 +1192,7 @@
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;