915 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
0730d3c676 set App.preferredSigner when using index v0 #1086
This was an oversight when we added this functionality, though there was
a related TODO.

41f85f3c9df934daba0ee0d60c4c01bb071fa6e7
2017-09-04 22:20:55 +02:00
Peter Serwylo
aa2d791531 Merge branch 'etag-fix' into 'master'
switch etag cache check to purely client-side

Closes #562

See merge request !574
2017-09-04 20:22:02 +00:00
Hans-Christoph Steiner
312bc9f503 Merge branch 'swap-crash-serving-fdroid' into 'master'
Fix crash when trying to swap.

See merge request !563
2017-09-04 20:08:53 +00:00
Hans-Christoph Steiner
2550329ab5 switch etag cache check to purely client-side
Instead of including the etag in the HTTP GET request and letting the
server set the Response Code depending on whether the etag machines, this
makes the client first issue a HEAD request, which is uses to get the etag
and the file size.  We need to do the HEAD beforehand anyway to get the
file size for resumable downloads, and this approach prevents the server
from using the etag as a form of tracking cookie:
http://lucb1e.com/rp/cookielesscookies/

closes #562
2017-09-04 20:56:12 +02:00
Hans-Christoph Steiner
2dbeb60666 Merge branch 'issue-995--installing-after-disabling-repo' into 'master'
Ensure apps are not kept in "Updates" when their repo is disabled.

Closes #995

See merge request !568
2017-09-01 14:00:00 +00:00
Christine Emrich
0d874a7ee8 Dismiss about dialog on touch outside #1082 2017-08-30 22:24:04 +02:00
Christine Emrich
f8c81a47d9 Apply selected theme to about dialog in settings #1083 2017-08-30 22:21:09 +02:00
Hans-Christoph Steiner
a48a92385e Merge branch 'issue-1117--empty-state-search' into 'master'
Empty search results now shows message (as in 0.102.3)

Closes #1117

See merge request !567
2017-08-29 14:00:39 +00:00
Christine Emrich
e9cdc5e952 Remove highlight from snapped screenshot #1068 2017-08-27 17:24:53 +02:00
Peter Serwylo
f3c48f8d6b Ensure apps are not kept in "Updates" when their repo is disabled.
This caused problems when users then tried to action the pending
install, where it would no longer have enough information to install the
app. Although it may be technically possible to keep enough information
around in memory to make the app installable, but it is not worth the
effort. If a user intentionally disables a repo, we should no longer be
responsible for keeping information about its apps around.

Fixes #995.
2017-08-08 21:12:59 +10:00
Peter Serwylo
0f8bec59e1 Show message when no search results are found.
Fixes #1117.
2017-08-08 11:35:23 +10:00
Peter Serwylo
a3a0c0a15d More verbose logging
There are some ACRA reports with this IllegalStateException getting hit.
It used to be that it was only ever because we forgot to request the
correct fields from the database. However now I'm not sure that this is
the only source. Perhaps it is also possible in response to parcelling
apk instances, or maybe something else? Either way, this should provide
further info about whether the apk doesn't belong to a repo for some
reason.
2017-08-01 13:04:08 +10:00
Peter Serwylo
3b41287cf7 Remove unused methods.
There are two methods which allow callers to choose which fields to
return. These were originally added for performance, so you only ask for
what you need. However empirically the performance gain doesn't mean
anything, because it is dwarfed by the query that was just executed.
However, it does open the code up to bugs because we forget to ask for
the right fields. So now it just returns all fields when querying for
apks.
2017-08-01 13:02:36 +10:00
Peter Serwylo
618f83bb23 Formatting 2017-08-01 11:59:44 +10:00
Peter Serwylo
2d377453d9 Ensure swapping doesn't get confused by apks in different repos.
While investigating #1086 which was about swap being busted, I
discovered that we recently introduced a worse bug when working with
multi sig stuff. The swap process, when installing an app (or even when
listening for if a user started installing - before they even did
anything), would ask for an apk from any repo. This is wrong, because we
should only ask for the apks from the swap repo when presented with a
swap dialog.

By fixing this so that it asks for a specific apk, this may also
fix the issue in #1086, because that was about us not asking for enough
info from the database for each Apk which was returned. Now we just
return all columns, because the performance overhead should be minimal,
but it prevents this class of bugs, where we didn't fully populate
our value object. However, I'm not confident that it is fixed, because I
was unable to reproduce it due to the other crash fixed in this change.

Relevant crash:

