diff options
author | Markus Doits <markus.doits@gmail.com> | 2011-01-23 21:37:06 +0000 |
---|---|---|
committer | Markus Doits <markus.doits@gmail.com> | 2011-01-23 21:37:06 +0000 |
commit | 3372e571577481bfa62140a131f5c0dea35936fc (patch) | |
tree | 0a5c14a9e33f9141f5544a2891f9b203c338d7ac /src/org/thialfihar/android/apg/utils/ApgCon.java | |
parent | 66263ab6e3d9ce3a67e5f10496c0b99a0dcd1752 (diff) | |
download | open-keychain-3372e571577481bfa62140a131f5c0dea35936fc.tar.gz open-keychain-3372e571577481bfa62140a131f5c0dea35936fc.tar.bz2 open-keychain-3372e571577481bfa62140a131f5c0dea35936fc.zip |
Allow to retrieve connection status
This tells, if a connection to APG *might* be possible (right version of
APG found)
Diffstat (limited to 'src/org/thialfihar/android/apg/utils/ApgCon.java')
-rw-r--r-- | src/org/thialfihar/android/apg/utils/ApgCon.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/org/thialfihar/android/apg/utils/ApgCon.java b/src/org/thialfihar/android/apg/utils/ApgCon.java index 09e183a96..5572dcdb5 100644 --- a/src/org/thialfihar/android/apg/utils/ApgCon.java +++ b/src/org/thialfihar/android/apg/utils/ApgCon.java @@ -29,7 +29,7 @@ import org.thialfihar.android.apg.IApgService; * </p> * * @author Markus Doits <markus.doits@googlemail.com> - * @version 0.9 + * @version 0.9.1 * */ public class ApgCon { @@ -87,6 +87,7 @@ public class ApgCon { private final static int api_version = 1; // aidl api-version it expects private final Context mContext; + private final error connection_status; private boolean async_running = false; private Object callback_object; private String callback_method; @@ -121,6 +122,7 @@ public class ApgCon { * */ public static enum error { + NO_ERROR, /** * generic error */ @@ -144,7 +146,8 @@ public class ApgCon { /** * found APG but without AIDL interface */ - APG_AIDL_MISSING + APG_AIDL_MISSING, + APG_API_MISSMATCH } private static enum ret { @@ -169,12 +172,14 @@ public class ApgCon { Log.v(TAG, "EncryptionService created"); mContext = ctx; + error tmp_connection_status = null; try { Log.v(TAG, "Searching for the right APG version"); ServiceInfo apg_services[] = ctx.getPackageManager().getPackageInfo("org.thialfihar.android.apg", PackageManager.GET_SERVICES | PackageManager.GET_META_DATA).services; if (apg_services == null) { Log.e(TAG, "Could not fetch services"); + tmp_connection_status = error.GENERIC; } else { boolean apg_service_found = false; for (ServiceInfo inf : apg_services) { @@ -185,12 +190,15 @@ public class ApgCon { Log.w(TAG, "Could not determine ApgService API"); Log.w(TAG, "This probably won't work!"); warning_list.add("(LOCAL) Could not determine ApgService API"); + tmp_connection_status = error.APG_API_MISSMATCH; } else if (inf.metaData.getInt("api_version") != api_version) { Log.w(TAG, "Found ApgService API version" + inf.metaData.getInt("api_version") + " but exspected " + api_version); Log.w(TAG, "This probably won't work!"); warning_list.add("(LOCAL) Found ApgService API version" + inf.metaData.getInt("api_version") + " but exspected " + api_version); + tmp_connection_status = error.APG_API_MISSMATCH; } else { Log.v(TAG, "Found api_version " + api_version + ", everything should work"); + tmp_connection_status = error.NO_ERROR; } } } @@ -199,6 +207,7 @@ public class ApgCon { Log.e(TAG, "Could not find APG with AIDL interface, this probably won't work"); error_list.add("(LOCAL) Could not find APG with AIDL interface, this probably won't work"); result.putInt(ret.ERROR.name(), error.APG_AIDL_MISSING.ordinal()); + tmp_connection_status = error.APG_NOT_FOUND; } } } catch (PackageManager.NameNotFoundException e) { @@ -207,7 +216,10 @@ public class ApgCon { Log.e(TAG, "Could not find APG, is it installed?"); error_list.add("(LOCAL) Could not find APG, is it installed?"); result.putInt(ret.ERROR.name(), error.APG_NOT_FOUND.ordinal()); + tmp_connection_status = error.APG_NOT_FOUND; } + + connection_status = tmp_connection_status; } /** try to connect to the apg service */ @@ -648,6 +660,10 @@ public class ApgCon { public Bundle get_result_bundle() { return result; } + + public error get_connection_status() { + return connection_status; + } /** * Clears all unfetched errors |