From 1ae3e604bd39cb182a21177f9cebba680bc276ab Mon Sep 17 00:00:00 2001
From: Henrik Tunedal <tunedal@gmail.com>
Date: Mon, 28 Mar 2011 18:25:23 +0200
Subject: [PATCH] Use unfiltered application list for updates

---
 src/org/fdroid/fdroid/AppDetails.java    |  2 +-
 src/org/fdroid/fdroid/DB.java            | 14 ++++++++------
 src/org/fdroid/fdroid/FDroid.java        |  2 +-
 src/org/fdroid/fdroid/SearchResults.java |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java
index 192830842..483d93f54 100644
--- a/src/org/fdroid/fdroid/AppDetails.java
+++ b/src/org/fdroid/fdroid/AppDetails.java
@@ -270,7 +270,7 @@ public class AppDetails extends ListActivity {
     // also when something has been installed/uninstalled.
     private void reset() {
         Log.d("FDroid", "Getting application details for " + appid);
-        app = db.getApps(appid, null, true).get(0);
+        app = db.getApps(appid, null, true, false).get(0);
         DB.Apk curver = app.getCurrentVersion(compatChecker);
         app_currentvercode = curver == null ? 0 : curver.vercode;
 
diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java
index 967af2ccd..969ccbeb4 100644
--- a/src/org/fdroid/fdroid/DB.java
+++ b/src/org/fdroid/fdroid/DB.java
@@ -411,7 +411,7 @@ public class DB {
 
     // Get the number of apps that have updates available.
     public int getNumUpdates() {
-        Vector<App> apps = getApps(null, null, false);
+        Vector<App> apps = getApps(null, null, false, true);
         int count = 0;
         for (App app : apps) {
             if (app.hasUpdates)
@@ -427,7 +427,9 @@ public class DB {
     // 'filter' - search text to filter on, or null
     // 'update' - update installed version information from device, rather than
     // simply using values cached in the database. Slower.
-    public Vector<App> getApps(String appid, String filter, boolean update) {
+    // 'exclusions' - apply filtering for compatibility, anti-features, etc.
+    public Vector<App> getApps(String appid, String filter, boolean update,
+                               boolean exclusions) {
 
         SharedPreferences prefs = PreferenceManager
                 .getDefaultSharedPreferences(mContext);
@@ -460,7 +462,7 @@ public class DB {
                 app.antiFeatures = DB.CommaSeparatedList.make(c
                         .getString(c.getColumnIndex("antiFeatures")));
                 boolean include = true;
-                if (app.antiFeatures != null) {
+                if (app.antiFeatures != null && exclusions) {
                     for (String af : app.antiFeatures) {
                         if (af.equals("Ads") && !pref_antiAds)
                             include = false;
@@ -476,7 +478,7 @@ public class DB {
                 }
                 app.requirements = DB.CommaSeparatedList.make(c
                         .getString(c.getColumnIndex("requirements")));
-                if (app.requirements != null) {
+                if (app.requirements != null && exclusions) {
                     for (String r : app.requirements) {
                         if (r.equals("root") && !pref_rooted) {
                             include = false;
@@ -511,7 +513,7 @@ public class DB {
                             + " where id = ? order by vercode desc",
                             new String[] { app.id });
                     c2.moveToFirst();
-                    boolean compatible = pref_showIncompat;
+                    boolean compatible = pref_showIncompat || !exclusions;
                     while (!c2.isAfterLast()) {
                         Apk apk = new Apk();
                         apk.id = app.id;
@@ -660,7 +662,7 @@ public class DB {
         // end, any that are still false can be removed.
         // TODO: Need to ensure that UI and UpdateService can't both be doing
         // an update at the same time.
-        updateApps = getApps(null, null, true);
+        updateApps = getApps(null, null, true, false);
         Log.d("FDroid", "AppUpdate: " + updateApps.size()
                 + " apps before starting.");
         // Wrap the whole update in a transaction. Make sure to call
diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java
index 1f04f183e..c15046013 100644
--- a/src/org/fdroid/fdroid/FDroid.java
+++ b/src/org/fdroid/fdroid/FDroid.java
@@ -310,7 +310,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
         apps_up.clear();
 
         long startTime = System.currentTimeMillis();
-        Vector<DB.App> apps = db.getApps(null, null, update);
+        Vector<DB.App> apps = db.getApps(null, null, update, true);
         if (apps.isEmpty()) {
             // Don't attempt this more than once - we may have invalid
             // repositories.
diff --git a/src/org/fdroid/fdroid/SearchResults.java b/src/org/fdroid/fdroid/SearchResults.java
index 943044eae..7d6d280ad 100644
--- a/src/org/fdroid/fdroid/SearchResults.java
+++ b/src/org/fdroid/fdroid/SearchResults.java
@@ -68,7 +68,7 @@ public class SearchResults extends ListActivity {
 
     private void updateView() {
         DB db = new DB(this);
-        Vector<DB.App> apps = db.getApps(null, mQuery, false);
+        Vector<DB.App> apps = db.getApps(null, mQuery, false, true);
         TextView tv = (TextView) findViewById(R.id.description);
         String headertext;
         if(apps.size()==0)