3276 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
d07c8b5d74 convert Installer's Exception into generic InstallFailedException
AndroidNotCompatibleException is not used for anything specific right now,
and in the process of adding verification to the start of the install
process, there will be other kinds of failures. So convert that Exception
into a general usage InstallFailedException.
2016-04-13 10:40:01 -04:00
Hans-Christoph Steiner
0b8796e56f add AndroidManifest parser for reading directly from APKs
This will make our algorithm choices a lot more flexible both in terms of
the Installer process and the swap repo process.
2016-04-13 10:40:01 -04:00
Hans-Christoph Steiner
fc9459d6c5 send Downloader progress on a 100 ms timer
No need to flood receivers with progress events since they are basically
always going to the UI, and the UI will only refresh every so often.  If
the refresh rate is 50Hz, then that's every 20ms.  100ms seems to make a
smooth enough progress bar, and saves some CPU time.  This becomes more
important if there are multiple downloads happening in the background, like
if we make DownloaderService support parallel downloads from different repos
2016-04-13 10:40:01 -04:00
Hans-Christoph Steiner
5e59f812ce port everything over to new Downloader.ACTION_PROGRESS
This replaces all of the previous progress events and listeners.
2016-04-13 10:40:01 -04:00
Hans-Christoph Steiner
2e3d2c84ae eliminate Interfaces used only internal to AppDetails class
When dealing with complex lifecycles like Fragments, it is important
to expose the reliance of the Fragment on the Activity, since they
have different lifecycles.

Just cast to AppDetails instead of adding complexity with unneeded
Interfaces.  The actual instance and class will be the same with or
without the Interfaces, so it does not help with lifecycle issues.
The methods that implement the interfaces only hide the fact that they
rely on an active instance of AppDetails, which can lead to
lifecycle-related crashes.

This is a step along the way to streamlining AppDetails Activity so that it
only uses Fragments when they are beneficial.
2016-04-13 10:40:01 -04:00
Hans-Christoph Steiner
20c66a825d use IntentService style to download all APKs via a queue
DownloaderService is based on IntentService to provide queued requests that
run in a background thread via the Handler and the HandlerThread.  It began
as the IntentService code, but it could not be a subclass because the
downloading needs to be cancelable.  IntentServices cannot be canceled and
they provide no visibility into their queue.

DownloaderService then announces relevant events via LocalBroadcastManager
and Intents with custom "action" Strings.

https://gitlab.com/fdroid/fdroidclient/issues/601 #601
2016-04-13 10:40:01 -04:00
Daniel Martí
d98d59a8d3 Merge branch 'check-privileged-certificate' into 'master'
Verify apk signature of privileged extension before installation

This implements a check that the signature of the extension apk is the same as the signature of F-Droid before installing the extension apk. Related issue: https://gitlab.com/fdroid/fdroidclient/issues/437

See merge request !256
2016-04-13 11:50:54 +00:00
Dominik Schürmann
15ec420db4 Check apk signature of privileged extension against F-Droid signature before installation 2016-04-13 13:35:48 +02:00
F-Droid Translatebot
f8ef7cda39 Pull translation updates from Weblate
Translators:

ezjerry liao    Traditional Chinese
Lev Lamberov    Russian
2016-04-13 09:54:01 +01:00
Daniel Martí
5fd591bbe8 Merge branch 'more-tests-and-bug-fixes' into 'master'
More tests and bug fixes

I pulled a few commits out of the !248 saga, and added a bug fix or two.  It would be easier if this was merged before !248 

ping @mvdan @pserwylo 

See merge request !255
2016-04-11 16:48:42 +00:00
Hans-Christoph Steiner
ed09b1af2d run UpdateService at lowest priority possible
Currently, UpdateService is running at default priority, which is the same
as the UI tasks, since it is a regular IntentService.  That means it would
put a noticable load on the device when running, especially on older
devices.  This should help with that.

#563 https://gitlab.com/fdroid/fdroidclient/issues/563
2016-04-11 11:26:21 -04:00
Hans-Christoph Steiner
22e40bfee1 port all but Provider tests to JUnit4 semantics
Android recently switched from JUnit 3 to 4 for its base testing classes.
It doesn't seem to support the old JUnit3 methods with gradle and AS. So
all the tests need to be ported to JUnit4 to work again.

#607 https://gitlab.com/fdroid/fdroidclient/issues/607
2016-04-11 11:26:21 -04:00
Hans-Christoph Steiner
6b3004160f HttpDownloaderTest: delete test files only if test succeeds
This helps with debugging. And since these tests run on the JVM,
deleteOnExit() actually works.
2016-04-11 11:26:21 -04:00
Hans-Christoph Steiner
eb93a38cf5 HttpDownloader: handle SSL errors like any other download error
Since SSLHandshakeException is a subclass of IOException, and all that is
happening is rethrowing an Exception, instead pass this one through so it
will be handled by the central Downloader error handling.  That's currently
just a Toast, but it can easily be expanded in the future.
2016-04-11 11:26:21 -04:00
Hans-Christoph Steiner
b86a30d40f fix expert mode version display when maxSdkVersion is MAX_VALUE
closes #616 https://gitlab.com/fdroid/fdroidclient/issues/616
2016-04-11 11:26:21 -04:00
Hans-Christoph Steiner
c4a1295095 move Theme handling to Preferences class
This is one of the last instances of direct SharedPreferences manipulation
in the code.  Moving it to Preferences like the rest.
2016-04-11 10:38:59 -04:00
Daniel Martí
230c06d536 Bump to 0.100-alpha3 v0.100-alpha3 2016-04-08 10:27:58 +01:00
Hans-Christoph Steiner
907507d27d Merge branch 'transition-v21' into 'master'
Shared element transition for app list item v21 and above

