281 Commits

Author SHA1 Message Date
Alexander Martinz
663c6bfba1 tests: libs: v1: add test for index-v1 signed with SHA-256
The test jar was provided by Torsten @ https://gitlab.com/fdroid/fdroidclient/-/merge_requests/1657#note_3258892087

Signed-off-by: Alexander Martinz <alex@katastima.org>
2026-04-16 22:18:37 +02:00
Alexander Martinz
61ae95f95e libs: v1: allow indices signed with SHA-256
Currently the IndexV1Verifier only allows SHA1-Digest.
Also allow indices to be signed using SHA-256-Digest to support
repositories using it.

-----

04-16 10:42:35.372 32370 32389 E RepoUpdateManager: Error updating repository http://192.168.1.50:3000/repo
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: org.fdroid.index.SigningException: Unsupported digest: SHA-256-Digest
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.v1.IndexV1Verifier.checkAttributes(IndexV1Verifier.kt:35)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.JarIndexVerifier.getStreamAndVerify(JarIndexVerifier.kt:45)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.v1.IndexV1Updater.updateRepo$lambda$4(IndexV1Updater.kt:62)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.v1.IndexV1Updater.$r8$lambda$P2XzF4413QJZBOBr6JwilkHT93g(IndexV1Updater.kt:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.v1.IndexV1Updater$$ExternalSyntheticLambda3.run(R8$$SyntheticClass:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at androidx.room.RoomDatabase.runInTransaction(RoomDatabase.kt:585)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.v1.IndexV1Updater.updateRepo(IndexV1Updater.kt:61)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.IndexUpdater.update$lambda$0(IndexUpdater.kt:63)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.IndexUpdater.$r8$lambda$NUzLiXgA9adSx93mFCWLY6GuflY(IndexUpdater.kt:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.IndexUpdater$$ExternalSyntheticLambda0.invoke(R8$$SyntheticClass:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.IndexUpdater.catchExceptions(IndexUpdater.kt:68)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.index.IndexUpdater.update(IndexUpdater.kt:62)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.RepoUpdateManager.updateRepos(RepoUpdateManager.kt:107)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.views.main.LatestViewBinder.lambda$new$0(LatestViewBinder.java:94)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.views.main.LatestViewBinder.$r8$lambda$6N6Nu2ia8Nb5Yj4UytWsESKNpgk(LatestViewBinder.java:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.views.main.LatestViewBinder$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.Utils.lambda$runOffUiThread$5(Utils.java:840)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.Utils.$r8$lambda$RTQXMghUr-8Q0IH1zJ5oQCPUbNc(Utils.java:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at org.fdroid.fdroid.Utils$$ExternalSyntheticLambda7.call(R8$$SyntheticClass:0)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:43)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4855)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:644)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:80)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:71)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at java.util.concurrent.FutureTask.run(FutureTask.java:317)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:348)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1154)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:652)
04-16 10:42:35.372 32370 32389 E RepoUpdateManager: 	at java.lang.Thread.run(Thread.java:1564)

-----

