From b0604ecc914ade4ac9bf0ab7bcbb3b8d43de297e Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Tue, 6 Sep 2016 22:55:53 -0700 Subject: [PATCH] ContextHubService: Don't change app handle on load Due to the way this logic was set up, every time we would load a new nanoapp, add_app_instance() would change the nanoapp's handle/"id" in manner that was invisible to closeTxnLoad(), so our JNI cache would use a different handle than what we passed to the Java callback. We remove this unnecessary changing of the handle/"id". Bug:31325144 Change-Id: I8678729f38fb804bc6a128ce9722fd35551fa1c1 --- core/jni/android_hardware_location_ContextHubService.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/core/jni/android_hardware_location_ContextHubService.cpp index 36444102fb07..a24aa3191dc1 100644 --- a/core/jni/android_hardware_location_ContextHubService.cpp +++ b/core/jni/android_hardware_location_ContextHubService.cpp @@ -393,16 +393,8 @@ static jint add_app_instance(const hub_app_info *appInfo, uint32_t hubHandle, app_instance_info_s entry; assert(appInfo); - const char *action = "Updated"; - if (db.appInstances.count(appInstanceHandle) == 0) { - action = "Added"; - appInstanceHandle = generate_id(); - if (appInstanceHandle < 0) { - ALOGE("Cannot find resources to add app instance %" PRId32, - appInstanceHandle); - return -1; - } - } + const char *action = + (db.appInstances.count(appInstanceHandle) == 0) ? "Added" : "Updated"; entry.appInfo = *appInfo; -- 2.11.0