Updating fastboot-info version check
Updating version to just be a single number. Reason for updating is
to keep format the same as Flashstation's
Test: fastboot_test
Bug: 194686221
Change-Id: I21ab0747e620d3f6d05c5170c3e55707eed0288a
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index cdcd036..b099f77 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1663,20 +1663,6 @@
return;
}
-static bool IsNumber(const std::string& s) {
- bool period = false;
- for (size_t i = 0; i < s.length(); i++) {
- if (!isdigit(s[i])) {
- if (!period && s[i] == '.' && i != 0 && i != s.length() - 1) {
- period = true;
- } else {
- return false;
- }
- }
- }
- return true;
-}
-
static bool IsIgnore(const std::vector<std::string>& command) {
if (command[0][0] == '#') {
return true;
@@ -1684,7 +1670,8 @@
return false;
}
-bool CheckFastbootInfoRequirements(const std::vector<std::string>& command) {
+bool CheckFastbootInfoRequirements(const std::vector<std::string>& command,
+ uint32_t host_tool_version) {
if (command.size() != 2) {
LOG(ERROR) << "unknown characters in version info in fastboot-info.txt -> "
<< android::base::Join(command, " ");
@@ -1696,18 +1683,20 @@
return false;
}
- if (!IsNumber(command[1])) {
- LOG(ERROR) << "version number contains non-numeric values in fastboot-info.txt -> "
+ uint32_t fastboot_info_version;
+ if (!android::base::ParseUint(command[1], &fastboot_info_version)) {
+ LOG(ERROR) << "version number contains non-numeric characters in fastboot-info.txt -> "
<< android::base::Join(command, " ");
return false;
}
LOG(VERBOSE) << "Checking 'fastboot-info.txt version'";
- if (command[1] < PLATFORM_TOOLS_VERSION) {
+ if (fastboot_info_version <= host_tool_version) {
return true;
}
+
LOG(ERROR) << "fasboot-info.txt version: " << command[1]
- << " not compatible with host tool version --> " << PLATFORM_TOOLS_VERSION;
+ << " not compatible with host tool version --> " << host_tool_version;
return false;
}
@@ -1721,7 +1710,9 @@
continue;
}
if (command.size() > 1 && command[0] == "version") {
- if (!CheckFastbootInfoRequirements(command)) {
+ uint32_t platform_tools_version;
+ android::base::ParseUint(PLATFORM_TOOLS_VERSION, &platform_tools_version);
+ if (!CheckFastbootInfoRequirements(command, platform_tools_version)) {
return {};
}
continue;