804 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
2c2d8c868c monitor Wifi changes with BroadcastReceiver/Service
The local repo will need to both have current wifi settings in order to
send the correct IP address, SSID, etc.  Also, this could be used to handle
interrupted downloads and updates, but that is not included in this commit.

refs #3204 https://dev.guardianproject.info/issues/3204
2014-05-06 11:55:52 -04:00
Hans-Christoph Steiner
db0b106656 nanohttpd submodule for supporting local HTTP repos
This webserver is the core of the kerplapp swap local repo when used over
IP connections (WiFi).  It is the smallest Java webserver we could find. It
is included as a git submodule, but then only the actual source files that
are needed are included.  They are symlinked in src/.

The git repo used is the one that we submitted upstream as a pull request.
The pull request contains changes required to support https://.  It has not
yet been accepted, so we cannot yet use the official repo.  Once the pull
request is included, this should be switched to the latest release in the
official git repo.

https://github.com/eighthave/nanohttpd
https://github.com/NanoHttpd/nanohttpd/pull/107

refs #3204 https://dev.guardianproject.info/issues/3204
2014-05-06 11:55:51 -04:00
Hans-Christoph Steiner
a89e4143c0 QR Code image generation into AsyncTask to keep things snappy
Generating the QR Code image can take some time, so do it in an AsyncTask
which then updates the ImageView once the QRCode is complete.  This will be
used for the kerplapp repo swapping process.

refs #3204 https://dev.guardianproject.info/issues/3204
refs #3201 https://dev.guardianproject.info/issues/3201
2014-05-05 19:38:40 -04:00
Hans-Christoph Steiner
3caec653e5 generate QR Codes internally based on ZXing's core.jar
This app needs to be able to generate QR Codes regardless of what other
app might be installed, so zxing's core.jar needs to be embedded in this
app.

This also includes two classes which are modified versions of ZXing classes
that allow the generation of QR Codes without the Barcode Scanner app being
installed:
https://stackoverflow.com/questions/4782543/integration-zxing-library-directly-into-my-android-application

The classes are src/com/google/zxing/encode/Contents.java which is a copy
of zxing/android/src/com/google/zxing/client/android/Contents.java; and
src/com/google/zxing/encode/QRCodeEncoder.java which is a heavily stripped
and modified version of
zxing/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java

refs #3204 https://dev.guardianproject.info/issues/3204
refs #2470 https://dev.guardianproject.info/issues/2470
2014-05-05 19:37:37 -04:00
Hans-Christoph Steiner
049cd56215 if it is not possible to make the sharing Uri, return a placeholder
The receiver of this can at least make some sense of it, versus null or a
blank string.  This prevents crashes where FDroid.repo.address is not yet
set since the wifi was never enabled or it does not have an IP address yet.
2014-05-05 19:37:37 -04:00
Hans-Christoph Steiner
1d1c682c2c fix crash when adding a repo without a fingerprint via URL/QR Code 2014-05-05 19:31:52 -04:00
Hans-Christoph Steiner
3701d7864a remove old https:// certificate pin for guardianproject.info
This secret key is no longer valid since the server was vulnerable to
Heartbleed.  Also fixed the formatting to be standard while I was at it.
2014-05-02 11:36:08 -04:00
Hans-Christoph Steiner
b8cffa6744 add extra checks when running Utils.calcFingerprint()
These provide a sanity check when calculating a fingerprint from a X.509
certificate stored as `repo.pubkey`.
2014-05-01 13:32:49 -04:00
Daniel Martí
a9495cd907 Merge branch 'master' of https://gitlab.com/eighthave/fdroidclient 2014-05-01 18:46:59 +02:00
Daniel Martí
253c880595 Hard-code number of UIL threads to 4
Making them dependant on the number of processors doesn't make much sense...
2014-05-01 18:45:43 +02:00
Hans-Christoph Steiner
57435aa6b6 catch IllegalArgumentException when dialog disappears before dismiss
It seems that sometimes checking dialog.isShowing() is not enough. I got a
crash on dialog.dismiss().  But since the dialog is already gone in that
case, just catch the Exception and move on. Here's the stacktrace:

 31760                 FDroid  D  Update took 45 seconds.
 31760                 FDroid  D  Invalidating preference 'lastUpdateCheck'.
 31760         AndroidRuntime  D  Shutting down VM
 31760         AndroidRuntime  E  FATAL EXCEPTION: main
 31760         AndroidRuntime  E  java.lang.IllegalArgumentException: View not attached to window manager
 31760         AndroidRuntime  E  at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:378)
 31760         AndroidRuntime  E  at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:223)
 31760         AndroidRuntime  E  at android.view.Window$LocalWindowManager.removeView(Window.java:432)
 31760         AndroidRuntime  E  at android.app.Dialog.dismissDialog(Dialog.java:278)
 31760         AndroidRuntime  E  at android.app.Dialog.access$000(Dialog.java:71)
 31760         AndroidRuntime  E  at android.app.Dialog$1.run(Dialog.java:111)
 31760         AndroidRuntime  E  at android.app.Dialog.dismiss(Dialog.java:268)
 31760         AndroidRuntime  E  at org.fdroid.fdroid.UpdateService$UpdateReceiver.onReceiveResult(UpdateService.java:124)
 31760         AndroidRuntime  E  at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:43)
 31760         AndroidRuntime  E  at android.os.Handler.handleCallback(Handler.java:587)
 31760         AndroidRuntime  E  at android.os.Handler.dispatchMessage(Handler.java:92)
 31760         AndroidRuntime  E  at android.os.Looper.loop(Looper.java:130)
 31760         AndroidRuntime  E  at android.app.ActivityThread.main(ActivityThread.java:3687)
 31760         AndroidRuntime  E  at java.lang.reflect.Method.invokeNative(Native Method)
 31760         AndroidRuntime  E  at java.lang.reflect.Method.invoke(Method.java:507)
 31760         AndroidRuntime  E  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
 31760         AndroidRuntime  E  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
 31760         AndroidRuntime  E  at dalvik.system.NativeStart.main(Native Method)
  119                          E  Dumpstate > /data/log/dumpstate_app_error
  119         ActivityManager  W  Force finishing activity org.fdroid.fdroid/.views.RepoDetailsActivity

