Added last focused window to notifyFocusChanged callback (2/3)
This will allow the system server to notify the client which window
gained focus and which lost focus.
Test: Builds and runs
Change-Id: Ida09afbdca44c14172bf32cba5927fa69f33217c
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 6f105ec..64120076 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -244,7 +244,7 @@
const sp<IBinder>& token,
const std::string& reason);
virtual void notifyInputChannelBroken(const sp<IBinder>& token);
- virtual void notifyFocusChanged(const sp<IBinder>& token);
+ virtual void notifyFocusChanged(const sp<IBinder>& oldToken, const sp<IBinder>& newToken);
virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags);
virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig);
virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
@@ -738,7 +738,8 @@
}
}
-void NativeInputManager::notifyFocusChanged(const sp<IBinder>& token) {
+void NativeInputManager::notifyFocusChanged(const sp<IBinder>& oldToken,
+ const sp<IBinder>& newToken) {
#if DEBUG_INPUT_DISPATCHER_POLICY
ALOGD("notifyFocusChanged");
#endif
@@ -746,12 +747,11 @@
JNIEnv* env = jniEnv();
- jobject tokenObj = javaObjectForIBinder(env, token);
- if (tokenObj) {
- env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyFocusChanged,
- tokenObj);
- checkAndClearExceptionFromCallback(env, "notifyFocusChanged");
- }
+ jobject oldTokenObj = javaObjectForIBinder(env, oldToken);
+ jobject newTokenObj = javaObjectForIBinder(env, newToken);
+ env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyFocusChanged,
+ oldTokenObj, newTokenObj);
+ checkAndClearExceptionFromCallback(env, "notifyFocusChanged");
}
void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
@@ -1762,7 +1762,7 @@
"notifyInputChannelBroken", "(Landroid/os/IBinder;)V");
GET_METHOD_ID(gServiceClassInfo.notifyFocusChanged, clazz,
- "notifyFocusChanged", "(Landroid/os/IBinder;)V");
+ "notifyFocusChanged", "(Landroid/os/IBinder;Landroid/os/IBinder;)V");
GET_METHOD_ID(gServiceClassInfo.notifyANR, clazz,
"notifyANR",