Signed-off-by: Alexander Martinz <alex@katastima.org>
2026-04-16 22:18:37 +02:00
Torsten Grote
6822186b8b [db] only add added repo to list, if not already there 2026-04-13 13:41:05 -03:00
Torsten Grote
61d8c21374 Disable HttpManagerIntegrationTest
because it fails on SDK 24 CI because of letsencrypt certs or cloudflare forced compression
2026-04-10 17:52:50 -03:00
Torsten Grote
87a50ff32d Remove cloudflare mirror from CI tests as this is flaky 2026-04-10 15:07:10 -03:00
Torsten Grote
5d32a4d5d4 [db] More fixes to RepoAdder
as it was still possible to add the same repo twice
2026-04-09 11:28:48 -03:00
Torsten Grote
faf908466c Fix formatting after ktfmt update 2026-04-03 13:21:16 -03:00
Torsten Grote
8535a89bfc [db] add file to PackageVersion 2026-04-03 13:21:13 -03:00
Torsten Grote
ac4de23691 [index] add file to PackageVersion 2026-04-03 13:21:12 -03:00
Matthew Bogner
1c9570575f Support for dnsA/dnsAAAA data added to v2 index 2026-04-02 13:11:58 +00:00
Torsten Grote
34b3fa31f4 [db] fix diff bug where zero-whitespace gets added more than once
This bug only affects CJK languages and apart from DB growth, the symptom is that word filtering in app lists doesn't find affected apps because we look for a single whitespace between tokens
2026-03-26 14:38:56 -03:00
Torsten Grote
fa2ef709cf [db] Deprecate usage of localization cache for name and summary 2026-03-26 14:38:56 -03:00
Torsten Grote
42314c8377 [db] Add SearchQueryRewriter and use it in AppSearchItemsTest
This code comes from SearchManager, but making it available in the DB library makes sense since the queries are specific to the DB implementation such as zero-whitespace hack.
2026-03-26 14:38:55 -03:00
Torsten Grote
757ac543b3 [db] Add search test: AppSearchItemsTest
the test tries to ensure that queries in various languages provide results within some limited test data
2026-03-26 14:38:55 -03:00
Torsten Grote
c88b47a494 [db] Move migration tests into their own package
as it got kinda crowded in the database package
2026-03-26 14:38:55 -03:00
Torsten Grote
13a3b313db [db] add a method for repairing Fts table, if corrupted
this is a bit hacky, but there seems to be very little information about this specific bug which affected several installs and either degraded search result quality or broke search completely.

In absence of a better fix or even a way to reproduce the issue, we are resorting to this.
2026-03-26 14:38:53 -03:00
Torsten Grote
853382a8b2 [db] list of repos in RepoManager is null until they have loaded
Otherwise, we can't differentiate between not having repos. This difference is important when a DB migration delays initial loading of repos.
2026-03-26 14:38:52 -03:00
Torsten Grote
6d7b10be86 Some fixes for TimingDatabase logging 2026-03-26 14:38:48 -03:00
Peter Serwylo
ba87e2e8ba DB Performance fixes focussing on App Details screen.
Added indexes based on slow query logs and associated `EXPLAIN QUERY
PLAN` output.

