From 3502896e653fb6c5cdbbf608a644c809b8f2f071 Mon Sep 17 00:00:00 2001 From: Henrik Tunedal Date: Tue, 8 Mar 2011 19:54:57 +0100 Subject: [PATCH] Check compatibility when determining current version --- src/org/fdroid/fdroid/AppDetails.java | 6 +++--- src/org/fdroid/fdroid/DB.java | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 3fdbe07f9..fe09a6500 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -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; diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index b21485b2f..c8f48228b 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -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)