Merge branch 'master' of git://gitorious.org/f-droid/fdroidclient
This commit is contained in:
commit
e49de99203
@ -25,6 +25,7 @@ import java.util.concurrent.Semaphore;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
public class FDroidApp extends Application {
|
public class FDroidApp extends Application {
|
||||||
|
|
||||||
@ -43,7 +44,9 @@ public class FDroidApp extends Application {
|
|||||||
icon_path.mkdir();
|
icon_path.mkdir();
|
||||||
|
|
||||||
apps = null;
|
apps = null;
|
||||||
DB.initDB(getApplicationContext());
|
Context ctx = getApplicationContext();
|
||||||
|
DB.initDB(ctx);
|
||||||
|
UpdateService.schedule(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,8 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Schedule (or cancel schedule for) this service, according to the
|
// Schedule (or cancel schedule for) this service, according to the
|
||||||
// current preferences. Should be called a) at boot, or b) if the preference
|
// current preferences. Should be called a) at boot, b) if the preference
|
||||||
// is changed.
|
// is changed, or c) on startup, in case we get upgraded.
|
||||||
// TODO: What if we get upgraded?
|
|
||||||
public static void schedule(Context ctx) {
|
public static void schedule(Context ctx) {
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager
|
SharedPreferences prefs = PreferenceManager
|
||||||
@ -76,7 +75,11 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
|
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
|
||||||
SystemClock.elapsedRealtime() + 5000,
|
SystemClock.elapsedRealtime() + 5000,
|
||||||
AlarmManager.INTERVAL_HOUR, pending);
|
AlarmManager.INTERVAL_HOUR, pending);
|
||||||
|
Log.d("FDroid", "Update scheduler alarm set");
|
||||||
|
} else {
|
||||||
|
Log.d("FDroid", "Update scheduler alarm not set");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendStatus(int statusCode ) {
|
protected void sendStatus(int statusCode ) {
|
||||||
@ -122,11 +125,13 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long elapsed = System.currentTimeMillis() - lastUpdate;
|
long elapsed = System.currentTimeMillis() - lastUpdate;
|
||||||
if (elapsed < interval * 60 * 60) {
|
if (elapsed < interval * 60 * 60 * 1000) {
|
||||||
Log.d("FDroid", "Skipping update - done " + elapsed
|
Log.d("FDroid", "Skipping update - done " + elapsed
|
||||||
+ "ms ago, interval is " + interval + " hours");
|
+ "ms ago, interval is " + interval + " hours");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.d("FDroid", "Unscheduled (manually requested) update");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean notify = prefs.getBoolean("updateNotify", false);
|
boolean notify = prefs.getBoolean("updateNotify", false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user