Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe6d4f51 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

ContextHubService: Don't double report app loads

Our logs would show us loading apps twice, when in reality we
load them once, and then update our caches with the app
version later.

There are other issues around how this code works (for example,
b/30970527), but this is an appropriate approach at this
stage of the release.

Bug: 30836667
Change-Id: I2e2a65bc8a2ef4d1703df0a0586a8ed251607af7
parent f8210797
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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;
    }
+6 −1
Original line number Diff line number Diff line
@@ -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
     */
+4 −2
Original line number Diff line number Diff line
@@ -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;