aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/openintents/openpgp
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-12-30 19:16:21 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2013-12-30 19:16:21 +0100
commit7c3a53d1496a376bdaaa3bf7c79c77fe6d90a3d2 (patch)
tree203735e739e46024d6084d7497e1bd6ad561e49d /OpenPGP-Keychain/src/org/openintents/openpgp
parent3235201cf3f62b345787f21d67dfd259d924b880 (diff)
downloadopen-keychain-7c3a53d1496a376bdaaa3bf7c79c77fe6d90a3d2.tar.gz
open-keychain-7c3a53d1496a376bdaaa3bf7c79c77fe6d90a3d2.tar.bz2
open-keychain-7c3a53d1496a376bdaaa3bf7c79c77fe6d90a3d2.zip
remote service: package signature verification, use string for service instead of getClass.getName
Diffstat (limited to 'OpenPGP-Keychain/src/org/openintents/openpgp')
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl1
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpConstants.java10
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpHelper.java2
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpListPreference.java31
-rw-r--r--OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpServiceConnection.java32
5 files changed, 39 insertions, 37 deletions
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
index 7cbf96b56..8f9e8a0fd 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/IOpenPgpService.aidl
@@ -50,7 +50,6 @@ interface IOpenPgpService {
*/
oneway void sign(in OpenPgpData input, in OpenPgpData output, in IOpenPgpCallback callback);
-
/**
* Encrypt
*
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpConstants.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpConstants.java
new file mode 100644
index 000000000..b1ca1bfe6
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpConstants.java
@@ -0,0 +1,10 @@
+package org.openintents.openpgp;
+
+public class OpenPgpConstants {
+
+ public static final String TAG = "OpenPgp API";
+
+ public static final int REQUIRED_API_VERSION = 1;
+ public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
+
+}
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpHelper.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpHelper.java
index 56c4a4dca..7305c47ce 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpHelper.java
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpHelper.java
@@ -40,7 +40,7 @@ public class OpenPgpHelper {
}
public boolean isAvailable() {
- Intent intent = new Intent(IOpenPgpService.class.getName());
+ Intent intent = new Intent(OpenPgpConstants.SERVICE_INTENT);
List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(intent, 0);
if (!resInfo.isEmpty()) {
return true;
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpListPreference.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpListPreference.java
index 551401b18..4fef3f32c 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpListPreference.java
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpListPreference.java
@@ -39,22 +39,19 @@ public class OpenPgpListPreference extends DialogPreference {
ArrayList<OpenPgpProviderEntry> mProviderList = new ArrayList<OpenPgpProviderEntry>();
private String mSelectedPackage;
- public static final int REQUIRED_API_VERSION = 1;
-
public OpenPgpListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- List<ResolveInfo> resInfo =
- context.getPackageManager().queryIntentServices(
- new Intent(IOpenPgpService.class.getName()), PackageManager.GET_META_DATA);
+ List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(
+ new Intent(OpenPgpConstants.SERVICE_INTENT), PackageManager.GET_META_DATA);
if (!resInfo.isEmpty()) {
for (ResolveInfo resolveInfo : resInfo) {
if (resolveInfo.serviceInfo == null)
continue;
String packageName = resolveInfo.serviceInfo.packageName;
- String simpleName = String.valueOf(resolveInfo.serviceInfo
- .loadLabel(context.getPackageManager()));
+ String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(context
+ .getPackageManager()));
Drawable icon = resolveInfo.serviceInfo.loadIcon(context.getPackageManager());
// get api version
@@ -95,8 +92,8 @@ public class OpenPgpListPreference extends DialogPreference {
TextView tv = (TextView) v.findViewById(android.R.id.text1);
// Put the image on the TextView
- tv.setCompoundDrawablesWithIntrinsicBounds(mProviderList.get(position).icon,
- null, null, null);
+ tv.setCompoundDrawablesWithIntrinsicBounds(mProviderList.get(position).icon, null,
+ null, null);
// Add margin between image and text (support various screen
// densities)
@@ -104,13 +101,12 @@ public class OpenPgpListPreference extends DialogPreference {
tv.setCompoundDrawablePadding(dp5);
// disable if it has the wrong api_version
- if (mProviderList.get(position).apiVersion == REQUIRED_API_VERSION) {
+ if (mProviderList.get(position).apiVersion == OpenPgpConstants.REQUIRED_API_VERSION) {
tv.setEnabled(true);
} else {
tv.setEnabled(false);
- tv.setText(tv.getText() + " (API v"
- + mProviderList.get(position).apiVersion + ", needs v"
- + REQUIRED_API_VERSION + ")");
+ tv.setText(tv.getText() + " (API v" + mProviderList.get(position).apiVersion
+ + ", needs v" + OpenPgpConstants.REQUIRED_API_VERSION + ")");
}
return v;
@@ -125,8 +121,8 @@ public class OpenPgpListPreference extends DialogPreference {
mSelectedPackage = mProviderList.get(which).packageName;
/*
- * Clicking on an item simulates the positive button
- * click, and dismisses the dialog.
+ * Clicking on an item simulates the positive button click, and dismisses
+ * the dialog.
*/
OpenPgpListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
dialog.dismiss();
@@ -134,9 +130,8 @@ public class OpenPgpListPreference extends DialogPreference {
});
/*
- * The typical interaction for list-based dialogs is to have
- * click-on-an-item dismiss the dialog instead of the user having to
- * press 'Ok'.
+ * The typical interaction for list-based dialogs is to have click-on-an-item dismiss the
+ * dialog instead of the user having to press 'Ok'.
*/
builder.setPositiveButton(null, null);
}
diff --git a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpServiceConnection.java b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpServiceConnection.java
index 56a922d73..f7ba06aaf 100644
--- a/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpServiceConnection.java
+++ b/OpenPGP-Keychain/src/org/openintents/openpgp/OpenPgpServiceConnection.java
@@ -29,14 +29,12 @@ public class OpenPgpServiceConnection {
private Context mApplicationContext;
private IOpenPgpService mService;
- private boolean bound;
- private String cryptoProviderPackageName;
-
- private static final String TAG = "OpenPgpServiceConnection";
+ private boolean mBound;
+ private String mCryptoProviderPackageName;
public OpenPgpServiceConnection(Context context, String cryptoProviderPackageName) {
- mApplicationContext = context.getApplicationContext();
- this.cryptoProviderPackageName = cryptoProviderPackageName;
+ this.mApplicationContext = context.getApplicationContext();
+ this.mCryptoProviderPackageName = cryptoProviderPackageName;
}
public IOpenPgpService getService() {
@@ -44,20 +42,20 @@ public class OpenPgpServiceConnection {
}
public boolean isBound() {
- return bound;
+ return mBound;
}
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IOpenPgpService.Stub.asInterface(service);
- Log.d(TAG, "connected to service");
- bound = true;
+ Log.d(OpenPgpConstants.TAG, "connected to service");
+ mBound = true;
}
public void onServiceDisconnected(ComponentName name) {
mService = null;
- Log.d(TAG, "disconnected from service");
- bound = false;
+ Log.d(OpenPgpConstants.TAG, "disconnected from service");
+ mBound = false;
}
};
@@ -67,23 +65,23 @@ public class OpenPgpServiceConnection {
* @return
*/
public boolean bindToService() {
- if (mService == null && !bound) { // if not already connected
+ if (mService == null && !mBound) { // if not already connected
try {
- Log.d(TAG, "not bound yet");
+ Log.d(OpenPgpConstants.TAG, "not bound yet");
Intent serviceIntent = new Intent();
serviceIntent.setAction(IOpenPgpService.class.getName());
- serviceIntent.setPackage(cryptoProviderPackageName);
+ serviceIntent.setPackage(mCryptoProviderPackageName);
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
Context.BIND_AUTO_CREATE);
return true;
} catch (Exception e) {
- Log.d(TAG, "Exception", e);
+ Log.d(OpenPgpConstants.TAG, "Exception on binding", e);
return false;
}
- } else { // already connected
- Log.d(TAG, "already bound... ");
+ } else {
+ Log.d(OpenPgpConstants.TAG, "already bound");
return true;
}
}