2822 Commits

Author SHA1 Message Date
Peter Serwylo
e72ba25fe5 Call stopService to ensure notification goes away. Always show download notifications.
Addresses a bug found in MR !273 whereby removing `stopForeground` results
in a persistent "Downloading ..." notification even though it was cancelled.

In the process of doing this, it also addresses / Fixes #621 by ensuring
that all downloads of apks are done in a foreground service, regardless
of the preference used for foreground updater service updating.
2016-05-11 13:18:18 +02:00
Hans-Christoph Steiner
c66b6c52b7 fix bug with enabling NetCipher on the wrong domains breaks SNI
I messed this up in f2621dcb558b12a4430b6301b4af4a824d57eb6d

fixes #629 https://gitlab.com/fdroid/fdroidclient/issues/629
2016-05-10 16:14:49 +02:00
Hans-Christoph Steiner
d73dac73ad delete DownloaderServiceTest stub, it is now crashing
DownloaderServiceTest is just a stub of a test that doesn't really test
anything yet.  It is now causing a NullPointerException, so its a problem:

 java.lang.NullPointerException
 	at org.fdroid.fdroid.net.DownloaderService.notifyDownloadComplete(DownloaderService.java:313)
 	at org.fdroid.fdroid.net.DownloaderService.handleIntent(DownloaderService.java:287)
 	at org.fdroid.fdroid.net.DownloaderService$ServiceHandler.handleMessage(DownloaderService.java:104)
 	at android.os.Handler.dispatchMessage(Handler.java:99)
 	at android.os.Looper.loop(Looper.java:137)
 	at android.os.HandlerThread.run(HandlerThread.java:60)
2016-05-10 15:38:27 +02:00
Hans-Christoph Steiner
0214e9e447 remove pointless method: DownloaderService.getPackageNameFromIntent()
This method provides the exact same results as the underlying method it
uses, intent.getStringExtra()

This was added in 0163d6efa6013181c2e6554760e5fa6e67a6daf9
2016-05-10 15:38:27 +02:00
Hans-Christoph Steiner
44b703a7d2 replace QUEUE_WHATS hack with urlString.hashCode() as ID
There is already a method for reproducibly generating an int based on
a the contents of a String, thanks to @pserwylo for finding it! So
urlString.hashCode() is used as the ID for Notifications and the
DownloaderService queue (msg.what).  This entirely replaces the
QUEUE_WHATS hack.  Both requestCode and msg.what just need to be
unique int, and that value can always be generated by the urlString.

This also fixes a bug preventing removing correct URL from Downloader queue.
b66810944fec802aa119c0e5ec8b7875930a2c22 made a change that breaks removing
the correct item from the queue. The `what` value must be fetched based on
urlString and fed to serviceHandler.removeMessages(what). The commit made
it use the `what` value from the last item that was queued. Those will
often be different things.

This also removes all stopForeground(true) calls except for the one in
onDestroy().  The nature of an IntentService, which DownloaderService
is basically a copy of, is to quit running once it is no longer
processing Intents.  That is also the time to remove the notification.
2016-05-10 15:38:27 +02:00
Hans-Christoph Steiner
18b3a05806 always cancel APK download progress reports
Before, these were not being reliably canceled before the final COMPLETE or
INTERRUPTED notification went out.  This moves closing the progress Timer
to a finally block after the Timer is setup, which should hopefully
guarantee the progress reports are always stopped.

This prevents any more progress reports from being sent, in case there is
one pending anywhere. downloaderProgressListener needs to be volatile to
ensure that the two threads are seeing the same values.

This was an omission on my part when putting together the DownloaderService
in !248
2016-05-10 15:38:27 +02:00
Hans-Christoph Steiner
3ee64b1bc0 fold DownloadCompleteService into DownloaderService
Having the notification as its own Service is overkill and really only
serves to increase complexity.  The notification stuff should not take much
time or resources at all.
2016-05-10 15:38:27 +02:00
Hans-Christoph Steiner
d6ed2a5e8a simplify downloadUninterruptedTests to improve reliability
Test downloads with actual files, not dynamically generated things.

