Add very basic support for <provides>

This commit is contained in:
Daniel Martí 2013-12-31 11:16:46 +01:00
parent e437898e33
commit bc74d97195
2 changed files with 17 additions and 4 deletions

View File

@ -104,7 +104,7 @@ public class DB {
+ "lastUpdated string," + "compatible int not null," + "lastUpdated string," + "compatible int not null,"
+ "ignoreAllUpdates int not null," + "ignoreAllUpdates int not null,"
+ "ignoreThisUpdate int not null," + "ignoreThisUpdate int not null,"
+ "primary key(id));"; + "provides string," + "primary key(id));";
public static class App implements Comparable<App> { public static class App implements Comparable<App> {
@ -121,6 +121,7 @@ public class DB {
detail_litecoinAddr = null; detail_litecoinAddr = null;
detail_webURL = null; detail_webURL = null;
categories = null; categories = null;
provides = null;
antiFeatures = null; antiFeatures = null;
requirements = null; requirements = null;
hasUpdates = false; hasUpdates = false;
@ -191,6 +192,9 @@ public class DB {
public int installedVerCode; public int installedVerCode;
public boolean userInstalled; public boolean userInstalled;
// List of app IDs that this app provides or null if there aren't any.
public CommaSeparatedList provides;
// List of categories (as defined in the metadata // List of categories (as defined in the metadata
// documentation) or null if there aren't any. // documentation) or null if there aren't any.
public CommaSeparatedList categories; public CommaSeparatedList categories;
@ -457,7 +461,7 @@ public class DB {
public String lastetag; // last etag we updated from, null forces update public String lastetag; // last etag we updated from, null forces update
} }
private final int DBVersion = 30; private final int DBVersion = 31;
private static void createAppApk(SQLiteDatabase db) { private static void createAppApk(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_APP); db.execSQL(CREATE_TABLE_APP);
@ -836,7 +840,8 @@ public class DB {
String cols[] = new String[] { "antiFeatures", "requirements", String cols[] = new String[] { "antiFeatures", "requirements",
"categories", "id", "name", "summary", "icon", "license", "categories", "id", "name", "summary", "icon", "license",
"curVersion", "curVercode", "added", "lastUpdated", "curVersion", "curVercode", "added", "lastUpdated",
"compatible", "ignoreAllUpdates", "ignoreThisUpdate" }; "compatible", "ignoreAllUpdates", "ignoreThisUpdate",
"provides" };
c = db.query(TABLE_APP, cols, null, null, null, null, null); c = db.query(TABLE_APP, cols, null, null, null, null, null);
c.moveToFirst(); c.moveToFirst();
while (!c.isAfterLast()) { while (!c.isAfterLast()) {
@ -862,6 +867,7 @@ public class DB {
app.compatible = c.getInt(12) == 1; app.compatible = c.getInt(12) == 1;
app.ignoreAllUpdates = c.getInt(13) == 1; app.ignoreAllUpdates = c.getInt(13) == 1;
app.ignoreThisUpdate = c.getInt(14); app.ignoreThisUpdate = c.getInt(14);
app.provides = DB.CommaSeparatedList.make(c.getString(15));
app.hasUpdates = false; app.hasUpdates = false;
if (getinstalledinfo && systemApks.containsKey(app.id)) { if (getinstalledinfo && systemApks.containsKey(app.id)) {
@ -881,6 +887,11 @@ public class DB {
} }
apps.put(app.id, app); apps.put(app.id, app);
if (app.provides != null) {
for (String id : app.provides) {
apps.put(id, app);
}
}
c.moveToNext(); c.moveToNext();
} }
@ -1038,7 +1049,7 @@ public class DB {
try { try {
String filter = "%" + query + "%"; String filter = "%" + query + "%";
c = db.query(TABLE_APP, new String[] { "id" }, c = db.query(TABLE_APP, new String[] { "id" },
"id like ? or name like ? or summary like ? or description like ?", "id like ? or provides like ? or name like ? or summary like ? or description like ?",
new String[] { filter, filter, filter, filter }, null, null, null); new String[] { filter, filter, filter, filter }, null, null, null);
c.moveToFirst(); c.moveToFirst();
while (!c.isAfterLast()) { while (!c.isAfterLast()) {

View File

@ -240,6 +240,8 @@ public class RepoXMLHandler extends DefaultHandler {
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
curapp.curVercode = -1; curapp.curVercode = -1;
} }
} else if (curel.equals("provides")) {
curapp.provides = DB.CommaSeparatedList.make(str);
} else if (curel.equals("categories")) { } else if (curel.equals("categories")) {
curapp.categories = DB.CommaSeparatedList.make(str); curapp.categories = DB.CommaSeparatedList.make(str);
} else if (curel.equals("antifeatures")) { } else if (curel.equals("antifeatures")) {