3785 Commits

Author SHA1 Message Date
Peter Serwylo
f184c97354 Don't allow download notifications to be cancelled, other than our "Cancel" action on them.
Until the notifications are reworked, this is the simplest solution.
In the near future, the notifications will likely be combined into one
more intelligent notification with better defined semantics.
2016-05-15 11:53:04 +10:00
Peter Serwylo
b2f7fbd980 Merge branch 'installer-manager-cosmetic-changes' into 'master'
Installer manager cosmetic changes

This branch as some cosmetic code changes related to the `InstallManagerService`. I have a few more that I'll be throwing in here too as I go along. By and large, it is renaming, annotating, minor refactoring. The semantics should not change at all with this change, any fixes to the `InstallManagerService` will be done through separate MRs. They are from issues listed in [this comment](https://gitlab.com/fdroid/fdroidclient/merge_requests/278#note_11762414) during my CR and testing of !278.

I realise that cosmetic changes often come with baggage because we all have slightly different ideas of what Java code should look like, but in general, I will strive to only make changes if I believe strongly that they will:
 * Improve understanding of the code (i.e. renaming, extracting methods)
 * Prevent future errors by new contributors (e.g. @NonNull/@Nullable annotations, extracting classes to encapsulate logic which requires developers to know they need to change multiple things at once)

I try not to make changes because:
 * I have a different opinion about formatting.
 * Hopefully any other unreasonable or disagreeable reason.

See merge request !282
2016-05-14 22:42:29 +00:00
Peter Serwylo
da8a142510 Fix Android Studio warnings.
Type parameters can be ommited if defined and declared in same statement.
`onStart()` is deprecated and not required, as we target APIs > 5.
`Intent.FLAG_ACTIVITY_CLEAR_TASK` is not supported on APIs < 11 but we target 8.
2016-05-15 08:33:29 +10:00
Peter Serwylo
ef75f30701 Ignore intents other than ACTION_INSTALL 2016-05-15 08:31:53 +10:00
Peter Serwylo
4f6910fca7 Rename 'startDownload' to 'initiateInstall'.
This is more apt given the change from `DownloaderService` to `InstallManagerService`.
2016-05-15 08:31:53 +10:00
Daniel Martí
f7299c6537 Merge branch 'WifiStateChangeService-fixes' into 'master'
WifiStateChangeService fixes

`WifiStateChangeService` had a number of issues, including being run often when there was no change, and being run twice at start-up.  Also, its _complete_ broadcast was being sent twice, in effect. That made for a lot of flaky behavior for the things that rely on that information, namely wifi swap.

See merge request !289
2016-05-13 11:06:18 +00:00
Hans-Christoph Steiner
5bb73999ad more javadoc about how the download URL is used as a unique ID 2016-05-13 12:52:48 +02:00
Hans-Christoph Steiner
426e03a649 switch out swap Repo instance all at once
Before, it would change fields in a final Repo instance, which means that
things could be out of sync when accessed.  Now it swaps out the old one
with a new Repo instance in one step.

The local repo variables are now declared volatile so that they are more
predictable when accessed from various threads (WifiStateChangeService,
SwapService, etc.)

askServerToSwapWithUs(NewRepoConfig) was unused, so I removed it.
2016-05-13 12:52:48 +02:00
Hans-Christoph Steiner
26d173acdc convert WifiStateChangeService to IntentService
The IntentService provides the nice incoming Intent queue.  It also runs
the Intent in a thread, so even the initial check is now in a very low
priority thread.  The queuing prevents the incoming Intents from competing.
This also simplifies the code since the lifecycle is more automatic now.
2016-05-13 12:52:48 +02:00
Hans-Christoph Steiner
7eeab77aaf in ACRA process, do not run everything in FDroidApp.onCreate()
The `android:process` statement in AndroidManifest.xml causes another
process to be created to run CrashReportActivity.  This was causing lots of
things to be started/run twice including CleanCacheService and
WifiStateChangeService.
2016-05-13 12:52:48 +02:00
Daniel Martí
9b96282cbf Bump to 0.100-alpha7 v0.100-alpha7 2016-05-12 23:12:10 +01:00
F-Droid Translatebot
c7f92d2ee6 Pull translation updates from Weblate
Translators:

Boris Timofeev           Russian
ezjerry liao             Traditional Chinese
Kristoffer Grundström    Swedish
Licaon Kter              Romanian
2016-05-12 23:06:13 +01:00
Daniel Martí
d9f1215142 Merge branch 'install-lint' into 'master'
Ignore lint for GET_UNINSTALLED_PACKAGES



See merge request !287
2016-05-12 22:04:34 +00:00
Daniel Martí
d1d0f13a41 Merge branch 'priv-stub' into 'master'
Use IPrivilegedCallback.Stub()



See merge request !288
2016-05-12 21:55:18 +00:00
Dominik Schürmann
0984a93133 Ignore lint for GET_UNINSTALLED_PACKAGES
Lint says that only GET_META_DATA and GET_SHARED_LIBRARY_FILES are allowed.
This contradicts Android's documentation where GET_UNINSTALLED_PACKAGES
is also allowed.

Fixes #605
2016-05-13 00:53:20 +03:00
Dominik Schürmann
6c84c79397 Use IPrivilegedCallback.Stub() 2016-05-13 00:44:24 +03:00
Daniel Martí
9a6e2f0c71 Merge branch 'android-n' into 'master'
Workaround for Android N2 preview bug with EXTRA_RETURN_RESULT

A workaround for the bug discussed in https://gitlab.com/fdroid/fdroidclient/issues/631
The check against N is ugly, because: https://commonsware.com/blog/2016/03/17/backwards-compatibility-n-developer-preview.html

After removing EXTRA_RETURN_RESULT for Android N, we no longer get a result back on N, so instead of a proper error handling I always assume that the installation succeeds. Better than nothing...

See merge request !286
2016-05-12 21:43:22 +00:00
Dominik Schürmann
69e2546821 Workaround for Android N2 preview bug with EXTRA_RETURN_RESULT 2016-05-13 00:20:08 +03:00
Daniel Martí
00608c1bc3 Merge branch 'master' into 'master'
swap fixes for 0.100

Here are a couple of swap fixes for the upcoming 0.100 release.

See merge request !285
2016-05-12 19:17:12 +00:00
Hans-Christoph Steiner
768b3d7688 register event receivers for SwapAppsView when Apk is available
This was crashing when coming to SwapAppsView because some of the flow
changed related to the new DownloaderService and InstallManagerService.

Also, this lazy loading is a tiny optimization that we cannot afford right
now, there are far too many lifecycle bugs with swap.
2016-05-12 19:05:26 +02:00
Hans-Christoph Steiner
cad7a9687d manage InstallManagerService queue with methods
This should hopefully make it a bit clearer how the list of active APKs is
managed.
2016-05-12 19:05:19 +02:00
Hans-Christoph Steiner
80ed1e7180 prevent crash when starting swap in Android 6.0+
This just stops the crash for now, it does not yet request the permission.
That'll be part of the big UX overhaul.

#656 https://gitlab.com/fdroid/fdroidclient/issues/656
2016-05-12 19:05:19 +02:00
Daniel Martí
e96dcd653d Merge branch 'ci-emulators' into 'master'
CI: speed up running of Android tests



See merge request !284
2016-05-12 16:47:42 +00:00
Daniel Martí
03da7366c9 CI: Don't use the confusing "build" gradle task
Be more explicit about what we're running. This also means that we wont
run the "read log here" stuff if the build failed, which didn't make any
sense. That should only be run if the unit tests fail.
2016-05-12 17:39:39 +01:00
Daniel Martí
6363e14f10 CI: Remove lock file after every task
I tried using after_script, but it seems to not be supported on
gitlab.com's public runners.
2016-05-12 15:40:48 +01:00
Daniel Martí
f02e478cc4 CI: No more need to set ADB_INSTALL_TIMEOUT
The default was bumped in the Android plugin version 2.0.0, so we are
safe now.
2016-05-12 15:40:48 +01:00
Daniel Martí
8ef32eba0c CI: Move variables to connectedCheck
AVD_SDK is only used there. And MALLOC_ARENA_MAX was added when the
android-17 emulator was added, so it should stay there.
2016-05-12 15:40:48 +01:00
Daniel Martí
7de5d4d551 Remove broken test coverage
This never worked properly with the Gitlab UI. Now it's even more broken
since we run the tests in different jobs.
2016-05-12 15:40:47 +01:00
Daniel Martí
9d79d372cd CI: Split build and connectedCheck tasks
Advantages:

* Failing unit tests don't keep the android tests from running
* CI should be overall faster as the tasks get run in parallel and the
  former `gradle` task was the longest by far

This will later simplify the multiplexing of the android tests onto
multiple emulators.
2016-05-12 15:40:47 +01:00
Daniel Martí
dc9973cdbc CI: set up android-17 emulator with the image 2016-05-12 15:10:38 +01:00
Hans-Christoph Steiner
2e04d4b82c Merge branch 'pmd-2' into 'master'
Enable a few more PMD rules

I did one last pass over https://pmd.github.io/pmd-5.4.1/pmd-java/rules/index.html and these are the only sane rules left that I could find.

So I'm pretty much done with adding PMD stuff :) Don't know if anyone feels strongly in favour of adding findbugs, but I think checkstyle+PMD is good for now.

See merge request !283
2016-05-12 12:53:56 +00:00
Daniel Martí
c432bf1ea0 PMD: Enable most empty code rules 2016-05-12 13:34:20 +01:00
Daniel Martí
65e2931fe8 PMD: Enable UnnecessaryWrapperObjectCreation 2016-05-12 13:34:20 +01:00
Daniel Martí
7a8151753b Changelog updates in preparation for 0.100 2016-05-12 11:51:17 +01:00
Peter Serwylo
9680ba1694 Merge branch 'enable-pmd-java-basic' into 'master'
Enable PMD java-basic

This is the fixes necessary to enable PMD's `java-basic` ruleset.  I think there will be a few rules in there that will largely be annoying, so we'll need to ultimately decide whether to use `// NOPMD` or just specify the rules we want from `java-basic`.

See merge request !280
2016-05-12 08:32:24 +00:00
Hans-Christoph Steiner
7fbdfaaae7 enable PMD's java-basic ruleset
* CollapsibleIfStatements is pedantic
* that one NOPMD is for debug logging, it'll go away

closes #623 https://gitlab.com/fdroid/fdroidclient/issues/623
2016-05-12 09:36:08 +02:00
Hans-Christoph Steiner
93433cff05 equals() and hashCode() should always be overridden together
This addressed the PMD error:
"Ensure you override both equals() and hashCode()"

#623 https://gitlab.com/fdroid/fdroidclient/issues/623
2016-05-12 09:25:04 +02:00
Hans-Christoph Steiner
23dad31426 make AndroidXMLDecompress a little less kludgey
#623 https://gitlab.com/fdroid/fdroidclient/issues/623
2016-05-12 09:25:04 +02:00
Hans-Christoph Steiner
103b2265ee make sure HTTP servers are able to skip the right amount
This should fix the PMD error:
"Check the value returned by the skip() method of an InputStream to see if
the requested number of bytes has been skipped."
2016-05-12 09:25:04 +02:00
Hans-Christoph Steiner
a0c20a35c3 Merge branch 'installer-manager-fixes' into 'master'
Installer manager fixes

Builds on the recently merged `InstallManagerService` to fix a few minor UX bugs:
 * Cancellation of pending downloads now removes notifications.
 * No longer shows "Downloading Downloading {AppName}" in notification, just "Downloading {AppName}"
 * If cached file is same size but corrupted, remove it and then continue with the process of downloading + installing

