Esempio n. 1
0
JSR177_STATUSCODE jsr177_reset_finish(jbyte *atr, jsize *atr_size, void *context) {
    int tmp_atr_size;
    javacall_result result = javacall_carddevice_reset_finish(atr, &tmp_atr_size, context);
    switch (result) {
    case JAVACALL_OK:
        *atr_size = tmp_atr_size;
        return JSR177_STATUSCODE_OK;
    case JAVACALL_FAIL:
    default:
        return JSR177_STATUSCODE_FAIL;
    case JSR177_STATUSCODE_WOULD_BLOCK:
        return JSR177_STATUSCODE_WOULD_BLOCK;
    }
}
Esempio n. 2
0
/**
 * Performs reset of the device.
 * <p>Java declaration:
 * <pre>
 * private native int reset0(byte[] atr);
 * </pre>
 * @param atr ATR bytes
 * @return Length of ATR in case of success, else -1 
 */
KNIEXPORT KNI_RETURNTYPE_INT 
KNIDECL(com_sun_cardreader_PlatformCardDevice_reset0) {
    jint retcode;
    javacall_int32 atr_length;
    char *atr_buffer;
    MidpReentryData* info;
    void *context = NULL;
    javacall_result status_code;
    
    KNI_StartHandles(1);
    KNI_DeclareHandle(atr_handle);

    info = (MidpReentryData*)SNI_GetReentryData(NULL);
    KNI_GetParameterAsObject(1, atr_handle);
    if (KNI_IsNullHandle(atr_handle)) {
        atr_buffer = NULL;
        atr_length = 0;
    } else {
        atr_length = KNI_GetArrayLength(atr_handle);
        atr_buffer = SNI_GetRawArrayPointer(atr_handle);
    }

    if (info == NULL) {
        status_code = javacall_carddevice_reset_start(atr_buffer, &atr_length, &context);
    } else {
        context = info->pResult;
        status_code = javacall_carddevice_reset_finish(atr_buffer, &atr_length, context);
    }

    if (status_code == JAVACALL_WOULD_BLOCK) {
        midp_thread_wait(CARD_READER_DATA_SIGNAL, SIGNAL_RESET, context);
        goto end;
    }

    if (status_code != JAVACALL_OK) {
        retcode = -1;
    } else {
        retcode = atr_length;
    }
end:
    KNI_EndHandles();
    KNI_ReturnInt(retcode);
}