Improve the automatic updates checks
The builds for each device are released more or less at the same time of the day, so check when the last build was released and schedule the next check accordingly. Also, allow multiple automatic updates check in the same day. There's no need to limit the number of checks since they are not frequent and this can affect negatively the effectiveness of the new algorithm. In addition to that, remove any pending oneshot alarm in case a subsequent check succeeds and log every new alarm. Change-Id: I4668f2e342e51d3578992eec6d8c270065d9aa21
This commit is contained in:
@@ -327,6 +327,12 @@ public class UpdatesActivity extends UpdatesListActivity {
|
||||
long millis = System.currentTimeMillis();
|
||||
preferences.edit().putLong(Constants.PREF_LAST_UPDATE_CHECK, millis).apply();
|
||||
updateLastCheckedString();
|
||||
if (json.exists() && preferences.getBoolean(Constants.PREF_AUTO_UPDATES_CHECK, true) &&
|
||||
Utils.checkForNewUpdates(json, jsonNew)) {
|
||||
UpdatesCheckReceiver.updateRepeatingUpdatesCheck(this);
|
||||
}
|
||||
// In case we set a one-shot check because of a previous failure
|
||||
UpdatesCheckReceiver.cancelUpdatesCheck(this);
|
||||
jsonNew.renameTo(json);
|
||||
} catch (IOException | JSONException e) {
|
||||
Log.e(TAG, "Could not read json", e);
|
||||
|
Reference in New Issue
Block a user