CV == 0 means none recommended. No CV declared means latest compatible apk recommended.

This commit is contained in:
Daniel Martí 2013-07-23 18:19:04 +02:00
parent 0c1b854b69
commit 03ca3e0e05
2 changed files with 25 additions and 15 deletions

View File

@ -191,26 +191,36 @@ public class DB {
// most recent, if for example there are betas etc.
public Apk getCurrentVersion() {
// Try and return the real current version first...
// Try and return the real current version first. It will find the
// closest version smaller than the curVercode, being the same
// vercode if it exists.
if (curVercode > 0) {
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.compatible && apk.vercode == curVercode)
return apk;
if (apk.compatible && apk.vercode <= curVercode
&& apk.vercode > latestcode) {
latestapk = apk;
latestcode = apk.vercode;
}
}
return latestapk;
}
// If we don't know the current version, or we don't have it, we
// return the most recent version we have...
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.compatible &&apk.vercode < curVercode
&& apk.vercode > latestcode) {
latestapk = apk;
latestcode = apk.vercode;
// If the current version was not set we return the most recent apk.
if (curVercode == -1) {
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.compatible && apk.vercode > latestcode) {
latestapk = apk;
latestcode = apk.vercode;
}
}
return latestapk;
}
return latestapk;
return null;
}
@Override

View File

@ -137,7 +137,7 @@ public class RepoXMLHandler extends DefaultHandler {
try {
curapk.vercode = Integer.parseInt(str);
} catch (NumberFormatException ex) {
curapk.vercode = 0;
curapk.vercode = -1;
}
} else if (curel.equals("size")) {
try {
@ -228,7 +228,7 @@ public class RepoXMLHandler extends DefaultHandler {
try {
curapp.curVercode = Integer.parseInt(str);
} catch (NumberFormatException ex) {
curapp.curVercode = 0;
curapp.curVercode = -1;
}
} else if (curel.equals("antifeatures")) {
curapp.antiFeatures = DB.CommaSeparatedList.make(str);