Fallback to version code in case lastUpdateMillis field is not populated
Test: presubmit
Bug: 193374411
Change-Id: I2006a1926c64cf01e12d82c90197b20f5cff9406
Merged-In: I2006a1926c64cf01e12d82c90197b20f5cff9406
(cherry picked from commit 5f2f289b64f163e491b9b53364ce04874f82b4e3)
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index e558db6..433f564 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1309,8 +1309,13 @@
if (info == apex_infos.end() || info->second->getIsFactory()) {
result += '/';
} else {
- // We use the mtime provided in the format as a version number.
- android::base::StringAppendF(&result, "/%" PRIu64, info->second->getLastUpdateMillis());
+ // In case lastUpdateMillis field is populated in apex-info-list.xml, we
+ // prefer to use it as version scheme. If the field is missing we
+ // fallback to the version code of the APEX.
+ uint64_t version = info->second->hasLastUpdateMillis()
+ ? info->second->getLastUpdateMillis()
+ : info->second->getVersionCode();
+ android::base::StringAppendF(&result, "/%" PRIu64, version);
}
}
#endif