Skip to content

Commit

Permalink
Merge pull request #1145 from garvankeeley/updater-safety
Browse files Browse the repository at this point in the history
Add safety checks to updater. Maybe overkill, best to be safe.
  • Loading branch information
garvankeeley committed Oct 29, 2014
2 parents 34f9d4d + 220b719 commit bdfe484
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,25 @@ public void onPostExecute(IResponse response) {
return;
}
Map<String, List<String>> headers = response.getHeaders();
if (headers == null) {
return;
}
Log.i(LOG_TAG, "Got headers: "+ headers.toString());
if (headers.get("Location") == null) {
return;
}
String locationUrl = headers.get("Location").get(0);
if (locationUrl == null || locationUrl.length() < 1) {
return;
}
String[] parts = locationUrl.split("/");
if (parts.length < 2) {
return;
}
String tag = parts[parts.length-1];
if (tag.length() < 2) {
return;
}
String latestVersion = tag.substring(1); // strip the 'v' from the beginning

String installedVersion = PackageUtils.getAppVersion(activity);
Expand Down Expand Up @@ -129,7 +144,7 @@ private void showUpdateDialog(final Context context,
msg = String.format(msg, installedVersion, latestVersion);

if (installedVersion.startsWith("0.") &&
latestVersion.startsWith("1.")) {
latestVersion.startsWith("1.")) {
// From 0.x to 1.0 and higher, the keystore changed
msg += " " + context.getString(R.string.must_uninstall_to_update);
}
Expand Down

0 comments on commit bdfe484

Please sign in to comment.