See merge request !281
2016-05-12 07:22:35 +00:00
Peter Serwylo
0967b79763 Remove notification correctly upon cancellation of download.
The check was set up to only cancel when the `AppDetails` for that app
was shown. This is the correct behaviour for the 'complete' event, but
not the cancel. The cancel event should always result in the relevant
notification being removed.
2016-05-12 16:54:14 +10:00
Peter Serwylo
5c4d23d2d6 Do full verification of apk before talking to installer.
If we are capable of bailing earlier rather than later, then we should. This way,
if a hash doesn't match, the file will be removed and a new download will begin,
as expected. The alternative is to let the installer catch the unmatching hashes.
By then though, it is too late to really do anything meaningfull and it becomes
more difficult to recover in a way that the user would expect.
2016-05-12 16:54:14 +10:00
Peter Serwylo
63807a688d Return app name correctly from getAppName().
Due to the earlier refactoring of `getNotificationTitle()` (or something like that)
to `getAppName()`, it was still returning `getString(downloading_apk, appName)` instead
of just the app name.
2016-05-12 16:54:14 +10:00
Peter Serwylo
7389315dfa Merge branch 'InstallManagerService' into 'master'
InstallManagerService

This provides an over-arching `Service` for managing the whole install process, from checking the cache, downloading files, handling the notification.  Ultimately, it should probably also handle starting and tracking progress of the final installation steps.

Note: this does undo some of the `Notification` handling stuff, putting it back to one notification per APK. I did that to get that part working OK for the short term, giving us time to figure out what the whole picture should look like.  I think @pserwylo has it pretty well sketched out in #592.  But I have no strong feelings about the notification stuff for 0.100, so I'm happy to shape this MR accordingly, provided its only a little work.


See merge request !278
2016-05-12 06:52:54 +00:00
Hans-Christoph Steiner
43be8f3fd1 delete temp files created by DownloaderFactory#create(Context, String) 2016-05-11 21:56:00 +02:00
Hans-Christoph Steiner
81f13279fe some tricks to get Cancel working on the download Notification
I wrestled with this a bunch, it seems quite difficult to make the Cancel
button on the notification responsive.  This collection of minor changes
made it more reliable, but its still kind of flaky.  I think the problem
might be related to the fact that it is creating a whole new Notification
instance, with the accompanying Intent and PendingIntent instances, for
every single download progress update.

closes #652 https://gitlab.com/fdroid/fdroidclient/issues/652
2016-05-11 21:56:00 +02:00
Hans-Christoph Steiner
62295b72b4 send ACTION_INTERRUPTED when APK is canceled from queue
If an APK was queued to download but had not started downloading yet, it
was not able to be fully canceled because ACTION_INTERRUPTED was not sent.
That meant that the UI never got updated, even though the APK was removed
from the queue.

#652 https://gitlab.com/fdroid/fdroidclient/issues/652
2016-05-11 21:56:00 +02:00
Hans-Christoph Steiner
78c0416c84 clear notification for app once it has been successfully installed
This logic is pretty basic for now, it'll have to be expanded a lot to
support the different UX between priv and non-priv installs.  For example,
priv updates will be able to happen entirely in the background.  Those will
then require leaving a notification to tell the user that the app was
updated so nothing can transparently install updates without the user
knowing.  When the user is an active part of each install, like the
non-priv experience requires, then keeping the "app installed" notification
feels like just extra noise.
2016-05-11 21:56:00 +02:00
Hans-Christoph Steiner
e75143530f track AppDetails visibility to improve Notification UX
If AppDetails is visible, then it'll automatically launch the install
process, and there is no need to put up a "Tap to install" notification.

And of course, whenever I search stackoverflow, I find an answer from
@commonsguy :)
https://stackoverflow.com/questions/18038399/how-to-check-if-activity-is-in-foreground-or-in-visible-background/18469643#18469643
2016-05-11 21:56:00 +02:00
Hans-Christoph Steiner
2080d77e6b temporary notification user experience to get something workable
this represents the current state of things until we can overhaul the whole
notifications and update UX as outlined in #592

https://gitlab.com/fdroid/fdroidclient/issues/592
2016-05-11 21:56:00 +02:00