Shared element transitions for API level v21 and above  
![JJhZVJh](/uploads/05ff326b69176e2e793cd17dca63637f/JJhZVJh.gif)

See merge request !251
2016-04-06 09:00:54 +00:00
Paresh Chouhan
cdd0848927 Shared element transition for app list item v21 and above 2016-04-05 22:45:51 +05:30
Hans-Christoph Steiner
d846e18d7f Merge branch 'fixes-and-cleanups' into 'master'
fixes and cleanups related to ongoing DownloaderService work

This includes a fix for bug that @mvdan found in the processing of `Apk.maxSdkVersion`, as well as some cleanups related to the ongoing work in !248 . Indeed a couple of these commits were pulled out of that MR.

See merge request !253
2016-04-05 15:22:59 +00:00
Hans-Christoph Steiner
35c2ef8c1c re-add SNI support to guardianproject.info repo
Apparently, it uses SNI, but does not always fail without SNI support.
2016-04-05 13:06:25 +02:00
Hans-Christoph Steiner
fd51fad73b keep the core Downloader classes pure Java for easy testing 2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
514e83e604 convert Downloader's outputFile to a read-only property
Since Downloader's outputFile variable is final, it can safely be used
as a public property variable.  This makes it simple to use in
subclasses. Making it a public final variable rather than a getter
also communicates that the value does not change since there is no
getter method that could potentially change it.

http://binkley.blogspot.com/2005/01/read-only-properties-in-java.html
2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
9d69098605 purge unused code from Installer classes 2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
0e1584f083 ignore gradle.properties
This file is generated by Android Studio whenever I'm using a proxy like
Tor.  Its not used otherwise, and should not be checked into git.
2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
70864e3479 use custom proguard config for running tests
The new Android Testing Support library stuff causes proguard to freak
out, so make proguard ignore all that stuff when running tests.
2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
fc0df0dcf4 make db maxSdkValues values use Byte.MAX_VALUE as max not 0
Having 0 mean max makes the logic confusing when maxSdkValue is used in
variable.  This sanitizes the data so that maxSdkValue is always just a
plain int value that can be used to test against.  It does this by
defaulting to Byte.MAX_VALUE (127) if it is not explicitly set. At the rate
of 24 SDK numbers in 8 years, that gives us about 24 years before we have
to think about setting it to Short.MAX_VALUE.

This fixes an issue created by e021eb5ca7e8f05dbce7c1b87833722542138302
db-version/54
2016-04-05 12:44:01 +02:00
Hans-Christoph Steiner
74713810dd Merge branch 'ci-image' into 'master'
Update to april 5th docker image

* Debian 8.4
* Now includes curl
* No longer has android-10
* build-tools 23.0.3

See merge request !254
2016-04-05 10:38:44 +00:00
Daniel Martí
53c8752444 Update to april 5th docker image
* Debian 8.4
* Now includes curl
* No longer has android-10
* build-tools 23.0.3
2016-04-05 10:43:48 +01:00
Daniel Martí
09324bbb78 One last fix after moving to gradle dir layout 2016-04-04 21:44:56 +01:00
F-Droid Translatebot
bfca096775 Pull translation updates from Weblate
Translators:

Franco                    Spanish
Jonatan                   Swedish
Mário Castanheira         Finnish
Mohamad Hasan Al Banna    Indonesian
msrn                      Finnish
2016-04-04 21:44:56 +01:00
Daniel Martí
04914d8d8b Merge branch 'gitlab-with-emulator-23' into 'master'
gitlab-ci: use android-17 emulator for `gradle connectedCheck`

The android-10 emulator does not report test failures so it is pretty useless at the moment.  After lots and lots of trying, the most recent emulator that I could get running on gitlab-ci was 17, so let's hope that turns out to be more useful.  I also had to reduce the RAM that was used, it seems that gitlab-ci does not let the docker images use much RAM.  This might be able to be improved by creating an pre-setup AVD image in the docker image used by this.

As you can see from the history, I tried lots of things to see if it is was possible to get a more recent emulator running on gitlab-ci.

See merge request !241
2016-04-04 20:28:51 +00:00
Hans-Christoph Steiner
37bca5d244 gitlab-ci: use android-17 emulator for gradle connectedCheck
The android-10 emulator does not report test failures so it is pretty
useless at the moment.  After lots and lots of trying, the most recent
emulator that I could get running on gitlab-ci was 17, so let's hope that
turns out to be more useful.  I also had to reduce the RAM that was used,
it seems that gitlab-ci does not let the docker images use much RAM.

