1502 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
1d359f82ce actually use index added/lastUpdated dates in UTC
The date/time written to index.xml and index-v1.json should always be in
UTC format.  These formats are often in the form of just a date, e.g.
2019-04-28.  Those are then converted to UNIX seconds, which includes the
time.  In the date only case, the time is assumed to be 00:00, which will
be different per time zone.

index-v1.json is better since it mostly uses Java-style UNIX time in millis
but the dates/times are parsed then stored in the local database in the old
format yyyy-MM-dd_HH:mm:ss which will result in different UNIX times when
the device is in different time zones.

fdroid/fdroidclient#1757
2019-05-10 16:30:23 +02:00
Hans-Christoph Steiner
c0c5721f6a Normalize Repo.lastUpdated values to contain the date and time
This also converts old Repo.lastUpdated values rather than just failing.
index.xml handling used to store the Repo "Last Updated" date used to store
the value as just an ISO date (2019-04-29), then the time was added.  So if
date/time parsing fails, this falls back to trying to parse just the date.
null is returned when parsing fails, and the Latest Tab shows nothing if
the Last Updated is null.

Some related tests were also tweaked.

Hopefully:
closes fdroid/fdroidclient#1757
2019-05-10 14:13:23 +02:00
Hans-Christoph Steiner
d62c0cf723 AppDetails: use inline OnClickListeners in Android style
no need to declare variables that are used in one place.  Also, reordered
related lines a bit for clarity.
2019-05-10 14:13:23 +02:00
ioTY
67af661640 Check whether fdroidPrivileged enabled 2019-05-10 14:13:23 +02:00
Hans-Christoph Steiner
af1040443e ignore Errors and Exceptions in background services
Throwable includes Errors and Exceptions.  Fixes stacktraces like these:

java.lang.RuntimeException: An error occurred while executing doInBackground()
	at android.os.AsyncTask$3.done(AsyncTask.java:325)
	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
	at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar)
	at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107)
	at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616)
	at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:32)
	at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391)
	at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382)
	at android.os.AsyncTask$2.call(AsyncTask.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
	... 3 more
java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar)
	at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107)
	at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616)
	at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:32)
	at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391)
	at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382)
	at android.os.AsyncTask$2.call(AsyncTask.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	at java.lang.Thread.run(Thread.java:761)
2019-05-10 14:13:23 +02:00
AmirAli Akbari
f76f9357d7 IndexV1Updater: Closing JarFile on end of use. Closes issue #1382. 2019-05-10 10:34:16 +00:00
Hans-Christoph Steiner
307abc5706 Merge branch 'finalize-1.6' into 'master'
Finalize 1.6

Closes #1556

See merge request fdroid/fdroidclient!813
2019-04-09 22:16:00 +00:00
mueller-ma
1c881baa9c Color swipe to refresh indicator 2019-04-09 21:26:32 +00:00
Hans-Christoph Steiner
d2fea72ed9 always update itself last
When auto-updates are enabled, the app should update itself last, to ensure
that all of the other apps are completely updated before this app is killed
as part of the update process.

closes #1556
2019-04-09 23:17:21 +02:00
Hans-Christoph Steiner
272a0e3f27 fix crash when there is no cache when DeleteCacheService runs
java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar)
at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107)
at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616)
at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:30)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
2019-04-09 14:39:45 +02:00
Hans-Christoph Steiner
593ce5284c fix insane NPE
java.lang.NullPointerException: println needs a message
 at android.util.Log.println_native(Native Method)
 at android.util.Log.e(Log.java:232)
 at org.fdroid.fdroid.net.DownloaderService.handleIntent(DownloaderService.java:232)
 at org.fdroid.fdroid.net.DownloaderService.access$000(DownloaderService.java:88)
 at org.fdroid.fdroid.net.DownloaderService$ServiceHandler.handleMessage(DownloaderService.java:108)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:148)
 at android.os.HandlerThread.run(HandlerThread.java:61)
