3999 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
ab1e869ebe use HEAD request when just checking the file size
This code will be changed again when implementing the client-side etag
check #562

closes #777
2016-11-10 20:44:53 +01:00
Hans-Christoph Steiner
096b7132c4 prevent AppDetailsHeaderFragment crash in startProgress()
The real solution would involve figuring out where to handle this in the
right spot in the lifecycle.  Since AppDetails is being totally replaced,
this is just to stop the crashing.

closes #802
2016-11-10 20:44:53 +01:00
Hans-Christoph Steiner
b9dad4bce6 handle dirs and I/O errors when parsing ACTION_PACKAGE_ADDED Intents
InstalledAppProviderService tries to keep a running log of what is actually
installed on the device.  It seems that ApplicationInfo.sourceDir and
related things sometimes returns a dir rather than an APK. So try to find
an APK in that folder.

closes #801
2016-11-10 20:44:53 +01:00
Hans-Christoph Steiner
b852c0dca0 Merge branch 'category-table' into 'master'
Store categories in separate category table

Currently, the category that an app is in is recorded in the database via the `fdroid_app.categories` column, containing a comma separated list of strings. This makes it hard to query. The existing code to get a list of categories was pretty bad as a result. 

This moves to a different data model whereby categories are stored in a separate table. Each repo is free to specify that an app is in arbitray caregories (as with before). This is represented by a join table between categories and app metadata.

The end result is that categories are much more a first class citizen than before, and they will be able to be queried easier - which is important for the new UI.

Note that the categories table need never be emptied, it can keep being appended to. The reason is that if there are no apps in a particular category (represented by no corresponding rows in the join table) then the category will not be shown to the user.

See merge request !409
2016-11-10 10:19:06 +00:00
Hans-Christoph Steiner
0c6ca09a7d Merge branch 'partially-fix-520--performance-when-changing-preference' into 'master'
Improve performance when changing "Unstable Updates" preference

This is only a partial solution to #520. 

It does as I suggested in the issue comments, by doing less work when the preference is checked. The proper solution is an `IntentService` which queues requests to update these details, but that is a (slightly) larger change for the future.

I also noticed it wasn't correctly notifying the UI of the change, so this now notifies the list of apps which can be updated. That was hard to test though, so not sure if it updates the UI correctly or not. It shouldn't do it _incorrectly_, but it may not work. The reason it should work is because the `AppListFragment` (baseclass of `CanUpdateAppsFragment`) uses a cursor loader with the `AppProvider.getCanUpdateUri()` URI. This `CursorLoader` should automatically attach an observer for that URI and requery if required.

See merge request !414
2016-11-10 10:17:03 +00:00
Hans-Christoph Steiner
b2b108c39e Merge branch 'fix-800--npe-uninstalling' into 'master'
Fall back to InstalledAppProvider when trying to identify the apk to uninstall.

Extracted `getInstalledApk()` method so that it could be better documented, and
makes the `uninstallApk()` more consise. It will now throw an `IllegalStateException`
if no apk is found, because as issue #800 shows we will end up with a NPE otherwise.

Fixes issue #800.

See merge request !413
2016-11-10 08:36:00 +00:00
Peter Serwylo
b2c497e5b9 Only update suggested versions, not other unneeded things.
Also, while we are here, lets notify the content observers that the suggested
versions have changed, so that the UI can update in response.
2016-11-10 12:57:49 +11:00
Peter Serwylo
fdc95c071d Rename from 'calc app details' to 'calc all details'
In preperation for a subsequent change to only calculate a subset of details
for performance reasons.
2016-11-10 12:25:55 +11:00
Peter Serwylo
f060efb7ba Remove outdated doc comment and simplify method. 2016-11-10 12:22:37 +11:00
Peter Serwylo
a7a52fbfba Fall back to InstalledAppProvider when trying to identify the apk to uninstall.
Extracted `getInstalledApk()` method so that it could be better documented, and
makes the `uninstallApk()` more consise. It will now throw an `IllegalStateException`
if no apk is found, because as issue #800 shows we will end up with a NPE otherwise.

