678 Commits

Author SHA1 Message Date
Peter Serwylo
c5bf2a131b Remove unused imports. 2015-11-30 18:16:11 +11:00
Peter Serwylo
8a6a62833b Alert update notification when saving details to DB. 2015-11-30 18:16:11 +11:00
Peter Serwylo
6969dcb90e Change "inserting" string to not include progress for last phase of update. 2015-11-30 18:16:11 +11:00
Peter Serwylo
90290f830a Send "inserting" message to notifications while committing temp provider.
Right now it says "50%" always, will need to think whether to ditch the
percentage completely, or to have the temp app/apk providers emit progress
events some how too.
2015-11-30 18:16:11 +11:00
Peter Serwylo
71f641860a More refactoring of AppProvider to use getTableName() instead of constant.
Although not used by the temp provider, it seemed strange having some of
the code always using the `DBHelper.TABLE_APP` and other code using
`getTableName()` where all of it could have used `getTableName()`.

Also moved commiting of the temp tables to the real tables into the
`RepoPersiter` instead of in `RepoUpdater`.
2015-11-30 18:16:10 +11:00
Peter Serwylo
b22b39ea26 Fix bug with SQL generation (missing . char) from bung rebase. 2015-11-30 18:16:10 +11:00
Peter Serwylo
ad6a8e5b4e Extracted RepoPersister class from RepoUpdater to separate security and DB logic. 2015-11-30 18:16:10 +11:00
Peter Serwylo
1d951e7689 Fixed repo updater tests. Fix to temp app/apk providers.
The repo xml handler now has a different mechanism for returning
data about the parsed xml file. This is done via a callback, rather
than storing the data in member variables. The tests now deal with
this correctly.

The update/delete operations of the TempAp[pk]Provider's didn't
work, so that has now been fixed.
2015-11-30 18:16:02 +11:00
Peter Serwylo
b34853a776 Cleanup before CR. 2015-11-30 18:14:44 +11:00
Peter Serwylo
cc0adcc5ad Save app details to temp table, then flush after update verified. 2015-11-30 18:14:44 +11:00
Peter Serwylo
9a2d390279 WIP: Do repo update database work in temp table for apks, then copy at end.
At the start of a repo update, it will create a copy of the apk table.
Throughout the update, it will query the original apk table for info.
All inserts and updates happen to the temp table. After the repo has been
verified as trusted, the original apk table is emptied, and all apks are
copied from the temp table to the real one.

I realise that the work done to query the apk table for info during the update
could happen against the temp table, but it was not neccesary to move all of
the queries that are required for this task to the temp apk provider.
2015-11-30 18:14:44 +11:00
Peter Serwylo
b989ef3ecc WIP: Stream index details to database rather than waiting until end.
Refactored repo update to stream apks from network -> jar file reader ->
xml parser -> database. No longer build up large lists of app metadata
to save. Saves memory, but is MUCH slower.

Does sig verification properly, but does it at the END of the process
and DOESN'T ROLL BACK on failure.

Quick and dirty benchmarks show an increase in time from ~25 seconds
to ~30 seconds on my Nexus 4 with Android 5.0. This doesn't seem so
bad to me, for the tradeoff that people on low end devices can actually
update now.

Also, as @eighthave pointed out, if we are able to stream the download
directly from the internet, then that time will drop to essentially
the time it takes to download the index.
2015-11-30 18:14:42 +11:00
Ruben Roy
1a54c61a50 Make progressbar in notification determinate 2015-11-27 18:43:16 +05:30
Christian Morgner
0df276eefc Remove initial HEAD request in HttpDownloader.setupConnection(), just add
credentials if present, fix checkstyle error in ManageReposActivity.
2015-11-16 21:02:39 +01:00
Christian Morgner
caabec7ef9 Reverted change in RepoProvider. 2015-11-16 13:48:08 +01:00
Christian Morgner
0c0342b12f Merge remote-tracking branch 'pserwylo/cmorgner-master' 2015-11-16 12:52:30 +01:00
Christian Morgner
e82382fe94 Modified return expression on MagageReposActivity.java. 2015-11-16 12:50:47 +01:00
Peter Serwylo
ee7761e1af CR: Replace String.isEmpty() with TextUtils.isEmpty(String).
String.isEmpty() is only supported in API v9, whereas we target
API v8 for now.
2015-11-16 18:05:37 +11:00
Peter Serwylo
0b3b32dab3 CR: Add overloaded createNewRepo method which provides default arguments.
Instead of passing in `null` each time you don't have a username/password,
this change provides those as meaningful default values in an overloaded
version of the method. This takes care of Java's lack of default argument
support.
2015-11-16 18:05:31 +11:00
Peter Serwylo
3426b3bb2d CR: Better deal with the possibility of crashes during database update.
This is for an abundance of caution. If the guard condition checks
for the presence of both username _and_ password fields, then a crash
or some sort of force close during the update (after adding username
but before password) will mean that next time the app runs, this
condition will evaluate to false and the password field will never
get added.
2015-11-16 18:05:16 +11:00
Peter Serwylo
97b60d937d CR: Apply database changes in chronological order.
As with the previous commit, there is probably not any harm doing this
in the way it was done. However it helps reason about the code if
changes are applied in the order that they were introduced. Especially
because each of them does something depending on the version of the
database at that point. With this change, you always know that at the
point that the function is run, the database version will be 51 (and
hence the structure of the database will be predictable).
2015-11-16 18:05:03 +11:00
Peter Serwylo
6957721479 CR: Leave old db update code as it was.
This may not have caused any trouble, but the principle behind the old
behaviour is that at the point that that was required, the fdroid_repo
table had that particular structure. There is a small chance that it
_may_ have some unintended consequences when upgrading clients with very
old database versions. Probably not, but may as well leave it as is.
2015-11-16 18:04:54 +11:00
Christian Morgner
34838fd0dc Added username & password fields to the REPO table, increased DB version to 52.
Extended DownloaderFactory to support optional username & password parameters.

