Merge branch 'master' of github.com:open-keychain/open-keychain

This commit is contained in:
Vincent Breitmoser 2014-08-21 00:02:33 +02:00
commit ad9339b23d
6 changed files with 71 additions and 41 deletions

View File

@ -8,6 +8,7 @@
* New icons to show status of key (by Brennan Novak) * New icons to show status of key (by Brennan Novak)
* Important bug fix: Importing of large key collections from a file is now possible * Important bug fix: Importing of large key collections from a file is now possible
* Notification showing cached passphrases * Notification showing cached passphrases
* Keys are connected to Android's contacts
This release wouldn't be possible without the work of Vincent Breitmoser (GSoC 2014), mar-v-in (GSoC 2014), Daniel Albert, Art O Cathain, Daniel Haß, Tim Bray, Thialfihar This release wouldn't be possible without the work of Vincent Breitmoser (GSoC 2014), mar-v-in (GSoC 2014), Daniel Albert, Art O Cathain, Daniel Haß, Tim Bray, Thialfihar

View File

@ -20,11 +20,13 @@ package org.sufficientlysecure.keychain;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.app.Application; import android.app.Application;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Environment; import android.os.Environment;
import android.provider.ContactsContract;
import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.helper.Preferences;
@ -112,8 +114,10 @@ public class KeychainApplication extends Application {
AccountManager manager = AccountManager.get(context); AccountManager manager = AccountManager.get(context);
Account[] accounts = manager.getAccountsByType(Constants.PACKAGE_NAME); Account[] accounts = manager.getAccountsByType(Constants.PACKAGE_NAME);
if (accounts == null || accounts.length == 0) { if (accounts == null || accounts.length == 0) {
Account dummy = new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME); Account account = new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME);
manager.addAccountExplicitly(dummy, null, null); manager.addAccountExplicitly(account, null, null);
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
} }
} }

View File

@ -21,6 +21,8 @@ import android.accounts.Account;
import android.app.Service; import android.app.Service;
import android.content.AbstractThreadedSyncAdapter; import android.content.AbstractThreadedSyncAdapter;
import android.content.ContentProviderClient; import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SyncResult; import android.content.SyncResult;
import android.os.Bundle; import android.os.Bundle;
@ -29,9 +31,11 @@ import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.provider.ContactsContract;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.KeychainApplication; import org.sufficientlysecure.keychain.KeychainApplication;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ContactHelper; import org.sufficientlysecure.keychain.helper.ContactHelper;
import org.sufficientlysecure.keychain.helper.EmailKeyHelper; import org.sufficientlysecure.keychain.helper.EmailKeyHelper;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -42,7 +46,7 @@ public class ContactSyncAdapterService extends Service {
private class ContactSyncAdapter extends AbstractThreadedSyncAdapter { private class ContactSyncAdapter extends AbstractThreadedSyncAdapter {
private final AtomicBoolean importDone = new AtomicBoolean(false); // private final AtomicBoolean importDone = new AtomicBoolean(false);
public ContactSyncAdapter() { public ContactSyncAdapter() {
super(ContactSyncAdapterService.this, true); super(ContactSyncAdapterService.this, true);
@ -51,47 +55,59 @@ public class ContactSyncAdapterService extends Service {
@Override @Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
final SyncResult syncResult) { final SyncResult syncResult) {
importDone.set(false); Log.d(Constants.TAG, "Performing a sync!");
KeychainApplication.setupAccountAsNeeded(ContactSyncAdapterService.this); // TODO: Import is currently disabled for 2.8, until we implement proper origin management
EmailKeyHelper.importContacts(getContext(), new Messenger(new Handler(Looper.getMainLooper(), // importDone.set(false);
new Handler.Callback() { // KeychainApplication.setupAccountAsNeeded(ContactSyncAdapterService.this);
@Override // EmailKeyHelper.importContacts(getContext(), new Messenger(new Handler(Looper.getMainLooper(),
public boolean handleMessage(Message msg) { // new Handler.Callback() {
Bundle data = msg.getData(); // @Override
switch (msg.arg1) { // public boolean handleMessage(Message msg) {
case KeychainIntentServiceHandler.MESSAGE_OKAY: // Bundle data = msg.getData();
Log.d(Constants.TAG, "Syncing... Done."); // switch (msg.arg1) {
synchronized (importDone) { // case KeychainIntentServiceHandler.MESSAGE_OKAY:
importDone.set(true); // Log.d(Constants.TAG, "Syncing... Done.");
importDone.notifyAll(); // synchronized (importDone) {
} // importDone.set(true);
return true; // importDone.notifyAll();
case KeychainIntentServiceHandler.MESSAGE_UPDATE_PROGRESS: // }
if (data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS) && // return true;
data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS_MAX)) { // case KeychainIntentServiceHandler.MESSAGE_UPDATE_PROGRESS:
Log.d(Constants.TAG, "Syncing... Progress: " + // if (data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS) &&
data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS) + "/" + // data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS_MAX)) {
data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS_MAX)); // Log.d(Constants.TAG, "Syncing... Progress: " +
return false; // data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS) + "/" +
} // data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS_MAX));
default: // return false;
Log.d(Constants.TAG, "Syncing... " + msg.toString()); // }
return false; // default:
} // Log.d(Constants.TAG, "Syncing... " + msg.toString());
} // return false;
}))); // }
synchronized (importDone) { // }
try { // })));
if (!importDone.get()) importDone.wait(); // synchronized (importDone) {
} catch (InterruptedException e) { // try {
Log.w(Constants.TAG, e); // if (!importDone.get()) importDone.wait();
return; // } catch (InterruptedException e) {
} // Log.w(Constants.TAG, e);
} // return;
// }
// }
ContactHelper.writeKeysToContacts(ContactSyncAdapterService.this); ContactHelper.writeKeysToContacts(ContactSyncAdapterService.this);
} }
} }
public static void requestSync(Context context) {
Bundle extras = new Bundle();
// no need to wait for internet connection!
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
ContentResolver.requestSync(
new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME),
ContactsContract.AUTHORITY,
extras);
}
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
return new ContactSyncAdapter().getSyncAdapterBinder(); return new ContactSyncAdapter().getSyncAdapterBinder();

