if (!packages.empty())
{
- vector<PackageInfo>::iterator found = find(packages.begin(), packages.end(), target_package);
- if (packages.end() != found)
+ int OptRating = -1;
+ std::string OptVersion = "";
+ std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
+
+ if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
+ group = CommonPackageManager::IntelRating;
+
+ int HardwareRating = GetHardwareRating(platform, cpu_id, group);
+ LOGD("Current hardware platform rating %d for (%d,%d)", HardwareRating, platform, cpu_id);
+
+ if (-1 == HardwareRating)
{
- result = found->GetInstalationPath();
+ LOGE("Cannot calculate rating for current hardware platform!");
}
else
{
- int OptRating = -1;
- std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
-
- if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
- group = CommonPackageManager::IntelRating;
-
- int HardwareRating = GetHardwareRating(platform, cpu_id, group);
- LOGD("Current hardware platform %d, %d", platform, cpu_id);
-
- if (-1 == HardwareRating)
- {
- LOGE("Cannot calculate rating for current hardware platform!");
- }
- else
+ vector<PackageInfo>::iterator found = packages.end();
+ for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
{
- for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
+ int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
+ LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), PackageRating, it->GetPlatform(), it->GetCpuID());
+ if ((PackageRating >= 0) && (PackageRating <= HardwareRating))
{
- int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
- if (PackageRating >= 0)
+ if (((it->GetVersion() >= OptVersion) && (PackageRating >= OptRating)) || (it->GetVersion() > OptVersion))
{
- if ((PackageRating <= HardwareRating) && (PackageRating > OptRating))
- {
- OptRating = PackageRating;
- found = it;
- }
+ OptRating = PackageRating;
+ OptVersion = it->GetVersion();
+ found = it;
}
}
+ }
- if ((-1 != OptRating) && (packages.end() != found))
- {
- result = found->GetInstalationPath();
- }
- else
- {
- LOGI("Found package is incompatible with current hardware platform");
- }
+ if ((-1 != OptRating) && (packages.end() != found))
+ {
+ result = found->GetInstalationPath();
+ }
+ else
+ {
+ LOGI("Found package is incompatible with current hardware platform");
}
}
}
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
+ result.push_back(std::pair<int, int>(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_VFPv3));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
- result.push_back(std::pair<int, int>(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
- result.push_back(std::pair<int, int>(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
+ result.push_back(std::pair<int, int>(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
return result;
}