当前位置: 首页>>代码示例>>Java>>正文


Java IsoDep类代码示例

本文整理汇总了Java中android.nfc.tech.IsoDep的典型用法代码示例。如果您正苦于以下问题:Java IsoDep类的具体用法?Java IsoDep怎么用?Java IsoDep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IsoDep类属于android.nfc.tech包,在下文中一共展示了IsoDep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTagDiscovered

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@Override
public void onTagDiscovered(final Tag tag) {
    Log.d(TAG, "Tag found: " + tag.toString());
    Log.d(TAG, "Id: " + HexStrings.toHexString(tag.getId()));
    for (String tech: tag.getTechList()) {
        Log.d(TAG, "Tech: " + tech);
    }

    if (Arrays.asList(tag.getTechList()).contains("android.nfc.tech.IsoDep")) {
        IsoDepApduInterface apduInterface;
        try {
            apduInterface = new IsoDepApduInterface(IsoDep.get(tag));
        } catch (IOException e) {
            fail(e.getMessage());
            e.printStackTrace();
            return;
        }

        dispatchLoadTask(apduInterface);
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:22,代码来源:NFCConnection.java

示例2: transceiveDER

import android.nfc.tech.IsoDep; //导入依赖的package包/类
private DERObject transceiveDER(IsoDep isoDep, DERObject input, boolean needsSelectAidApdu) throws IOException {
    final long startTimeTransceive = System.currentTimeMillis();
    final byte[] derPayload = input.serializeToDER();
    byte[] derResponse;
    Log.d(TAG, "transceiveDER - start - send derPayload length=" + derPayload.length + " byte");

    derResponse = assembleFragment(isoDep, derPayload, needsSelectAidApdu);
    derResponse = keepAliveLoop(isoDep, derResponse);
    derResponse = concatNextResponseBytes(isoDep, derResponse);
    DERObject result = DERParser.parseDER(derResponse);

    long duration = System.currentTimeMillis() - startTimeTransceive;
    Log.d(TAG, "transceiveDER - end - " +
                        "took " + duration + " ms - " +
                        "received length=" + result.getPayload().length + " byte");
    return result;
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:18,代码来源:NFCServerCLTV.java

示例3: assembleFragment

import android.nfc.tech.IsoDep; //导入依赖的package包/类
private byte[] assembleFragment(IsoDep isoDep, byte[] derPayload, boolean needsSelectAidApdu) throws IOException {
    int fragmentByte = 0;
    byte[] derResponse = new byte[0];
    while (fragmentByte < derPayload.length) {
        byte[] fragment = new byte[0];
        if (needsSelectAidApdu) {
            Log.d(TAG, "transceiveDER - select Aid Apdu");
            byte[] retval = isoDep.transceive(NFCUtils.createSelectAidApdu(NFCUtils.AID_ANDROID));
            Log.d(TAG, "transceiveDER - select Aid Apdu OK! "+retval.length);
            if(NFCUtils.isKeepAlive(retval)) {
                needsSelectAidApdu = false;
            }
        }

        int endLength = Math.min(derPayload.length, fragmentByte + NFCUtils.DEFAULT_MAX_FRAGMENT_SIZE);
        byte[] fragmentPart = Arrays.copyOfRange(derPayload, fragmentByte, endLength);
        fragment = ClientUtils.concatBytes(fragment, fragmentPart);

        Log.d(TAG, "transceiveDER - about to send fragment size: " + fragment.length);
        derResponse = isoDep.transceive(fragment);
        Log.d(TAG, "transceiveDER - received payload: " + Arrays.toString(derResponse));
        fragmentByte += fragment.length;
    }
    return derResponse;
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:26,代码来源:NFCServerCLTV.java

示例4: onTagDiscovered

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
    Log.d(TAG, "onTagDiscovered: " + tag);

    final long startTime = System.currentTimeMillis();
    long duration;

    try {
        IsoDep isoDep = IsoDep.get(tag);
        isoDep.connect();
        onTagDiscovered(tag, isoDep, true);
    } catch (Throwable e) {
        Log.e(TAG, "Exception in onTagDiscovered", e);
        getPaymentRequestDelegate().onPaymentError(e.getMessage());
    }
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:17,代码来源:NFCServerCLTV.java

示例5: enableDispatch

import android.nfc.tech.IsoDep; //导入依赖的package包/类
/**
 * Activate NFC dispacher to read NFC Card Set the most important priority to the foreground application
 */
public static void enableDispatch(Activity activity) {

       if (isNfcEnabled(activity)) {

           NfcAdapter adapter = getNfcAdapter(activity);

           PendingIntent pendingIntent = PendingIntent.getActivity(
                   activity,
                   0,
                   new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
                   0);

           IntentFilter[] intentFilter = new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) };
           String[][] techList = new String[][] { { IsoDep.class.getName() } };

           adapter.enableForegroundDispatch(activity, pendingIntent, intentFilter, techList);
       }
}
 
开发者ID:hipay,项目名称:hipay-fullservice-sdk-android,代码行数:22,代码来源:NFCUtils.java

示例6: create

import android.nfc.tech.IsoDep; //导入依赖的package包/类
/**
 * Creates a transceiver for the specified tag.
 * @return null is returned if a transceiver could not be created
 */
public static Transceiver create(Logger logger, Tag tag)
{
	IsoDep isoDep = IsoDep.get(tag);
	if (null == isoDep)
	{
		logger.warn(TAG, "Unable to create IsoDep for NFC tag: " + StringUtil.join(tag.getTechList(), ", "));
		return null;
	}

	logger.info(TAG, "Connnecting to ISO-DEP: " + isoDep.isConnected());
	try
	{
		isoDep.connect();
		isoDep.setTimeout(30000);
		return new Transceiver(logger, isoDep);
	}
	catch (Exception ex)
	{
		logger.error(TAG, "Unable to connect to ISO-DEP", ex);
		return null;
	}
}
 
开发者ID:PIVopacity,项目名称:PIVOpacityDemo-android,代码行数:27,代码来源:Transceiver.java

示例7: readRecord

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@TargetApi(10)
private static CreditCardNfcResult readRecord(IsoDep paramIsoDep, byte paramByte1, byte paramByte2)
  throws IOException, TagReadTimeoutException
{
  ResponseApdu localResponseApdu = new ResponseApdu(transceive(paramIsoDep, ApduUtil.buildReadCommand(paramByte1, paramByte2).command));
  if (ApduUtil.matchesStatus(localResponseApdu, ResponseApdu.WRONG_LENGTH_LE)) {
    localResponseApdu = new ResponseApdu(transceive(paramIsoDep, ApduUtil.buildReadCommand(paramByte1, paramByte2, localResponseApdu.statusWord2).command));
  }
  if (ApduUtil.matchesStatus(localResponseApdu, ResponseApdu.SUCCESS_SW))
  {
    CreditCardNfcResult localCreditCardNfcResult = TlvUtil.parseCreditCardInfoFromTlv(TlvParser.parseTlv(localResponseApdu));
    if (localCreditCardNfcResult != null) {
      return localCreditCardNfcResult;
    }
  }
  return null;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:18,代码来源:NfcReader.java

示例8: onChallengeReceived

import android.nfc.tech.IsoDep; //导入依赖的package包/类
private void onChallengeReceived() {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(getActivity());
    if (adapter == null) {
        Toast.makeText(getActivity(), R.string.no_nfc, Toast.LENGTH_LONG).show();
    } else if (adapter.isEnabled()) {
        Intent intent = getActivity().getIntent();
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent tagIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);
        IntentFilter iso = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);

        ((MainActivity) getActivity()).setOnNFCListener(SignFragment.this);
        adapter.enableForegroundDispatch(getActivity(), tagIntent, new IntentFilter[]{iso},
                new String[][]{new String[]{IsoDep.class.getName()}});

        getView().findViewById(R.id.progressBar).setVisibility(View.INVISIBLE);
        ((TextView) getView().findViewById(R.id.status_text)).setText(R.string.swipe);
    } else {
        Toast.makeText(getActivity(), R.string.nfc_disabled, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:Yubico,项目名称:android-u2f-demo,代码行数:21,代码来源:SignFragment.java

示例9: onChallengeReceived

import android.nfc.tech.IsoDep; //导入依赖的package包/类
private void onChallengeReceived() {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(getActivity());
    if (adapter == null) {
        Toast.makeText(getActivity(), R.string.no_nfc, Toast.LENGTH_LONG).show();
    } else if (adapter.isEnabled()) {
        Intent intent = getActivity().getIntent();
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent tagIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);
        IntentFilter iso = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);

        ((MainActivity) getActivity()).setOnNFCListener(EnrollFragment.this);
        adapter.enableForegroundDispatch(getActivity(), tagIntent, new IntentFilter[]{iso},
                new String[][]{new String[]{IsoDep.class.getName()}});

        getView().findViewById(R.id.progressBar).setVisibility(View.INVISIBLE);
        ((TextView) getView().findViewById(R.id.status_text)).setText(R.string.swipe);
    } else {
        Toast.makeText(getActivity(), R.string.nfc_disabled, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:Yubico,项目名称:android-u2f-demo,代码行数:21,代码来源:EnrollFragment.java

示例10: doTransceiveUTF8

import android.nfc.tech.IsoDep; //导入依赖的package包/类
private String doTransceiveUTF8(IsoDep iso, byte[] command) throws IOException {
    final byte[] ret = iso.transceive(command);

    Log.d(TAG, "Sent: " + ByteArrayToHexString(command) + "\nRecv: " + ByteArrayToHexString(ret));

    final StringBuffer buffer = new StringBuffer();
    for(int i = 1; i < ret.length; i++) {
        buffer.append((char)ret[i]);
    }

    final String retStr = buffer.toString();

    Log.d(TAG, "UTF-8: " + retStr);
    return retStr;
}
 
开发者ID:UoLCompSoc,项目名称:IDCardReader,代码行数:16,代码来源:MainActivity.java

示例11: get

import android.nfc.tech.IsoDep; //导入依赖的package包/类
public static AndroidCard get(Tag tag) throws IOException {
    IsoDep card = IsoDep.get(tag);

    if(card != null) {
        /* Workaround for the Samsung Galaxy S5 (since the
         * first connection always hangs on transceive).
         * TODO: This could be improved if we could identify
         * Samsung Galaxy S5 devices
         */
        card.connect();
        card.close();
        return new AndroidCard(card);
    } else {
        return null;
    }
}
 
开发者ID:fidesmo,项目名称:nordpol,代码行数:17,代码来源:AndroidCard.java

示例12: doInBackground

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@Override
protected String doInBackground(Tag... params) {
    Tag tag = params[0];

    tagCommunicator = IsoDep.get(tag);

    try {
        tagCommunicator.connect();
        tagCommunicator.setTimeout(5000);

        if (tagCommunicator.isConnected()) {
            readCard();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:jthuraisamy,项目名称:MasterTap,代码行数:20,代码来源:CardReaderTask.java

示例13: get

import android.nfc.tech.IsoDep; //导入依赖的package包/类
public static AndroidCard get(Tag tag) throws IOException {
    IsoDep card = IsoDep.get(tag);

    /* Workaround for the Samsung Galaxy S5 (since the
     * first connection always hangs on transceive).
     * TODO: This could be improved if we could identify
     * Samsung Galaxy S5 devices
     */
    card.connect();
    card.close();

    if(card != null) {
        return new AndroidCard(card);
    } else {
        return null;
    }
}
 
开发者ID:greenaddress,项目名称:WalletCordova,代码行数:18,代码来源:AndroidCard.java

示例14: onTagDiscovered

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
    doTapFeedback();
    clearImage();
    // maybe clear console or show separator, depends on settings
    if (mAutoClear) {
        clearMessages();
    } else {
        addMessageSeparator();
    }
    // get IsoDep handle and run xcvr thread
    IsoDep isoDep = IsoDep.get(tag);
    if (isoDep == null) {
        onError(getString(R.string.wrong_tag_err));
    } else {
        ReaderXcvr xcvr = new PaymentReaderXcvr(isoDep, "", this, TEST_MODE_EMV_READ);
        new Thread(xcvr).start();
    }
}
 
开发者ID:doc-rj,项目名称:smartcard-reader,代码行数:20,代码来源:EmvReadActivity.java

示例15: onTagDiscovered

import android.nfc.tech.IsoDep; //导入依赖的package包/类
@Override
public void onTagDiscovered(Tag tag) {
    doTapFeedback();
    clearImage();
    // maybe clear console or show separator, depends on settings
    if (mAutoClear) {
        clearMessages();
    } else {
        // two separators between taps/discoveries
        addMessageSeparator();
        addMessageSeparator();
    }
    // get IsoDep handle and run xcvr thread
    IsoDep isoDep = IsoDep.get(tag);
    if (isoDep == null) {
        onError(getString(R.string.wrong_tag_err));
    } else {
        List<SmartcardApp> memberApps = mGrpToMembersMap.get(mSelectedGrpPos);
        new Thread(new BatchReaderXcvr(isoDep, memberApps, this)).start();
    }
}
 
开发者ID:doc-rj,项目名称:smartcard-reader,代码行数:22,代码来源:BatchSelectActivity.java


注:本文中的android.nfc.tech.IsoDep类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。