Fixes issue #800.
2016-11-10 11:16:29 +11:00
Peter Serwylo
2263352ca4 Add test for miscellanious update from f-droid.org metadata
During development of a new feature, I noticed a bug occuring only after using
the new feature for several days. This was because the metadata only infrequently
changes in ways which cause certain code paths to be hit. By having the f-droid.org
metadata from several days apart in the test suite, it allows for testing more
of these cases. In the future, even later versions of the metadata can be added
to ensure that we can update happily from old to new metadata.
2016-11-10 09:09:47 +11:00
Peter Serwylo
9785536910 Use the Query object rather than the SQLiteDatabase#query() method.
This ensures that all of the relevant joins are in place, so that when
the updater asks to `queryPackageName()` then it can assume that we have
already joined onto the `Schema.PackageTable`.
2016-11-10 09:09:43 +11:00
Peter Serwylo
354f0a9b53 Make it explicit that the CATEGORIES column is not for selecting from.
Renamed the `Schema.AppMetadata.Categories.CATEGORIES` constant into the
`Schema.AppMetadata.ForWriting.Categories.CATEGORIES` constant. This is
to make it very clear that it is not for reading from the database.
2016-11-10 08:09:49 +11:00
Peter Serwylo
68f666685f Make category helper functions query new category table 2016-11-10 08:09:49 +11:00
Peter Serwylo
634fe1084a Move category helper functions to CategoryProvider
Don't change anything yet, just move them.
2016-11-10 08:09:49 +11:00
Peter Serwylo
a7a7f77b42 Refactored categories field from column in metadata table to join table.
When updating existing apps or inserting new apps, instead of splatting
a comma separated list into a single sqlite3 column, we now put it into
several rows in the `CatJoinTable`. This is done after deleting existing
categories, to make sure that if the app has been removed from a category,
then this is reflected during the update.
2016-11-10 08:09:49 +11:00
Peter Serwylo
b2d5bcc94a When querying based on category, use join table. 2016-11-10 08:09:49 +11:00
Peter Serwylo
3e3fdd5c07 Added category to keyword search. 2016-11-10 08:09:49 +11:00
Peter Serwylo
8757acca1a Added category provider.
Not used by anything yet.
2016-11-10 08:09:49 +11:00
Peter Serwylo
99f7cab62e Added "category" table and "category to app metadata" join table.
Nothing uses these added tables yet.
db-version/65
2016-11-10 08:09:49 +11:00
Peter Serwylo
bb7cfc14cc Comments for the Schema.PackageTable. 2016-11-10 08:09:49 +11:00
Peter Serwylo
19ca68cb30 Removed unused category view in app details.
It was hidden some time ago, and nobody seems to miss it.
Also, we will be redoing this view soon anyway. In the meantime,
this category stuff is changing and this view should be removed.
2016-11-10 08:09:49 +11:00
Daniel Martí
6f0b33a092 Bump to 0.102-alpha2 v0.102-alpha2 2016-11-02 21:19:34 +00:00
F-Droid Translatebot
eae81b51ee Pull translation updates from Weblate
Translators:

Andy               Finnish
Buru Gher          Bulgarian
Matej Kolarević    Croatian
Sérgio Marques     Portuguese (Portugal)
Tobias Bannert     German
Verdulo            Esperanto
2016-11-02 21:19:18 +00:00
Hans-Christoph Steiner
dd5f84f226 Merge branch 'ci-bumps' into 'master'
ACRA and Checkstyle bumps

See merge request !412
2016-11-01 18:44:21 +00:00
Daniel Martí
04c7176a2a Bump checkstyle to 7.2 2016-10-31 14:19:30 +00:00
Daniel Martí
28853fb2ec Bump ACRA to 4.9.1
Changes: https://github.com/ACRA/acra/wiki/ChangeLog#acra-491-12-oct-2016
2016-10-31 14:07:41 +00:00
Hans-Christoph Steiner
8c68849e82 Merge branch 'clear-up-reset-transient' into 'master'
Be a little more concise about when we need to run migration for v64.

Before it is not apparant that the migration introduced for v64 is associated with that particular version. This is because the guard condition used to bail out from the upgrade is more closely related to a previous migration.

This is due to a flaw with the desigh of `resetTransient()`, whereby it always resets the database to the schema _of the current F-Droid version being run_, not of the tables as they stood at the time of the particular migration being introduced.

This clarifies the guard condition for v64 by allowing it to query whether the schema has been created fresh or not during this particular invocation of `onUpgrade()`

**Note:** this is less to do with the v64 migration, but rather I came across the exact same issue while working on category table related changes. At that point I realised I made a slight mistake with the `resetTransient()` method.

**Also:** I'm happy to entertain other designs if anybody is that interested. One other approach is to change the guard condition to:

```
if (version >= 64 || fieldExists(db, ApkTable.NAME, "...")) {
  ... add field ....
}
```

However that suffers a little bit when the migration is a little more complex and checking if a field exists may not be enough.