2019-04-09 14:39:45 +02:00
Hans-Christoph Steiner
66e909d606 standardize all Downloaders on 8k block sizes
This is needed since this affects the onProgress broadcasts, and sending
too many can peg the device's CPU.  1k was just too small.  ANd 8k works
fine for Bluetooth.

fdroid/fdroidclient#1590
2019-04-09 14:39:45 +02:00
Jonas L
94e441cc9c Improve adding repos from the clipboard
In some cases (e.g. when using Firefox Klar) and copying the URL
(of a link), then only the uri is set and not the text. This
prevented (before this commit) the autofill of the
add package source dialog in such cases.
2019-03-29 09:14:43 +00:00
Hans-Christoph Steiner
81139c40fa trigger WifiStateChangeService after user accepts location perms
Normally, WifiStateChangeService finds the SSID when F-Droid starts. But if
the user hasn't granted location permissions yet, then WifiStateChangeService
won't have been able to read the SSID yet.
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
43d3653753 create utility method for sending Toasts from Services 2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
f21e4b5931 fix crashes when parsing bad dates
java.lang.ArrayIndexOutOfBoundsException: length=13; index=42
at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:454)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2340)
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2740)
at java.util.Calendar.updateTime(Calendar.java:2589)
at java.util.Calendar.getTimeInMillis(Calendar.java:1101)
at java.util.Calendar.getTime(Calendar.java:1074)
at java.text.SimpleDateFormat.parseInternal(SimpleDateFormat.java:1518)
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1413)
at java.text.DateFormat.parse(DateFormat.java:356)
at org.fdroid.fdroid.Utils.parseDateFormat(Utils.java:577)
at org.fdroid.fdroid.Utils.parseDate(Utils.java:592)
at org.fdroid.fdroid.data.Apk.<init>(Apk.java:178)


java.lang.NumberFormatException: Not a number:
at android.icu.math.BigDecimal.bad(BigDecimal.java:3349)
at android.icu.math.BigDecimal.<init>(BigDecimal.java:526)
at android.icu.math.BigDecimal.<init>(BigDecimal.java:910)
at android.icu.text.DigitList.getBigDecimalICU(DigitList.java:278)
at android.icu.text.DecimalFormat.parse(DecimalFormat.java:2058)
at android.icu.text.DecimalFormat.parse(DecimalFormat.java:1931)
at java.text.DecimalFormat.parse(DecimalFormat.java:804)
at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:2353)
at java.text.SimpleDateFormat.parseInternal(SimpleDateFormat.java:1615)
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1528)
at java.text.DateFormat.parse(DateFormat.java:360)
at org.fdroid.fdroid.Utils.parseDateFormat(Utils.java:577)
at org.fdroid.fdroid.Utils.parseDate(Utils.java:592)
at org.fdroid.fdroid.data.App.<init>(App.java:311)
at org.fdroid.fdroid.views.whatsnew.WhatsNewAdapter.onBindViewHolder(WhatsNewAdapter.java:95)
at org.fdroid.fdroid.views.whatsnew.WhatsNewAdapter.onBindViewHolder(WhatsNewAdapter.java:19)

java.lang.ArrayIndexOutOfBoundsException: length=13; index=36
at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:454)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2411)
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2813)
at java.util.Calendar.updateTime(Calendar.java:3397)
at java.util.Calendar.getTimeInMillis(Calendar.java:1761)
at java.util.Calendar.getTime(Calendar.java:1734)
at java.text.SimpleDateFormat.parseInternal(SimpleDateFormat.java:1633)
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1528)
at java.text.DateFormat.parse(DateFormat.java:360)
at org.fdroid.fdroid.Utils.parseDateFormat(Utils.java:577)
at org.fdroid.fdroid.Utils.parseDate(Utils.java:592)
at org.fdroid.fdroid.data.App.<init>(App.java:314)
at org.fdroid.fdroid.views.updates.UpdatesAdapter.onCanUpdateLoadFinished(UpdatesAdapter.java:241)
at org.fdroid.fdroid.views.updates.UpdatesAdapter.onLoadFinished(UpdatesAdapter.java:224)
at org.fdroid.fdroid.views.updates.UpdatesAdapter.onLoadFinished(UpdatesAdapter.java:67)
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
56ddbf2056 fix crash on bad values in minSdkVersion
java.lang.NumberFormatException: For input string: "@2131034146"
at java.lang.Integer.parseInt(Integer.java:615)
at java.lang.Integer.parseInt(Integer.java:650)
at org.fdroid.fdroid.data.App.getMinTargetMaxSdkVersions(App.java:1092)
at org.fdroid.fdroid.data.App.initInstalledApk(App.java:769)
at org.fdroid.fdroid.data.App.getInstance(App.java:395)
at
org.fdroid.fdroid.localrepo.CacheSwapAppsService.onHandleIntent(CacheSwapAppsService.java:77)
at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
2019-03-29 00:11:16 +01:00
Hans-Christoph Steiner
c7c16131e9 fix OBB support for repositories
The repoId was hard-coded to 0.