```
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.fdroid.fdroid.data.Apk.getUrl()' on a null object reference
  at org.fdroid.fdroid.views.swap.SwapAppsView$AppListAdapter$ViewHolder.setApp(SwapAppsView.java:311)
  at org.fdroid.fdroid.views.swap.SwapAppsView$AppListAdapter.bindView(SwapAppsView.java:422)
  at org.fdroid.fdroid.views.swap.SwapAppsView$AppListAdapter.newView(SwapAppsView.java:414)
  at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:269)
  at android.widget.AbsListView.obtainView(AbsListView.java:2349)
  at android.widget.ListView.makeAndAddView(ListView.java:1864)
  at android.widget.ListView.fillDown(ListView.java:698)
...
```
2017-08-01 11:59:41 +10:00
Hans-Christoph Steiner
a71eb243fa remove unused imports 2017-07-18 10:09:34 +02:00
Hans-Christoph Steiner
f30b73ed17 remove unused imports 2017-07-18 09:40:40 +02:00
Peter Serwylo
1bd9a73dbc Cache results of category-id query.
Each app insert required asking the database for the ID of each
category an app is in. Given the categories don't change (ever)
but are only appended to, we can cache the results in a static
Java variable for increased performance.

This reduced the "repo persister" logic for me from 50 seconds
for main F-Droid and 100 seconds for Archive, down to 15 seconds
and 30 seconds respectively.
2017-07-17 14:34:34 +10:00
Peter Serwylo
e26748e0e0 Remove now-unneccesary "update" code from repo updater.
Now that we need only "insert" new apps rather than"
 * Identify if an app exists
 * If so, update
 * If not, insert

There is much less code required for all of this stuff.
2017-07-17 14:33:16 +10:00
Peter Serwylo
5bde27daa8 Only copy the apps/apks for the current repo to temp tables.
When preparing a temp database to write to, don't copy all apps/apks.
Instead, only copy those _not_ belonging to the repo we are updating.
In an ideal world, we'd not even need to copy them, but we need
their IDs to be in the temp database so that we don't accidentally
use the same auto-generated ID as the main database.

This also means that we can drop the check for "does this app exist,
and hence should we UPDATE it instead of INSERTing it?" and always
just insert it.

Then, when copying the temp table back to disk, first delete all
apps/apks _belonging to the repo being updated_. Then, copy back the
apks/apps we found in the repo. This again improves performance because
we no longer need to bopy back and forth data which we know
wont change (as evidenced by the fact it belongs to a differen trepo).

I don't think this was possible earlier before we did the work to
support repo priorities properly. That is because we had a single app
which was serviced by several repositories. Now, we have multiple
entries in the `fdroid_app` table, for each repo which supports
that app.
2017-07-17 14:27:43 +10:00
Peter Serwylo
8c3441939f Pass through the ID of the repo being updated to the temp tables.
This will allow for more intelligent and efficient copying of data back
and forth from temp to persistent tables.
2017-07-17 12:45:55 +10:00
Peter Serwylo
e62f695a48 Force refresh of repos so that preferred signer is present.
It is a bit harsh to do this, but the rationale is explained in #1105.

Fixes #1105.
2017-07-12 17:12:46 +10:00
Peter Serwylo
2523134485 Add drop shadow to toolbar items in AppDetails.
This is so that feature images with white backgrounds to not completely
obscure the icons.