See merge request !408
2016-10-25 14:07:22 +00:00
Daniel Martí
6aba30fe7f Merge branch 'new-ci' into 'master'
Bump to new CI image, bump buildTools to 25

See merge request !410
2016-10-25 11:07:39 +00:00
Daniel Martí
3af5416f09 Bump to new CI image, bump buildTools to 25 2016-10-23 17:09:17 +01:00
F-Droid Translatebot
40665e335a Pull translation updates from Weblate
Translators:

Allan Nordhøy     Norwegian Bokmål
Enol P            Asturian
Ivan Krušlin      Croatian
Raphaël Barman    French
riotism           Chinese (Hong Kong)
2016-10-23 16:30:07 +01:00
Peter Serwylo
d65e72638b Reimplement columnExists using PRAGMA table_info.
For some reason, the existing approach of "select * and then see if the
column of interest is in the results set" didn't work as expected under
tests. Perhaps SQLite is caching the list of columns for the purpose of
`select *` even after running an `alter table add column` query?

Either way, I couldn't figure out why it wasn't working as expected.
This left us with two options:

 * Try to `select columnToCheck` and see if it throws an exception
 * Query columns using `PRAGMA table_info.

The exception thrown when a column doesn't exist is not specific enough
for our code to check that this is the exact exception that occured. It
is not possible to say: `try { ... } catch (SQLiteColumnNotFound e) { ...}`
unfotunately. Also, there is a cost associated with unwinding the stack
to process an exception, which means exceptions probably shouldn't be
used in unexceptional circumstances such as this.

This change instead uses `PRAGMA table_info(tableOfInterest)` and then
iterates over the cursor looking for the relevant column. Even if the
performance is worse than the stack unwinding of an exception, it is
more concise and less hacky.
2016-10-19 06:44:08 +11:00
Peter Serwylo
63a609fbab Moved methods away from top of DBHelper class.
The fact there are arbitrary migrations at the top of the file (between
`onCreate()` and `onUpdate()` makes it harder to scan this file.

This changeset moves these methods verbatim, without changing any of
the method bodies or signatures.
2016-10-18 18:00:36 +11:00
Peter Serwylo
a317877120 Be a little more concise about what to do when running migration for v64.
Before it is not apparant that the migration introduced for v64 is
associated with that particular version. This is because the guard
condition used to bail out from the upgrade is more closely related
to a previous migration.

This is due to a flaw with the desigh of `resetTransient()`, whereby
it always resets the database to the schema _of the current F-Droid
version being run_, not of the tables as they stood at the time of
the particular migration being introduced.

This clarifies the guard condition for v64 by instead explicitly asking
if the columns of interest exist yet in this particular invocation of
`onUpgrade()`.
2016-10-18 18:00:30 +11:00
Hans-Christoph Steiner
5d2c2bc6e6 Merge branch 'fix-npe-verifying-perms' into 'master'
Fix npe verifying perms

Fixed a NPE for apps with no permissions.

Here is an example of the logging output for a couple of apps too after my change:

```
D/ApkVerifier(10929): Checking permissions
D/ApkVerifier(10929): Actual:
D/ApkVerifier(10929):   None
D/ApkVerifier(10929): Expected:
D/ApkVerifier(10929):   None
```

and

```
D/ApkVerifier(10929): Checking permissions
D/ApkVerifier(10929): Actual:
D/ApkVerifier(10929):   android.permission.READ_EXTERNAL_STORAGE
D/ApkVerifier(10929):   android.permission.WRITE_EXTERNAL_STORAGE
D/ApkVerifier(10929):   android.permission.SET_WALLPAPER
D/ApkVerifier(10929):   android.permission.SET_WALLPAPER_HINTS
D/ApkVerifier(10929):   android.permission.WRITE_SETTINGS
D/ApkVerifier(10929): Expected:
D/ApkVerifier(10929):   android.permission.SET_WALLPAPER
D/ApkVerifier(10929):   android.permission.READ_EXTERNAL_STORAGE
D/ApkVerifier(10929):   android.permission.SET_WALLPAPER_HINTS
D/ApkVerifier(10929):   android.permission.WRITE_SETTINGS
D/ApkVerifier(10929):   android.permission.WRITE_EXTERNAL_STORAGE
```

See merge request !407
2016-10-17 14:42:23 +00:00
Peter Serwylo
2b2958f89c Added explicit test for null permissions.
This wouldn'tve actually found the problem in the previous commit,
due to the null happening before checking permissions while logging perms.
However, still seems like a nice test to have so that the method itself
handles nulls correctly.
2016-10-16 20:52:42 +11:00
Peter Serwylo
b72cdff522 Guard against null, and improve logging in ApkVerifier. 2016-10-16 20:28:19 +11:00
Daniel Martí
ad2059574e Merge branch 'category-tests' into 'master'
Improved category tests

In preparation for implementing the [new category UI](https://gitlab.com/fdroid/fdroidclient/uploads/01d865e65604c41b0a472f0d39e7f1a7/Categories.png) I will be refactoring the database so that categories get their own table. In preparation for that, this MR improves the categories tests so that they also test the ability to query apps based on their categories.

See merge request !406
2016-10-13 17:58:59 +00:00
Peter Serwylo
c771e9a394 Added test for querying apps based on category
The previous category tests only checked that certain categories
would indeed find their way into the database if certain app metadata
is saved. It didn't check the other direction, using these categories
in queries.
2016-10-13 08:52:17 +11:00
Peter Serwylo
8e2e14d703 Migrating category tests to their own class in preperation for giving them their own DB table 2016-10-13 08:41:51 +11:00
Hans-Christoph Steiner
189c8bd452 Merge branch 'fix-783--process-list-bug' into 'master'
Guard against null in getRunningAppProcesses

Fixes #783.

See merge request !405
2016-10-12 20:22:00 +00:00
Peter Serwylo
0e70495046 Guard against getRunningAppProcesses() returning null 2016-10-13 06:42:49 +11:00
Peter Serwylo
e2e1d3111c Extract code to check for ACRA process into method
Makes it easier to document the code and simplifies FDroidApp#onCreate().
2016-10-13 06:20:06 +11:00
F-Droid Translatebot
2428a89288 Pull translation updates from Weblate
Translators:

Alessandro “Acn0w” Cecchin    Italian
ezjerry liao                  Traditional Chinese
zmni                          Indonesian
2016-10-12 13:20:52 +01:00
Hans-Christoph Steiner
53e8061ef3 Merge branch 'support-extended-permissions' into 'master'
Support extended <uses-permissions/> tags

`<uses-permission-sdk-23>` is a new tag for requesting permissions on _android-23_ and above.  `<uses-permission/>` and `<uses-permission-sdk-23>` both can have optional _maxSdkVersion_ values, and these need to be fully supported in order for the Privileged Extension to be able to check the APK permissions against the index.xml permissions.  This is needed so that it can prompt the user once, then download and install the APK after that.  Its also needed for transparent background updates to check if the permissions have changed in the update.

This gets closer to the complete support, really the full permissions should be stored in the database.  Then the only
conversion would happen ewhen parsing the XML.  Right now, it still stores the old F-Droid permissions names, i.e. without
`android.permission.`.  Then those are converted when they are loaded from the DB into an Apk instance.

See merge request !402
2016-10-11 07:00:00 +00:00
Hans-Christoph Steiner
6f0c9ff88a support extended 'uses-permissions' tags in APKs
<uses-permissions/> tags can have min and max SDK to take effect.  This is
not supported currently, and it necessary especially with the privileged
installer so it can properly represent the permissions that an APK is
requesting.

For example:
<uses-permission
  android:name="android.permission.MANAGE_ACCOUNTS"
  android:maxSdkVersion="22" />
<uses-permission-sdk-23
  android:name="android.permission.CAMERA" />
<uses-permission-sdk-23
  android:name="android.permission.CALL_PHONE"
  android:maxSdkVersion="23" />
2016-10-11 08:44:51 +02:00
Hans-Christoph Steiner
2350b4e694 move shareable test classes into new separate section: testShared
This allows some of the mock classes to be shared across Robolectric and
emulator tests.
2016-10-11 08:44:51 +02:00
Hans-Christoph Steiner
d7022dd498 rename Apk.permissions to requestedPermissions like PackageInfo
android.content.pm.PackageInfo is the Android class for representing data
about an APK/package.  Since Apk.permission is the same thing, we should
use the same name.
2016-10-11 08:44:51 +02:00
Daniel Martí
43f380b6b6 Merge branch 'lint-fixes' into 'master'
lint fixes

This fixes a few lint warnings and promotes them to errors so that CI builds catch them in the future.

See merge request !404
2016-10-11 06:35:41 +00:00
Hans-Christoph Steiner
a5a90954bc fix lint UnsafeProtectedBroadcastReceiver
Android won't protect us from other apps sending other Intents to these
receivers, so at least check that the action string matches what its
looking for.  This is based on a lint recommendation.
2016-10-10 20:15:47 +02:00