Cleaned up the update process a bit
This commit is contained in:
parent
aa58a8aad1
commit
23109ca778
@ -206,8 +206,8 @@ public class DB {
|
||||
public static abstract class CompatibilityChecker {
|
||||
|
||||
// Because Build.VERSION.SDK_INT requires API level 5
|
||||
protected final static int SDK_INT
|
||||
= Integer.parseInt(Build.VERSION.SDK);
|
||||
protected final static int SDK_INT = Integer
|
||||
.parseInt(Build.VERSION.SDK);
|
||||
|
||||
public abstract boolean isCompatible(Apk apk);
|
||||
|
||||
@ -252,7 +252,8 @@ public class DB {
|
||||
if (apk.features != null) {
|
||||
for (String feat : apk.features) {
|
||||
if (!features.contains(feat)) {
|
||||
Log.d("FDroid","Incompatible based on lack of " + feat);
|
||||
Log.d("FDroid", "Incompatible based on lack of "
|
||||
+ feat);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -351,10 +352,10 @@ public class DB {
|
||||
db.execSQL(CREATE_TABLE_APK);
|
||||
onUpgrade(db, 1, DB_UPGRADES.length + 1);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("address",
|
||||
mContext.getString(R.string.default_repo_address));
|
||||
values.put("pubkey",
|
||||
mContext.getString(R.string.default_repo_pubkey));
|
||||
values.put("address", mContext
|
||||
.getString(R.string.default_repo_address));
|
||||
values.put("pubkey", mContext
|
||||
.getString(R.string.default_repo_pubkey));
|
||||
values.put("inuse", 1);
|
||||
values.put("priority", 10);
|
||||
db.insert(TABLE_REPO, null, values);
|
||||
@ -433,7 +434,8 @@ public class DB {
|
||||
result.add("All");
|
||||
Cursor c = null;
|
||||
try {
|
||||
c = db.rawQuery("select distinct category from " + TABLE_APP + " order by category", null);
|
||||
c = db.rawQuery("select distinct category from " + TABLE_APP
|
||||
+ " order by category", null);
|
||||
c.moveToFirst();
|
||||
while (!c.isAfterLast()) {
|
||||
String s = c.getString(c.getColumnIndex("category"));
|
||||
@ -495,8 +497,8 @@ public class DB {
|
||||
while (!c.isAfterLast()) {
|
||||
|
||||
App app = new App();
|
||||
app.antiFeatures = DB.CommaSeparatedList.make(c
|
||||
.getString(c.getColumnIndex("antiFeatures")));
|
||||
app.antiFeatures = DB.CommaSeparatedList.make(c.getString(c
|
||||
.getColumnIndex("antiFeatures")));
|
||||
boolean include = true;
|
||||
if (app.antiFeatures != null && exclusions) {
|
||||
for (String af : app.antiFeatures) {
|
||||
@ -515,8 +517,8 @@ public class DB {
|
||||
include = false;
|
||||
}
|
||||
}
|
||||
app.requirements = DB.CommaSeparatedList.make(c
|
||||
.getString(c.getColumnIndex("requirements")));
|
||||
app.requirements = DB.CommaSeparatedList.make(c.getString(c
|
||||
.getColumnIndex("requirements")));
|
||||
if (app.requirements != null && exclusions) {
|
||||
for (String r : app.requirements) {
|
||||
if (r.equals("root") && !pref_rooted) {
|
||||
@ -565,7 +567,8 @@ public class DB {
|
||||
apk.hashType = c2.getString(c2
|
||||
.getColumnIndex("hashType"));
|
||||
apk.sig = c2.getString(c2.getColumnIndex("sig"));
|
||||
apk.srcname = c2.getString(c2.getColumnIndex("srcname"));
|
||||
apk.srcname = c2
|
||||
.getString(c2.getColumnIndex("srcname"));
|
||||
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
||||
apk.apkName = c2
|
||||
.getString(c2.getColumnIndex("apkName"));
|
||||
@ -575,8 +578,8 @@ public class DB {
|
||||
.getColumnIndex("minSdkVersion"));
|
||||
apk.permissions = CommaSeparatedList.make(c2
|
||||
.getString(c2.getColumnIndex("permissions")));
|
||||
apk.features = CommaSeparatedList.make(c2
|
||||
.getString(c2.getColumnIndex("features")));
|
||||
apk.features = CommaSeparatedList.make(c2.getString(c2
|
||||
.getColumnIndex("features")));
|
||||
app.apks.add(apk);
|
||||
if (!compatible && compatChecker.isCompatible(apk)) {
|
||||
// At least one compatible APK.
|
||||
@ -588,8 +591,7 @@ public class DB {
|
||||
|
||||
if (compatible) {
|
||||
result.add(app);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Log.d("FDroid", "Excluding incompatible application: "
|
||||
+ app.id);
|
||||
}
|
||||
@ -615,6 +617,9 @@ public class DB {
|
||||
try {
|
||||
getUpdates(result);
|
||||
db.setTransactionSuccessful();
|
||||
} catch (Exception e) {
|
||||
Log.e("FDroid", "Exception while getting updates: "
|
||||
+ Log.getStackTraceString(e));
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
@ -750,7 +755,10 @@ public class DB {
|
||||
|
||||
// Called instead of endUpdate if the update failed.
|
||||
public void cancelUpdate() {
|
||||
if (updateApps != null) {
|
||||
db.endTransaction();
|
||||
updateApps = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Called during update to supply new details for an application (or
|
||||
|
@ -260,7 +260,6 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
db.beginUpdate();
|
||||
Vector<DB.Repo> repos = db.getRepos();
|
||||
for (DB.Repo repo : repos) {
|
||||
boolean success = false;
|
||||
if (repo.inuse) {
|
||||
|
||||
try {
|
||||
@ -273,8 +272,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
+ repo.address);
|
||||
getRemoteFile(ctx, repo.address + "/index.jar",
|
||||
"tempindex.jar");
|
||||
String jarpath = ctx.getFilesDir()
|
||||
+ "/tempindex.jar";
|
||||
String jarpath = ctx.getFilesDir() + "/tempindex.jar";
|
||||
JarFile jar;
|
||||
JarEntry je;
|
||||
try {
|
||||
@ -306,8 +304,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
Log.d("FDroid", "No signature found in index");
|
||||
return false;
|
||||
}
|
||||
Log.d("FDroid", "Index has "
|
||||
+ certs.length + " signature"
|
||||
Log.d("FDroid", "Index has " + certs.length
|
||||
+ " signature"
|
||||
+ (certs.length > 1 ? "s." : "."));
|
||||
|
||||
boolean match = false;
|
||||
@ -355,17 +353,15 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
repo.pubkey = handler.pubkey;
|
||||
db.updateRepoByAddress(repo);
|
||||
}
|
||||
success = true;
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("FDroid", "Exception updating from " + repo.address
|
||||
+ ":\n" + Log.getStackTraceString(e));
|
||||
db.cancelUpdate();
|
||||
return false;
|
||||
} finally {
|
||||
ctx.deleteFile("tempindex.xml");
|
||||
ctx.deleteFile("tempindex.jar");
|
||||
if (!success)
|
||||
db.cancelUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ public class UpdateService extends Service {
|
||||
|
||||
if (success && notify) {
|
||||
if (db.getNumUpdates() > prevUpdates) {
|
||||
// And the user wants to know.
|
||||
NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
Notification notification = new Notification(
|
||||
R.drawable.icon,
|
||||
|
Loading…
x
Reference in New Issue
Block a user