The new JobScheduler API can opportunitistically run a job based on whether
there is good internet, connected to power, etc. This is very useful for
running updates. Ideally, updates would always happen in the background
while on unmetered internet and connected to power.
#588
Each time the device connects to a wifi network, this waits for 2 minutes,
then if the wifi is still connected, it re-schedules the index update to
happen now. The goal is to favor unmetered networks as much as possible
when downloading the index and any automatic app updates.
This is only needed on older platforms, JobScheduler handles this for us on
android-21+
This changes the flow of the update triggering so that any Intent sent to
UpdateService can potentially trigger an update, depending only on the
state of the internet and the "Only on WiFi" preference. Instead of having
a timer that checks every hour to see if it is time to run the update, just
let AlarmManager send a trigger Intent based on the timing in the
"Update Interval" setting.
The update schedule is reset each time F-Droid restarts, and also each time
the user returns from the settings, so if AlarmManager fails us in the time
being, the updates will be rescheduled next time F-Droid is restarted, the
device is rebooted, etc.
refs #662
Some devices send multiple copies of given events, like a Moto G often
sends three {@code CONNECTED} events. So they have to be debounced to
keep the {@link #BROADCAST} useful.
For now, swap repos are only trusted as long as swapping is active. They
should have a long lived trust based on the signing key, but that requires
that the repos are stored in the database by fingerprint, not by URL
address.
#295#703
For mirroring to work on multiple repos, this must be stored and used per-
repo. The timeout and number of tries seem fine to keep global to reduce
the total amount of mirror churn when this logic is searching.
Apps that are built as part of the ROM and signed by the platform keys
should very rarely be swapped. This removes them from the default
list by comparing the signing keys.
This filter is deliberately only included on the list function and not on
the search function. If people want to share system apps, they'll be able
to find them with the search function, but the system apps won't show up
by default.
https://source.android.com/devices/tech/ota/sign_builds#certificates-keyscloses#440
This should make swap remember if Bluetooth/WiFi was disabled when swapping
started, then automatically disable it when swapping is done. This also
makes swapping remember the swap "visibility" that the user set, and restore
that when the user starts swapping again. There are logic bugs elsewhere
in the whole thing that prevent this from always working, but the state
should be set and stored properly.
If F-Droid gets killed during the install/update process, then the install
procedure would keep getting readded and redownloaded since it is a sticky
Intent. The test is very specific so that this does not block things like
installing updates with the same versionCode, which happens sometimes, and
is allowed by Android.
#1271
The "Only on WiFi" pref originally only controlled index updates, but now
it makes sense to include all of the various files that are downloaded.
#1381
The standard pattern is to pass a Context in rather than call things like
getPackageManager in. It should only pass a PackageManager if that is
actually being reused.
This shouldn't change the logic at all.
The permissions from uses-permission and uses-permission-sdk-23 should be
combined into a single list of permissions that are being requested for the
current SDK version. The previous code was overwriting one or the other,
based on the order that Jackson happen to call setRequestedPermissions().
closes#1139#890#1394
admin#65
This completes the work started in 195aaae7e52dc1c47741965904ed17bdc816a71c
closes#1395closes#1400
# Conflicts:
# app/src/main/java/org/fdroid/fdroid/UpdateService.java
In order to save disk space and memory, at a cost of some CPU time,
this makes sure that all downloaded images are not bigger than the
device can support. A nice side effect of this process is that EXIF
information is stripped from JPEG files since they are read into a
Bitmap, then written out as a PNG. This should complete the JPEG EXIF
stripping started in 2a3aaacf2347679f30e2c8feffb92f25bb882c8b with
considerExifParams(false)
!653