diff --git a/src/org/thialfihar/android/apg/utils/ApgCon.java b/src/org/thialfihar/android/apg/utils/ApgCon.java index 3e0b75524..8a11b8cac 100644 --- a/src/org/thialfihar/android/apg/utils/ApgCon.java +++ b/src/org/thialfihar/android/apg/utils/ApgCon.java @@ -15,6 +15,7 @@ import android.os.IBinder; import android.util.Log; import org.thialfihar.android.apg.IApgService; +import org.thialfihar.android.apg.utils.ApgConInterface.OnCallFinishListener; /** * A APG-AIDL-Wrapper @@ -29,7 +30,7 @@ import org.thialfihar.android.apg.IApgService; *
* * @author Markus Doits- * Note, that any warning, error, callback, result etc. is not cleared with + * Note, that any warning, error, callback, result, etc. is not cleared with * this. *
* @@ -639,7 +629,7 @@ public class ApgCon { public Bundle get_result_bundle() { return result; } - + public error get_connection_status() { return connection_status; } @@ -675,154 +665,23 @@ public class ApgCon { } /** - * Set a callback object and method - * - *- * After an async execution is finished, obj.meth() will be called. You can - * use this in order to get notified, when encrypting/decrypting of long - * data finishes and do not have to poll {@link #is_running()} in your - * thread. Note, that if the call of the method fails for whatever reason, - * you won't get notified in any way - so you still should check - * {@link #is_running()} from time to time. - *
- * - *- * It produces a warning fetchable with {@link #get_next_warning()} when the - * callback fails. - *
- * - *
- *
- * .... your class ...
- * public void callback() {
- * // do something after encryption finished
- * }
- *
- * public void encrypt() {
- * ApgCon mEnc = new ApgCon(context);
- * // set parameters
- * mEnc.set_arg(key, value);
- * ...
- *
- * // set callback object and method
- * mEnc.set_callback( this, "callback" );
- *
- * // start asynchronous call
- * mEnc.call_async( call );
- *
- * // when the call_async finishes, the method "callback()" will be called automatically
- * }
- *
- *
- *
- * @param obj
- * The object, which has the public method meth
- * @param meth
- * Method to call on the object obj
- *
- * @see #set_callback(Object, String, boolean)
- */
- public void set_callback(Object obj, String meth) {
- set_callback(obj, meth, default_callback_return_self);
- }
-
- /**
- * Set a callback and whether to return self as a additional parameter
- *
- * - * This does the same as {@link #set_callback(Object, String)} with one - * Additionally parameter return_self. - *
- *- * The additional parameter controls, whether to return itself as a - * parameter to the callback method meth (in order to go on working after - * async execution has finished). This means, your callback method must have - * one parameter of the type ApgCon. - *
- * - * @param obj - * The object, which has the public method meth - * @param meth - * Method to call on the object obj - * @param return_self - * Whether to return itself as an parameter to meth - */ - public void set_callback(Object obj, String meth, boolean return_self) { - set_callback_object(obj); - set_callback_method(meth); - set_callback_return_self(return_self); - } - - /** - * Set a callback object + * Set a callback listener when call to AIDL finishes * * @param obj * a object to call back after async execution - * @see #set_callback(Object, String) + * @see ApgConInterface */ - public void set_callback_object(Object obj) { - callback_object = obj; - } - - /** - * Set a callback method - * - * @param meth - * a method to call on a callback object after async execution - * @see #set_callback(Object, String) - */ - public void set_callback_method(String meth) { - callback_method = meth; - } - - /** - * Set whether to return self on callback - * - * @param arg - * set results as param for callback method - * @see #set_callback(Object, String) - */ - public void set_callback_return_self(boolean arg) { - callback_return_self = arg; + public void set_onCallFinishListener(OnCallFinishListener lis) { + onCallFinishListener = lis; } /** * Clears any callback object * - * @see #set_callback(Object, String) + * @see #set_onCallFinishListener(OnCallFinishListener) */ - public void clear_callback_object() { - callback_object = null; - } - - /** - * Clears any callback method - * - * @see #set_callback(Object, String) - */ - public void clear_callback_method() { - callback_method = null; - } - - /** - * Sets to default value of whether to return self on callback - * - * @see #set_callback(Object, String, boolean) - * @see #default_callback_return_self - */ - public void clear_callback_return_self() { - callback_return_self = default_callback_return_self; - } - - /** - * Clears anything related to callback - * - * @see #set_callback(Object, String) - */ - public void clear_callback() { - clear_callback_object(); - clear_callback_method(); - clear_callback_return_self(); + public void clear_onCallFinishListener() { + onCallFinishListener = null; } /** @@ -855,7 +714,7 @@ public class ApgCon { * Note, that when an async execution ({@link #call_async(String)}) is * running, it's result, warnings etc. will still be evaluated (which might * be not what you want). Also mind, that any callback you set is also - * reseted, so on finishing the async execution any defined callback will + * reseted, so on finishing the execution any before defined callback will * NOT BE TRIGGERED. * */ @@ -863,12 +722,8 @@ public class ApgCon { clear_errors(); clear_warnings(); clear_args(); - clear_callback(); + clear_onCallFinishListener(); result.clear(); } - public ApgCon get_self() { - return this; - } - } diff --git a/src/org/thialfihar/android/apg/utils/ApgConInterface.java b/src/org/thialfihar/android/apg/utils/ApgConInterface.java new file mode 100644 index 000000000..57ef0d9c4 --- /dev/null +++ b/src/org/thialfihar/android/apg/utils/ApgConInterface.java @@ -0,0 +1,9 @@ +package org.thialfihar.android.apg.utils; + +import android.os.Bundle; + +public interface ApgConInterface { + public static interface OnCallFinishListener { + public abstract void onCallFinish(Bundle result); + } +}