aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-04-04 13:18:43 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-04-04 13:18:43 +0200
commit1b38a5b2e398ed25019b9a44d62e30e0118ff6e5 (patch)
tree909f523f67bc474fd19601a37b56ce5d7f8fac30 /OpenPGP-Keychain-API
parenta9f868a5e74e2c540d0b71d69560b780c7e16a06 (diff)
parentb06f142c5046618d97737d3f7f482ca7198f24e4 (diff)
downloadopen-keychain-1b38a5b2e398ed25019b9a44d62e30e0118ff6e5.tar.gz
open-keychain-1b38a5b2e398ed25019b9a44d62e30e0118ff6e5.tar.bz2
open-keychain-1b38a5b2e398ed25019b9a44d62e30e0118ff6e5.zip
Merge remote-tracking branch 'origin/master' into db-overhaul
Diffstat (limited to 'OpenPGP-Keychain-API')
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml4
-rw-r--r--OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java40
2 files changed, 37 insertions, 7 deletions
diff --git a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
index 74bc88708..d62c26495 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.sufficientlysecure.keychain.demo"
- android:versionCode="3"
- android:versionName="2">
+ android:versionCode="4"
+ android:versionName="3">
<uses-sdk
android:minSdkVersion="9"
diff --git a/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java
index c80656c52..0395a7bc5 100644
--- a/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java
+++ b/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java
@@ -25,34 +25,64 @@ import android.content.ServiceConnection;
import android.os.IBinder;
public class OpenPgpServiceConnection {
+
+ // interface to create callbacks for onServiceConnected
+ public interface OnBound {
+ public void onBound(IOpenPgpService service);
+ }
+
private Context mApplicationContext;
- private boolean mBound;
private IOpenPgpService mService;
private String mProviderPackageName;
+ private OnBound mOnBoundListener;
+
+ /**
+ * Create new OpenPgpServiceConnection
+ *
+ * @param context
+ * @param providerPackageName specify package name of OpenPGP provider,
+ * e.g., "org.sufficientlysecure.keychain"
+ */
public OpenPgpServiceConnection(Context context, String providerPackageName) {
this.mApplicationContext = context.getApplicationContext();
this.mProviderPackageName = providerPackageName;
}
+ /**
+ * Create new OpenPgpServiceConnection
+ *
+ * @param context
+ * @param providerPackageName specify package name of OpenPGP provider,
+ * e.g., "org.sufficientlysecure.keychain"
+ * @param onBoundListener callback, executed when connection to service has been established
+ */
+ public OpenPgpServiceConnection(Context context, String providerPackageName,
+ OnBound onBoundListener) {
+ this.mApplicationContext = context.getApplicationContext();
+ this.mProviderPackageName = providerPackageName;
+ this.mOnBoundListener = onBoundListener;
+ }
+
public IOpenPgpService getService() {
return mService;
}
public boolean isBound() {
- return mBound;
+ return (mService != null);
}
private ServiceConnection mServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IOpenPgpService.Stub.asInterface(service);
- mBound = true;
+ if (mOnBoundListener != null) {
+ mOnBoundListener.onBound(mService);
+ }
}
public void onServiceDisconnected(ComponentName name) {
mService = null;
- mBound = false;
}
};
@@ -63,7 +93,7 @@ public class OpenPgpServiceConnection {
*/
public boolean bindToService() {
// if not already bound...
- if (mService == null && !mBound) {
+ if (mService == null) {
try {
Intent serviceIntent = new Intent();
serviceIntent.setAction(IOpenPgpService.class.getName());