880 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
544b924ab9 copy org.fdroid.fdroid.localrepo.LocalRepoKeystore from Kerplapp
This is the keystore used for both the index.jar signing key and the key
and certificate needed to support HTTPS connections.

https://github.com/guardianproject/Kerplapp

refs #3380 https://dev.guardianproject.info/issues/3380
2014-05-25 22:53:18 -04:00
Hans-Christoph Steiner
b0c27869b6 new tricks to improve mDNS/Bonjour resolution
Before, it didn't seem to find anything unless I ran this on my laptop:
`avahi-browse -a -v`

So added two recommended practices from other jmdns code for Android:

* force full resolution on receiving serviceAdded()
* feed the WiFi's IP address to jmdns when creating an instance

fixes #3379 https://dev.guardianproject.info/issues/3379
2014-05-25 22:53:18 -04:00
Peter Serwylo
b2c63c6dc7 More robust multi-threaded downloading.
ApkDownloaders keep track of a unique id. This id is passed through with
each event coming from the downloader. When progress events are received,
if they don't have the same id as the current downloader, they are ignored.

When returning to the app details screen after leaving, if a download
completed in the mean time, automatically show the install screen. Otherwise,
when you, e.g. return to your devices home screen during a download, the
download keeps occuring in the background, but we are unable to make use of
the resulting downloaded file.
2014-05-24 08:42:49 +09:30
Peter Serwylo
009c8a6be5 Don't show progress in AppDetails when using a cached download.
The ApkDownloader now returns true or false depending on whether it
is using a cached version on disk, or hitting the network.
I was also a little more defensive about checking for if downloadHandler
is null before deciding to show a progress dialog.
2014-05-24 07:20:41 +09:30
Peter Serwylo
2f7d6f6452 Made constructor of ApkDownloader public.
Previously it was in the org.fdroid.fdroid package, along with
most other things. As such, it only need a package-local constructor.
However, now it has moved to the .net subpackage, and needs to be
made public.
2014-05-24 07:20:41 +09:30
Peter Serwylo
d9e5b07054 Removed unneeded todo's, add docs. 2014-05-24 07:20:41 +09:30
Peter Serwylo
75586ec4e5 Moved ApkDownloader to .net package
This is where it belongs, along with the other downloader code.
2014-05-24 07:20:41 +09:30
Peter Serwylo
1e1be1e73b Support orientation changes during app download.
Keep track of the downloader after an orientation change, and
make sure that there is always UI feedback beeing shown.

Removed resetRequired after merge conflict (the content observer
now deals with this for us in a much nicer way).

Conflicts:
	src/org/fdroid/fdroid/AppDetails.java
