aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdithya Abraham Philip <adithyaphilip@gmail.com>2015-08-19 01:13:12 +0530
committerAdithya Abraham Philip <adithyaphilip@gmail.com>2015-08-20 21:02:29 +0530
commit0251f0e41695d3961dde553ba9ab76fa46583abb (patch)
tree2aa105658d112f1ac213dc106d87072a814bd2a2
parentf625a26bbd9e4e1049480028b7738ff4e37fd712 (diff)
downloadopen-keychain-0251f0e41695d3961dde553ba9ab76fa46583abb.tar.gz
open-keychain-0251f0e41695d3961dde553ba9ab76fa46583abb.tar.bz2
open-keychain-0251f0e41695d3961dde553ba9ab76fa46583abb.zip
introduced constants for keyserver sync, fixed sync issue
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java20
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java13
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java82
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java9
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java2
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml1
12 files changed, 77 insertions, 68 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
index be38c6dba..a244972fb 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
@@ -29,6 +29,7 @@ public final class Constants {
public static final boolean DEBUG = BuildConfig.DEBUG;
public static final boolean DEBUG_LOG_DB_QUERIES = false;
public static final boolean DEBUG_SYNC_REMOVE_CONTACTS = false;
+ public static final boolean DEBUG_KEYSERVER_SYNC = false;
public static final String TAG = DEBUG ? "Keychain D" : "Keychain";
@@ -126,7 +127,7 @@ public final class Constants {
public static final class Defaults {
public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, hkps://pgp.mit.edu";
- public static final int PREF_VERSION = 5;
+ public static final int PREF_VERSION = 6;
}
public static final class key {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
index 1d6de260d..311ef2d3b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java
@@ -23,12 +23,10 @@ import android.app.Application;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
-import android.os.Bundle;
import android.os.Environment;
import android.provider.ContactsContract;
import android.widget.Toast;
@@ -36,7 +34,7 @@ import android.widget.Toast;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
-import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
import org.sufficientlysecure.keychain.ui.ConsolidateDialogActivity;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.util.Log;
@@ -45,7 +43,6 @@ import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.util.TlsHelper;
import java.security.Security;
-import java.util.Arrays;
import java.util.HashMap;
@@ -99,7 +96,7 @@ public class KeychainApplication extends Application {
setupAccountAsNeeded(this);
// Update keyserver list as needed
- Preferences.getPreferences(this).upgradePreferences();
+ Preferences.getPreferences(this).upgradePreferences(this);
TlsHelper.addStaticCA("pool.sks-keyservers.net", getAssets(), "sks-keyservers.netCA.cer");
@@ -151,18 +148,7 @@ public class KeychainApplication extends Application {
// for contact sync
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
- // for keyserver sync
- ContentResolver.setIsSyncable(account, Constants.PROVIDER_AUTHORITY, 1);
- ContentResolver.setSyncAutomatically(account, Constants.PROVIDER_AUTHORITY,
- true);
- // TODO: Increase periodic update time after testing
- Log.e("PHILIP", "enabled periodic keyserversync");
- ContentResolver.addPeriodicSync(
- new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE),
- Constants.PROVIDER_AUTHORITY,
- new Bundle(),
- 60
- );
+ KeyserverSyncAdapterService.enableKeyserverSync(context);
} else {
Log.e(Constants.TAG, "Adding account failed!");
}
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 5aac05712..558b8ce7d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
@@ -360,7 +360,7 @@ public class HkpKeyserver extends Keyserver {
try {
data = query(request, proxy);
} catch (HttpError httpError) {
- Log.e(Constants.TAG, "Failed to get key at HkpKeyserver", httpError);
+ Log.d(Constants.TAG, "Failed to get key at HkpKeyserver", httpError);
throw new QueryFailedException("not found");
}
Matcher matcher = PgpHelper.PGP_PUBLIC_KEY.matcher(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 bde161db7..4b991ddda 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportOperation.java
@@ -232,7 +232,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3);
}
} catch (Keyserver.QueryFailedException e) {
- Log.e(Constants.TAG, "query failed", e);
+ Log.d(Constants.TAG, "query failed", e);
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3, e.getMessage());
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java
index 9aceb946c..975cf541a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java
@@ -93,13 +93,13 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
log.add(OperationResult.LogType.MSG_REVOKE_OK, 1);
return new RevokeResult(RevokeResult.RESULT_OK, log, masterKeyId);
} else {
- log.add(OperationResult.LogType.MSG_REVOKE_KEY_FAIL, 1);
+ log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1);
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
}
} catch (PgpKeyNotFoundException | ProviderHelper.NotFoundException e) {
Log.e(Constants.TAG, "could not find key to revoke", e);
- log.add(OperationResult.LogType.MSG_REVOKE_KEY_FAIL, 1);
+ log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1);
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
index d498bd9a1..5ac1e89bb 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
@@ -763,10 +763,9 @@ public abstract class OperationResult implements Parcelable {
MSG_DEL_FAIL (LogLevel.WARN, R.plurals.msg_del_fail),
MSG_REVOKE_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_revoke_error_empty),
- MSG_REVOKE_ERROR_MULTI_SECRET (LogLevel.DEBUG, R.string.msg_revoke_error_multi_secret),
- MSG_REVOKE_ERROR_NOT_FOUND (LogLevel.DEBUG, R.string.msg_revoke_error_multi_secret),
+ MSG_REVOKE_ERROR_NOT_FOUND (LogLevel.ERROR, R.string.msg_revoke_error_not_found),
MSG_REVOKE (LogLevel.DEBUG, R.string.msg_revoke_key),
- MSG_REVOKE_KEY_FAIL (LogLevel.ERROR, R.string.msg_revoke_key_fail),
+ MSG_REVOKE_ERROR_KEY_FAIL (LogLevel.ERROR, R.string.msg_revoke_key_fail),
MSG_REVOKE_OK (LogLevel.OK, R.string.msg_revoke_ok),
// keybase verification
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
index e8eea6831..cbb71276c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -700,20 +700,14 @@ public class ProviderHelper {
new String[]{"" + masterKeyId},
null
);
- ContentValues lastUpdatedEntry = null;
if (lastUpdatedCursor.moveToNext()) {
- lastUpdatedEntry = new ContentValues(2);
+ // there was an entry to re-insert
+ // this operation must happen after the new key is inserted
+ ContentValues lastUpdatedEntry = new ContentValues(2);
lastUpdatedEntry.put(UpdatedKeys.MASTER_KEY_ID,
lastUpdatedCursor.getLong(INDEX_MASTER_KEY_ID));
lastUpdatedEntry.put(UpdatedKeys.LAST_UPDATED,
lastUpdatedCursor.getLong(INDEX_LAST_UPDATED));
- Log.e("PHILIP", "cv: " + lastUpdatedEntry + " actual: " + masterKeyId);
- }
- lastUpdatedCursor.close();
-
- if (lastUpdatedEntry != null) {
- // there was an entry to re-insert
- // this operation must happen after the new key is inserted
operations.add(
ContentProviderOperation
.newInsert(UpdatedKeys.CONTENT_URI)
@@ -721,6 +715,7 @@ public class ProviderHelper {
.build()
);
}
+ lastUpdatedCursor.close();
try {
// delete old version of this keyRing, which also deletes all keys and userIds on cascade
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
index 7688b9252..b36d23775 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ContactSyncAdapterService.java
@@ -45,7 +45,7 @@ public class ContactSyncAdapterService extends Service {
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
final SyncResult syncResult) {
- Log.d(Constants.TAG, "Performing a sync!");
+ Log.d(Constants.TAG, "Performing a contact sync!");
// TODO: Import is currently disabled for 2.8, until we implement proper origin management
// importDone.set(false);
// KeychainApplication.setupAccountAsNeeded(ContactSyncAdapterService.this);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java
index baf649701..3243df1a8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeyserverSyncAdapterService.java
@@ -1,6 +1,7 @@
package org.sufficientlysecure.keychain.service;
import android.accounts.Account;
+import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
@@ -25,6 +26,7 @@ import android.os.Messenger;
import android.os.PowerManager;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
+import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
@@ -50,6 +52,20 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class KeyserverSyncAdapterService extends Service {
+ // how often a sync should be initiated, in s
+ public static final long SYNC_INTERVAL =
+ Constants.DEBUG_KEYSERVER_SYNC
+ ? TimeUnit.MINUTES.toSeconds(2) : TimeUnit.DAYS.toSeconds(3);
+ // time since last update after which a key should be updated again, in s
+ public static final long KEY_UPDATE_LIMIT =
+ Constants.DEBUG_KEYSERVER_SYNC ? 1 : TimeUnit.DAYS.toSeconds(7);
+ // time by which a sync is postponed in case of a
+ public static final long SYNC_POSTPONE_TIME =
+ Constants.DEBUG_KEYSERVER_SYNC ? 30 * 1000 : TimeUnit.MINUTES.toMillis(5);
+ // Time taken by Orbot before a new circuit is created
+ public static final int ORBOT_CIRCUIT_TIMEOUT = (int) TimeUnit.MINUTES.toMillis(10);
+
+
private static final String ACTION_IGNORE_TOR = "ignore_tor";
private static final String ACTION_UPDATE_ALL = "update_all";
private static final String ACTION_SYNC_NOW = "sync_now";
@@ -61,8 +77,6 @@ public class KeyserverSyncAdapterService extends Service {
@Override
public int onStartCommand(final Intent intent, int flags, final int startId) {
- Log.e("PHILIP", "Sync adapter service starting" + intent.getAction());
-
switch (intent.getAction()) {
case ACTION_CANCEL: {
mCancelled.set(true);
@@ -103,7 +117,6 @@ public class KeyserverSyncAdapterService extends Service {
public void handleMessage(Message msg) {
switch (msg.what) {
case OrbotRequiredDialogActivity.MESSAGE_ORBOT_STARTED: {
- Log.e("PHILIP", "orbot activity returned");
asyncKeyUpdate(KeyserverSyncAdapterService.this,
new CryptoInputParcel());
break;
@@ -177,10 +190,8 @@ public class KeyserverSyncAdapterService extends Service {
private void handleUpdateResult(ImportKeyResult result) {
if (result.isPending()) {
- Log.e(Constants.TAG, "Keyserver sync pending result: "
- + result.getRequiredInputParcel().mType);
// result is pending due to Orbot not being started
- // try to start it silently, if disabled show notificationaa
+ // try to start it silently, if disabled show notifications
new OrbotHelper.SilentStartManager() {
@Override
protected void onOrbotStarted() {
@@ -199,7 +210,8 @@ public class KeyserverSyncAdapterService extends Service {
}
}.startOrbotAndListen(this, false);
} else if (isUpdateCancelled()) {
- Log.d(Constants.TAG, "Keyserver sync cancelled");
+ Log.d(Constants.TAG, "Keyserver sync cancelled, postponing by" + SYNC_POSTPONE_TIME
+ + "ms");
postponeSync();
} else {
Log.d(Constants.TAG, "Keyserver sync completed: Updated: " + result.mUpdatedKeys
@@ -216,14 +228,13 @@ public class KeyserverSyncAdapterService extends Service {
PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(
AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime() + 30 * 1000,
+ SystemClock.elapsedRealtime() + SYNC_POSTPONE_TIME,
pi
);
}
private void asyncKeyUpdate(final Context context,
final CryptoInputParcel cryptoInputParcel) {
- Log.e("PHILIP", "async key update starting");
new Thread(new Runnable() {
@Override
public void run() {
@@ -234,7 +245,7 @@ public class KeyserverSyncAdapterService extends Service {
}
private synchronized ImportKeyResult updateKeysFromKeyserver(final Context context,
- final CryptoInputParcel cryptoInputParcel) {
+ final CryptoInputParcel cryptoInputParcel) {
mCancelled.set(false);
ArrayList<ParcelableKeyRing> keyList = getKeysToUpdate(context);
@@ -278,10 +289,6 @@ public class KeyserverSyncAdapterService extends Service {
private ImportKeyResult staggeredUpdate(Context context, ArrayList<ParcelableKeyRing> keyList,
CryptoInputParcel cryptoInputParcel) {
Log.d(Constants.TAG, "Starting staggered update");
- // assuming maxCircuitDirtiness is 10min in Tor
- // final int MAX_CIRCUIT_DIRTINESS = (int) TimeUnit.MINUTES.toSeconds(10);
- // TODO: PHILIP remove after testing
- final int MAX_CIRCUIT_DIRTINESS = (int) TimeUnit.MINUTES.toSeconds(1);
// final int WEEK_IN_SECONDS = (int) TimeUnit.DAYS.toSeconds(7);
final int WEEK_IN_SECONDS = 0;
ImportOperation.KeyImportAccumulator accumulator
@@ -289,10 +296,10 @@ public class KeyserverSyncAdapterService extends Service {
for (ParcelableKeyRing keyRing : keyList) {
int waitTime;
int staggeredTime = new Random().nextInt(1 + 2 * (WEEK_IN_SECONDS / keyList.size()));
- if (staggeredTime >= MAX_CIRCUIT_DIRTINESS) {
+ if (staggeredTime >= ORBOT_CIRCUIT_TIMEOUT) {
waitTime = staggeredTime;
} else {
- waitTime = MAX_CIRCUIT_DIRTINESS + new Random().nextInt(MAX_CIRCUIT_DIRTINESS);
+ waitTime = ORBOT_CIRCUIT_TIMEOUT + new Random().nextInt(ORBOT_CIRCUIT_TIMEOUT);
}
Log.d(Constants.TAG, "Updating key with fingerprint " + keyRing.mExpectedFingerprint +
" with a wait time of " + waitTime + "s");
@@ -342,18 +349,14 @@ public class KeyserverSyncAdapterService extends Service {
final int INDEX_LAST_UPDATED = 1;
// all time in seconds not milliseconds
- // TODO: PHILIP correct TIME_MAX after testing
- // final long TIME_MAX = TimeUnit.DAYS.toSeconds(7);
- final long TIME_MAX = 1;
final long CURRENT_TIME = GregorianCalendar.getInstance().getTimeInMillis() / 1000;
- Log.e("PHILIP", "week: " + TIME_MAX + " current: " + CURRENT_TIME);
Cursor updatedKeysCursor = context.getContentResolver().query(
KeychainContract.UpdatedKeys.CONTENT_URI,
new String[]{
KeychainContract.UpdatedKeys.MASTER_KEY_ID,
KeychainContract.UpdatedKeys.LAST_UPDATED
},
- "? - " + KeychainContract.UpdatedKeys.LAST_UPDATED + " < " + TIME_MAX,
+ "? - " + KeychainContract.UpdatedKeys.LAST_UPDATED + " < " + KEY_UPDATE_LIMIT,
new String[]{"" + CURRENT_TIME},
null
);
@@ -361,7 +364,7 @@ public class KeyserverSyncAdapterService extends Service {
ArrayList<Long> ignoreMasterKeyIds = new ArrayList<>();
while (updatedKeysCursor.moveToNext()) {
long masterKeyId = updatedKeysCursor.getLong(INDEX_UPDATED_KEYS_MASTER_KEY_ID);
- Log.d(Constants.TAG, "Keyserver sync: {" + masterKeyId + "} last updated at {"
+ Log.d(Constants.TAG, "Keyserver sync: Ignoring {" + masterKeyId + "} last updated at {"
+ updatedKeysCursor.getLong(INDEX_LAST_UPDATED) + "}s");
ignoreMasterKeyIds.add(masterKeyId);
}
@@ -391,6 +394,7 @@ public class KeyserverSyncAdapterService extends Service {
if (ignoreMasterKeyIds.contains(keyId)) {
continue;
}
+ Log.d(Constants.TAG, "Keyserver sync: Updating {" + keyId + "}");
String fingerprint = KeyFormattingUtils
.convertFingerprintToHex(keyCursor.getBlob(INDEX_FINGERPRINT));
String hexKeyId = KeyFormattingUtils
@@ -420,13 +424,6 @@ public class KeyserverSyncAdapterService extends Service {
context.startService(intent);
}
- // TODO: PHILIP remove!
- @Override
- public void onDestroy() {
- Log.e("PHILIP", "onDestroy");
- super.onDestroy();
- }
-
private Notification getOrbotNoification(Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.ic_stat_notify_24dp)
@@ -467,6 +464,33 @@ public class KeyserverSyncAdapterService extends Service {
return builder.build();
}
+ public static void enableKeyserverSync(Context context) {
+ try {
+ AccountManager manager = AccountManager.get(context);
+ Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
+
+ Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
+ if (accounts.length == 0) {
+ if (!manager.addAccountExplicitly(account, null, null)) {
+ Log.e(Constants.TAG, "Adding account failed!");
+ }
+ }
+ // for keyserver sync
+ ContentResolver.setIsSyncable(account, Constants.PROVIDER_AUTHORITY, 1);
+ ContentResolver.setSyncAutomatically(account, Constants.PROVIDER_AUTHORITY,
+ true);
+ ContentResolver.addPeriodicSync(
+ account,
+ Constants.PROVIDER_AUTHORITY,
+ new Bundle(),
+ SYNC_INTERVAL
+ );
+ } catch (SecurityException e) {
+ Log.e(Constants.TAG, "SecurityException when adding the account", e);
+ Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
+ }
+ }
+
// from de.azapps.mirakel.helper.Helpers from https://github.com/MirakelX/mirakel-android
private Bitmap getBitmap(int resId, Context context) {
int mLargeIconWidth = (int) context.getResources().getDimension(
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 0596b0079..370511c4f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
@@ -26,6 +26,7 @@ import android.preference.PreferenceManager;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Constants.Pref;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
import java.net.Proxy;
import java.util.ArrayList;
@@ -306,7 +307,7 @@ public class Preferences {
return new ProxyPrefs(true, false, Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT,
Constants.Orbot.PROXY_TYPE);
} else if (useNormalProxy) {
- return new ProxyPrefs(useTor, useNormalProxy, getProxyHost(), getProxyPort(), getProxyType());
+ return new ProxyPrefs(false, true, getProxyHost(), getProxyPort(), getProxyType());
} else {
return new ProxyPrefs(false, false, null, -1, null);
}
@@ -356,7 +357,7 @@ public class Preferences {
}
}
- public void upgradePreferences() {
+ public void upgradePreferences(Context context) {
if (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0) !=
Constants.Defaults.PREF_VERSION) {
switch (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0)) {
@@ -394,6 +395,10 @@ public class Preferences {
}
// fall through
case 5: {
+ KeyserverSyncAdapterService.enableKeyserverSync(context);
+ }
+ // fall through
+ case 6: {
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
index 6305d2033..d85ad9128 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
@@ -409,7 +409,7 @@ public class OrbotHelper {
private ProgressDialog mProgressDialog;
public void startOrbotAndListen(final Context context, final boolean showProgress) {
- Log.e("PHILIP", "starting orbot listener");
+ Log.d(Constants.TAG, "starting orbot listener");
if (showProgress) {
showProgressDialog(context);
}
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 2d9b22852..643f41004 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -1314,7 +1314,6 @@
</plurals>
<string name="msg_revoke_error_empty">"Nothing to revoke!"</string>
- <string name="msg_revoke_error_multi_secret">"Secret keys can only be revoked individually!"</string>
<string name="msg_revoke_error_not_found">"Cannot find key to revoke!"</string>
<string name="msg_revoke_key">"Revoking key %s"</string>
<string name="msg_revoke_key_fail">"Failed revoking key"</string>