Testing with the progress reports is really hard with multiple URLs, so
just test progress with a single URL for now, and multiple URLs can still
be tested without the progress check.

fixes #650 https://gitlab.com/fdroid/fdroidclient/issues/650
2016-05-09 20:00:28 +02:00
F-Droid Translatebot
aaf5bfe1db Pull translation updates from Weblate
Translators:

Adrià García-Alzórriz  Catalan
Oliver Zehm            German
Tobias Bannert         German
2016-05-09 11:14:58 +01:00
Daniel Martí
5f6762f543 Remove some dead code found by Studio 2016-05-07 23:14:20 +01:00
Daniel Martí
98130de4ae Apply a few weaker access suggestions from Studio 2016-05-07 23:14:20 +01:00
Daniel Martí
0baf443b63 Remove now unused cache_downloaded_on string
We now use a list of time durations to keep the files for.
2016-05-07 23:14:20 +01:00
Daniel Martí
d847f2caef AppDetails: Also check null View in header
Mirror the check already being done in the other fragment. As reported
via ACRA:

	ANDROID_VERSION=4.4.4
	APP_VERSION_NAME=0.100-alpha6
	STACK_TRACE=java.lang.NullPointerException
		at org.fdroid.fdroid.AppDetails$AppDetailsHeaderFragment.updateViews(AppDetails.java:1524)
		at org.fdroid.fdroid.AppDetails$AppDetailsHeaderFragment.updateViews(AppDetails.java:1519)
		at org.fdroid.fdroid.AppDetails.refreshHeader(AppDetails.java:624)
		at org.fdroid.fdroid.AppDetails.onAppChanged(AppDetails.java:549)
		at org.fdroid.fdroid.AppDetails.access$000(AppDetails.java:100)
		at org.fdroid.fdroid.AppDetails$AppObserver.onChange(AppDetails.java:141)
		at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:180)
		at android.os.Handler.handleCallback(Handler.java:733)
		at android.os.Handler.dispatchMessage(Handler.java:95)
		at android.os.Looper.loop(Looper.java:136)
		at android.app.ActivityThread.main(ActivityThread.java:5146)
		at java.lang.reflect.Method.invokeNative(Native Method)
		at java.lang.reflect.Method.invoke(Method.java:515)
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
		at dalvik.system.NativeStart.main(Native Method)
2016-05-07 22:38:33 +01:00
Daniel Martí
1a94c46e87 Fix NPE crash when clearing files in a directory
This was very probably introduced with the new CleanCacheService stuff.
Reported via ACRA:

	ANDROID_VERSION=6.0.1
	APP_VERSION_NAME=0.100-alpha6
	STACK_TRACE=java.lang.NullPointerException: Attempt to get length of null array
		at org.fdroid.fdroid.Utils.clearOldFiles(Utils.java:349)
		at org.fdroid.fdroid.Utils.clearOldFiles(Utils.java:351)
		at org.fdroid.fdroid.Utils.clearOldFiles(Utils.java:351)
		at org.fdroid.fdroid.CleanCacheService.onHandleIntent(CleanCacheService.java:54)
		at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
		at android.os.Handler.dispatchMessage(Handler.java:102)
		at android.os.Looper.loop(Looper.java:148)
		at android.os.HandlerThread.run(HandlerThread.java:61)

There is nothing to clear if the directory could not be obtained for
some reason, so this seems like a reasonable fix. Anything is better
than a crash anyway.
2016-05-07 22:30:31 +01:00
Daniel Martí
a9c73dd278 Avoid NPE in getNotificationTitle
See the following crash reported via ACRA:

	java.lang.NullPointerException
	    at org.fdroid.fdroid.net.DownloaderService.getNotificationTitle(DownloaderService.java:188)
	    at org.fdroid.fdroid.net.DownloaderService.createNotification(DownloaderService.java:167)
	    at org.fdroid.fdroid.net.DownloaderService.handleIntent(DownloaderService.java:274)
	    at org.fdroid.fdroid.net.DownloaderService$ServiceHandler.handleMessage(DownloaderService.java:107)
	    at android.os.Handler.dispatchMessage(Handler.java:102)
	    at android.os.Looper.loop(Looper.java:136)
	    at android.os.HandlerThread.run(HandlerThread.java:61)

