2011-05-18 18:19:47 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2011 Markus Doits <markus.doits@googlemail.com>
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-04 23:08:08 +00:00
|
|
|
package org.thialfihar.android.apg.utils;
|
|
|
|
|
|
2011-01-20 16:53:51 +00:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
2011-01-05 14:07:09 +00:00
|
|
|
import java.util.ArrayList;
|
2011-01-04 23:08:08 +00:00
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.ComponentName;
|
|
|
|
|
import android.content.ServiceConnection;
|
|
|
|
|
import android.content.Intent;
|
2011-01-18 22:09:05 +00:00
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.content.pm.ServiceInfo;
|
2011-01-19 22:33:06 +00:00
|
|
|
import android.os.AsyncTask;
|
2011-01-05 14:07:09 +00:00
|
|
|
import android.os.Bundle;
|
2011-01-04 23:08:08 +00:00
|
|
|
import android.os.IBinder;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import org.thialfihar.android.apg.IApgService;
|
2011-01-25 19:39:07 +00:00
|
|
|
import org.thialfihar.android.apg.utils.ApgConInterface.OnCallFinishListener;
|
2011-01-04 23:08:08 +00:00
|
|
|
|
|
|
|
|
/**
|
2011-01-20 20:00:28 +00:00
|
|
|
* A APG-AIDL-Wrapper
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
2011-01-04 23:08:08 +00:00
|
|
|
* This class can be used by other projects to simplify connecting to the
|
2011-01-20 20:00:28 +00:00
|
|
|
* APG-AIDL-Service. Kind of wrapper of for AIDL.
|
|
|
|
|
* </p>
|
2011-01-20 11:55:36 +00:00
|
|
|
*
|
2011-01-20 20:00:28 +00:00
|
|
|
* <p>
|
2011-01-04 23:08:08 +00:00
|
|
|
* It is not used in this project.
|
2011-01-20 20:00:28 +00:00
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @author Markus Doits <markus.doits@googlemail.com>
|
2011-06-05 19:05:57 +00:00
|
|
|
* @version 1.0rc1
|
2011-01-20 20:00:28 +00:00
|
|
|
*
|
2011-01-04 23:08:08 +00:00
|
|
|
*/
|
|
|
|
|
public class ApgCon {
|
2011-05-18 18:19:47 +00:00
|
|
|
private static final boolean LOCAL_LOGV = true;
|
|
|
|
|
private static final boolean LOCAL_LOGD = true;
|
2011-01-04 23:08:08 +00:00
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
private final static String TAG = "ApgCon";
|
|
|
|
|
private final static int API_VERSION = 1; // aidl api-version it expects
|
|
|
|
|
|
|
|
|
|
public int secondsToWaitForConnection = 15;
|
|
|
|
|
|
|
|
|
|
private class CallAsync extends AsyncTask<String, Void, Void> {
|
2011-01-19 22:33:06 +00:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void doInBackground(String... arg) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "Async execution starting");
|
2011-01-19 22:33:06 +00:00
|
|
|
call(arg[0]);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-25 19:39:07 +00:00
|
|
|
protected void onPostExecute(Void res) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "Async execution finished");
|
2011-06-05 19:05:57 +00:00
|
|
|
mAsyncRunning = false;
|
2011-01-25 19:39:07 +00:00
|
|
|
|
2011-01-19 22:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-04 23:08:08 +00:00
|
|
|
|
|
|
|
|
private final Context mContext;
|
2011-06-05 19:05:57 +00:00
|
|
|
private final error mConnectionStatus;
|
|
|
|
|
private boolean mAsyncRunning = false;
|
|
|
|
|
private OnCallFinishListener mOnCallFinishListener;
|
2011-01-04 23:08:08 +00:00
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
private final Bundle mResult = new Bundle();
|
|
|
|
|
private final Bundle mArgs = new Bundle();
|
|
|
|
|
private final ArrayList<String> mErrorList = new ArrayList<String>();
|
|
|
|
|
private final ArrayList<String> mWarningList = new ArrayList<String>();
|
2011-01-05 14:07:09 +00:00
|
|
|
|
2011-01-04 23:08:08 +00:00
|
|
|
/** Remote service for decrypting and encrypting data */
|
2011-06-05 19:05:57 +00:00
|
|
|
private IApgService mApgService = null;
|
2011-01-04 23:08:08 +00:00
|
|
|
|
|
|
|
|
/** Set apgService accordingly to connection status */
|
2011-06-05 19:05:57 +00:00
|
|
|
private ServiceConnection mApgConnection = new ServiceConnection() {
|
2011-01-04 23:08:08 +00:00
|
|
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "IApgService bound to apgService");
|
2011-06-05 19:05:57 +00:00
|
|
|
mApgService = IApgService.Stub.asInterface(service);
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onServiceDisconnected(ComponentName className) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "IApgService disconnected");
|
2011-06-05 19:05:57 +00:00
|
|
|
mApgService = null;
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
};
|
2011-06-05 19:05:57 +00:00
|
|
|
|
2011-01-20 20:00:28 +00:00
|
|
|
/**
|
|
|
|
|
* Different types of local errors
|
|
|
|
|
*/
|
2011-01-04 23:08:08 +00:00
|
|
|
public static enum error {
|
2011-06-05 19:05:57 +00:00
|
|
|
/**
|
|
|
|
|
* no error
|
|
|
|
|
*/
|
2011-01-23 21:37:06 +00:00
|
|
|
NO_ERROR,
|
2011-01-20 20:00:28 +00:00
|
|
|
/**
|
|
|
|
|
* generic error
|
|
|
|
|
*/
|
|
|
|
|
GENERIC,
|
|
|
|
|
/**
|
|
|
|
|
* connection to apg service not possible
|
|
|
|
|
*/
|
|
|
|
|
CANNOT_BIND_TO_APG,
|
|
|
|
|
/**
|
|
|
|
|
* function to call not provided
|
|
|
|
|
*/
|
|
|
|
|
CALL_MISSING,
|
|
|
|
|
/**
|
|
|
|
|
* apg service does not know what to do
|
|
|
|
|
*/
|
|
|
|
|
CALL_NOT_KNOWN,
|
|
|
|
|
/**
|
|
|
|
|
* could not find APG being installed
|
|
|
|
|
*/
|
|
|
|
|
APG_NOT_FOUND,
|
|
|
|
|
/**
|
|
|
|
|
* found APG but without AIDL interface
|
|
|
|
|
*/
|
2011-01-23 21:37:06 +00:00
|
|
|
APG_AIDL_MISSING,
|
2011-06-05 19:05:57 +00:00
|
|
|
/**
|
|
|
|
|
* found APG but with wrong API
|
|
|
|
|
*/
|
2011-01-23 21:37:06 +00:00
|
|
|
APG_API_MISSMATCH
|
2011-01-20 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 20:00:28 +00:00
|
|
|
private static enum ret {
|
2011-01-20 16:36:03 +00:00
|
|
|
ERROR, // returned from AIDL
|
|
|
|
|
RESULT, // returned from AIDL
|
|
|
|
|
WARNINGS, // mixed AIDL and LOCAL
|
|
|
|
|
ERRORS, // mixed AIDL and LOCAL
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* Creates a new ApgCon object and searches for the right APG version on
|
|
|
|
|
* initialization. If not found, errors are printed to the error log.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @param ctx
|
|
|
|
|
* the running context
|
|
|
|
|
*/
|
2011-01-04 23:08:08 +00:00
|
|
|
public ApgCon(Context ctx) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "EncryptionService created");
|
2011-01-04 23:08:08 +00:00
|
|
|
mContext = ctx;
|
2011-01-18 22:09:05 +00:00
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
error tmpError = null;
|
2011-01-18 22:09:05 +00:00
|
|
|
try {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "Searching for the right APG version");
|
2011-06-05 19:05:57 +00:00
|
|
|
ServiceInfo apgServices[] = ctx.getPackageManager().getPackageInfo("org.thialfihar.android.apg",
|
2011-01-18 22:09:05 +00:00
|
|
|
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA).services;
|
2011-06-05 19:05:57 +00:00
|
|
|
if (apgServices == null) {
|
2011-01-18 22:09:05 +00:00
|
|
|
Log.e(TAG, "Could not fetch services");
|
2011-06-05 19:05:57 +00:00
|
|
|
tmpError = error.GENERIC;
|
2011-01-18 22:09:05 +00:00
|
|
|
} else {
|
2011-06-05 19:05:57 +00:00
|
|
|
boolean apgServiceFound = false;
|
|
|
|
|
for (ServiceInfo inf : apgServices) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "Found service of APG: " + inf.name);
|
2011-01-18 22:09:05 +00:00
|
|
|
if (inf.name.equals("org.thialfihar.android.apg.ApgService")) {
|
2011-06-05 19:05:57 +00:00
|
|
|
apgServiceFound = true;
|
2011-01-18 22:09:05 +00:00
|
|
|
if (inf.metaData == null) {
|
|
|
|
|
Log.w(TAG, "Could not determine ApgService API");
|
|
|
|
|
Log.w(TAG, "This probably won't work!");
|
2011-06-05 19:05:57 +00:00
|
|
|
mWarningList.add("(LOCAL) Could not determine ApgService API");
|
|
|
|
|
tmpError = 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);
|
2011-01-18 22:09:05 +00:00
|
|
|
Log.w(TAG, "This probably won't work!");
|
2011-06-05 19:05:57 +00:00
|
|
|
mWarningList.add("(LOCAL) Found ApgService API version" + inf.metaData.getInt("api_version") + " but exspected " + API_VERSION);
|
|
|
|
|
tmpError = error.APG_API_MISSMATCH;
|
2011-01-18 22:12:47 +00:00
|
|
|
} else {
|
2011-06-05 19:05:57 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "Found api_version " + API_VERSION + ", everything should work");
|
|
|
|
|
tmpError = error.NO_ERROR;
|
2011-01-18 22:09:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
if (!apgServiceFound) {
|
2011-01-18 22:09:05 +00:00
|
|
|
Log.e(TAG, "Could not find APG with AIDL interface, this probably won't work");
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Could not find APG with AIDL interface, this probably won't work");
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.APG_AIDL_MISSING.ordinal());
|
|
|
|
|
tmpError = error.APG_NOT_FOUND;
|
2011-01-18 22:09:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
2011-01-25 19:38:56 +00:00
|
|
|
Log.e(TAG, "Could not find APG, is it installed?", e);
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Could not find APG, is it installed?");
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.APG_NOT_FOUND.ordinal());
|
|
|
|
|
tmpError = error.APG_NOT_FOUND;
|
2011-01-18 22:09:05 +00:00
|
|
|
}
|
2011-06-05 19:05:57 +00:00
|
|
|
|
|
|
|
|
mConnectionStatus = tmpError;
|
2011-01-25 19:39:07 +00:00
|
|
|
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** try to connect to the apg service */
|
|
|
|
|
private boolean connect() {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "trying to bind the apgService to context");
|
2011-01-04 23:08:08 +00:00
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
if (mApgService != null) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "allready connected");
|
2011-01-04 23:08:08 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2011-06-05 19:05:57 +00:00
|
|
|
mContext.bindService(new Intent(IApgService.class.getName()), mApgConnection, Context.BIND_AUTO_CREATE);
|
2011-01-04 23:08:08 +00:00
|
|
|
} catch (Exception e) {
|
2011-01-25 19:38:56 +00:00
|
|
|
Log.e(TAG, "could not bind APG service", e);
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
int waitCount = 0;
|
|
|
|
|
while (mApgService == null && waitCount++ < secondsToWaitForConnection) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "sleeping 1 second to wait for apg");
|
2011-01-04 23:08:08 +00:00
|
|
|
android.os.SystemClock.sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
if (waitCount >= secondsToWaitForConnection) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "slept waiting for nothing!");
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Disconnects ApgCon from Apg
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* This should be called whenever all work with APG is done (e.g. everything
|
|
|
|
|
* you wanted to encrypt is encrypted), since connections with AIDL should
|
|
|
|
|
* not be upheld indefinitely.
|
|
|
|
|
* <p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* Also, if you destroy you end using your ApgCon-instance, this must be
|
|
|
|
|
* called or else the connection to APG is leaked
|
|
|
|
|
* </p>
|
|
|
|
|
*/
|
2011-01-19 22:33:06 +00:00
|
|
|
public void disconnect() {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "disconnecting apgService");
|
2011-06-05 19:05:57 +00:00
|
|
|
if (mApgService != null) {
|
|
|
|
|
mContext.unbindService(mApgConnection);
|
|
|
|
|
mApgService = null;
|
2011-01-19 22:33:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-04 23:08:08 +00:00
|
|
|
private boolean initialize() {
|
2011-06-05 19:05:57 +00:00
|
|
|
if (mApgService == null) {
|
2011-01-04 23:08:08 +00:00
|
|
|
if (!connect()) {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGV ) Log.v(TAG, "connection to apg service failed");
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Calls a function from APG's AIDL-interface
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* After you have set up everything with {@link #setArg(String, String)}
|
2011-01-20 11:55:36 +00:00
|
|
|
* (and variants), you can call a function from the AIDL-interface. This
|
|
|
|
|
* will
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>start connection to the remote interface (if not already connected)</li>
|
|
|
|
|
* <li>call the passed function with all set up parameters synchronously</li>
|
2011-06-05 19:05:57 +00:00
|
|
|
* <li>set up everything to retrieve the mResult and/or warnings/errors</li>
|
2011-01-25 19:39:07 +00:00
|
|
|
* <li>call the callback if provided
|
2011-01-20 11:55:36 +00:00
|
|
|
* </ul>
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* Note your thread will be blocked during execution - if you want to call
|
2011-06-05 19:05:57 +00:00
|
|
|
* the function asynchronously, see {@link #callAsync(String)}.
|
2011-01-20 11:55:36 +00:00
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @param function
|
|
|
|
|
* a remote function to call
|
|
|
|
|
* @return true, if call successful (= no errors), else false
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #callAsync(String)
|
|
|
|
|
* @see #setArg(String, String)
|
|
|
|
|
* @see #setOnCallFinishListener(OnCallFinishListener)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-01-05 14:07:09 +00:00
|
|
|
public boolean call(String function) {
|
2011-06-05 19:05:57 +00:00
|
|
|
boolean success = this.call(function, mArgs, mResult);
|
|
|
|
|
if (mOnCallFinishListener != null) {
|
2011-01-25 19:39:07 +00:00
|
|
|
try {
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "About to execute callback");
|
2011-06-05 19:05:57 +00:00
|
|
|
mOnCallFinishListener.onCallFinish(mResult);
|
2011-05-18 18:19:47 +00:00
|
|
|
if( LOCAL_LOGD ) Log.d(TAG, "Callback executed");
|
2011-01-25 19:39:07 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
Log.w(TAG, "Exception on callback: (" + e.getClass() + ") " + e.getMessage(), e);
|
2011-06-05 19:05:57 +00:00
|
|
|
mWarningList.add("(LOCAL) Could not execute callback (" + e.getClass() + "): " + e.getMessage());
|
2011-01-25 19:39:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success;
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Calls a function from remote interface asynchronously
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* This does exactly the same as {@link #call(String)}, but asynchronously.
|
|
|
|
|
* While connection to APG and work are done in background, your thread can
|
|
|
|
|
* go on executing.
|
|
|
|
|
* <p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* To see whether the task is finished, you have to possibilities:
|
|
|
|
|
* <ul>
|
2011-06-05 19:05:57 +00:00
|
|
|
* <li>In your thread, poll {@link #isRunning()}</li>
|
|
|
|
|
* <li>Supply a callback with {@link #setOnCallFinishListener(OnCallFinishListener)}</li>
|
2011-01-20 11:55:36 +00:00
|
|
|
* </ul>
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @param function
|
|
|
|
|
* a remote function to call
|
|
|
|
|
*
|
|
|
|
|
* @see #call(String)
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #isRunning()
|
|
|
|
|
* @see #setOnCallFinishListener(OnCallFinishListener)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void callAsync(String function) {
|
|
|
|
|
mAsyncRunning = true;
|
|
|
|
|
new CallAsync().execute(function);
|
2011-01-19 22:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
private boolean call(String function, Bundle pArgs, Bundle pReturn) {
|
2011-01-04 23:08:08 +00:00
|
|
|
|
|
|
|
|
if (!initialize()) {
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Cannot bind to ApgService");
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.CANNOT_BIND_TO_APG.ordinal());
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (function == null || function.length() == 0) {
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Function to call missing");
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.CALL_MISSING.ordinal());
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2011-06-05 19:05:57 +00:00
|
|
|
Boolean success = (Boolean) IApgService.class.getMethod(function, Bundle.class, Bundle.class).invoke(mApgService, pArgs, pReturn);
|
|
|
|
|
mErrorList.addAll(pReturn.getStringArrayList(ret.ERRORS.name()));
|
|
|
|
|
mWarningList.addAll(pReturn.getStringArrayList(ret.WARNINGS.name()));
|
2011-01-20 16:36:03 +00:00
|
|
|
return success;
|
2011-01-04 23:08:08 +00:00
|
|
|
} catch (NoSuchMethodException e) {
|
2011-01-25 19:38:56 +00:00
|
|
|
Log.e(TAG, "Remote call not known (" + function + "): " + e.getMessage(), e);
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Remote call not known (" + function + "): " + e.getMessage());
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.CALL_NOT_KNOWN.ordinal());
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
2011-01-20 16:53:51 +00:00
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
Throwable orig = e.getTargetException();
|
2011-01-25 19:38:56 +00:00
|
|
|
Log.w(TAG, "Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "': " + orig.getMessage(), orig);
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Exception of type '" + orig.getClass() + "' on AIDL call '" + function + "': " + orig.getMessage());
|
2011-01-20 16:53:51 +00:00
|
|
|
return false;
|
2011-01-04 23:08:08 +00:00
|
|
|
} catch (Exception e) {
|
2011-01-25 19:38:56 +00:00
|
|
|
Log.e(TAG, "Generic error (" + e.getClass() + "): " + e.getMessage(), e);
|
2011-06-05 19:05:57 +00:00
|
|
|
mErrorList.add("(LOCAL) Generic error (" + e.getClass() + "): " + e.getMessage());
|
|
|
|
|
mResult.putInt(ret.ERROR.name(), error.GENERIC.ordinal());
|
2011-01-04 23:08:08 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Set a string argument for APG
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* This defines a string argument for APG's AIDL-interface.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* To know what key-value-pairs are possible (or required), take a look into
|
|
|
|
|
* the IApgService.aidl
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* Note, that the parameters are not deleted after a call, so you have to
|
2011-06-05 19:05:57 +00:00
|
|
|
* reset ({@link #clearArgs()}) them manually if you want to.
|
2011-01-20 11:55:36 +00:00
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the key
|
|
|
|
|
* @param val
|
|
|
|
|
* the value
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #clearArgs()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setArg(String key, String val) {
|
|
|
|
|
mArgs.putString(key, val);
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
2011-01-09 17:17:27 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Set a string-array argument for APG
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* If the AIDL-parameter is an {@literal ArrayList<String>}, you have to use
|
|
|
|
|
* this function.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* <code>
|
|
|
|
|
* <pre>
|
2011-06-05 19:05:57 +00:00
|
|
|
* setArg("a key", new String[]{ "entry 1", "entry 2" });
|
2011-01-20 11:55:36 +00:00
|
|
|
* </pre>
|
|
|
|
|
* </code>
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the key
|
|
|
|
|
* @param vals
|
|
|
|
|
* the value
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #setArg(String, String)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setArg(String key, String vals[]) {
|
2011-01-13 20:12:02 +00:00
|
|
|
ArrayList<String> list = new ArrayList<String>();
|
|
|
|
|
for (String val : vals) {
|
|
|
|
|
list.add(val);
|
|
|
|
|
}
|
2011-06-05 19:05:57 +00:00
|
|
|
mArgs.putStringArrayList(key, list);
|
2011-01-13 20:12:02 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Set up a boolean argument for APG
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the key
|
|
|
|
|
* @param vals
|
|
|
|
|
* the value
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #setArg(String, String)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setArg(String key, boolean val) {
|
|
|
|
|
mArgs.putBoolean(key, val);
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
2011-01-13 20:12:02 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Set up a int argument for APG
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the key
|
|
|
|
|
* @param vals
|
|
|
|
|
* the value
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #setArg(String, String)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setArg(String key, int val) {
|
|
|
|
|
mArgs.putInt(key, val);
|
2011-01-09 20:12:12 +00:00
|
|
|
}
|
2011-01-13 20:12:02 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Set up a int-array argument for APG
|
|
|
|
|
* <p>
|
|
|
|
|
* If the AIDL-parameter is an {@literal ArrayList<Integer>}, you have to
|
|
|
|
|
* use this function.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the key
|
|
|
|
|
* @param vals
|
|
|
|
|
* the value
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #setArg(String, String)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setArg(String key, int vals[]) {
|
2011-01-13 20:12:02 +00:00
|
|
|
ArrayList<Integer> list = new ArrayList<Integer>();
|
|
|
|
|
for (int val : vals) {
|
|
|
|
|
list.add(val);
|
|
|
|
|
}
|
2011-06-05 19:05:57 +00:00
|
|
|
mArgs.putIntegerArrayList(key, list);
|
2011-01-13 20:12:02 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Clears all arguments
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* Anything the has been set up with the various
|
2011-06-05 19:05:57 +00:00
|
|
|
* {@link #setArg(String, String)} functions, is cleared.
|
2011-01-20 11:55:36 +00:00
|
|
|
* </p>
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* Note, that any warning, error, callback, mResult, etc. is not cleared with
|
2011-01-20 11:55:36 +00:00
|
|
|
* this.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @see #reset()
|
|
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void clearArgs() {
|
|
|
|
|
mArgs.clear();
|
2011-01-09 20:12:12 +00:00
|
|
|
}
|
2011-01-05 14:07:09 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Return the object associated with the key
|
|
|
|
|
*
|
|
|
|
|
* @param key
|
|
|
|
|
* the object's key you want to return
|
|
|
|
|
* @return an object at position key, or null if not set
|
|
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public Object getArg(String key) {
|
|
|
|
|
return mArgs.get(key);
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Iterates through the errors
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* With this method, you can iterate through all errors. The errors are only
|
|
|
|
|
* returned once and deleted immediately afterwards, so you can only return
|
|
|
|
|
* each error once.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @return a human readable description of a error that happened, or null if
|
|
|
|
|
* no more errors
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #hasNextError()
|
|
|
|
|
* @see #clearErrors()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public String getNextError() {
|
|
|
|
|
if (mErrorList.size() != 0)
|
|
|
|
|
return mErrorList.remove(0);
|
2011-01-09 17:17:27 +00:00
|
|
|
else
|
|
|
|
|
return null;
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Check, if there are any new errors
|
|
|
|
|
*
|
|
|
|
|
* @return true, if there are unreturned errors, false otherwise
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #getNextError()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public boolean hasNextError() {
|
|
|
|
|
return mErrorList.size() != 0;
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 16:36:03 +00:00
|
|
|
/**
|
2011-01-20 20:00:28 +00:00
|
|
|
* Get the numeric representation of the last error
|
2011-01-20 16:36:03 +00:00
|
|
|
*
|
|
|
|
|
* <p>
|
2011-01-20 20:00:28 +00:00
|
|
|
* Values <100 mean the error happened locally, values >=100 mean the error
|
|
|
|
|
* happened at the remote side (APG). See the IApgService.aidl (or get the
|
2011-06-05 19:05:57 +00:00
|
|
|
* human readable description with {@link #getNextError()}) for what
|
2011-01-20 20:00:28 +00:00
|
|
|
* errors >=100 mean.
|
2011-01-20 16:36:03 +00:00
|
|
|
* </p>
|
|
|
|
|
*
|
2011-01-20 20:00:28 +00:00
|
|
|
* @return the id of the error that happened
|
2011-01-20 16:36:03 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public int getError() {
|
|
|
|
|
if (mResult.containsKey(ret.ERROR.name()))
|
|
|
|
|
return mResult.getInt(ret.ERROR.name());
|
2011-01-20 20:00:28 +00:00
|
|
|
else
|
2011-01-20 16:36:03 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Iterates through the warnings
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* With this method, you can iterate through all warnings. The warnings are
|
|
|
|
|
* only returned once and deleted immediately afterwards, so you can only
|
|
|
|
|
* return each warning once.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @return a human readable description of a warning that happened, or null
|
|
|
|
|
* if no more warnings
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #hasNextWarning()
|
|
|
|
|
* @see #clearWarnings()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public String getNextWarning() {
|
|
|
|
|
if (mWarningList.size() != 0)
|
|
|
|
|
return mWarningList.remove(0);
|
2011-01-09 17:17:27 +00:00
|
|
|
else
|
|
|
|
|
return null;
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Check, if there are any new warnings
|
|
|
|
|
*
|
|
|
|
|
* @return true, if there are unreturned warnings, false otherwise
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #getNextWarning()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public boolean hasNextWarning() {
|
|
|
|
|
return mWarningList.size() != 0;
|
2011-01-05 14:07:09 +00:00
|
|
|
}
|
2011-01-04 23:08:08 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Get the result
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* This gets your mResult. After doing an encryption or decryption with APG,
|
2011-01-23 21:36:44 +00:00
|
|
|
* you get the output with this function.
|
2011-01-20 11:55:36 +00:00
|
|
|
* </p>
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* Note, that when your last remote call is unsuccessful, the mResult will
|
2011-01-20 11:55:36 +00:00
|
|
|
* still have the same value like the last successful call (or null, if no
|
2011-06-05 19:05:57 +00:00
|
|
|
* call was successful). To ensure you do not work with old call's mResults,
|
|
|
|
|
* either be sure to {@link #reset()} (or at least {@link #clearResult()})
|
2011-01-20 11:55:36 +00:00
|
|
|
* your instance before each new call or always check that
|
2011-06-05 19:05:57 +00:00
|
|
|
* {@link #hasNextError()} is false.
|
2011-01-20 11:55:36 +00:00
|
|
|
* </p>
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @return the mResult of the last {@link #call(String)} or
|
2011-01-20 11:55:36 +00:00
|
|
|
* {@link #call_asinc(String)}.
|
|
|
|
|
*
|
|
|
|
|
* @see #reset()
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #clearResult()
|
|
|
|
|
* @see #getResultBundle()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public String getResult() {
|
|
|
|
|
return mResult.getString(ret.RESULT.name());
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-23 21:36:44 +00:00
|
|
|
/**
|
2011-06-05 19:05:57 +00:00
|
|
|
* Get the mResult bundle
|
2011-01-23 21:36:44 +00:00
|
|
|
*
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* Unlike {@link #getResult()}, which only returns any en-/decrypted
|
2011-01-23 21:36:44 +00:00
|
|
|
* message, this function returns the complete information that was returned
|
|
|
|
|
* by Apg. This also includes the "RESULT", but additionally the warnings,
|
|
|
|
|
* errors and any other information.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* For warnings and errors it is suggested to use the functions that are
|
2011-06-05 19:05:57 +00:00
|
|
|
* provided here, namely {@link #getError()}, {@link #getNextError()},
|
2011-01-23 21:36:44 +00:00
|
|
|
* {@link #get_next_Warning()} etc.), but if any call returns something non
|
2011-06-05 19:05:57 +00:00
|
|
|
* standard, you have access to the complete mResult bundle to extract the
|
2011-01-23 21:36:44 +00:00
|
|
|
* information.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @return the complete mResult-bundle of the last call to apg
|
2011-01-23 21:36:44 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public Bundle getResultBundle() {
|
|
|
|
|
return mResult;
|
2011-01-23 21:36:44 +00:00
|
|
|
}
|
2011-01-25 19:39:07 +00:00
|
|
|
|
2011-06-05 19:05:57 +00:00
|
|
|
public error getConnectionStatus() {
|
|
|
|
|
return mConnectionStatus;
|
2011-01-23 21:37:06 +00:00
|
|
|
}
|
2011-01-23 21:36:44 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Clears all unfetched errors
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #getNextError()
|
|
|
|
|
* @see #hasNextError()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void clearErrors() {
|
|
|
|
|
mErrorList.clear();
|
|
|
|
|
mResult.remove(ret.ERROR.name());
|
2011-01-13 20:12:02 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Clears all unfetched warnings
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #getNextWarning()
|
|
|
|
|
* @see #hasNextWarning()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void clearWarnings() {
|
|
|
|
|
mWarningList.clear();
|
2011-01-13 20:12:02 +00:00
|
|
|
}
|
2011-01-18 22:09:05 +00:00
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
2011-06-05 19:05:57 +00:00
|
|
|
* Clears the last mResult
|
2011-01-20 11:55:36 +00:00
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #getResult()
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void clearResult() {
|
|
|
|
|
mResult.remove(ret.RESULT.name());
|
2011-01-13 20:28:08 +00:00
|
|
|
}
|
2011-01-13 20:12:02 +00:00
|
|
|
|
2011-01-19 22:33:06 +00:00
|
|
|
/**
|
2011-01-25 19:39:07 +00:00
|
|
|
* Set a callback listener when call to AIDL finishes
|
2011-01-19 22:33:06 +00:00
|
|
|
*
|
|
|
|
|
* @param obj
|
|
|
|
|
* a object to call back after async execution
|
2011-01-25 19:39:07 +00:00
|
|
|
* @see ApgConInterface
|
2011-01-23 21:36:59 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void setOnCallFinishListener(OnCallFinishListener lis) {
|
|
|
|
|
mOnCallFinishListener = lis;
|
2011-01-23 21:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Clears any callback object
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #setOnCallFinishListener(OnCallFinishListener)
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public void clearOnCallFinishListener() {
|
|
|
|
|
mOnCallFinishListener = null;
|
2011-01-20 11:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks, whether an async execution is running
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* If you started something with {@link #callAsync(String)}, this will
|
2011-01-20 11:55:36 +00:00
|
|
|
* return true if the task is still running
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @return true, if an async task is still running, false otherwise
|
|
|
|
|
*
|
2011-06-05 19:05:57 +00:00
|
|
|
* @see #callAsync(String)
|
2011-01-23 21:36:59 +00:00
|
|
|
*
|
2011-01-20 11:55:36 +00:00
|
|
|
*/
|
2011-06-05 19:05:57 +00:00
|
|
|
public boolean isRunning() {
|
|
|
|
|
return mAsyncRunning;
|
2011-01-19 22:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-20 11:55:36 +00:00
|
|
|
/**
|
|
|
|
|
* Completely resets your instance
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* This currently resets everything in this instance. Errors, warnings,
|
2011-06-05 19:05:57 +00:00
|
|
|
* mResults, callbacks, ... are removed. Any connection to the remote
|
2011-01-20 11:55:36 +00:00
|
|
|
* interface is upheld, though.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
2011-06-05 19:05:57 +00:00
|
|
|
* Note, that when an async execution ({@link #callAsync(String)}) is
|
|
|
|
|
* running, it's mResult, warnings etc. will still be evaluated (which might
|
2011-01-20 11:55:36 +00:00
|
|
|
* be not what you want). Also mind, that any callback you set is also
|
2011-01-25 19:39:07 +00:00
|
|
|
* reseted, so on finishing the execution any before defined callback will
|
2011-01-20 11:55:36 +00:00
|
|
|
* NOT BE TRIGGERED.
|
|
|
|
|
* </p>
|
|
|
|
|
*/
|
2011-01-13 20:12:02 +00:00
|
|
|
public void reset() {
|
2011-06-05 19:05:57 +00:00
|
|
|
clearErrors();
|
|
|
|
|
clearWarnings();
|
|
|
|
|
clearArgs();
|
|
|
|
|
clearOnCallFinishListener();
|
|
|
|
|
mResult.clear();
|
2011-01-04 23:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|