aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-08 19:24:47 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-08 19:24:47 +0200
commit8123fd69255d3dda04311aea83f4c2735edd4ec5 (patch)
treefa84337f96b1bf2438d3b9d298974a238aacb7f1 /OpenPGP-Keychain/src/org/sufficientlysecure
parent11103623c5e2508153a7f3d0c3f521b2768c0387 (diff)
downloadopen-keychain-8123fd69255d3dda04311aea83f4c2735edd4ec5.tar.gz
open-keychain-8123fd69255d3dda04311aea83f4c2735edd4ec5.tar.bz2
open-keychain-8123fd69255d3dda04311aea83f4c2735edd4ec5.zip
lock thread for user input
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java22
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java3
2 files changed, 19 insertions, 6 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
index 687da8a86..1a43b49c1 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -57,10 +57,12 @@ public class CryptoService extends Service {
// just one pool of 4 threads, pause on every user action needed
final ArrayBlockingQueue<Runnable> mPoolQueue = new ArrayBlockingQueue<Runnable>(20);
- // TODO: ? only one pool, -> one thread at a time
- PausableThreadPoolExecutor mThreadPool = new PausableThreadPoolExecutor(1, 1, 10,
+ // TODO: Are these parameters okay?
+ PausableThreadPoolExecutor mThreadPool = new PausableThreadPoolExecutor(2, 4, 10,
TimeUnit.SECONDS, mPoolQueue);
+ final Object userInputLock = new Object();
+
public static final String ACTION_SERVICE_ACTIVITY = "org.sufficientlysecure.keychain.crypto_provider.IServiceActivityCallback";
@Override
@@ -425,11 +427,15 @@ public class CryptoService extends Service {
public void onCachedPassphrase(boolean success) throws RemoteException {
Log.d(Constants.TAG, "current therad id: " + Thread.currentThread().getId());
mThreadPool.resume();
+
+ synchronized (userInputLock) {
+ userInputLock.notifyAll();
+ }
}
@Override
public void onSelectedPublicKeys(long[] keyIds) throws RemoteException {
- // TODO Auto-generated method stub
+ mThreadPool.resume();
}
@@ -536,6 +542,14 @@ public class CryptoService extends Service {
intent.putExtras(extras);
}
getApplication().startActivity(intent);
- }
+ // lock current thread for user input
+ synchronized (userInputLock) {
+ try {
+ userInputLock.wait();
+ } catch (InterruptedException e) {
+ Log.e(Constants.TAG, "CryptoService", e);
+ }
+ }
+ }
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
index 2ea3f530a..482f79728 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
@@ -268,15 +268,14 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity", e);
}
- finish();
} else {
try {
mServiceCallback.onCachedPassphrase(false);
} catch (RemoteException e) {
Log.e(Constants.TAG, "ServiceActivity", e);
}
- finish();
}
+ finish();
}
};