more info:
https://stackoverflow.com/questions/19538282/view-not-attached-to-window-manager-dialog-dismiss
2014-05-01 12:44:01 -04:00
Hans-Christoph Steiner
615bcfb666 try to find ManageRepo's Fragment before recreating it
This helps with dealing with listFragment being null after a rotation. That
was happening when an Intent was coming in from a QR Code scanner, and
the screen was rotated during the process.  This snippet was taken from
SearchResults.java

This is Peter Serwylo's idea, I just typed it up and tested it :)
2014-05-01 12:44:01 -04:00
Hans-Christoph Steiner
8395472f8d test index.jar signature checking
I got scared by seeing the Android docs' version of JarFile.getInputStream,
which didn't mention SecurityException or the signature checking. But it
seems that even tho its not in the Android docs, Android implements it the
same as Java does.  It is good to have these tests in place anyhow, since
this is an essential piece of the security process of FDroid.

* http://docs.oracle.com/javase/6/docs/api/java/util/jar/JarFile.html#getInputStream(java.util.zip.ZipEntry)
* https://developer.android.com/reference/java/util/jar/JarFile.html#getInputStream(java.util.zip.ZipEntry)

refs #2627 https://dev.guardianproject.info/issues/2627
refs #2959 https://dev.guardianproject.info/issues/2959
2014-05-01 12:44:01 -04:00
Daniel Martí
d80eec031c Re-enable loading of icons with fling
Reduce their thread priority to try to avoid it from lagging the scrolling
2014-05-01 16:03:56 +02:00
Daniel Martí
fbf9d4b409 Merge branch 'fix/update-notification' into 'master'
Fix/update notification