View File

@ -454,6 +454,9 @@ public class KeychainIntentService extends IntentService
setProgress(R.string.progress_done, 100, 100); setProgress(R.string.progress_done, 100, 100);
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
/* Output */ /* Output */
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, saveResult);
} catch (Exception e) { } catch (Exception e) {
@ -502,6 +505,8 @@ public class KeychainIntentService extends IntentService
if (result.mSecret > 0) { if (result.mSecret > 0) {
providerHelper.consolidateDatabaseStep1(this); providerHelper.consolidateDatabaseStep1(this);
} }
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
} catch (Exception e) { } catch (Exception e) {
@ -709,6 +714,9 @@ public class KeychainIntentService extends IntentService
} }
if (success) { if (success) {
// make sure new data is synced into contacts
ContactSyncAdapterService.requestSync(this);
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY);
} }

View File

@ -16,6 +16,7 @@ And don't add newlines before or after p tags because of transifex -->
<li>New icons to show status of key (by Brennan Novak)</li> <li>New icons to show status of key (by Brennan Novak)</li>
<li>Important bug fix: Importing of large key collections from a file is now possible</li> <li>Important bug fix: Importing of large key collections from a file is now possible</li>
<li>Notification showing cached passphrases</li> <li>Notification showing cached passphrases</li>
<li>Keys are connected to Android's contacts</li>
</ul> </ul>
<p>This release wouldn't be possible without the work of Vincent Breitmoser (GSoC 2014), mar-v-in (GSoC 2014), Daniel Albert, Art O Cathain, Daniel Haß, Tim Bray, Thialfihar</p> <p>This release wouldn't be possible without the work of Vincent Breitmoser (GSoC 2014), mar-v-in (GSoC 2014), Daniel Albert, Art O Cathain, Daniel Haß, Tim Bray, Thialfihar</p>

View File

@ -722,7 +722,7 @@
<string name="label_user_id">Identity</string> <string name="label_user_id">Identity</string>
<string name="unknown_uid">&lt;unknown&gt;</string> <string name="unknown_uid">&lt;unknown&gt;</string>
<string name="empty_certs">No certificates for this key</string> <string name="empty_certs">No certificates for this key</string>
<string name="certs_text">Only certificates created with your keys and self-certificates are displayed here.</string> <string name="certs_text">Only self-certificates and certificates created with your keys are displayed here.</string>
<string name="section_uids_to_certify">Identities to certify</string> <string name="section_uids_to_certify">Identities to certify</string>
<string name="label_revocation">Revocation Reason</string> <string name="label_revocation">Revocation Reason</string>
<string name="label_verify_status">Verification Status</string> <string name="label_verify_status">Verification Status</string>