From af509e431e50bfae6f4911531fbc49d89a5cdadd Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 11 Apr 2018 11:24:11 +0200 Subject: [PATCH 1/5] reformat localrepo code in using Android Studio Ctrl-Alt-L --- .../localrepo/CacheSwapAppsService.java | 1 - .../fdroid/localrepo/LocalRepoKeyStore.java | 21 ++++---- .../fdroid/localrepo/LocalRepoManager.java | 1 - .../fdroid/fdroid/localrepo/SwapService.java | 48 ++++++++++--------- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/CacheSwapAppsService.java b/app/src/main/java/org/fdroid/fdroid/localrepo/CacheSwapAppsService.java index 9e6313554..885c8bee2 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/CacheSwapAppsService.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/CacheSwapAppsService.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; - import org.apache.commons.io.FileUtils; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Utils; diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java index 70d0834ea..8706a5aea 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoKeyStore.java @@ -2,7 +2,7 @@ package org.fdroid.fdroid.localrepo; import android.content.Context; import android.util.Log; - +import kellinwood.security.zipsigner.ZipSigner; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Utils; import org.spongycastle.asn1.ASN1Sequence; @@ -19,6 +19,9 @@ import org.spongycastle.operator.ContentSigner; import org.spongycastle.operator.OperatorCreationException; import org.spongycastle.operator.jcajce.JcaContentSignerBuilder; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.X509KeyManager; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -46,12 +49,6 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.X509KeyManager; - -import kellinwood.security.zipsigner.ZipSigner; - // TODO Address exception handling in a uniform way throughout @SuppressWarnings("LineLength") @@ -162,8 +159,8 @@ public final class LocalRepoKeyStore { KeyManager defaultKeyManager = keyManagerFactory.getKeyManagers()[0]; KeyManager wrappedKeyManager = new KerplappKeyManager( (X509KeyManager) defaultKeyManager); - keyManagers = new KeyManager[] { - wrappedKeyManager, + keyManagers = new KeyManager[]{ + wrappedKeyManager, }; } catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException | CertificateException | OperatorCreationException | IOException e) { Log.e(TAG, "Error loading keystore", e); @@ -254,7 +251,7 @@ public final class LocalRepoKeyStore { private void addToStore(String alias, KeyPair kp, Certificate cert) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException { Certificate[] chain = { - cert, + cert, }; keyStore.setKeyEntry(alias, kp.getPrivate(), "".toCharArray(), chain); @@ -272,8 +269,8 @@ public final class LocalRepoKeyStore { keyManagerFactory.init(keyStore, "".toCharArray()); KeyManager defaultKeyManager = keyManagerFactory.getKeyManagers()[0]; KeyManager wrappedKeyManager = new KerplappKeyManager((X509KeyManager) defaultKeyManager); - keyManagers = new KeyManager[] { - wrappedKeyManager, + keyManagers = new KeyManager[]{ + wrappedKeyManager, }; } diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java index 5e6f3736f..f7b05fe70 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java @@ -14,7 +14,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; import android.util.Log; - import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Hasher; import org.fdroid.fdroid.Preferences; diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/SwapService.java b/app/src/main/java/org/fdroid/fdroid/localrepo/SwapService.java index b3099cfb5..6f8060b9d 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/SwapService.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/SwapService.java @@ -20,7 +20,6 @@ import android.support.v4.app.NotificationCompat; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; import android.util.Log; - import org.apache.http.HttpHost; import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; @@ -42,6 +41,10 @@ import org.fdroid.fdroid.localrepo.type.SwapType; import org.fdroid.fdroid.localrepo.type.WifiSwap; import org.fdroid.fdroid.net.WifiStateChangeService; import org.fdroid.fdroid.views.swap.SwapWorkflowActivity; +import rx.Observable; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -56,11 +59,6 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; -import rx.Observable; -import rx.Subscription; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - /** * Central service which manages all of the different moving parts of swap which are required * to enable p2p swapping of apps. @@ -115,10 +113,10 @@ public class SwapService extends Service { * Call {@link Observable#subscribe()} on this in order to be notified of peers * which are found. Call {@link Subscription#unsubscribe()} on the resulting * subscription when finished and you no longer want to scan for peers. - * + *