I'm not sure what the source of the null App was (could be that we
couldn't access the DB for some reason, or perhaps that somehow the app
wasn't in it anymore). In any case, it doesn't hurt to double check
here.

If the app is null, simply fall back to the title without the app name.
2016-05-07 21:28:06 +01:00
Daniel Martí
1192468015 Do not ellipsize description on Android 2.X
For some reason, even when showing the entire description some words at
the end of lines and paragraphs still get cut off. This results in
little parts of the description being completely inaccessible.

Ellipsizing is just cosmetic, so ditch it on 2.X altogether. I tested
and proved that this fixes the issue with an android-10 x86 emulator,
after reproducing the bug.

Keep the ellipsizing on newer versions, as it doesn't misbehave on
those.

Fixes #510.
2016-05-07 21:28:06 +01:00
Daniel Martí
6ce94a22d3 Never suppress UnusedDeclaration on TAG fields
Remove the ones that weren't used at all. They can be added back if
they're ever actually used. Moreover, one of them was even named
incorrectly.
2016-05-07 21:28:06 +01:00
Daniel Martí
78af79cd4f checkstyle: enable OneTopLevelClass
The only remaining error was ClipboardCompat, which was unnecessarily
exposing three top-level classes. Make the two implementation classes be
nested, private and static.
2016-05-07 21:28:06 +01:00
Daniel Martí
6311ad5c6b Run remove-unused-trans.py after !277
Automated change. No issues with lint or any of the other tests.
2016-05-06 10:27:35 +01:00
Hans-Christoph Steiner
7e53baf4c1 Merge branch 'installer-ui-updates' into 'master'
Installer UI updates and lint fixes