Fixes #1097.
2017-07-10 12:59:52 +10:00
Hans-Christoph Steiner
6c247e3201 Jackson gives us {"repo": {"mirrors": ["foo", "bar"] as ArrayList
I was optimistic and guessed it was a String[], since that's what is needed.

Found by @cde while working on #35
2017-07-07 18:06:49 +02:00
Hans-Christoph Steiner
2a7fe78483 split IndexV1Updater's repo saving into working code
RepoUpdater.prepareRepoDetailsForSaving() was broken here because the Repo
properties were being set before calling it, and then the Repo instance was
passed to it for comparison.  So the comparison was always saying the value
was unchanged.  In IndexV1Updater, the flow doesn't need those checks.

This also fixes the bug where added repos never had their name/description/
icon/etc show up in ManageRepos and RepoDetails.

@cde found this bug working on mirror support, thanks!

related to #35
closes #1016
2017-07-07 18:06:49 +02:00
Hans-Christoph Steiner
7dbf03c435 Apk.isMediaInstalled() needs to check using sanitized file names
The install process automatically sanitizes filenames to avoid exploits
that put attack code in the filename.  Media files are also installed using
this logic, so the installed check needs to use sanitized file names to be
accurate.
2017-07-07 17:09:14 +05:30
Hans-Christoph Steiner
c5a1b11315 allow spaces in file names
This will be more important as people work with media, since it is quite
common to use spaces in filenames generated by humans.  Media files will
not be built by fdroid, so most likely, they will have human-generated
names.
2017-07-07 12:10:52 +05:30
Hans-Christoph Steiner
06bcf75f9b put the faster check first in App.isInstalled()
A > is much faster than all the stuff that isMediaInstalled() has to do,
so put > first, so that if it is true, isMediaInstalled() is not executed.
2017-07-07 12:10:51 +05:30
Chirayu Desai
0d8b0c7fd4 Introduce FileInstaller, a way to handle media files from F-Droid
* This installer is invoked when for non-apk/media files, and
  copies them to an appropriate folder on the sdcard.
* We also introduce a FileInstallerActivity to ask for storage
  permissions at runtime, as needed by Android 6.0 and above,
  and handle the install/uninstall process.
* A toast is shown with the install path after installation.

TODO:
* Manage Installed Apps screen doesn't show media files.
2017-07-07 12:10:48 +05:30
Chirayu Desai
cbf3133e43 AppProvider: Use IS instead of = for suggestedApk calculation
* For non apk files, the signature column would be NULL always,
and in SQLite NULL = NULL is false, but NULL IS NULL is true.

See http://www.sqlite.org/lang_expr.html Operators
2017-07-07 11:41:02 +05:30
Hans-Christoph Steiner
8f680bc1aa Merge branch 'improve-updates-tab-stability' into 'master'
Refactor `AppListItemController` to improve updates tab stability

See merge request !549
2017-07-06 22:15:41 +00:00
Peter Serwylo
2fc8060a5d Check file size first before checking hash to save cycles. 2017-07-06 14:09:17 +10:00
Peter Serwylo
2a40e082e6 Don't try to notify the user for apks which are already installed.
If an app is downloaded into our cache, but an app with the same hash is
already installed, don't bother notifying people about it.

Extracted the logic for finding the path to an apk on disk (given a
PackageInfo object) to also be used by AppUpdateStatusSerice.

Change logging so that if we discard a downloaded file we Log.i instead
of Utils.debugLog. This is so that when debugging a release build we can
see what is happening, because this specific problem was easier to debug
with release builds (rather than setting up a custom fdroid repo).
2017-07-06 13:56:01 +10:00
Peter Serwylo
bf4b0d89a1 Ensure that the suggestedVersionCode is updated after [un]installing.
Previously, it was only done on repo update.

Now it is done whenever an app is installed or unisntalled. The query to
update the suggested version for each app is quite slow when run at the
end of a repo update. However in this change, we are limiting the query
to only update a single app, which means that performance should not be
a problem.
2017-07-06 09:22:23 +10:00
Peter Serwylo
677fd3a522 Use signature as well as version code in app details for suggested apk. 2017-07-06 09:22:23 +10:00
Peter Serwylo
41f85f3c9d Correctly check for 'suggestedApk' in app details.
Take into account the preferred/installed signature instead of just the
version code.
2017-07-06 09:22:23 +10:00
Peter Serwylo
caac895442 Add "preferredSigner" field to App.
At present, this is chosen from the first package in the index-v1
metadata.
2017-07-06 09:22:21 +10:00
Hans-Christoph Steiner
ba84bbb9ea reduce massive verbosity of org.fdroid.fdroid.data.AppProviderTest 2017-07-05 17:42:18 +02:00
Hans-Christoph Steiner
8ba7882a98 Merge branch 'issue-1054--index-v1-progress-via-broadcasts' into 'master'
Add progress reporting for index-v1 (using `LocalBroadcastManager`)

Closes #1054

See merge request !550
2017-07-05 15:41:33 +00:00
Hans-Christoph Steiner
b9277f52e7 Merge branch 'issue-938--feature-graphic-priority' into 'master'
Order apps in main screen by date, new, then presence of feature graphic

Closes #938

See merge request !555
2017-07-04 20:48:02 +00:00
Peter Serwylo
5b52835097 Order apps in main screen by date, new, then presence of feature graphic
This is a conservative fix. If we wanted to really highlight the
feature graphic functionality and reward upstream devs for keeping
metadata up to date, then we could also take apps which were recently
updated, and prioritise them over new apps if they have a feature
graphic.

Fixes #938.

Also fixed display of feature graphic in main screen by getting full
path to image, not the relative path (e.g. "en-US/featureGraphic.png").
2017-07-04 13:09:22 +10:00
Peter Serwylo
3d195c9dc0 Report progress correctly
Was previously sending an indeterminate progress event, when we actually knew
how long was remaining.
2017-07-03 15:41:08 +10:00
Peter Serwylo
b7a20bbf01 Remove one layer of indirection in LocalBraodcasts for updating repo.
This creates a hard dependence between `RepoUpdater` and
`UpdateService`. However this could be trivially extracted by moving the
helper methods from `UpdateService` to `RepoUpdater`, and making the
broadcasts more "repo updater" oriented. That would also require
changing the broadcasts which `UpdateService` listens for.
2017-07-03 15:41:05 +10:00
Peter Serwylo
df20d2df8d Add progress reporting for index-v1.
Reuses the "commiting" message to indicate how many apps have been
processed so far.

Refactors existing progress handling between `RepoUpdater` and
`UpdateService` to use `LocalBroadcastManager` in preference to
`ProgressListener`. Still needs to use `ProgressListener` to talk
between `RepoUpdater` and the `Downloader` +
`ProgressBufferedInputStream`.

The only change that is related to something more important than
notifications is the fact that now `IndexV1Updater` makes use of the
`indexUrl`. To do so, because it is final, the base class constructor
delegates to `getIndexUrl()` which is overriden by the v1 updater.
This is required because we want to differentiate between broadcasts
coming from different repo update processes.

Fixes #1054.
2017-07-03 09:31:48 +10:00
Peter Serwylo
b658c0b44e Don't show apps/categories after disabling repo.
This was setup to work correctly, but for two problems:

 * The `cursor.close()` in `CategoriesViewBinder` stops the cursor from
   being requeried when required.

 * The `AppProvider` was not notifying correctly after deleting apps
   belonging to a repo.

Fixes #1028.
2017-06-29 17:33:52 +10:00
Peter Serwylo
945c6f24e6 Formatting, comments, checkstyle.
Moved methods around so the class is more coherent when reading from top
to bottom.

Added some comments.

Formatted lines to be under 120 chars. No longer suppress line length checkstyle messages.
2017-06-29 11:33:42 +10:00
Peter Serwylo
427d7bcbfa Further refactor the AppListItemController for readability and predictability.
This breaks out subclasses for each specific type of app list item,
allowing for code reuse, but also letting the specific business logic
belonging to each different app list item to be separate.

This is particularly helpful in the following situation:

 * In the search results, it is great to be able to render "App
   downloaded, ready to install" in the same manner as the update tab.

 * In the installed app list, this is not desired. Indeed, the status
   text which should be shown should reference the currently installed
   version and whether the user has ignored any updates.

By separating the AppListItemController into subclasses, it reduced the
need to handle several different types of text view (e.g.
"installedStatus", "status", "ignoredStatus", "downloadReady"), and
replace them all with a "status" and "secondaryStatus" TextView. What is
displayed in status and secondaryStatus is up to the individual
subclasses of AppListItemController.
2017-06-29 11:14:57 +10:00
Peter Serwylo
ef230f749c Added "Successfully Installed" status text to updates tab.
Also:
 * Extracted common styles into `@Style/AppListItemStatusText`.
 * Fixed left margin on older devices (where `layout_marginStart` doesn't
   exist).
2017-06-28 17:29:54 +10:00
Peter Serwylo
d0cf621314 Refactor the AppListItemControler to be more predictable.
Previously, there were different pieces of business logic, invoked at
different times, which would touch subsets of the UI.

This change rips that out, and replaces it with a single place where the
UI is setup. This can always be called safely, and it will render the
correct data for the current state of the app (e.g. downloading, waiting
for install, etc).

The AppListItemState class is a dumb object which keeps track of what is
supposed to be displayed in the UI. The AppListItemController now
creates a different AppListItemState depending on what state the list
item is in. This AppListItemState is then used to bind the values of
each UI widget.

All of the binding code is now in the single `resetView()` method, but
all of the business logic for what the view should look like is
separated into different `getViewState*()` methods.

This separation should make it easier to make sense of the UI code, and
hopefully should be testable should somebody choose to write tests for
it in the future.
2017-06-28 17:08:16 +10:00
Hans-Christoph Steiner
61ab88f8ea Merge branch 'acra-fixes' into 'master'
ACRA fixes

Closes #1074

See merge request !544
2017-06-26 10:13:54 +00:00