fdroid/fdroidclient#1403
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
5f14628524 DownloaderService: improve debug logs for Canonical vs Download URLs 2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
edb2b838eb DownloaderService: track active using the canonical URL
This was using the actual download URL, which might change, depending on
whether a mirror was used.

closes #1727
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
0aab6bc422 standardize on EXTRA_CANONICAL_URL throughout the code base
There were a few different constants used, this unifies them all into one,
so that it is easy to track where it is used, and what it means.
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
3378c0a333 rename Canonical vs. Download URL in InstallManagerService process
AppUpdateStatusManager and InstallManagerService should be using only the
Canonical URL of the package since that is the global unique ID.  The actual
URL used to download it needs to be isolated in DownloaderService, which can
entirely manage the mirror selection process.  This is just a bunch of
renaming to make this all clearer.
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
3a5f96e0b3 DownloaderService: use canonical URL to fix progress updates
The download URL is not the unique ID, the canonical URL is.

closes #1736
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
7f22c3c221 DownloaderService: convert String to Uri to avoid repeated parsing
This parses the String into a Uri once per Intent, rather than once per
broadcast.  The Uri instance is also nicer to work with, since it is the
native URL format for Intents.

It should make the progress updates a bit more efficient also.
fdroid/fdroidclient#1742
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
288577407d move towards only using canonical URLs in InstallManagerService
Only DownloaderService really needs to know about the mirror tricks, the
rest of the process should only ever use the canonical URL to keep things
simple.
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
04298f8886 DownloaderService: only broadcast progress when it actually changes
On a slow download, this could send like 100+ updates even though no more
data had been received.

closes #1742
2019-03-28 11:41:10 +01:00
Hans-Christoph Steiner
d794c5a77c purge urlString from ProgressListener, it is unused and confusing 2019-03-28 11:41:03 +01:00
Hans-Christoph Steiner
6b0a784a26 normalize canonical URL variable names 2019-03-26 21:46:38 +01:00
Hans-Christoph Steiner
e346d2351b rename AppUpdateStatus.getUniqueKey to getCanonicalUrl
This highlights the relationship between the various things that are using
the canonical URL as the unique ID.
2019-03-26 21:46:38 +01:00
Hans-Christoph Steiner
4ea775be00 remove wrong "ERROR" description from Downloader Intend Extras
Looks like a copy-paste bug in a160476a14c40412728f4974f53d1a18f7064346
2019-03-26 21:46:38 +01:00
Hans-Christoph Steiner
a0b318c383 rename Apk.getUrl() to getCanonicalUrl() to highlight it is also an ID
This method returns the URL that points to the canonical download
source for this package.  This is also used as the unique ID for
tracking downloading, progress, and notifications throughout the
whole install process.  It is guaranteed to uniquely represent
this file since it points to a file on the file system of the
canonical webserver.
2019-03-26 21:46:38 +01:00
Hans-Christoph Steiner
19a0428944 Merge branch 'download-updates-by-default' into 'master'
Download updates by default