This might be able to be improved by creating an pre-setup AVD image in the
docker image used by this.
2016-04-04 21:14:56 +02:00
Hans-Christoph Steiner
409a50fe92 gitlab-ci: upload full build logs to clbin.com
I find that the logs dumped into the gitlab-ci screens are generally
unreadable, so here, only the errors are dumped into the build log, then
the rest are uploaded to clbin, a paste bin, where the whole text can be
viewed and downloaded in a clean, raw format.
2016-04-04 21:13:44 +02:00
Hans-Christoph Steiner
ac2cfe557d Merge branch 'simplify-internal-api-and-tests' into 'master'
Add non-emulator tests and simplify internal API

A lot of the purely internal API is using constructs which are not needed for internal APIs.  The internal API can be viewed and changed by any contributor, so its better to not cover all possible future uses.  Indeed to keep the codebase simple, it should be the opposite: the app's code should reflect what is actually happening now, not what might happen in the future.

This also adds tests that run on the JVM rather than the emulator.

These commits where originally in !248 but I'm submitting them separately since !248 is too big.

See merge request !250
2016-04-04 12:28:45 +00:00
Hans-Christoph Steiner
0bf221383b make RepoUpdater's index URL a property for easy use
Since the DownloaderService's events are all based on the complete download
URLs, and RepoUpdater is where the update URLs are built, this makes the
full download URL into a read-only property of RepoUpdater so it can be
used wherever there is an instance of RepoUpdater

This is also important because having the `final` property highlights
the lifecycle of that variable: it does not change during the entire
life of a RepoUpdater Instance.
2016-04-04 13:21:18 +02:00
Hans-Christoph Steiner
8befba0522 send Downloader progress only via its DownloaderProgressListener
Instead of duplicate APIs, standardize on a single API, and use that
everywhere via the Downloader.LOCAL_ACTION_PROGRESS event that is already
wired in.
2016-04-04 13:21:18 +02:00
Hans-Christoph Steiner
ae0976d24a move HTTP Auth to HttpDownloader to make it testable
This also encapsulates the HTTP Auth stuff better so that it will be easier
to wrap it all into a event-based service.
2016-04-04 13:21:18 +02:00
Hans-Christoph Steiner
591b23b5ab Downloader.cancelDownload() instead of using external Thread logic
This is needed so that downloads can be canceled from within an
IntentService. Since the Downloader classes do not have any Thread logic in
them, they shouldn't use Thread logic within them anyway.

This also removes the unused argument to AsyncDownloader.attemptCancel().
2016-04-04 13:21:18 +02:00
Hans-Christoph Steiner
74274d21b4 move SanitizedFileTest into non-Android tests
It can run in plain java, so might as well.
2016-04-04 10:53:12 +02:00
Hans-Christoph Steiner
bc3d8a89b6 add tests of HttpDownloader 2016-04-04 10:53:12 +02:00
Daniel Martí
f033276f67 Merge branch 'apply-for-android-8' into 'master'
SharedPreferences.Editor.apply() for android 8

Turns out that `SharedPreferences.Editor.apply()` was not added until `android-9`, so this is a little trick to support `android-8` still after the changes in c3b47ecd5a380678dd2df3dc2549155429d28514

See merge request !249
2016-04-02 21:38:57 +00:00
Hans-Christoph Steiner
e021eb5ca7 standardize SDK version test methods
I just took the most common method, using the SDK int value, and applied
that throughout the code to have it consistent.
2016-04-02 22:46:41 +02:00
Hans-Christoph Steiner
610ead83d0 make version of Editor.apply() for SDK 8
This is not pretty, but its the best I could think of.

Fixes this lint error:
Call requires API level 9 (current min is 8): android.content.SharedPreferences.Editor#apply [NewApi]
2016-04-02 22:46:37 +02:00
Daniel Martí
5175eacd6d CHANGELOG: include bugfix notes from stable branch 2016-04-01 16:56:21 +01:00
Hans-Christoph Steiner
4485d7c2cb Merge branch 'random-fixes-2' into 'master'
Gradle fixes, enable PMD unusedcode rules



See merge request !246
2016-04-01 08:39:50 +00:00
Daniel Martí
fddce692db PMD: Get closer to obeying unnecessary
Don't enable it just yet, it's way too pedantic with parenthesis.
2016-03-31 21:54:11 +01:00
Daniel Martí
b4dd9c857e Get closer to obeying PMD's unused code rules 2016-03-31 21:40:33 +01:00
Daniel Martí
0e76a2e1fe Fix source directories after gradle layout switch
'src' works because we're only doing java files under that directory.
But it would be slower than needed, and in the case of PMD it would also
use the test files which wasn't intended at all.
2016-03-31 21:40:33 +01:00
Daniel Martí
52436350c6 Make Android Studio a little happier 2016-03-31 21:40:30 +01:00