1207 Commits

Author SHA1 Message Date
Chirayu Desai
204ac3cca9 PackageManagerCompat: Handle exceptions better
* Don't catch all exceptions, only what we expect.
* Also re-format comments as javadoc
2017-06-14 17:45:12 +05:30
Peter Serwylo
edf84c533d Added more explicit test for UpdateService and its can update notification 2017-06-13 12:52:17 +10:00
Peter Serwylo
5a292b8e77 Cleanup tests by extracting common code, and test canUpdate query. 2017-06-13 12:52:16 +10:00
Peter Serwylo
0409a7dcd6 Use provider helper methods instead of manually invoking.
The fact that Cursors are used with the apk provider is more of an
implementation detail (to some extent). It is a crappy, leaky
implementation right now, but still an implementation detail.
2017-06-13 12:52:16 +10:00
Peter Serwylo
28b7d69e60 Don't show versions with a different sig if installed.
This should probably be done on the database level, if purely for the
fact that we have a good set of unit tests for that. However it is still
quite clean to do so here.
2017-06-13 12:52:16 +10:00
Peter Serwylo
189b2277ba Refactor ApkProvider.getApkFromAnyRepo to getSuggestedApk(Apk).
This is really the intention of the method, given it used to accept
a version code and a package name. Now it optionally accepts a sig
also. If present, it will restrict the query to apks with that sig.

Also added to the multi-sig tests to ensure this method takes it into
consideration.
2017-06-13 12:52:16 +10:00
Peter Serwylo
b092d52403 Find better way to detach DB which doesn't pollute test output 2017-06-13 12:49:35 +10:00
Peter Serwylo
655a30c309 Use integer instead of boolean.
There is some magic conversions going on so that booleans get
converted into integers, but they are only on Android. Under
robolectric, it throws a class cast exception instead.
2017-06-13 12:49:35 +10:00
Peter Serwylo
f7d9be9cd5 Remove System.out.print's. Replace with Logs where appropriate.
Some were removed and left removed if they were run during tests,
because the tests are supposed to be automated and the noise they added
would not have helped diagnose a failure.

Also removed the dead code around "uses-feature" which will never
get implemented, especially as it is in the XML index.
2017-06-13 12:49:15 +10:00
Peter Serwylo
de149cf589 Remove subselect and use better index.
The main problem is that we were using an index on fdroid_apk.vercode,
when it should have been using an index on fdroid_apk.appId. There are
thousands of apks which would match based on vercode, but only two or
three which match based on appId. This improves performance of the
calculate-suggested-vercode query from 25,000ms to 100ms.
2017-06-13 09:05:37 +10:00
Peter Serwylo
bb96cdeff9 Refactor join between installed apps and packages. 2017-06-13 09:05:37 +10:00
Peter Serwylo
b729f4dc84 Add slow query logging to updateSuggestedFrom* methods.
Produces the following output:

D  Explain:
D    SCAN TABLE fdroid_app
D    EXECUTE CORRELATED SCALAR SUBQUERY 0
D    SEARCH TABLE fdroid_apk USING INDEX apk_vercode
D    EXECUTE CORRELATED SCALAR SUBQUERY 1
D    SEARCH TABLE fdroid_app AS innerAppName USING INTEGER PRIMARY KEY (rowid=?)
D    EXECUTE CORRELATED SCALAR SUBQUERY 2
D    SEARCH TABLE fdroid_package AS pkg USING INTEGER PRIMARY KEY (rowid=?)
D    SEARCH TABLE fdroid_installedApp AS installed USING INDEX sqlite_autoindex_fdroid_installedApp_1 (appId=?)

There are two possibilities here, one is the number of correlated sub
queries (three seems a bit excessive). Alterantively, it could be the
fact that one of the inner queries is using a string index (appId=?)
instead of an integer primary key.
2017-06-13 09:05:31 +10:00
Peter Serwylo
d0444dafca Clarify comments in response to CR. 2017-06-12 14:22:07 +10:00
Peter Serwylo
82eb50c2fe Add test for multi-repo multi-sig apps 2017-06-12 14:22:05 +10:00
Peter Serwylo
aa472ba764 Drop the composite vercode + repo primary key from apk table
We expect repos to serve multiple apks with the same version code but
different signing certificates in the future.
2017-06-12 13:48:36 +10:00
Peter Serwylo
b95a330ccf Restrict suggested versions to those with the same sig as installed.
Only if there is actually a version installed.
2017-06-12 13:48:36 +10:00
Peter Serwylo
44ffaa37d6 Add suggested version tests.
Some are failing as expected, but should define the correct behaviour.

Still needs support for multi-repo tests.
2017-06-12 13:48:35 +10:00
Peter Serwylo
aae0a57dfe Improve performance of suggested version calculation.
The history of this is that #974 identified a problem, which was fixed
in !497. That MR added test coverage for the bug.

However, the fix for it actually added a huge performance hit, on the
order of 30 seconds or so when calculating the suggested version.