See merge request fdroid/fdroidclient!806
2019-03-26 20:41:25 +00:00
Hans-Christoph Steiner
51431d59ee cleanup imports 2019-03-26 21:29:13 +01:00
Hans-Christoph Steiner
496a3a2938 fix padding of top item in Latest Tab 2019-03-26 21:28:20 +01:00
mueller-ma
59fe365ed6 Remove feature graphic of first app from "Latest" view
Closes #1748
2019-03-26 18:08:38 +01:00
Hans-Christoph Steiner
e3cfe3690d set "Automatically download updates" to default true
But keep "Automatically install updates" default false for devices with
Privileged Extension.
2019-03-26 16:19:07 +01:00
Hans-Christoph Steiner
4f1855c8a1 App Details: show the app's Translation links
fdroid/fdroidserver!450

icon is:
https://material.io/tools/icons/?search=trans&icon=translate&style=baseline
2019-03-22 22:16:08 +01:00
Hans-Christoph Steiner
3862f941e6 add new criteria for apps shown in Latest tab
This adds requirements before an app is shown on the Latest tab.  It must
have all of these:

* name
* summary
* description
* license
* What's New entry
* at least some text localized

And then it must have at least one of these:

* screenshots
* feature graphic
2019-03-22 22:16:08 +01:00
Hans-Christoph Steiner
dcb1c3accd add flag to track localized apps for selecting in Latest tab 2019-03-22 22:16:08 +01:00
Hans-Christoph Steiner
765bd2892d Merge branch 'nearby-view' into 'master'
Improve nearby swap splash layout

See merge request fdroid/fdroidclient!800
2019-03-22 08:46:39 +00:00
AJ Jordan
8eea0f6c34
Mention F-Droid in index file fetch error string
The problem here is that oftentimes, the index fetch will happen
automatically in the background while the user is in a different app. If
the fetch fails, the warning text changed here is displayed as a toast,
but without this change there's no way to tell that it's coming from
F-Droid.
2019-03-21 13:18:08 -04:00
mueller-ma
05bbe94b47 Improve nearby swap splash layout
* Rename ids to something meaningful
* Remove inner layouts from constraint layout
* Use same text and button styles
* Make sure the background image doesn't overlap with the text
2019-03-17 00:04:40 +01:00
Hans-Christoph Steiner
6a18ba1b85 RepoDetails: hide mirror lists if they are not useful
e.g., empty lists or the official mirror list just repeating the canonical
URL.
2019-02-21 00:18:25 +01:00
Hans-Christoph Steiner
b1569795a2 IndexV1Updater: use LinkedHashSet to preserve mirror ordering 2019-02-21 00:18:25 +01:00
Hans-Christoph Steiner
c3ec29df93 RepoDetails: add switches to disable any or all mirrors
This also needs to handle mirror lists with 1 element, since mirrors can
now be disabled. If the user disables all mirrors, then there will be only one URL in the
list of mirrors.  Asking for a random mirror in that case should not return
null, but the one enabled mirror.


closes #1696
2019-02-20 21:10:34 +01:00
Hans-Christoph Steiner
a81a61be61 RepoDetails: convert mirror lists to have on/off switches 2019-02-20 15:59:29 +01:00
Hans-Christoph Steiner
14b4a7e00a cache all downloads based on canonical URL, not download URL
This makes the download cache be shared across all mirrors used to download
rather than having a cache per-mirror.
2019-02-20 13:39:26 +01:00
Hans-Christoph Steiner
dd14b9e315 choose random mirror for each package/APK download
This spreads downloads across all available mirrors randomly.  This could
definitely be improved, like choosing the fastest or nearest mirror, or
only .onion addresses on Tor.  This will improve the current situation and
should reduce the load on f-droid.org a lot.

fdroidclient#1696
2019-02-20 13:39:26 +01:00
Hans-Christoph Steiner
89422e9c8f clarify get mirrors method: Repo.getRandomMirror() 2019-02-20 13:39:26 +01:00
Hans-Christoph Steiner
cf9a6b851d RepoAdapter: code cleanup
Remove unused code and simplify to only present args that are used. This is
remnants from:

fdroidclient#490
fdroidclient#606
fdroidclient!295
fdroidclient!242
2019-02-20 13:39:26 +01:00