Extended HttpDownloader to check for HTTP 401 Authorization Required status code
and send a simple HTTP Basic Authentication header with all requests.

Extended ManageReposActivity to support repositories that use HTTP Basic
Authentication, added a dialog to prompt for username and password.

Extended RepoDetailsActivity to be able to display and modify the authentication
credentials.
2015-11-15 13:04:23 +01:00
Daniel Martí
31313bc9ee Specify why the DM downloader is disabled
Closes both issues since they don't affect official builds anymore, for
as long as this is disabled.

Closes #445.
Closes #459.
2015-11-14 17:18:15 +01:00
Daniel Martí
b6e2f2d691 Remove one lone Log.d in prod code 2015-11-14 14:19:29 +01:00
Daniel Martí
9fc1aba8bc Checkstyle fix 2015-11-13 20:46:52 +01:00
Daniel Martí
14a79b5577 Remove unused parameters 2015-11-13 18:50:43 +01:00
Daniel Martí
d951ccd221 Make a few declarations final 2015-11-13 18:44:08 +01:00
Daniel Martí
682cf58aa9 Merge branch 'search-widget' into 'master'
Replace search dialog with a search widget

SearchView is the recommended way to implement search UI. See https://developer.android.com/guide/topics/search/search-dialog.html#UsingSearchWidget

The UX is still far from ideal but looks much better now.

Before and after (Gingerbred):

![gingerbred-before](/uploads/f724afaf152aeef8ff9cb3e838427d22/gingerbred-before.png)
![gingerbred-after](/uploads/da67fe57d2a55e64cce7d0cba31aa181/gingerbred-after.png)

Before and after (Lollipop):

![lollipop-before](/uploads/4a50258993a8304d984450456d07e3bb/lollipop-before.png)
![lollipop-after](/uploads/4b49b2f802eca567c6713fe653b10331/lollipop-after.png)


See merge request !168
2015-11-13 17:22:19 +00:00
Daniel Martí
7581d8443e Merge branch 'lint-unused-resources' of https://gitlab.com/relan/fdroidclient
Fix some lint warnings about unused resources

No functional changes, just cleanups.
2015-11-13 18:19:13 +01:00
Daniel Martí
04a2c4b70d Fix tests by never caching a null signature
This also keeps us from future possible NPE or null signature issues, if
we ever call getPackageSig on a PackageInfo with no signatures.
2015-11-13 11:42:47 +01:00
Christian Morgner
405e411200 Enable HttpDownloader to use URL-based HTTP Basic Authentication. 2015-11-13 09:30:08 +01:00
relan
c3fd3984b8 Remove the code related to the compact layout
Compact layout preference is gone.
2015-11-13 09:25:49 +03:00
relan
e841d63ea9 Replace search dialog with a search widget
SearchView is the recommended way to implement search UI. See
https://developer.android.com/guide/topics/search/search-dialog.html#UsingSearchWidget
2015-11-13 08:27:55 +03:00
relan
f0d72a3ec4 Remove search button from the search results activity
It violates app navigation logic.
2015-11-13 08:27:55 +03:00
relan
7fdcd706fd Split tabs layouts
Use separate layouts for the three tabs. This simplifies code and improves
maintainability.
2015-11-09 15:43:09 +03:00
relan
080527bf2e Remove ThemeableListFragment
Not sure why it was added initially but now it appears to be unneeded:
the support library does everything right and the lists are themed
properly without any hacks.
2015-11-09 15:42:52 +03:00
relan
817cac3002 Remove dead code in CanUpdateAppsFragment
Remove unused layout creation code. If needed, it can be re-added later as
an XML resource which is a much more maintainable way to define layouts.
2015-11-09 15:08:53 +03:00
Peter Serwylo
1a5bd84fad Never fallback to UIL for handling image downloads, only use for displaying.
Our `IconDownloader` extended `BaseImageDownloader` from UIL. There was an
explicit check in the F-Droid `IconDownloader` which looks for
HTTP/HTTPS/Bluetooth schemes. If it wasn't one of these, it fell back
to the base class. This was what was happening for local cached image
files. As such, when the `getInputStream(...)` method was refactored
to only use F-Droids `DownloadFactory` and not delegate to the base class,
it failed on local "file://" URLs.