This updates UI classes of the installer to reflect the changes of AOSP's installer and fixes some lint errors.
* No more differentiation between personal and device permissions (didn't even notice that there was a differentiation here...)
* Icon for "other" permission group

I carefully merged only the changes from AOSP that are related to us and decided against maintaining different versions of the AppSecurityPermissions.

There will be more changes and discussions to the installer UI coming in the next days.

See merge request !277
2016-05-06 07:55:56 +00:00
Dominik Schürmann
26f8c851ec Fix checkstyle errors 2016-05-06 08:43:23 +03:00
F-Droid Translatebot
60bafa168c Pull translation updates from Weblate
Translators:

Adrià García-Alzórriz     Spanish
Alberto Moshpirit         Spanish
Danial Behzadi            Persian
Enol P                    Asturian
Kristjan Räts             Estonian
Marcelo Santana           Portuguese (Brazil)
Mohamad Hasan Al Banna    Indonesian
Verdulo                   Esperanto
Verdulo                   Polish
2016-05-06 00:44:01 +01:00
Dominik Schürmann
fad9844d1f AppSecurityPermissions: Suppress lint for classes 2016-05-05 21:17:50 +03:00
Dominik Schürmann
8b0b8bd6d9 AppSecurityPermissions: fix some lint errors 2016-05-05 21:17:44 +03:00
Dominik Schürmann
2da380a04d Update InstallConfirmActivity and permissions_list from AOSP 2016-05-05 21:17:37 +03:00
Dominik Schürmann
06a8ff5787 AppSecurityPermissions: changes from Android 6 2016-05-05 21:16:53 +03:00
Dominik Schürmann
a2cb5f1ccf AppSecurityPermissions: changes from Android 5.2 2016-05-05 21:12:57 +03:00
Daniel Martí
afea37450b Bump to 0.100-alpha6 2016-05-03 11:18:53 +01:00
F-Droid Translatebot
b0131a7490 Pull translation updates from Weblate
Translators:

Adrià García-Alzórriz    Catalan
Adrià García-Alzórriz    Spanish
Marcelo Santana          Portuguese (Brazil)
Mladen Pejaković         Serbian
naofum                   Japanese
Tobias Bannert           German
Verdulo                  Esperanto
Verdulo                  Polish
YFdyh000                 Simplified Chinese
2016-05-03 11:17:39 +01:00
Daniel Martí
3563e586c4 Merge branch 'cleancacheservice' into 'master'
CleanCacheService

This creates `CleanCacheService` to do all of the cache clean up at the lowest possible priority.  It also adds a preference to set how long to keep cached APKs.

See merge request !260
2016-05-02 23:15:47 +00:00
Daniel Martí
e3ebab9bc3 Merge branch 'updater-speed-improvements' into 'master'
Updater speed improvements during "Saving Application Details"

I've been able to reproduce #324 OutOfMemory errors on an emulator with 12MiB of heap space. This branch did _not_ have an OOM error when updating with F-Droid and F-Droid Archive repos enabled. They successfully update without problem.

Fixes #45.

The "Saving Application Details" stage of repository updating is where each apk has its suggested version calculated, icon URLs calculated, etc. These all require [correlated subqueries](https://en.wikipedia.org/wiki/Correlated_subquery) resulting in a full scan of the apk table for each row in the app table. This takes in the order of 25 seconds on my Moto X 2nd Gen.

This branch improves this process by doing the queries in an [sqlite in-memory database](https://sqlite.org/inmemorydb.html), with the results transferred to the database on disk when done. The time required drops from 25 seconds to ~0.5 seconds on my device.

*Note:* I was hoping this would also improve the "Processing ..." Part of the udpater, given it was inserting into an in memory table instead of on disk. If it did have any effect, it was negligible though, so that part is still likely slower than it could be. Each 50 apps (and their associated apks) takes between 150ms and 500ms on my Moto X.

*Secondary Note:* When creating the in memory database, I create indexes for some columns as per before. This technically should slow down the inserts we do, however in practice they had almost no effect. As such, I've left the index creation there because it is required for the correlated subqueries to not suck. 

See merge request !269
2016-05-02 21:31:35 +00:00
Hans-Christoph Steiner
77052c2b45 remove cosmetic changes to security sensitive code: RepoUpdater
Security-sensitive code should not be changed unless there is a good reason
to do so.  It is too easy to introduce bugs.  This change does not address
an issue, so I'm reverting it. See comment in javadoc header for the class.

This reverts commit 2074718391c2c17a974218bc6565cce2dc05407e for just the
RepoUpdater.java file.
2016-05-02 20:38:31 +02:00
Hans-Christoph Steiner
cbf1bda433 add preference to set the time to keep cached APKs
This schedules CleanCacheService to run regularly, and delete files older
than the value set in the new "Keep cached apps" preference. It auto-
migrates the old "Cache packages" pref to the new one.  The default cache
time for people who did not have "Cache packages" enabled is one day.
2016-05-02 20:38:31 +02:00
Hans-Christoph Steiner
83ee0c8f0b clean up cached files in a low priority IntentService
This moves the cache file deletion to a dedicated IntentService that runs
at the lowest possible priority.  The cache cleanup does not need to happen
with any kind of priority, so it shouldn't delay the app start or take any
resources away from foreground processes.

This also changes the logic around the "Cache packages" preference. The
downloader always saves APKs, then if "Cache packages" is disabled, those
APKs are deleted when they are older than an hour.

This also simplifies Utils.deleteFiles() since the endswith arg is no
longer needed.
2016-05-02 20:38:31 +02:00
Hans-Christoph Steiner
6fa8477650 make Utils.getApkCacheDir() more likely to succeed
* if there is a file there, remove it

The paths are all from the system, so are safe. No SanitizedFile is needed.
Plus, this method was not checking if the original and sanitized versions
where different, and instead just creating the sanitized version. I worry
that could cause odd bugs.
2016-05-02 20:38:11 +02:00
Hans-Christoph Steiner
6c47ade379 move init sequence comments to javadoc comments
By putting these comments into javadoc, they are directly describing the
code where it is, and there are many tools in IDEs for searching, viewing,
sorting, etc. javadoc comments.  Plain comments do not have those tools.
2016-05-02 20:38:11 +02:00
Hans-Christoph Steiner
972ef3b078 remove unused arg from FileCompat.setReadable()
Just trying to keep the code as close to what is actually used as possible.
2016-05-02 20:38:11 +02:00
F-Droid Translatebot
32fc118b3d Pull translation updates from Weblate
Translators:

Ajeje Brazorf     Sardinian
Allan Nordhøy     Norwegian Bokmål
Paresh Chouhan    Hindi
Sérgio Marques    Portuguese (Portugal)
tacsipacsi        Hungarian
2016-05-01 23:23:25 +01:00
Daniel Martí
90aa73dc40 Merge branch 'restrict-priv-ext' into 'master'
Fixes for priv extension install

For now, disable install of privileged extension on Android >=5.1 until we found better methods.
Also, fix crash of dialogs on Android 6 using a workaround for transparent activities and some code simplifications.

See merge request !259
2016-05-01 22:19:41 +00:00
Dominik Schürmann
cf694b6d83 Disable install of privileged ext on Android 5.1 2016-05-01 23:15:41 +02:00
Dominik Schürmann
834c08db3c Code cleanup in Installer 2016-05-01 23:14:29 +02:00
Dominik Schürmann
17f712870b Fix crash of transparent dialogs on Android 6 2016-05-01 23:10:41 +02:00
Daniel Martí
023a6d01bd PMD: Enable some extra boolean/logic rules 2016-04-29 19:22:30 +01:00
Daniel Martí
ac8d3ff600 PMD: Enable and obey UnnecessaryParentheses
This works on statements, not expressions, so it's a lot easier and
saner to obey than UselessParentheses.
2016-04-29 19:22:04 +01:00
Peter Serwylo
f9b22442ed Simplify detach code by catching exception istead of querying for attached dbs. 2016-04-28 15:06:47 +10:00
Peter Serwylo
721dcb00c1 Use temporary, in memory database for update process.
This increases the speed of the complex queries required at the end
of the update process to:
 * calculate suggested version codes
 * figure out icon urls
 * etc,
by two orders of magnitude.
2016-04-28 15:06:44 +10:00
Peter Serwylo
ab248525e0 Don't do a subquery in a subquery in a subquery.
This was there as a workaround for #1, but that has subsequently
been fixed. Thus, the hack is no longer required. Also removed an
additional `AND` because it is already performed in the `JOIN`.
I supsect this last one would've been eliminated by the sqlite
optimizer anyway, but the query is slightly simpler now.

This fix doesn't improve performance as much as I'd hoped, but it
is something.
2016-04-28 09:04:26 +10:00
Daniel Martí
fdd441c382 Add Estonian (et, Eesti) to the langs list
Its first translations were added in the previous commit, pulled from
Weblate.
2016-04-27 15:27:38 +01:00
F-Droid Translatebot
9faa84fa90 Pull translation updates from Weblate
Translators:

Danial Behzadi            Persian
fastest noob              Turkish
Fert Bálint               Hungarian
Green Lunar               Hebrew
Jean-Baptiste             French
Karola Marky              Japanese
Kristjan Räts             Estonian
Licaon Kter               Romanian
Marian Hanzel             Slovak
Mohamad Hasan Al Banna    Indonesian
naofum                    Japanese
Tobias Bannert            German
YFdyh000                  Simplified Chinese
2016-04-27 15:09:16 +01:00
Daniel Martí
27d1187216 Merge branch 'notifications' into 'master'
Added cancel action to notifications.

![Screenshot__Apr_27__2016_2-41-30_AM_](/uploads/7756406732c8583117532e5fed151a2c/Screenshot__Apr_27__2016_2-41-30_AM_.png)

See merge request !267
2016-04-26 22:53:11 +00:00