Make InputApplicationInfo as a part of InputApplicationHandle (2/2)
InputWindowHandle::updateInfo would also call InputApplicationHandle::updateInfo that may access the null pointer if the focus application changed in same time. - To replace allocated mInfo in updateInfo(), make it as an object member variable of InputApplicationHandle. Bug: 128930899 Test: atest inputflinger_tests Change-Id: I7494527be8ae7e76bea672c3dc33380aef07b057
This commit is contained in:
@@ -56,30 +56,25 @@ bool NativeInputApplicationHandle::updateInfo() {
|
||||
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||
jobject obj = env->NewLocalRef(mObjWeak);
|
||||
if (!obj) {
|
||||
releaseInfo();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mInfo) {
|
||||
mInfo = new InputApplicationInfo();
|
||||
}
|
||||
mInfo.name = getStringField(env, obj, gInputApplicationHandleClassInfo.name, "<null>");
|
||||
|
||||
mInfo->name = getStringField(env, obj, gInputApplicationHandleClassInfo.name, "<null>");
|
||||
|
||||
mInfo->dispatchingTimeout = env->GetLongField(obj,
|
||||
mInfo.dispatchingTimeout = env->GetLongField(obj,
|
||||
gInputApplicationHandleClassInfo.dispatchingTimeoutNanos);
|
||||
|
||||
jobject tokenObj = env->GetObjectField(obj,
|
||||
gInputApplicationHandleClassInfo.token);
|
||||
if (tokenObj) {
|
||||
mInfo->token = ibinderForJavaObject(env, tokenObj);
|
||||
mInfo.token = ibinderForJavaObject(env, tokenObj);
|
||||
env->DeleteLocalRef(tokenObj);
|
||||
} else {
|
||||
mInfo->token.clear();
|
||||
mInfo.token.clear();
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(obj);
|
||||
return true;
|
||||
return mInfo.token.get() != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user