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