* The returned object will scan for peers on a background thread, and emit * found peers on the mian thread. - * + *

* Invoking this in multiple places will return the same, cached, peer finder. * That is, if in the past it already found some peers, then you subscribe * to it in the future, the future subscriber will still receive the peers @@ -129,9 +127,9 @@ public class SwapService extends Service { Utils.debugLog(TAG, "Scanning for nearby devices to swap with..."); if (peerFinder == null) { peerFinder = PeerFinder.createObservable(getApplicationContext()) - .subscribeOn(Schedulers.newThread()) - .observeOn(AndroidSchedulers.mainThread()) - .distinct(); + .subscribeOn(Schedulers.newThread()) + .observeOn(AndroidSchedulers.mainThread()) + .distinct(); } return peerFinder; } @@ -141,14 +139,14 @@ public class SwapService extends Service { // ("Step" refers to the current view being shown in the UI) // ========================================================== - public static final int STEP_INTRO = 1; - public static final int STEP_SELECT_APPS = 2; - public static final int STEP_JOIN_WIFI = 3; - public static final int STEP_SHOW_NFC = 4; - public static final int STEP_WIFI_QR = 5; - public static final int STEP_CONNECTING = 6; - public static final int STEP_SUCCESS = 7; - public static final int STEP_CONFIRM_SWAP = 8; + public static final int STEP_INTRO = 1; + public static final int STEP_SELECT_APPS = 2; + public static final int STEP_JOIN_WIFI = 3; + public static final int STEP_SHOW_NFC = 4; + public static final int STEP_WIFI_QR = 5; + public static final int STEP_CONNECTING = 6; + public static final int STEP_SUCCESS = 7; + public static final int STEP_CONFIRM_SWAP = 8; /** * Special view, that we don't really want to actually store against the @@ -158,7 +156,8 @@ public class SwapService extends Service { */ public static final int STEP_INITIAL_LOADING = 9; - @SwapStep private int step = STEP_INTRO; + @SwapStep + private int step = STEP_INTRO; /** * Current screen that the swap process is up to. @@ -174,7 +173,8 @@ public class SwapService extends Service { return this; } - @NonNull public Set getAppsToSwap() { + @NonNull + public Set getAppsToSwap() { return appsToSwap; } @@ -299,9 +299,10 @@ public class SwapService extends Service { * This is the same as, e.g. {@link Context#getSystemService(String)} */ @IntDef({STEP_INTRO, STEP_SELECT_APPS, STEP_JOIN_WIFI, STEP_SHOW_NFC, STEP_WIFI_QR, - STEP_CONNECTING, STEP_SUCCESS, STEP_CONFIRM_SWAP, STEP_INITIAL_LOADING}) + STEP_CONNECTING, STEP_SUCCESS, STEP_CONFIRM_SWAP, STEP_INITIAL_LOADING}) @Retention(RetentionPolicy.SOURCE) - public @interface SwapStep { } + public @interface SwapStep { + } // ================================================= // Have selected a specific peer to swap with @@ -340,6 +341,7 @@ public class SwapService extends Service { * which is only available in API >= 11. * Package names are reverse-DNS-style, so they should only have alpha numeric values. Thus, * this uses a comma as the separator. + * * @see SwapService#deserializePackages(String) */ private static String serializePackages(Set packages) { From 1e6fb13ebc2ae507e8afab7e5095f71bfb16be33 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 10 Apr 2018 12:07:37 +0200 Subject: [PATCH 2/5] register to receive gitlab nightly URLs They have one more path segment than the others, e.g.: https://gitlab.com/fdroid/fdroidclient-nightly/raw/master/fdroid/repo --- app/src/main/AndroidManifest.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bb851b750..2e9d78a04 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -471,6 +471,8 @@ + + @@ -479,6 +481,8 @@ + +