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/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 45a9bc0..df28f30 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -1760,14 +1760,14 @@
}
// Native callback
- private void notifyFocusChanged(IBinder token) {
- if (mFocusedWindow.asBinder() == token) {
+ private void notifyFocusChanged(IBinder oldToken, IBinder newToken) {
+ if (mFocusedWindow.asBinder() == newToken) {
Log.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow=" + mFocusedWindow);
return;
}
setPointerCapture(false);
- mFocusedWindow = IWindow.Stub.asInterface(token);
+ mFocusedWindow = IWindow.Stub.asInterface(newToken);
}
// Native callback.
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",