Commit Graph

7764 Commits

Author SHA1 Message Date
Torsten Grote
dfd8eb178f [db] improve loading of versions
faster permission loading and more tests
2022-07-21 16:55:58 -03:00
Torsten Grote
a47ab38533 [db] Run tests also locally with roboelectric
This is much faster and doesn't require a device. However, the test should also continue to run on-device as this is the sqlite version used in practice.
2022-07-21 16:55:58 -03:00
Torsten Grote
1fd3205f84 [db] Implement interfaces from index library
so we can use UpdateChecker and CompatibilityChecker with our DB classes
2022-07-21 16:49:25 -03:00
Torsten Grote
663f7fd305 [db] Add IndexV2Updater and RepoUpdater
The IndexV2Updater fetches the new entry.jar, verifies it and then either processes a diff or the full index.

The RepoUpdater is a convenience class that encapsulates updating repos with potentially more than one format. It tries v2 first (in case the repo has upgraded) and falls back to v1 if the repo isn't known to support v2 already (downgrade protection).
2022-07-21 16:49:25 -03:00
Torsten Grote
8236f48b38 [db] Implement diffing via DbV2DiffStreamReceiver 2022-07-21 16:49:24 -03:00
Torsten Grote
56af97990e [db] make repo icon and name localizable
One of those last minute requests for changing index structure...

We don't bother with making a new table for localizable repo icons. They just get serialized into the DB. If we ever need to update the structure, we can consider wiping the icons. They can get updated with a full index update.
2022-07-21 16:49:24 -03:00
Torsten Grote
3c8cc6c9d8 [db] use prefix and postfix when serializing lists of strings into the DB
This makes for safer LIKE queries
2022-07-21 16:49:24 -03:00
Torsten Grote
0f1d0e03dc [db] remove grouping of author and donation fields
at the explicit request of Hans who feels strongly about it.
2022-07-21 16:49:24 -03:00
Torsten Grote
03ba42bbc1 [db] Add webBaseUrl to Repository
and test another auto-migration with it
2022-07-21 16:49:24 -03:00
Torsten Grote
0a2075b51e [db] allow clearing all repos
used for panic responder in F-Droid
2022-07-21 16:49:24 -03:00
Torsten Grote
7fbb08de1b [db] explicitly clear repo data before updating with full index
In JSON, keys can come in any order, so we need to handle the case that we receive packages before the repo metadata. Now we explicitly clear data and rename the insert method to insertOrReplace in order to make it clear that data gets replaced.

Also, we pass the repoId into the constructor of the DB stream receivers to make clear that one receiver is meant to receive a single pre-existing repo.
2022-07-21 16:49:23 -03:00
Torsten Grote
8d60009e49 [db] Add app preferences and let UpdateChecker use them 2022-07-21 16:49:23 -03:00
Torsten Grote
69673475cc [db] Let UpdateChecker also check for known vulnerabilities 2022-07-21 16:49:23 -03:00
Torsten Grote
89a2a50f7c [db] store localized name and summary in DB
otherwise we can't really sort *all* apps by name in an efficient manner
2022-07-21 16:49:23 -03:00
Torsten Grote
8f132fc6d0 [db] Enable strict API mode and ktlint for database library 2022-07-21 16:49:23 -03:00
Torsten Grote
5ab385ac57 [db] Store repo version in DB 2022-07-21 16:49:23 -03:00
Torsten Grote
1a73527c1e Use sharedTest sourceSet from index library instead own TestUtils 2022-07-21 16:49:22 -03:00
Torsten Grote
772cdb170f [db] Calculate app compatibility in DB
and remove feature version as it app can't even use that.

Compatibility checking has been added to the DB layer as a post-processing step only because the UI wants to query for that on the app level (which would need all APKs).
2022-07-21 16:49:22 -03:00
Torsten Grote
1cfa06d6b5 [db] Add special queries for AppListItems 2022-07-21 16:49:22 -03:00
Torsten Grote
0fd4eb9c0c [db] Add UpdateChecker
Doing the actual update check is more work than it would be with keeping info about all installed apps in the DB. However, this way, we don't need to keep that info in sync with reality. Also, we need to check for updates only after updating repos, so there we are on a worker thread already anyway and an spare an extra second.
2022-07-21 16:49:22 -03:00
Torsten Grote
6f79b4dc17 [db] Allow pre-populating the database via onCreate callback
Also add more methods for managing repos and improve selecting apps from repos
2022-07-21 16:49:22 -03:00
Torsten Grote
81ab1b56f2 [db] Add a method for getting an app without specifying the repoId 2022-07-21 16:49:22 -03:00
Torsten Grote
0627d3276a [db] Add repo preferences as separate table
and use it in IndexV1Updater
2022-07-21 16:49:21 -03:00
Torsten Grote
3d69c13228 [db] Prepare DB for use by UI
Add AppOverviewItem and certificates for repos
2022-07-21 16:49:21 -03:00
Torsten Grote
b1f1d031f7 [db] Add simple IndexV1Updater (not in final form)
just to be able to get a real DB into the app for further testing
2022-07-21 16:49:21 -03:00
Torsten Grote
9d696e01cb [db] Add support for apps and streaming 2022-07-21 16:49:21 -03:00
Torsten Grote
75a6267cec [db] First prototype 2022-07-21 16:49:21 -03:00
Torsten Grote
cb717bc305 [download] Add docs for special exceptions
These are needed, so callers of the downloader can react to special errors.