This change introduces a `LocalFileDownloader` and makes the `DownloaderFactory`
aware of it.

The `BaseImageDownloader` class only provides support for the following schemes:

 * HTTP
 * HTTPS
 * File
 * Android content providers
 * Android assets
 * Android drawables

F-Droid now supports HTTP, HTTPS, and File URLs. There is not currently any
need for content proiders, assets or drawables to get icons for apps in F-Droid.
If there is a need in the future (e.g. an issue currently discusses loading
icons from installed apps if possible) then that specific `Downloader` can get
introduced to solve the problem.
2015-11-08 10:30:23 +11:00
Daniel Martí
eefbee969e Store installed app signature in cache
This means we can fetch the signatures only once instead of every time we need
them. Start by using the cache in AppDetails.
2015-11-07 13:57:34 +01:00
Daniel Martí
bb9426763c Remove <p> from comments
These are written manually and mostly don't contain HTML. Some html is
fine if you want to use links or markup, but <p> elements are just
pointless and very seldom used. Be consistent in not using them.
2015-11-07 13:25:01 +01:00
Daniel Martí
40092a07dd Don't duplicate repo info in UpdateException
The exception already contains the repo object, so don't hard-code the
address in the message string again.
2015-11-07 13:19:30 +01:00
Daniel Martí
94b30a54a6 Merge branch 'test-multi-repos' into 'master'
Added tests for multiple repositories providing same apks

Right now, multi repo support works, but is kinda funky. While fixing #324, I accidentally broke this support without realising it. So in the interests of making my approach to #324 more test driven, I've written some tests for multi repo support.

Initially I wrote tests for the actual correct, desirable behaviour. Then when it became apparant that we dont' do this, I commented those tests out (but left them there for hopefully future multi-repo work) and then added tests for the current behaviour to make sure we don't introduce regressions.

Android unit testing framework is nice for testing content providers. It is nice for testing file handling. However I really struggled to get it working with both. Had to do some interesting things with instrumentation and contexts in order to get it to work.

I'm sure Android has nice `Service` testing capabilities too. But given the trouble with instrumentation/contexts/files/providers/etc, it was easier for me to refactor the parts of `UpdateService` that I needed to test into a separate, testable class. 

See merge request !163
2015-11-07 11:45:47 +00:00
Peter Serwylo
12d5c5c7b4 Format to make checkstyle happy. Remove unused code. 2015-11-07 09:40:44 +11:00
Peter Serwylo
94410c5dbc Code formatting to pass checkStyle. 2015-11-07 08:39:23 +11:00
Peter Serwylo
3ad429aa6b Guard against null activity.
Came across this whibluetooth swap.
I think it is reasonable to guard against null activities here, because
we are likely not releasing observers correctly, and thus the observer
may receieve a notification when the activity is not attached.
2015-11-07 08:39:23 +11:00
Peter Serwylo
f388f32fcf Don't use download manager for Bluetooth downloads.
The F-Droid Bluetooth downloader must be used for these, as it is a
custom protocol and Android download manager only understands HTTP
and HTTPS.
2015-11-07 08:39:23 +11:00
Peter Serwylo
012cdce37b Make closing of Downloaders more concise.
The base `Downloader` class now wraps the `InputStream` returned by
any child classes, in order to notify the child class when that stream
is closed. This prevents each child class having to figure out a way
to be notified of this.

Also removed some dead code which was unused.
2015-11-07 08:36:17 +11:00
Peter Serwylo
0685c16efe More work on multi-repo tests, currently broken due to F-Droid being broken.
(One of) the problems with F-Droid's multiple support is that there is
a primary key on the fdroid_apk table which is a composite of:

 * id
 * vercode

Which means that two repos providing the same version means one will
update the other, rather than ending up with two different versions.

Instead, there should be some other way to differentiate apks from
different sources. Firstly, it should take into account the signing
cert. Secondly, it may taken into account the hash, because two people
could sign different apks with the same cert and then we are back at
square one.
2015-11-07 08:05:13 +11:00
Peter Serwylo
b6218c6d05 Refactored code which inserts apps into database to make testable.
Putting it in the UpdateService made it a little tricky to test, so
I moved it out to a separate class called `RepoPersister`.
2015-11-07 08:05:13 +11:00