Check compatibility when determining current version

This commit is contained in:
Henrik Tunedal 2011-03-08 19:54:57 +01:00
parent cea9278ef2
commit 3502896e65
2 changed files with 11 additions and 8 deletions

View File

@ -227,7 +227,7 @@ public class AppDetails extends ListActivity {
Log.d("FDroid", "Getting application details for " + appid);
app = db.getApps(appid, null, true).get(0);
DB.Apk curver = app.getCurrentVersion();
DB.Apk curver = app.getCurrentVersion(compatChecker);
app_currentvercode = curver == null ? 0 : curver.vercode;
// Get the signature of the installed package...
@ -310,7 +310,7 @@ public class AppDetails extends ListActivity {
super.onCreateOptionsMenu(menu);
menu.clear();
DB.Apk curver = app.getCurrentVersion();
DB.Apk curver = app.getCurrentVersion(compatChecker);
if (app.installedVersion != null && curver != null
&& !app.installedVersion.equals(curver.version)) {
menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(
@ -354,7 +354,7 @@ public class AppDetails extends ListActivity {
case INSTALL:
// Note that this handles updating as well as installing.
curapk = app.getCurrentVersion();
curapk = app.getCurrentVersion(compatChecker);
if (curapk != null)
install();
return true;

View File

@ -119,22 +119,25 @@ public class DB {
// This should be the 'current' version, as in the most recent stable
// one, that most users would want by default. It might not be the
// most recent, if for example there are betas etc.
public Apk getCurrentVersion() {
// To skip compatibility checks, pass null as the checker.
public Apk getCurrentVersion(DB.Apk.CompatibilityChecker checker) {
// Try and return the version that's in Google's market first...
if (marketVersion != null && marketVercode > 0) {
for (Apk apk : apks) {
if (apk.vercode == marketVercode)
if (apk.vercode == marketVercode
&& (checker == null || checker.isCompatible(apk)))
return apk;
}
}
// If we don't know the market version, or we don't have it, we
// return the most recent version we have...
// return the most recent compatible version we have...
int latestcode = -1;
Apk latestapk = null;
for (Apk apk : apks) {
if (apk.vercode > latestcode) {
if (apk.vercode > latestcode
&& (checker == null || checker.isCompatible(apk))) {
latestapk = apk;
latestcode = apk.vercode;
}
@ -561,7 +564,7 @@ public class DB {
// installed version is not the 'current' one AND the installed
// version is older than the current one.
for (App app : result) {
Apk curver = app.getCurrentVersion();
Apk curver = app.getCurrentVersion(compatChecker);
if (curver != null && app.installedVersion != null
&& !app.installedVersion.equals(curver.version)) {
if (app.installedVerCode < curver.vercode)