ContextHubService: Don't double report app loads

am: fe6d4f518a

Change-Id: I00d7537e70ea97c57d4a8e05a05000418c64339e
This commit is contained in:
Greg Kaiser
2016-08-26 03:36:37 +00:00
committed by android-build-merger
3 changed files with 19 additions and 5 deletions

View File

@@ -322,9 +322,16 @@ public class ContextHubService extends IContextHubService.Stub {
appInfo.setNeededReadMemBytes(PRE_LOADED_APP_MEM_REQ);
appInfo.setNeededWriteMemBytes(PRE_LOADED_APP_MEM_REQ);
String action;
if (mNanoAppHash.containsKey(appInstanceHandle)) {
action = "Updated";
} else {
action = "Added";
}
mNanoAppHash.put(appInstanceHandle, appInfo);
Log.d(TAG, "Added app instance " + appInstanceHandle + " with id " + appId
+ " version " + appVersion);
Log.d(TAG, action + " app instance " + appInstanceHandle + " with id "
+ appId + " version " + appVersion);
return 0;
}

View File

@@ -113,7 +113,12 @@ public class NanoAppInstanceInfo {
}
/**
* Set the application version
* Get the application version
*
* NOTE: There is a race condition where shortly after loading, this
* may return -1 instead of the correct version.
*
* TODO(b/30970527): Fix this race condition.
*
* @return int - version of the app
*/

View File

@@ -357,7 +357,9 @@ 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,
@@ -380,8 +382,8 @@ static jint add_app_instance(const hub_app_info *appInfo, uint32_t hubHandle,
hubHandle, entry.instanceId, entry.truncName,
entry.appInfo.version);
ALOGW("Added App 0x%" PRIx64 " on hub Handle %" PRId32
" as appInstance %" PRId32, entry.truncName,
ALOGW("%s App 0x%" PRIx64 " on hub Handle %" PRId32
" as appInstance %" PRId32, action, entry.truncName,
entry.hubHandle, appInstanceHandle);
return appInstanceHandle;