我正在使用一个api来控制连接到android设备的指纹扫描仪。我需要调用的本机方法要求将指针和双指针混合交给该方法,但我不确定如何做到这一点。
原始c方法的定义如下:
BioErrType BioGetTemplates(BioHandle handle, char**badgeNumberList,uint8_t *templateIndexList, BioTemplate**bioTemplateList)
提供的java方法用于调用它:
public native int BioGetTemplates(int handle, int [] badgeNumberList, byte [] templateIndexList, byte [][]bioTemplateList);
原始c方法的文档说明:
*** Gets from the biometric device a template for each of the listed
***badge numbers.
***
*** The badgeNumberList pointer is a pointer to a null terminated array
***of pointers to badge number strings. The bioTemplateList should be an
***array of pointers to memory where templates can be stored, one pointer
***for each possible template returned.
*** The templateIndexList is a pointer to an array of template indices.
***If templateIndexList is not null, than its size must be the same as the
***number of badge number strings provided via badgeNumberList, which must
***be the same size as the array of template pointers provided via
***bioTemplateList. If templateIndexList is null, than the bioTemplateList
***array size must be a device specific multiple of the number of badge
***numbers. For all current devices, this multiple is 2, corresponding to
***a primary and secondary template for each badge number.
*** Each template is copied from the device to the memory at the
***corresponding pointer in the bioTemplateList. If no template for a
***given badge number and template index is stored in the device, the
***corresponding pointer in the bioTemplateList is set to NULL. If a
***template pointer in bioTemplateList is NULL and yet a template exists
***for the corresponding badge number and index, BIOAPI_INVALID is returned.
*** The applications program shall provide a separate buffer, of a size
***specific to the device type, for every template it expects.
***
***returns:
*** BIOAPI_OK if all templates found were copied to the provided template
***buffers.
*** BIOAPI_INVALID if the handle is invalid or the badgeNumberList pointer
***is null or if the bioTemplateList pointer is null, or if any badge
***number in the list is invalid, or if any template index is out of range
***for the device, or if a null template pointer is provided for a
***template that is requested and is in the device, or if the device could
***not successfully be talked to. This error code can be returned even if
***some of the templates were copied from the device, if the function was
***not able to complete.
*** BIOAPI_BUSY if another thread is currently using the library.
我当前调用代码的尝试:
int[] badgeNumberList = { 100, 0 };
byte[] templateIndexList = new byte[2 * (badgeNumberList.length - 1)];
byte[][] bioTemplateList = new byte[1][2];
try {
mBio.bioGetTemplates(badgeNumberList, templateIndexList,
bioTemplateList);
byte[] byteArr = bioTemplateList[0];
BigInteger bigTemplate = new BigInteger(byteArr);
Log.d(TAG, CLASS + "." + METHOD + " BigInt is: "
+ bigTemplate.toString());
} catch (BioError e) {
Log.w(TAG, CLASS + "." + METHOD + ": " + e.getMessage());
}
注意,mbio对象是façade到提供的JavaAPI,该api处理传入句柄并基于方法的整数返回抛出错误。
我意识到我对输出没有做正确的事情,但到目前为止,我只想看到一些输出,然后我可以稍后处理它。
当前运行此代码会抛出一个无效错误。
我目前无法在设备本身上进行调试,只能写入日志。
谢谢你的帮助。
2条答案
按热度按时间oxalkeyp1#
这只是猜测。
0可能无效?
如果我在设计javaapi,我会忽略诸如“空终止数组”之类的概念,它们只服务于弱c数据结构。所以,
int [] badgeNumberList
只是一个徽章号码的列表。尝试:
你真的需要javaapi的文档。
pes8fvy92#
我和编写api的人谈过,正确的调用是: