aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java9
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java11
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java6
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java11
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java2
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml2
7 files changed, 27 insertions, 22 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java
index 4e68e76c5..4d2bc8593 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/CloudSearch.java
@@ -24,6 +24,9 @@ import java.net.Proxy;
import java.util.ArrayList;
import java.util.Vector;
+import android.support.annotation.NonNull;
+
+
/**
* Search two or more types of server for online keys.
*/
@@ -31,8 +34,8 @@ public class CloudSearch {
private final static long SECONDS = 1000;
- public static ArrayList<ImportKeysListEntry> search(final String query, Preferences.CloudSearchPrefs cloudPrefs,
- final Proxy proxy)
+ public static ArrayList<ImportKeysListEntry> search(
+ @NonNull final String query, Preferences.CloudSearchPrefs cloudPrefs, @NonNull final Proxy proxy)
throws Keyserver.CloudSearchFailureException {
final ArrayList<Keyserver> servers = new ArrayList<>();
@@ -68,7 +71,7 @@ public class CloudSearch {
// wait for either all the searches to come back, or 10 seconds. If using proxy, wait 30 seconds.
synchronized (results) {
try {
- if (proxy != null) {
+ if (proxy == Proxy.NO_PROXY) {
results.wait(30 * SECONDS);
} else {
results.wait(10 * SECONDS);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
index 3b52a0306..f05ff3836 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
@@ -46,6 +46,8 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import android.support.annotation.NonNull;
+
import de.measite.minidns.Client;
import de.measite.minidns.Question;
import de.measite.minidns.Record;
@@ -226,7 +228,7 @@ public class HkpKeyserver extends Keyserver {
return client;
}
- private String query(String request, Proxy proxy) throws QueryFailedException, HttpError {
+ private String query(String request, @NonNull Proxy proxy) throws QueryFailedException, HttpError {
try {
URL url = new URL(getUrlPrefix() + mHost + ":" + mPort + request);
Log.d(Constants.TAG, "hkp keyserver query: " + url + " Proxy: " + proxy);
@@ -243,7 +245,7 @@ public class HkpKeyserver extends Keyserver {
} catch (IOException e) {
Log.e(Constants.TAG, "IOException at HkpKeyserver", e);
throw new QueryFailedException("Keyserver '" + mHost + "' is unavailable. Check your Internet connection!" +
- (proxy == null ? "" : " Using proxy " + proxy));
+ (proxy == Proxy.NO_PROXY ? "" : " Using proxy " + proxy));
}
}
@@ -373,7 +375,7 @@ public class HkpKeyserver extends Keyserver {
}
@Override
- public String get(String keyIdHex, Proxy proxy) throws QueryFailedException {
+ public String get(String keyIdHex, @NonNull Proxy proxy) throws QueryFailedException {
String request = "/pks/lookup?op=get&options=mr&search=" + keyIdHex;
Log.d(Constants.TAG, "hkp keyserver get: " + request + " using Proxy: " + proxy);
String data;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java
index 89575338f..76223becc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java
@@ -133,7 +133,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
@NonNull
private ImportKeyResult serialKeyRingImport(Iterator<ParcelableKeyRing> entries, int num,
String keyServerUri, Progressable progressable,
- Proxy proxy) {
+ @NonNull Proxy proxy) {
if (progressable != null) {
progressable.setProgress(R.string.progress_importing, 0, 100);
}
@@ -197,8 +197,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
if (entry.mExpectedFingerprint != null) {
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, "0x" +
entry.mExpectedFingerprint.substring(24));
- data = keyServer.get("0x" + entry.mExpectedFingerprint, proxy)
- .getBytes();
+ data = keyServer.get("0x" + entry.mExpectedFingerprint, proxy).getBytes();
} else {
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, entry.mKeyIdHex);
data = keyServer.get(entry.mKeyIdHex, proxy).getBytes();
@@ -400,8 +399,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
return new ImportKeyResult(null,
RequiredInputParcel.createOrbotRequiredOperation(), cryptoInput);
}
- proxy = Preferences.getPreferences(mContext).getProxyPrefs().parcelableProxy
- .getProxy();
+ proxy = Preferences.getPreferences(mContext).getProxyPrefs().getProxy();
} else {
proxy = cryptoInput.getParcelableProxy().getProxy();
}
@@ -444,8 +442,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
ArrayList<ParcelableKeyRing> list = new ArrayList<>();
list.add(pkRing);
- return serialKeyRingImport(list.iterator(), 1, keyServer,
- ignoreProgressable, proxy);
+ return serialKeyRingImport(list.iterator(), 1, keyServer, ignoreProgressable, proxy);
}
};
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java
index d4bbaa9fd..836894f59 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/UploadOperation.java
@@ -95,10 +95,10 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
if (proxyIsTor) {
log.add(LogType.MSG_UPLOAD_PROXY_TOR, 1);
- } else if (proxy != null && proxy != Proxy.NO_PROXY) {
- log.add(LogType.MSG_UPLOAD_PROXY, 1, proxy.toString());
- } else {
+ } else if (proxy == Proxy.NO_PROXY) {
log.add(LogType.MSG_UPLOAD_PROXY_DIRECT, 1);
+ } else {
+ log.add(LogType.MSG_UPLOAD_PROXY, 1, proxy.toString());
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
index ade75f926..7e2328e99 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
@@ -17,13 +17,14 @@
package org.sufficientlysecure.keychain.util;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.Nullable;
import java.net.InetSocketAddress;
import java.net.Proxy;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+
/**
* used to simply transport java.net.Proxy objects created using InetSockets between services/activities
*/
@@ -48,10 +49,10 @@ public class ParcelableProxy implements Parcelable {
return new ParcelableProxy(null, -1, null);
}
- @Nullable
+ @NonNull
public Proxy getProxy() {
if (mProxyHost == null) {
- return null;
+ return Proxy.NO_PROXY;
}
/*
* InetSocketAddress.createUnresolved so we can use this method even in the main thread
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
index 32d98826d..559c5556f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
@@ -23,6 +23,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.sufficientlysecure.keychain.Constants;
@@ -325,6 +326,7 @@ public class Preferences {
else this.parcelableProxy = new ParcelableProxy(hostName, port, type);
}
+ @NonNull
public Proxy getProxy() {
return parcelableProxy.getProxy();
}
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index bc22237d7..d86022b54 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -1306,7 +1306,7 @@
<string name="msg_backup_success">"Backup operation successful"</string>
<string name="msg_upload">"Uploading public key"</string>
- <string name="msg_upload_proxy_direct">"Using proxy: none"</string>
+ <string name="msg_upload_proxy_direct">"Using proxy: None"</string>
<string name="msg_upload_proxy_tor">"Using proxy: TOR"</string>
<string name="msg_upload_proxy">"Using proxy: %s"</string>
<string name="msg_upload_server">"Server: %s"</string>
='n729' href='#n729'>729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116