2014-05-24 07:20:41 +09:30
Peter Serwylo
11ddf0478c Better handling of cancelling of downloads.
One thing that still annoys me is that indeterminate progress dialog
still shows "0/100" due to the number formatter being used to display
the values in the TextView. Solution (from http://stackoverflow.com/a/6784180)
is to either make a custom dialog, or at the very least, in API 11 or higher
we can set the number formatter to display nothing.

Don't show the full download path of repo.
The full path includes the path to the index.jar, as well as ?clientVersion=*.
This is undesirable, the main purpose of even showing where we are downloading
from is to differentiate between multiple repos being updated at once.
2014-05-24 07:20:40 +09:30
Peter Serwylo
3ed2cde207 Added AsyncDownloadWrapper and used it in AppDetails to download apks.
This has a very different interface to the Downloader class, because
a handful of operations need to be run off the main thread (not just
download, but also totalDownloadSize and perhaps cache tag related
stuff). The AsyncDownloadWrapper provides its own listener, more
specific than just the progress listener, which invokes functions
at different points in time (e.g. download failed, completed, cancelled).

Refactored progress events to use string types instead of ints.
This way, it is less likely that two different events from
different processes will clash with each other.

Conflicts:
	src/org/fdroid/fdroid/AppDetails.java
2014-05-24 07:20:40 +09:30
Peter Serwylo
0e0e042cd0 Change DownloadHandler from using runOnUiThread() to send/handleMessage().
It still executes the download on another thread, and receives progress
events on that thread. However it now posts those events to the main UI
thread for them to get handled.

Also refactored Downloader/HttpDownloader a tad further. Some caching
stuff was pushed down from HttpDownloader -> Downloader (renamed from
eTag to just cacheTag). HttpDownloader.download() was recursively calling
itself, so I made the base class download() method abstract, and instead
the stream downloading is done in "protected void downloadFromStream()"

Other minor stuff:
 * Prefixed some log TAGs with package names, to make them easier to grep.
 * Removed a little bit of unused code (parameter to DownloadHandler).
2014-05-24 07:20:40 +09:30
Hans-Christoph Steiner
91f2f1014e SKETCH - DOES NOT WORK: move HTTP code into HttpDownloader
This is the beginning of moving to a Downloader class and subclasses that
are used everywhere for downloading APKs, indexes, and icons.

I think that the ETag value can probably be used everywhere as the
unique ID for testing whether to download content, so I moved that to the
super class Downloader. But that's just a guess as of now...
2014-05-24 07:20:40 +09:30
Hans-Christoph Steiner
084a048740 ApkDownloader: rename remoteFile() to getRemoteAddress()
Since it doesn't return a java.io.File but a String with the remote address
2014-05-24 07:20:40 +09:30
Peter Serwylo
19e722a9d7 wire up ProgressListener to new ApkDownloader structure
Conflicts:
	src/org/fdroid/fdroid/AppDetails.java
2014-05-24 07:20:40 +09:30
Hans-Christoph Steiner
9588f30778 normalize null checks for ProgressListeners
This removes the RepoUpdater.isInteractive() method to normalize the code
used to check whether a ProgressListener is null throughout the project.
2014-05-24 07:20:40 +09:30
Hans-Christoph Steiner
d9f9b682d4 simplify ProgressListener.Event creation and use
This aims to simplify the creation and use of Event objects among classes
that implement the ProgressListener Interface.  This is also needed in
order to split out the downloading support from various places and put it
all into a centralized

refs #2598 https://dev.guardianproject.info/issues/2598
https://gitorious.org/f-droid/fdroidclient/merge_requests/29
2014-05-24 07:20:39 +09:30
Peter Serwylo
a44ce0e4e7 Rough guess at what ApkDownloader refactor could look like. 2014-05-24 07:20:39 +09:30
Hans-Christoph Steiner
c4b0eb9b51 .Downloader --> .ApkDownloader to distinguish from .net.Downloader
org.fdroid.froid.Downloader is only used for downloading APKs, so name it
appropriately.

refs #2598 https://dev.guardianproject.info/issues/2598
2014-05-24 07:20:39 +09:30
Peter Serwylo
2c80f1a758 Split net.Downloader into abstract Downloader and concrete HttpDownloader.
This will allow the more general, non HTTP related stuff (progress events,
stream copying) to occur in a separate base class. HTTP specific stuff
(HTTP status codes, etag cache checking) is done in the HTTPDownloader
base class.
2014-05-24 07:20:39 +09:30
Hans-Christoph Steiner
8ebce69d5d use mDNS TXT records to detect FDroid repos, path, etc.
FDroid repos are advertised via Bonjour as plain HTTP or HTTPS services,
since they are browseable with a standard Web Browser. The "Find Local
Repos" browser in FDroid should only show FDroid repos, not any website,
so that is detected using a "type" TXT record in the FDroid broadcasts.
2014-05-20 18:44:47 -04:00
Hans-Christoph Steiner
30ecc1c9f6 use MulticastLock for better Bonjour/mDNS performance
Multicast transmission is subject to heavy power management on Android,
because it apparently can be a battery drain.  mDNS/Bonjour is based
entirely on multicast, so in order to have good Bonjour performance, there
needs to be good multicast performance.  MulticastLock provides that.

fixes #3381 https://dev.guardianproject.info/issues/3381
2014-05-20 18:44:47 -04:00
Hans-Christoph Steiner
f2994b0764 replace Android NSD browsing with jmdns
Android's NSD is only included in Android >= 16, and seems to be buggy. So
This replaces the NSD code entirely with jmdns, which works on all Android
versions.

fixes #2900 https://dev.guardianproject.info/issues/2900
fixes #3379 https://dev.guardianproject.info/issues/3379
2014-05-20 18:44:47 -04:00
Hans-Christoph Steiner
b5f7c0a481 preference for the "name" of the local repo
This name is used in the RepoList, the local repo website title, the
Bonjour broadcast, etc.  By default, a name is generated using the make and
model of the phone plus a random number.
2014-05-20 18:44:47 -04:00
Hans-Christoph Steiner
248cefe1f3 fix notification launching LocalRepoActivity
It was not working on my Nexus 7 running stock 4.4.2.  This seems to be the
recommend fix:
https://code.google.com/p/android/issues/detail?id=61850
2014-05-20 18:44:47 -04:00
Hans-Christoph Steiner
d25a395936 broadcast local repo via Bonjour/mDNS to enable auto-discovery
This adds support for registering the local repo with Bonjour/mDNS so that
it is broadcast out to all devices on the local network.  This makes it
easy to discover and add local repos on the same wifi.

refs #2900 https://dev.guardianproject.info/issues/2900
2014-05-20 18:37:45 -04:00
Hans-Christoph Steiner
7ca966be05 in local repo, make relative links to the index.html page
This should make the local repo files portable, like if the app gets
moved to the SD card or things like that.
2014-05-20 18:37:44 -04:00
Hans-Christoph Steiner
8a6204205f store "Add Repo" AlertDialog to prevent crash on rotation
When the "Add Repo" dialog was showing and the screen was rotated, it would
first leak the AlertDialog because it was not dismissed, then it would
crash after rotation, because the AlertDialog was trying to be restored but
no longer existed.  That's what I think was happening at least... the
solution surprised me a bit here...
2014-05-15 11:46:17 -04:00
Hans-Christoph Steiner
09cbd036fa make new instances of LocalRepoActivity show state properly
LocalRepoActivity needs to get the current state of the LocalRepoService so
it can correctly represent it in the UI.

fixes #25 https://gitlab.com/fdroid/fdroidclient/issues/25
2014-05-15 09:37:37 -04:00
Hans-Christoph Steiner
776ad3f540 use only android-14 items in SelectLocalApps until appcompat-v7 is added
Set android-14 as minimum for SelectLocalApps and make sure that everything
will work on >= 14.

fixes #26 https://gitlab.com/fdroid/fdroidclient/issues/26
2014-05-15 09:37:37 -04:00
Dominik Schürmann
acd3137cbc Make prefs coherent, rename them, and rename SystemPermissionInstaller to SystemInstaller 2014-05-12 18:59:03 +02:00
Dominik Schürmann
2bd686dfe8 Add preference to opt-out of SystemPermissionInstaller 2014-05-12 12:55:17 +02:00
Dominik Schürmann
c65a25524c Log errors 2014-05-12 11:45:26 +02:00
Dominik Schürmann
54ce7a07a6 Cleanup for getActivityInstaller 2014-05-12 11:31:25 +02:00
Dominik Schürmann
91ddc838a7 More cleanup in installer classes 2014-05-11 11:16:26 +02:00
Dominik Schürmann
aeae0bcec3 Code/doc cleanup 2014-05-11 11:13:16 +02:00
Dominik Schürmann
6710e9a4b9 dont show update all button for now... 2014-05-11 02:31:53 +02:00
Dominik Schürmann
6419915d5a Strings for error dialog, cleanup 2014-05-11 02:25:50 +02:00
Dominik Schürmann
df696ed81e Installer: define all methods as abstract that need to be implemented in subclasses 2014-05-11 02:13:27 +02:00
Dominik Schürmann
04577d213c Use ContentObserver to observe install status 2014-05-11 01:38:17 +02:00
Dominik Schürmann
919f9c63b8 Merge master into super-fdroid 2014-05-11 00:38:53 +02:00
Dominik Schürmann
d250ac727b Cleanup installer code 2014-05-11 00:36:54 +02:00
Dominik Schürmann
e1d9e0f3b1 Document installer callback hack 2014-05-11 00:26:31 +02:00
Dominik Schürmann
c48dcdc785 Change callback 2014-05-11 00:03:26 +02:00
Dominik Schürmann
0887da72ed Add default installer for Android >= 4.0 2014-05-10 19:46:46 +02:00
Hans-Christoph Steiner
efacc22c10 include app icons in the SelectLocalApps view
Since we have the packageName, we can just fetch the Drawables directly.
This uses some shortcuts to try to make things run faster.  For example,
the ImageView does not have an ID, instead it is references by the index
number within the LinearLayout.
2014-05-08 00:58:42 -04:00
Hans-Christoph Steiner
107eab5eac Local Repo webserver turns itself off if it was automatically started
When you visit LocalRepoActivity, the swapping webserver is automatically
turned on, since it is required for any swapping to happen.  When it was
automatically turned on, it will automatically turn itself off after 15
minutes to make sure that it doesn't stay running forever.  If the user
manually turns it off, that cancels the automatic stop.
2014-05-08 00:58:42 -04:00
Hans-Christoph Steiner
16399b760b start the local repo webserver by default when going to LocalRepoActivity
To make it dead simple to swap repos when going to the Local Repos screen.
2014-05-08 00:58:42 -04:00
Hans-Christoph Steiner
2256cd00e1 start/stop Local Repo from any Activity
This forces the use of the Application's Context, so we can be sure the
webserver will run as long as FDroid is running.  It also checks to make
sure whether the webserver is running before trying to start it.
2014-05-08 00:58:42 -04:00
Hans-Christoph Steiner
7401366ac9 quick improvement of LocalRepoActivity layout
This is meant to try to make the on/off state of the webserver that serves
the local repo more apparent.
2014-05-08 00:58:42 -04:00
Hans-Christoph Steiner
8d3d325967 apply light/dark theme to all Local Repo related Activities 2014-05-07 21:55:37 -04:00