Check compatibility when determining current version
This commit is contained in:
parent
cea9278ef2
commit
3502896e65
@ -227,7 +227,7 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
Log.d("FDroid", "Getting application details for " + appid);
|
Log.d("FDroid", "Getting application details for " + appid);
|
||||||
app = db.getApps(appid, null, true).get(0);
|
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;
|
app_currentvercode = curver == null ? 0 : curver.vercode;
|
||||||
|
|
||||||
// Get the signature of the installed package...
|
// Get the signature of the installed package...
|
||||||
@ -310,7 +310,7 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
menu.clear();
|
menu.clear();
|
||||||
DB.Apk curver = app.getCurrentVersion();
|
DB.Apk curver = app.getCurrentVersion(compatChecker);
|
||||||
if (app.installedVersion != null && curver != null
|
if (app.installedVersion != null && curver != null
|
||||||
&& !app.installedVersion.equals(curver.version)) {
|
&& !app.installedVersion.equals(curver.version)) {
|
||||||
menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(
|
menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(
|
||||||
@ -354,7 +354,7 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
case INSTALL:
|
case INSTALL:
|
||||||
// Note that this handles updating as well as installing.
|
// Note that this handles updating as well as installing.
|
||||||
curapk = app.getCurrentVersion();
|
curapk = app.getCurrentVersion(compatChecker);
|
||||||
if (curapk != null)
|
if (curapk != null)
|
||||||
install();
|
install();
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,22 +119,25 @@ public class DB {
|
|||||||
// This should be the 'current' version, as in the most recent stable
|
// 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
|
// one, that most users would want by default. It might not be the
|
||||||
// most recent, if for example there are betas etc.
|
// 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...
|
// Try and return the version that's in Google's market first...
|
||||||
if (marketVersion != null && marketVercode > 0) {
|
if (marketVersion != null && marketVercode > 0) {
|
||||||
for (Apk apk : apks) {
|
for (Apk apk : apks) {
|
||||||
if (apk.vercode == marketVercode)
|
if (apk.vercode == marketVercode
|
||||||
|
&& (checker == null || checker.isCompatible(apk)))
|
||||||
return apk;
|
return apk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't know the market version, or we don't have it, we
|
// 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;
|
int latestcode = -1;
|
||||||
Apk latestapk = null;
|
Apk latestapk = null;
|
||||||
for (Apk apk : apks) {
|
for (Apk apk : apks) {
|
||||||
if (apk.vercode > latestcode) {
|
if (apk.vercode > latestcode
|
||||||
|
&& (checker == null || checker.isCompatible(apk))) {
|
||||||
latestapk = apk;
|
latestapk = apk;
|
||||||
latestcode = apk.vercode;
|
latestcode = apk.vercode;
|
||||||
}
|
}
|
||||||
@ -561,7 +564,7 @@ public class DB {
|
|||||||
// installed version is not the 'current' one AND the installed
|
// installed version is not the 'current' one AND the installed
|
||||||
// version is older than the current one.
|
// version is older than the current one.
|
||||||
for (App app : result) {
|
for (App app : result) {
|
||||||
Apk curver = app.getCurrentVersion();
|
Apk curver = app.getCurrentVersion(compatChecker);
|
||||||
if (curver != null && app.installedVersion != null
|
if (curver != null && app.installedVersion != null
|
||||||
&& !app.installedVersion.equals(curver.version)) {
|
&& !app.installedVersion.equals(curver.version)) {
|
||||||
if (app.installedVerCode < curver.vercode)
|
if (app.installedVerCode < curver.vercode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user