Removed my excessive debugging.
This commit is contained in:
parent
6c64bdcb16
commit
fa6777ae9d
@ -1002,7 +1002,6 @@ public class DB {
|
|||||||
values.put("features", CommaSeparatedList.str(upapk.features));
|
values.put("features", CommaSeparatedList.str(upapk.features));
|
||||||
values.put("compatible", upapk.compatible ? 1 : 0);
|
values.put("compatible", upapk.compatible ? 1 : 0);
|
||||||
if (oldapk != null) {
|
if (oldapk != null) {
|
||||||
Log.d("FDroid", "Updating apk '" + upapk.id + "' with hash '" + upapk.detail_hash + "'");
|
|
||||||
db.update(TABLE_APK, values,
|
db.update(TABLE_APK, values,
|
||||||
"id = ? and vercode = " + Integer.toString(oldapk.vercode),
|
"id = ? and vercode = " + Integer.toString(oldapk.vercode),
|
||||||
new String[] { oldapk.id });
|
new String[] { oldapk.id });
|
||||||
|
@ -285,7 +285,6 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
|
||||||
if (etag != null)
|
if (etag != null)
|
||||||
connection.setRequestProperty("If-None-Match", etag);
|
connection.setRequestProperty("If-None-Match", etag);
|
||||||
int totalBytes = 0;
|
|
||||||
int code = connection.getResponseCode();
|
int code = connection.getResponseCode();
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
// Testing in the emulator for me, showed that figuring out the filesize took about 1 to 1.5 seconds.
|
// Testing in the emulator for me, showed that figuring out the filesize took about 1 to 1.5 seconds.
|
||||||
@ -311,8 +310,9 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
if (et != null)
|
if (et != null)
|
||||||
retag.append(et);
|
retag.append(et);
|
||||||
}
|
}
|
||||||
Log.d("FDroid", "Fetched " + url + " (" + totalBytes + " bytes) in "
|
Log.d("FDroid", "Fetched " + url + " (" + progressEvent.total +
|
||||||
+ (System.currentTimeMillis() - startTime) + "ms");
|
" bytes) in " + (System.currentTimeMillis() - startTime) +
|
||||||
|
"ms");
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,136 +180,79 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!changes && success) {
|
if (!changes && success) {
|
||||||
Log.d("FDroid", "Not updating any apps, because no repos were changed.");
|
Log.d("FDroid", "Not checking app details or compatibility, because all repos were up to date.");
|
||||||
} else if (changes && success) {
|
} else if (changes && success) {
|
||||||
|
|
||||||
sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility));
|
sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility));
|
||||||
List<DB.App> acceptedapps = new ArrayList<DB.App>();
|
List<DB.App> acceptedapps = new ArrayList<DB.App>();
|
||||||
List<DB.App> prevapps = ((FDroidApp) getApplication()).getApps();
|
List<DB.App> prevapps = ((FDroidApp) getApplication()).getApps();
|
||||||
|
|
||||||
boolean anyRepoToUpdate = false;
|
DB db = DB.getDB();
|
||||||
for (DB.Repo repo : repos) {
|
try {
|
||||||
boolean keepThisRepo = false;
|
|
||||||
for(int repoId : keeprepos) {
|
|
||||||
if (repo.id == repoId) {
|
|
||||||
keepThisRepo = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!keepThisRepo) {
|
|
||||||
anyRepoToUpdate = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!anyRepoToUpdate) {
|
// Need to flag things we're keeping despite having received
|
||||||
Log.d("FDroid", "Not checking app details or compatibility, because all repos were up to date.");
|
// no data about during the update. (i.e. stuff from a repo
|
||||||
} else {
|
// that we know is unchanged due to the etag)
|
||||||
sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility));
|
for (int keep : keeprepos) {
|
||||||
List<DB.App> acceptedapps = new ArrayList<DB.App>();
|
for (DB.App app : prevapps) {
|
||||||
List<DB.App> prevapps = ((FDroidApp) getApplication()).getApps();
|
boolean keepapp = false;
|
||||||
|
for (DB.Apk apk : app.apks) {
|
||||||
DB db = DB.getDB();
|
if (apk.repo == keep) {
|
||||||
try {
|
keepapp = true;
|
||||||
|
break;
|
||||||
// Need to flag things we're keeping despite having received
|
}
|
||||||
// no data about during the update. (i.e. stuff from a repo
|
}
|
||||||
// that we know is unchanged due to the etag)
|
if (keepapp) {
|
||||||
|
DB.App app_k = null;
|
||||||
// keeep repos are the unchanged ones...
|
for (DB.App app2 : apps) {
|
||||||
Log.d("FDroid", "Checking " + keeprepos.size() + " unchanged repos.");
|
if (app2.id.equals(app.id)) {
|
||||||
for (int keep : keeprepos) {
|
app_k = app2;
|
||||||
|
|
||||||
// prevapps are all previous apps (and their respective apks
|
|
||||||
// These *DON'T* yet have the details_hash set)...
|
|
||||||
Log.d("Fdroid", "Checking '" + keep + "' repo to populate its apk details...");
|
|
||||||
for (DB.App app : prevapps) {
|
|
||||||
boolean keepapp = false;
|
|
||||||
for (DB.Apk apk : app.apks) {
|
|
||||||
|
|
||||||
// only continue below if the apk is in the sqlite database,
|
|
||||||
// and belongs to one of the unchanged repos...
|
|
||||||
|
|
||||||
if (apk.repo == keep) {
|
|
||||||
Log.d("FDroid", "App '" + app.id + "' has apk '" + apk.id + "' which belongs to repo " + keep);
|
|
||||||
keepapp = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keepapp) {
|
if (app_k == null) {
|
||||||
DB.App app_k = null;
|
apps.add(app);
|
||||||
|
app_k = app;
|
||||||
// "apps" are the ones found in the index.xml files from
|
|
||||||
// every index.xml file we came across during update...
|
|
||||||
// Not that this excludes apps from up-to-date repos (due to etag)...
|
|
||||||
|
|
||||||
Log.d("FDroid", "Searching through apps from index.xml to figure out if they match (the unchanged) '" + app.id + "'..." );
|
|
||||||
for (DB.App app2 : apps) {
|
|
||||||
if (app2.id.equals(app.id)) {
|
|
||||||
|
|
||||||
// "app_k" is the DB.App which is in an index.xml file
|
|
||||||
// that we downloaded, and also in the database, and in
|
|
||||||
// a repo which was up to date... I think...
|
|
||||||
|
|
||||||
Log.d("FDroid", "Found matching app '" + app2.id + "' in one of the index.xml files..." );
|
|
||||||
app_k = app2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just assign it from the "prevapps" - those
|
|
||||||
// which game straight from sqlite. In this case,
|
|
||||||
// app_k will *NOT* have hash_details set...
|
|
||||||
|
|
||||||
if (app_k == null) {
|
|
||||||
|
|
||||||
Log.d("FDroid", "Could not find matching app in index.xml files (searched " + apps.size() + " apps). Wlil just assign it from the SQLite version...");
|
|
||||||
apps.add(app);
|
|
||||||
app_k = app;
|
|
||||||
}
|
|
||||||
app_k.updated = true;
|
|
||||||
// At this point, we set the hash_details for each
|
|
||||||
// of app_k's apks...
|
|
||||||
Log.d("FDroid", "Populating details for app '" + app_k.id + "' (should set the details_hash for us)...");
|
|
||||||
db.populateDetails(app_k, keep);
|
|
||||||
for (DB.Apk apk : app.apks)
|
|
||||||
if (apk.repo == keep)
|
|
||||||
apk.updated = true;
|
|
||||||
}
|
}
|
||||||
|
app_k.updated = true;
|
||||||
|
db.populateDetails(app_k, keep);
|
||||||
|
for (DB.Apk apk : app.apks)
|
||||||
|
if (apk.repo == keep)
|
||||||
|
apk.updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prevUpdates = db.beginUpdate(prevapps);
|
|
||||||
for (DB.App app : apps) {
|
|
||||||
if (db.updateApplication(app))
|
|
||||||
acceptedapps.add(app);
|
|
||||||
}
|
|
||||||
db.endUpdate();
|
|
||||||
if (notify)
|
|
||||||
newUpdates = db.getNumUpdates();
|
|
||||||
for (DB.Repo repo : repos)
|
|
||||||
db.writeLastEtag(repo);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
db.cancelUpdate();
|
|
||||||
Log.e("FDroid", "Exception during update processing:\n"
|
|
||||||
+ Log.getStackTraceString(ex));
|
|
||||||
errmsg = "Exception during processing - " + ex.getMessage();
|
|
||||||
success = false;
|
|
||||||
} finally {
|
|
||||||
DB.releaseDB();
|
|
||||||
}
|
|
||||||
if (success) {
|
|
||||||
for (DB.App app : acceptedapps)
|
|
||||||
getIcon(app, repos);
|
|
||||||
((FDroidApp) getApplication()).invalidateApps();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevUpdates = db.beginUpdate(prevapps);
|
||||||
|
for (DB.App app : apps) {
|
||||||
|
if (db.updateApplication(app))
|
||||||
|
acceptedapps.add(app);
|
||||||
|
}
|
||||||
|
db.endUpdate();
|
||||||
|
if (notify)
|
||||||
|
newUpdates = db.getNumUpdates();
|
||||||
|
for (DB.Repo repo : repos)
|
||||||
|
db.writeLastEtag(repo);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
db.cancelUpdate();
|
||||||
|
Log.e("FDroid", "Exception during update processing:\n"
|
||||||
|
+ Log.getStackTraceString(ex));
|
||||||
|
errmsg = "Exception during processing - " + ex.getMessage();
|
||||||
|
success = false;
|
||||||
|
} finally {
|
||||||
|
DB.releaseDB();
|
||||||
}
|
}
|
||||||
|
if (success) {
|
||||||
|
for (DB.App app : acceptedapps)
|
||||||
|
getIcon(app, repos);
|
||||||
|
((FDroidApp) getApplication()).invalidateApps();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success && changes && notify) {
|
if (success && changes && notify) {
|
||||||
Log.d("FDroid", "Updates before:" + prevUpdates + ", after: "
|
Log.d("FDroid", "Notifying updates. Apps before:" + prevUpdates
|
||||||
+ newUpdates);
|
+ ", apps after: " + newUpdates);
|
||||||
if (newUpdates > prevUpdates) {
|
if (newUpdates > prevUpdates) {
|
||||||
NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
Notification notification = new Notification(
|
Notification notification = new Notification(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user