Probable fix to notification problem

This commit is contained in:
Ciaran Gultnieks 2011-12-05 17:06:50 +00:00
parent 23109ca778
commit ba2861dcc8
2 changed files with 12 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2010 Ciaran Gultnieks, ciaran@ciarang.com * Copyright (C) 2010-11 Ciaran Gultnieks, ciaran@ciarang.com
* Copyright (C) 2009 Roberto Jacinto, roberto.jacinto@caixamagica.pt * Copyright (C) 2009 Roberto Jacinto, roberto.jacinto@caixamagica.pt
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -658,6 +658,7 @@ public class DB {
|| !app.installedVersion.equals(version)) { || !app.installedVersion.equals(version)) {
setInstalledVersion(app.id, version, vercode); setInstalledVersion(app.id, version, vercode);
app.installedVersion = version; app.installedVersion = version;
app.installedVerCode = vercode;
} }
} else { } else {
if (app.installedVersion != null) { if (app.installedVersion != null) {
@ -775,7 +776,7 @@ public class DB {
if (app.id.equals(upapp.id)) { if (app.id.equals(upapp.id)) {
// Log.d("FDroid", "AppUpdate: " + app.id // Log.d("FDroid", "AppUpdate: " + app.id
// + " is already in the database."); // + " is already in the database.");
updateAppIfDifferent(app, upapp); updateApp(app, upapp);
app.updated = true; app.updated = true;
found = true; found = true;
for (Apk upapk : upapp.apks) { for (Apk upapk : upapp.apks) {
@ -807,7 +808,7 @@ public class DB {
// Log // Log
// .d("FDroid", "AppUpdate: " + upapp.id // .d("FDroid", "AppUpdate: " + upapp.id
// + " is a new application."); // + " is a new application.");
updateAppIfDifferent(null, upapp); updateApp(null, upapp);
for (Apk upapk : upapp.apks) { for (Apk upapk : upapp.apks) {
updateApkIfDifferent(null, upapk); updateApkIfDifferent(null, upapk);
upapk.updated = true; upapk.updated = true;
@ -818,13 +819,15 @@ public class DB {
} }
// Update application details in the database, if different to the // Update application details in the database.
// previous ones.
// 'oldapp' - previous details - i.e. what's in the database. // 'oldapp' - previous details - i.e. what's in the database.
// If null, this app is not in the database at all and // If null, this app is not in the database at all and
// should be added. // should be added.
// 'upapp' - updated details // 'upapp' - updated details
private void updateAppIfDifferent(App oldapp, App upapp) { // Note that we deliberately do not update installedVersion or
// installedVerCode here - for a new app, they default correctly,
// and for an existing app we want to keep that cached data.
private void updateApp(App oldapp, App upapp) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put("id", upapp.id); values.put("id", upapp.id);
values.put("name", upapp.name); values.put("name", upapp.name);
@ -837,8 +840,6 @@ public class DB {
values.put("trackerURL", upapp.trackerURL); values.put("trackerURL", upapp.trackerURL);
values.put("sourceURL", upapp.sourceURL); values.put("sourceURL", upapp.sourceURL);
values.put("donateURL", upapp.donateURL); values.put("donateURL", upapp.donateURL);
values.put("installedVersion", upapp.installedVersion);
values.put("installedVerCode", upapp.installedVerCode);
values.put("marketVersion", upapp.marketVersion); values.put("marketVersion", upapp.marketVersion);
values.put("marketVercode", upapp.marketVercode); values.put("marketVercode", upapp.marketVercode);
values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures)); values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures));

View File

@ -112,7 +112,9 @@ public class UpdateService extends Service {
getBaseContext(), db); getBaseContext(), db);
if (success && notify) { if (success && notify) {
if (db.getNumUpdates() > prevUpdates) { int newUpdates = db.getNumUpdates();
Log.d("FDroid", "Updates before:" + prevUpdates + ", after: " +newUpdates);
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(
R.drawable.icon, R.drawable.icon,