Note: There are some composite primary keys with `repoId` +
`packageName` + ..., and we still ad an index on `packageName`.
This is because the order matters in composite keys. It might
be possible to restructure the primary key to be `packageName` +
`repoId` + ..., however this requires removing the table and
recreating it which is more complex then just adding an index on
`packageIndex` in addition to the primary key. There is also no
guarantee that things wont slow down when restructuring the primary key,
because there may be some cases where it is important that `repoId` is
first in that index.
2026-03-26 14:38:48 -03:00
Peter Serwylo
262d322dc5 Instrument db to monitor slow queries and log explain statements.
Only enabled in debug mode. When auditing performance, make sure
to tune the parameters to the open helper. By default it will log
and explain queries that take more than 2s.
2026-03-26 14:38:45 -03:00
Torsten Grote
69ac6a88a8 Improve readability of DbAppChecker and add tests 2026-03-06 17:39:32 -03:00
Torsten Grote
85c247608e Fix multi-platform issue with custom DNS 2026-03-06 17:39:31 -03:00
Torsten Grote
2d7e94c7a5 Migrate to AGP9
fixes multi-platform JVM builds
2026-03-06 17:39:31 -03:00
Torsten Grote
7ac0714b40 Migrate to com.android.kotlin.multiplatform.library plugin
because it will be required in AGP9
2026-03-06 17:39:31 -03:00
Torsten Grote
81a04d078e [db] Fix detection of new apps
Sometimes the added and the lastUpdated timestamp are some seconds apart, so we can't expect them to be equal for new apps. We simply treat everything as new that was added in the last 14 days.
2026-03-06 17:39:30 -03:00
Torsten Grote
36f70ba9af Reformat XML files 2026-02-26 17:12:13 -03:00
Torsten Grote
cdf58c6ffb Auto-format all files with ktfmt 2026-02-26 17:12:13 -03:00
Torsten Grote
f6cb2dc235 [db] add method for retrieving anti-features
so the UI can use them for filtering app lists
2026-02-25 16:17:25 -03:00
Matthew Bogner
206ffbb26f DNS cache feature 2.0 refactor + fix 2026-02-21 21:30:09 +00:00
Torsten Grote
738adc7a80 [db] only flag compatible updates in other repos if older than a week 2026-02-05 12:09:55 -03:00
Torsten Grote
a9f5e325fe Show issue for apps we had installed with different signer 2026-01-26 15:17:05 -03:00
Torsten Grote
c1efc6f6f1 Don't show issue for apps with incompatible signer installed by other stores
The other store is likely to provide updates and this is a common use case with Aurora or Google Play, so people get flagged false positives.
2026-01-26 14:33:20 -03:00
Torsten Grote
9f3a615b5a [db] add missing API surface 2026-01-05 17:24:10 -03:00
Torsten Grote
c0f90bf0b6 [db] don't progress report total bytes for entry.jar download
because we'll download another file afterwards and progress reporting would jump to 100% two times. Also entry.jar is really small, so downloading that is fast and doesn't benefit from detailed progress reporting anyway.
2026-01-05 17:24:10 -03:00
Torsten Grote
dea8a2e504 [db] track and clear repo update errors
Historically, we've just shown a giant Toast for repo update errors, now we track them in the DB, so we can properly expose them in the UI.
2026-01-05 17:24:10 -03:00
Torsten Grote
f81060859d [db] Migration to version 10
adds a couple of fields we wanted for some time:
* isPrimary for mirrors
* repo errors
* app labels for pre-approved installs
2026-01-05 17:24:10 -03:00
Torsten Grote
29e2d15386 [db] Update repositoriesState atomically in RepoManager
Otherwise, concurrency issues may cause a broken state such as the same repo being in the list two times.
2025-12-29 11:23:59 -03:00
Torsten Grote
41653a80a0 [db] add a way to get apps for a list of package names
this will be used to get the apps most downloaded
2025-12-29 11:23:59 -03:00
Torsten Grote
8b4e42935e [db] Add new DbAppChecker which finds updates and apps with issues
This is similar to DbUpdateChecker which only finds updates.
2025-12-29 11:23:59 -03:00
Torsten Grote
88f817e5ca [db] allow providing PackageInfo maps to avoid hammering PackageManager
The app may maintain PackageInfo for apps already, so there's no need to keep asking the system for it. We could instead just work with what we already have.

Also, we discovered that chunking the package names isn't needed for newer Android versions. This is only relevant for whom has more than 999 apps installed.
2025-12-29 11:23:59 -03:00
Ray c
a4ffd9c535 Resurrect from my 'Elvis' falls' in getBestLocale
Apparently Elvis' got style
2025-11-05 07:10:57 +00:00
Torsten Grote
07b56f0516 Upgrade Dokka syntax to v2 2025-11-04 08:50:56 -03:00
Torsten Grote
5a04b315d5 Upgrade maven publishing plugin 2025-11-04 08:50:56 -03:00
Torsten Grote
1e4c9f39ed Enable Binary compatibility validation
which is still experimental, but allows us to sport API breakage in CI. It still doesn't produce anything for the database lib.
2025-11-04 08:50:55 -03:00
Torsten Grote
911b337db7 Untangle libraries slightly by creating a common core library 2025-11-04 08:50:55 -03:00
Torsten Grote
ba7731af6c Migrate build scripts from Groovy to Kotlin 2025-11-04 08:50:55 -03:00
Torsten Grote
cc2010ff63 [db] Increase concurrency delay for RepoAdderTest
still a hack, but synchronizing the coroutines doesn't seem trivial
2025-11-04 08:50:54 -03:00
Torsten Grote
800d5bfe85 [db] Fix bug where repos/mirrors could be added twice
This could happen when tapping a button quickly two times in the UI. While we had provisions to ensure proper states, these didn't work, because a parallel fetching job would mess with our state allowing the adding code to run more than once.
2025-11-04 08:50:54 -03:00
Torsten Grote
77d8127015 [db] Don't cancel index fetching after enabling archive
This can cause other exceptions (e.g. in json parsing) which prevent repo from getting added properly.

Also, when updating the archive for the first time, we can now re-use the downloaded index.
2025-11-04 08:50:54 -03:00
Torsten Grote
4ad356249a [db] Fix UI update when deleting repo 2025-11-04 08:50:54 -03:00