In addition to making update notifications work again (fixing issue #20) I also removed an unused class, and made the update count easily accessible from the AppProvider.Helper class.
2014-04-30 23:10:35 +00:00
Peter Serwylo
826854592f Made app update notifications work again.
The update service now queries the app provider for installed
apps which can and want to be updated.
2014-05-01 07:05:14 +09:30
Peter Serwylo
3bca6d3f70 Merge branch 'package-broadcasts' into 'master'
Package broadcasts (fixes #19)
2014-04-30 20:05:04 +00:00
Daniel Martí
a0b39cd150 PREF_UPD_NOTIFY default is true, not false 2014-04-30 00:33:10 +02:00
Daniel Martí
663a95c7a9 Don't crash if a repo has zero apps/apks
Also, a couple of typo fixes
2014-04-29 23:56:06 +02:00
Daniel Martí
88285b0a6b Fix: Don't always use /icons/ due to wrong SQL param order 2014-04-29 20:06:56 +02:00
Daniel Martí
7a16bf4ce5 Fix broadcast receiving of package updates
* It is PACKAGE_REPLACED, not PACKAGE_CHANGED:
  http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_CHANGED

* REMOVED and then ADDED are fired as well as REPLACED when upgrading an
  application:
  http://stackoverflow.com/questions/5217237/package-removed-then-package-added-are-fired-along-with-package-replaced-inten
2014-04-29 18:18:38 +02:00
Dominik Schürmann
fb1e19e510 Merge branch 'super-fdroid' of gitlab.com:fdroid/fdroidclient into super-fdroid 2014-04-28 18:46:44 +02:00
Dominik Schürmann
033db01b9a Information about system permissions 2014-04-28 18:45:04 +02:00
Hans-Christoph Steiner
527f649fc2 move getSharingUri() to Utils for easier reuse
This method will also be used by the local repo for swapping.
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
4dc2c60863 add more checks on fingerprints fed to Utils.formatFingerprint()
This is the gateway to the user, so this should present trusted info!
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
cce393de09 "unverified" repo state for repos w/ fingerprints but not yet pubkeys
If a repo was configured with a fingerprint, but it has not yet updated and
gotten the pubkey from the index.jar, then it will be in an "unverified"
state, i.e. the signing key fingerprint is stored, but it has not yet been
used to check against the pubkey in the index.jar
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
a0970d0720 when adding a repo with fingerprint, make sure to store the pubkey
The logic here is crufty, so I slapped a flag in there to make sure that
the pubkey gets stored when someone configures a repo and includes the
fingerprint.  When the fingerprint is set, it will first download the
index.jar and verify it against that fingerprint.  The logic for storing
the pubkey permanently happens later in the XML parsing, so there needs to
be a flag to signal to store the pubkey in this case.

Before the flow was always index.xml -> get pubkey -> index.jar.  Really,
there should no longer be support for unsigned repos, then all of this
stuff can be dramatically simplified.

fixes #2924 https://dev.guardianproject.info/issues/2924
refs #2960 https://dev.guardianproject.info/issues/2960
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
649bfa10b7 fix silly bug in signing key fingerprint calculation for display
This was causing the first byte of the signature to be chopped off, so
therefore it would not validate since the fingerprint of the cert from
the net connection had the right fingerprint, but it was compared to the
stored, truncated version.

This also means that the database version needs to be bumped to trigger an
upgrade so that the bad 62 char fingerprints are removed from the database.
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
aa1b9e6696 allow incoming repos via Intent when on ManageRepo view
Since before, incoming repo Intents where handled in the Fragment's
onCreate(), an Intent that was received while the Fragment was visible was
just ignored.  Activities have onNewIntent() for that, but Fragments don't
so the repo Intent handling had to be moved to the ManageRepo Activity.
That makes for a more direct relationship anyway, since ManageRepo is what
is configured as receiving all those Intents in AndroidManifest.xml.
2014-04-28 11:59:36 -04:00
Daniel Martí
7d3723fe69 Remove EXTRA_NOT_UNKNOWN_SOURCE from DefaultInstaller
Doesn't work because:
* In this installer, we are not a system app
* Our intent action is of type ACTION_VIEW, not ACTION_INSTALL_PACKAGE

The equivalent of "we are not an unknown source" would be the other
installers, such as the Root and System ones.
2014-04-28 17:43:33 +02:00
Dominik Schürmann
53d9a15d11 Fix comment in CanUpdateAppsFragment 2014-04-27 22:30:49 +02:00
Dominik Schürmann
d7203535e7 Add update all button (no functionality yet) 2014-04-27 22:22:21 +02:00
Dominik Schürmann
b3ca915459 RootInstaller: multiple apks 2014-04-27 21:40:22 +02:00
Dominik Schürmann
2399f954ed Installer: Starting with better error handling, new callback design 2014-04-27 20:42:45 +02:00
Dominik Schürmann
fbc47c1428 Show dialog if root access was denied 2014-04-27 20:11:36 +02:00
Dominik Schürmann
36b269cd19 Clarify comment in prefs 2014-04-27 20:02:03 +02:00
Dominik Schürmann
c4e7e617b2 Add root access preference 2014-04-27 19:59:28 +02:00
Dominik Schürmann
7ed69c93fc Installation/Delete with root shell, add preference for root access, fixes to Installer classes 2014-04-27 18:56:47 +02:00
Dominik Schürmann
7451f00534 Refactoring old code using an abstract class 2014-04-26 02:01:26 +02:00
Daniel Martí
1f154adf42 Merge branch 'master' into super-fdroid
Conflicts:
	AndroidManifest.xml
	lint.xml
	src/org/fdroid/fdroid/AppDetails.java
2014-04-25 20:20:43 +02:00
Peter Serwylo
d287dca854 Refactored SearchView into Activity + ListFragment (Fixes #11)
This allowed for the use of LoaderCallbacks which seem like a better
way at managing the lifecycle of the cursors which our ContentProviders
return.
2014-04-25 18:21:49 +09:30
Peter Serwylo
71db322b6d Don't implement 'update' for installed apps, use replace (Fixes #14)
There were some weird edge cases that couldn't quite be pinned down,
whereby installing an app would result in a unique key violation being
hit. One example was when somebody was installing an apk from a file
manager. It seems that this doesn't trigger a PACKAGE_CHANGED, but
rather a PACKAGE_INSTALLED. The end result is that it attempts to insert
a record that already exists in the installed apps table. Because we
have a unique key constraing on the appId, it breaks.

This commit changes the way that we insert installed app details.
Instead of inserting some times, and updating other times, we always
insert. If we hit a unique key violation, the row is deleted, and then
the new values are reinserted.
2014-04-24 13:07:16 +09:30
Hans-Christoph Steiner
4a55cdf938 option to send via bluetooth any installed app on the AppDetails page
This takes the code used for sending the FDroid.apk and applies it to any
installed app.  So the user can go to the AppDetails for any installed app
and select "Send via Bluetooth" from the menu, and send the app to another
phone.
2014-04-22 11:09:49 -04:00
Hans-Christoph Steiner
0db711c08d enable sending installed APKs via NFC/Android Beam on AppDetails
If you are viewing the AppDetails screen for an installed app, this code
configures Android Beam to send the APK for that installed app if the you
initiate via NFC.

Also move the SDK checks into each method so that they are easier to use
without doing the wrong thing.
2014-04-22 11:09:49 -04:00
Daniel Martí
87775be76c Update UIL, adapt to the changes 2014-04-20 12:51:50 +02:00
Peter Serwylo
4e24050760 Adding our own cache of currently installed apks in the database.
Previously the data was not stored anywhere, and each time we wanted
to know about all installed apps, we built a ridiculously long SQL
query. The query had essentially one "OR" clause for each installed
app. To make matters worse, it also required one parameter for each
of these, so we could bind the installed app name to a "?" in the query.
SQL has a limit of (usually) 999 parameters which can be provided to
a query, which meant it would fall over if the user had more than
1000 apps installed.

This change introduces a new table called "fdroid_installedApps".
It is initialized on first run, by iterating over the installed apps
as given by the PackageManager. It is subsequenty kept up to date
by a set of BroadcastReceivers, which listen for apps being
uninstalled/installed/upgraded.

It also includes tests to verify that queries of installed apps,
when there are more than 1000 apps installed, don't break.

Finally, tests are also now able to to insert into providers other
than the one under test. This is due to the fact that the providers
often join onto tables managed by other providers.
2014-04-20 16:50:22 +09:30
Peter Serwylo
de085f7e02 Added ApkProvider.get() to return a single apk.
This allows you to specify the Uri of a single apk, and
it will return it. Right now it is just used in a test, but
hopefully it will be useful in other situations too.
I forgot to commit this last time, and didn't review my patch
well enough before submitting.
2014-04-12 19:02:15 +00:00
Daniel Martí
8ed76f47ee More improvements to the app list layout
* Don't use a RelativeLayout for the whole thing
* Use more external paddings, not per-element paddings
* Center everything vertically
2014-04-10 16:33:15 +02:00
Daniel Martí
e7f76705c8 Move "receiver" and "address" into UpdateService.EXTRA_... 2014-04-10 15:56:10 +02:00
Daniel Martí
f6707490f8 Move "from" into AppDetails.EXTRA_FROM 2014-04-10 15:52:11 +02:00