This fixes that performance problem by removing the need for a sub
query. The end goal is to take the following query:

```
UPDATE app
SET suggestedVersion = (
  SELECT MAX(apk.version)
  FROM apk
  WHERE ...
)
```

and the `WHERE` clause needs to somehow join the outer `app` table with
the inner `apk` table, such that the repo in question does not matter.
It can't just join directly from `apk.appId -> app.rowid`, because the
`app` is specific to a given repository, but we want to select the
`MAX(apk.version)` from every related apk, regardless of repo.

This commit solves it by joining the inner `apk` table onto an
intermediate `app` table, which is used purely so that we can select
apks where their `packageId` is the same as the `packageId` of the app
being updated.
2017-06-12 13:47:41 +10:00
Peter Serwylo
833ae329e4 Merge branch 'enforce-max-length-118' into 'master'
enforce max line length set by Android Studio, gitlab, etc.

See merge request !532
2017-06-11 20:53:44 +00:00
Hans-Christoph Steiner
72d7d902e0 Merge branch 'fix-fdroid-update-prompt' into 'master'
Fix incorrect persistent + annoying notification to update F-Droid.

Closes #1027 and #776

See merge request !530
2017-06-08 10:46:45 +00:00
Hans-Christoph Steiner
318bbfc140 Merge branch 'category-tweaks' into 'master'
Add final artwork and correctly read colours.

Closes #1039

See merge request !535
2017-06-08 10:18:56 +00:00
Peter Serwylo
5b6e515a06 Add final artwork and correctly read colours.
Carrie specified colours earlier, and they were added to the code.
However they were not being read correctly. This changes that so that
lowercase resource names (e.g. "category_games") are used instead.

It also adds the final category artwork, for "Games" which was
missed prior.

The rest still generate colours and patterns if they don't have a colour
or an image specified.
2017-06-08 17:24:12 +10:00
Peter Serwylo
5b182ef38d Merge branch 'master' into 'master'
Made app_details2_header text selectable. This addresses #1032.

See merge request !533
2017-06-08 03:28:16 +00:00
Peter Serwylo
9e33dcf0db Wait 3 seconds before refreshing the view.
With a 1 second debounce, I was getting the view to refresh
several times in response to large apps being processed (e.g.
Firefox, OSMAnd, etc). This was on a (relatively) recent Moto X
2nd Gen, so it would be even more visible on an older device.

