aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-07-25 16:25:20 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-07-25 16:25:20 +0200
commit7cca7b1ffa416a354c08e1cb6b5776ae55fc19ab (patch)
treec5200b200a5f8624f553992c5897ffef7732e79c /OpenPGP-Keychain/src
parent14350679d1ef17fe1add86b1ec1def99f9a8f0cc (diff)
downloadopen-keychain-7cca7b1ffa416a354c08e1cb6b5776ae55fc19ab.tar.gz
open-keychain-7cca7b1ffa416a354c08e1cb6b5776ae55fc19ab.tar.bz2
open-keychain-7cca7b1ffa416a354c08e1cb6b5776ae55fc19ab.zip
Redifine Service callbacks
Diffstat (limited to 'OpenPGP-Keychain/src')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java2
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java6
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl8
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java50
4 files changed, 45 insertions, 21 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
index e3aa0ed49..3f12a5e8b 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
@@ -19,7 +19,7 @@ public class CryptoConsumersActivity extends SherlockFragmentActivity {
mActionBar = getSupportActionBar();
- setContentView(R.layout.crypto_consumers_activity);
+ setContentView(R.layout.crypto_consumer_list_activity);
mActionBar.setDisplayShowTitleEnabled(true);
mActionBar.setDisplayHomeAsUpEnabled(true);
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 c7d40d376..71b78ee01 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -263,7 +263,7 @@ public class CryptoService extends Service {
private final IServiceActivityCallback.Stub mBinderServiceActivity = new IServiceActivityCallback.Stub() {
@Override
- public void register(boolean success, String packageName) throws RemoteException {
+ public void onRegistered(boolean success, String packageName) throws RemoteException {
if (success) {
// resume threads
@@ -280,7 +280,7 @@ public class CryptoService extends Service {
}
@Override
- public void cachePassphrase(boolean success, String passphrase) throws RemoteException {
+ public void onCachedPassphrase(boolean success) throws RemoteException {
}
@@ -355,8 +355,6 @@ public class CryptoService extends Service {
Log.d(Constants.TAG, "starting activity...");
Intent intent = new Intent(getBaseContext(), ServiceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- // intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setAction(action);
if (extras != null) {
intent.putExtras(extras);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
index 871560cc8..e9949e1ae 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
@@ -19,10 +19,8 @@ package org.sufficientlysecure.keychain.remote_api;
interface IServiceActivityCallback {
+ oneway void onRegistered(in boolean success, in String packageName);
- oneway void register(in boolean success, in String packageName);
-
- oneway void cachePassphrase(in boolean success, in String passphrase);
-
-
+ oneway void onCachedPassphrase(in boolean success);
+
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
index 055de9be1..981568944 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
@@ -16,6 +16,8 @@
package org.sufficientlysecure.keychain.remote_api;
+import java.util.ArrayList;
+
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.remote_api.IServiceActivityCallback;
@@ -35,30 +37,32 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
+import android.os.RemoteException;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.LinearLayout;
public class ServiceActivity extends SherlockFragmentActivity {
- public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.REGISTER";
- public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.CRYPTO_CACHE_PASSPHRASE";
+ public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.remote_api.REGISTER";
+ public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.remote_api.CRYPTO_CACHE_PASSPHRASE";
public static final String EXTRA_SECRET_KEY_ID = "secretKeyId";
public static final String EXTRA_PACKAGE_NAME = "packageName";
- private IServiceActivityCallback mService;
+ private IServiceActivityCallback mServiceCallback;
private boolean mServiceBound;
private ServiceConnection mServiceActivityConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
- mService = IServiceActivityCallback.Stub.asInterface(service);
+ mServiceCallback = IServiceActivityCallback.Stub.asInterface(service);
Log.d(Constants.TAG, "connected to ICryptoServiceActivity");
mServiceBound = true;
}
public void onServiceDisconnected(ComponentName name) {
- mService = null;
+ mServiceCallback = null;
Log.d(Constants.TAG, "disconnected from ICryptoServiceActivity");
mServiceBound = false;
}
@@ -70,7 +74,7 @@ public class ServiceActivity extends SherlockFragmentActivity {
* @return
*/
public boolean bindToService() {
- if (mService == null && !mServiceBound) { // if not already connected
+ if (mServiceCallback == null && !mServiceBound) { // if not already connected
try {
Log.d(Constants.TAG, "not bound yet");
@@ -129,7 +133,20 @@ public class ServiceActivity extends SherlockFragmentActivity {
if (ACTION_REGISTER.equals(action)) {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
- setContentView(R.layout.register_crypto_consumer_activity);
+ setContentView(R.layout.crypto_consumer_register_activity);
+ LinearLayout layoutRegister = (LinearLayout) findViewById(R.id.register_crypto_consumer_register_layout);
+ LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.register_crypto_consumer_edit_layout);
+
+ // if already registered show edit buttons
+ ArrayList<String> allowedPkgs = ProviderHelper.getCryptoConsumers(this);
+ if (allowedPkgs.contains(packageName)) {
+ Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName);
+ layoutRegister.setVisibility(View.GONE);
+ layoutEdit.setVisibility(View.VISIBLE);
+ } else {
+ layoutRegister.setVisibility(View.VISIBLE);
+ layoutEdit.setVisibility(View.GONE);
+ }
Button allowButton = (Button) findViewById(R.id.register_crypto_consumer_allow);
Button disallowButton = (Button) findViewById(R.id.register_crypto_consumer_disallow);
@@ -141,7 +158,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName);
// Intent data = new Intent();
- setResult(RESULT_OK);
+ try {
+ mServiceCallback.onRegistered(true, packageName);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
});
@@ -150,7 +171,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
@Override
public void onClick(View v) {
- setResult(RESULT_CANCELED);
+ try {
+ mServiceCallback.onRegistered(false, packageName);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
});
@@ -160,7 +185,6 @@ public class ServiceActivity extends SherlockFragmentActivity {
showPassphraseDialog(secretKeyId);
} else {
Log.e(Constants.TAG, "Wrong action!");
- setResult(RESULT_CANCELED);
finish();
}
}
@@ -176,7 +200,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
@Override
public void handleMessage(Message message) {
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
- setResult(RESULT_OK);
+ try {
+ mServiceCallback.onCachedPassphrase(true);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
}