Also signal that getInputStream() can throw NotFoundException for repo version fallback.
2022-07-21 16:49:20 -03:00
Torsten Grote
4846154b78 [download] Add new download method for v2 index
that receives total file size and ensures that the downloaded file has the provided sha256 hash
2022-07-21 16:49:20 -03:00
Torsten Grote
702d8f92cc [index] rename packageId to packageName
as this seems to be the more established term
2022-07-20 10:37:25 -03:00
Torsten Grote
d63c09a91e [index] Rename IndexV2Verifier to EntryVerifier at the insistence of Hans 2022-07-17 15:57:15 -03:00
Torsten Grote
59625d446e [index] Add more tests for error cases 2022-07-17 15:57:14 -03:00
Torsten Grote
8b2d96dc1b [index] Add LocaleChooser with getBestLocale() method and test
This is for getting the best matching localized content.
2022-07-17 15:57:14 -03:00
Torsten Grote
bb6238406d [index] fix screenshot sorting for tests 2022-07-17 15:57:14 -03:00
Torsten Grote
a4d378171d [index] make v1.OldIndexException public
and remember if the timestamp was the same, so we can treat this as the repo hasn't changed hen updating.
2022-07-17 15:57:14 -03:00
Torsten Grote
688a5f98b3 [index] allow passing versionCode into test data generation 2022-07-17 15:57:14 -03:00
Torsten Grote
632833a3e7 [index] Add UpdateChecker with tests
Also introduce interfaces for important classes, so they can be implemented by stuff like database classes as well. This makes UpdateChecker and CompatibilityChecker more generic.

Also add tests for CompatibilityChecker.
2022-07-17 15:57:14 -03:00
Torsten Grote
17acd0d56f [index] add methods to walk over all files in the index v2 2022-07-17 15:57:13 -03:00
Torsten Grote
6c3184abd9 [index] Add IndexV1Creator for Android
This also can serve as a base for an IndexV2Creator later.
2022-07-17 15:57:13 -03:00
Torsten Grote
9b947f7052 [index] Add README and LICENSE 2022-07-17 15:57:13 -03:00
Torsten Grote
fcd180dd3b [index] Let proguard keep serializer() methods 2022-07-17 15:57:13 -03:00
Torsten Grote
4cea518bfa [index] Reject old v1 indexes 2022-07-17 15:57:13 -03:00
Torsten Grote
795c579111 [index] Add maven-publish plugin for publishing to maven central 2022-07-17 15:57:13 -03:00
Torsten Grote
d2d8b4ee9f [index] Add dokka for creating HTML library docs 2022-07-17 15:57:12 -03:00
Torsten Grote
f9ea53bbe1 [index] Add an IndexV2Verifier
that shares most code with IndexV1Verifier using a common sub-class. The only difference are the json file name and which digests will be accepted.
2022-07-17 15:57:12 -03:00
Torsten Grote
469e17b613 [index] implement diffing for V2 via IndexV2DiffStreamProcessor
This uses hacky reflection and doesn't properly diff everything it could, but just what we need for the DB

This commit also sneaks in some last minute change requests for the indexV2 structure
2022-07-17 15:57:12 -03:00
Torsten Grote
78bcda2d7d [index] remove grouping of author and donation fields
at the explicit request of Hans who feels strongly about it.
2022-07-17 15:57:12 -03:00
Torsten Grote
d6ce02c922 [index] Add proper test data and clean up some things for tests 2022-07-17 15:57:12 -03:00
Torsten Grote
1195ee0547 [index] Add CompatibilityChecker for determining if app is compatible with current device 2022-07-17 15:57:12 -03:00
Torsten Grote
a64f1a48ef [index] Implement verification for Index V1 2022-07-17 15:57:11 -03:00