The side effect of updating frequently is that the main list
of apps flashes regularly in front of the user (see #986).

This "update the view" is only in response to a background
task that is expected to take several seconds (e.g. 30 seconds)
anyway, so waiting 3 seconds instead of 1 is not particularly
problematic.
2017-06-08 09:12:52 +10:00
Peter Serwylo
1dbf5704b6 Don't remove ourselves from the installed app cache.
If F-Droid was actually removed, then we wouldn't even
have an installed app cache (we aren't even on the device
any more). As such, ignore all requests to remove F-Droid
because it complicates the installed apk cache. Specifically,
there is a race condition between the "compare apk cache to
package manager" and the "package removed receiver", where
the later was overriding the former.
2017-06-08 08:59:07 +10:00
Peter Serwylo
116cb88b81 Fix incorrect persistent + annoying notification to update F-Droid.
There is a persistent shared preference which dictates whether apps
have been successfully downloaded and are ready to install. When
the `InstallManagerService` used to receive an `ACTION_INSTALL_COMPLETE`
broadcast, it would update this preference to no longer be installing.
However, this never got received in the case of F-Droid updating itself.
In that case, we need to instead wait for the system to broadcast an
`Intent.ACTION_PACKAGE_ADDED` intent. This change waits until that
point before removing the preference.

Fixes #1027.
2017-06-08 08:59:05 +10:00
Hans-Christoph Steiner
48fd6d287d enforce max line length at 118
gitlab's diff views wrap badly when lines are longer than 118.  Android
Studio places a grey line in the UI at 120.

@SuppressWarnings("LineLength") is added to a bunch of files to prevent
making this commit huge.  People can remove that as they work on those
files, and fix the issues then.

I also ran Android Studio's default Ctrl-Alt-L code formatter, where it was
easy to do, and I was already in the file.
2017-06-06 16:12:23 +02:00
Hans-Christoph Steiner
a0015cda32 correct method name: getLocalizedListEntry()
This gets the data, it does not set it.  And it matches the other
getLocalized*() methods.
2017-06-06 16:12:23 +02:00
Steffan Byrne
63cad0d754 Made app_details2_header text selectable. This addresses #1032. 2017-06-05 22:07:40 -04:00
ByteHamster
f66781eac6 Improved font color in dark theme 2017-06-03 09:58:53 +02:00
Hans-Christoph Steiner
9967ed9923 Bump to 0.103.2 2017-05-31 19:38:06 +02:00
Hans-Christoph Steiner
db120c0f1f lint: make UnusedResources an error
!520
2017-05-31 17:29:40 +02:00
Hans-Christoph Steiner
feeb8c17ad remove unused string: installDowngrade
If this is needed in the future, this commit can be reverted in git.
2017-05-31 12:31:11 +02:00
Hans-Christoph Steiner
76fca35c2e remove unused string: menu_send_apk_bt
If this is needed in the future, this commit can be reverted in git.
2017-05-31 12:31:10 +02:00
Hans-Christoph Steiner
f6c669783d remove unused string: empty_search_available_app_list
If this is needed in the future, this commit can be reverted in git.
2017-05-31 12:31:10 +02:00
Hans-Christoph Steiner
edc9941e8b make LocalizationTest log the troublesome string locale and key 2017-05-31 12:29:25 +02:00
Hans-Christoph Steiner
793b62878b Weblate 2017-05-31 09:50:25 +00:00
Hans-Christoph Steiner
087e86b312 Merge branch 'fix-notifications' into 'master'
Fix notification problems

Closes #1013

See merge request !523
2017-05-31 09:09:08 +00:00
Hans-Christoph Steiner
d70d597d81 Merge branch 'delete-unused-resources' into 'master'
Delete unused resources

See merge request !520
2017-05-31 07:58:40 +00:00
Felix Ableitner
07cd5e82fc Remove unused resources 2017-05-31 12:22:47 +09:00
Peter Serwylo
f617402f32 Remove PendingDownload in favour of Downloading
The response to receiving PendingDownload was always a more specific
case of the Downloading event. By removing it, the code which was listening
for Downloading events is capable of doing everything that the PendingDownloading
listeners were doing.
2017-05-31 11:47:10 +10:00
Peter Serwylo
a656e8e133 Remove dead code.
Fixes #1013.
2017-05-31 11:47:10 +10:00
Peter Serwylo
b3ed64ddaf Simplify and clean up updates view logic.
Same as how AppDetails2 was recently cleaned up to depend more on
AppUpdateStatusManager.

In addition, it also removes items from the "X apps can be updated"
lower part of the "Updates" view when they are present in the upper half
(i.e. the half showing feedback about the current download/install
progress).
2017-05-31 11:47:10 +10:00
Peter Serwylo
2a9fefd54e Simplify logic in UpdatesAdapter.
No longer do we try to nicely maintain the state of the adapter in "Updates"
in order to notify the recycler view about changes to its underlying data.
Instead, we just rebuild the entire structure each time a new thing needs
to be shown/removed.

This means no more smooth scrolling to the relevant item after it is
changed, but it results in a far less buggy interface.
2017-05-31 11:47:10 +10:00
Peter Serwylo
b69587ca65 Make contract about nullable currentApp explicit.
This identified a couple of places where it needed to be guarded
against.
2017-05-31 11:47:10 +10:00
Peter Serwylo
7d1fac2729 Extract isDownloading check into method of status class.
This is also going to be used elsewhere.
2017-05-31 11:47:10 +10:00
Peter Serwylo
8e2a099e51 Make app status updates include parcelized version of status.
This means that we no longer need to receive an APK_URL and then
directly ask the status manager for the relevant status object.
This causes problems when consecutive updates happen in the same event
loop, e.g. download started + download complete. In this case, the
receiver will receive two events for the same app. When it asks for the
associated status object for the first (download started) event, it will
receive a status that says "download complete ready to install". This is
because the status object has already been updated by the second event.

Furthermore, the broadcast manager must receive a copy of the status
object, not the original object. This is because the broadcast manager
doesn't parcel the relevant extras until the end of the event loop. This
means that if the status is changed twice in one frame, then both
parcels will end up looking the same. By sending through a copy instead,
this ensures that any listener receives the statuses in the correct
order, rather than two parceled versions of the same status
notification.
2017-05-31 11:47:10 +10:00
Peter Serwylo
ee7055e118 Listen to AppUpdateStatusManager events instead of DownloadManager events.
Also, make sure to correctly update the app details view when te user
leaves then returns to the view. Prior to this, the user would need to
wait for a download event to be received. However even that was broken,
because the download listener was not being added correctly once the
user returned to the app details screen.
2017-05-31 11:47:10 +10:00
Peter Serwylo
be727ae7c0 Fix missing category images.
Even though the categoyr mage loader explicitly says not to cache
images on disk (because they are not coming from the network anyway),
UIL still uses the `FilenameGenerator` to come up with a disk cache name.

Because the file name generator takes the "path" of the URL being
downloaded, and the categories are loaded like "drawable://2134234",
there is no path. As such, the file name ends up being meaningless.

This results in the image loader testing for the existance of the file
on disk (even though we asked not to cache on disk), and then failing
with an IOException (that gets swallowed).

By providing a meaningful name from the file name generator, it now
works as expected.

Fixes #1039.
2017-05-31 09:27:29 +10:00
Hans-Christoph Steiner
702cf2dec8 Weblate 2017-05-30 16:02:59 +00:00