Commit 4193c00f authored by Andrey Zaytsev's avatar Andrey Zaytsev Committed by Commit Bot

Omaha on Android: correctly handling the 'noupdate' status in the on-demand check

When the latest version on the Omaha server matches the installed one, the server doesn't return a version string; instead, status="noupdate" is returned.

Bug: 1070620
Change-Id: I114b3b67f0461f65d5db7f05009cd7dfa106a8d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2307210
Auto-Submit: Andrey Zaytsev <andzaytsev@google.com>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789924}
parent 3df7cfbb
...@@ -65,11 +65,14 @@ public class OmahaBase { ...@@ -65,11 +65,14 @@ public class OmahaBase {
public final String latestVersion; public final String latestVersion;
public final String downloadUrl; public final String downloadUrl;
public final int serverDate; public final int serverDate;
public final String updateStatus;
protected VersionConfig(String latestVersion, String downloadUrl, int serverDate) { protected VersionConfig(
String latestVersion, String downloadUrl, int serverDate, String updateStatus) {
this.latestVersion = latestVersion; this.latestVersion = latestVersion;
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
this.serverDate = serverDate; this.serverDate = serverDate;
this.updateStatus = updateStatus;
} }
} }
...@@ -204,6 +207,11 @@ public class OmahaBase { ...@@ -204,6 +207,11 @@ public class OmahaBase {
? UpdateStatus.OFFLINE ? UpdateStatus.OFFLINE
: UpdateStatus.FAILED; : UpdateStatus.FAILED;
} }
// If the version matches exactly, the Omaha server will return status="noupdate" without
// providing the latest version number.
if (versionConfig.updateStatus != null && versionConfig.updateStatus.equals("noupdate")) {
return UpdateStatus.UPDATED;
}
Log.i(TAG, Log.i(TAG,
"OmahaBase::checkForUpdates(): Received latest version String from Omaha " "OmahaBase::checkForUpdates(): Received latest version String from Omaha "
+ "server: \"" + versionConfig.latestVersion + "\""); + "server: \"" + versionConfig.latestVersion + "\"");
...@@ -642,6 +650,8 @@ public class OmahaBase { ...@@ -642,6 +650,8 @@ public class OmahaBase {
static VersionConfig getVersionConfig(SharedPreferences sharedPref) { static VersionConfig getVersionConfig(SharedPreferences sharedPref) {
return new VersionConfig(sharedPref.getString(OmahaBase.PREF_LATEST_VERSION, ""), return new VersionConfig(sharedPref.getString(OmahaBase.PREF_LATEST_VERSION, ""),
sharedPref.getString(OmahaBase.PREF_MARKET_URL, ""), sharedPref.getString(OmahaBase.PREF_MARKET_URL, ""),
sharedPref.getInt(OmahaBase.PREF_SERVER_DATE, -2)); sharedPref.getInt(OmahaBase.PREF_SERVER_DATE, -2),
// updateStatus is only used for the on-demand check.
null);
} }
} }
...@@ -91,7 +91,7 @@ public class ResponseParser { ...@@ -91,7 +91,7 @@ public class ResponseParser {
XMLParser parser = new XMLParser(xml); XMLParser parser = new XMLParser(xml);
Node rootNode = parser.getRootNode(); Node rootNode = parser.getRootNode();
parseRootNode(rootNode); parseRootNode(rootNode);
return new VersionConfig(getNewVersion(), getURL(), getDaystartDays()); return new VersionConfig(getNewVersion(), getURL(), getDaystartDays(), getUpdateStatus());
} }
public int getDaystartSeconds() { public int getDaystartSeconds() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment