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


Java IsoDep.setTimeout方法代码示例

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


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

示例1: 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

示例2: U2F_V2

import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
public U2F_V2(IsoDep tag) throws IOException, APDUError {
    this.tag = tag;
    tag.setTimeout(5000);
    tag.connect();
    try {
        send(SELECT_COMMAND);
    } catch (APDUError e) {
        if(e.getCode() == 0x6a82) {
            send(SELECT_COMMAND_YUBICO);
        } else {
            throw e;
        }
    }
}
 
开发者ID:Yubico,项目名称:android-u2f-demo,代码行数:15,代码来源:U2F_V2.java

示例3: transceiveApdu

import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
static byte[] transceiveApdu(IsoDep tag, byte[] cmd) {
	if (tag != null) {
		try {
			if (!tag.isConnected()) {
				tag.connect();
				tag.setTimeout(10000);
			}

			return tag.transceive(cmd);
		} catch (Exception e) {
		}
	}
	return null;
}
 
开发者ID:sinpolib,项目名称:nfcspy,代码行数:15,代码来源:NfcManager.java

示例4: IsoDepApduInterface

import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
public IsoDepApduInterface(final IsoDep tag) throws IOException {
    this.tag = tag;

    tag.connect();
    tag.setTimeout(TAG_TIMEOUT);
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:7,代码来源:IsoDepApduInterface.java

示例5: readIntent

import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@TargetApi(10)
public static CreditCardNfcResult readIntent(Intent paramIntent)
  throws IOException, UnsupportedTagException, TagReadTimeoutException, TagReadException
{
  IsoDep localIsoDep = IsoDep.get((Tag)paramIntent.getParcelableExtra("android.nfc.extra.TAG"));
  if (localIsoDep == null) {
    throw new UnsupportedTagException();
  }
  try
  {
    localIsoDep.connect();
    localIsoDep.setTimeout(NFC_TIMEOUT_MS);
    String[] arrayOfString1 = ApduUtil.SUPPORTED_PSE_AIDS;
    int i = arrayOfString1.length;
    for (int j = 0; j < i; j++)
    {
      ResponseApdu localResponseApdu = new ResponseApdu(transceive(localIsoDep, ApduUtil.buildSelectCommand(arrayOfString1[j]).command));
      CreditCardNfcResult localCreditCardNfcResult2;
      if (ApduUtil.matchesStatus(localResponseApdu, ResponseApdu.SUCCESS_SW))
      {
        TlvDatum localTlvDatum = TlvUtil.findNestedTlv(TlvParser.parseTlv(localResponseApdu), TlvUtil.APPLICATION_IDENTIFIER_TAG);
        if (localTlvDatum != null) {
          localCreditCardNfcResult2 = aidRead(localIsoDep, TlvUtil.getValue(localTlvDatum));
        }
      }
      for (CreditCardNfcResult localCreditCardNfcResult1 = localCreditCardNfcResult2; localCreditCardNfcResult1 != null; localCreditCardNfcResult1 = null) {
        return localCreditCardNfcResult1;
      }
    }
    String[] arrayOfString2 = ApduUtil.SUPPORTED_AIDS;
    int k = arrayOfString2.length;
    for (int m = 0; m < k; m++)
    {
      CreditCardNfcResult localCreditCardNfcResult3 = aidRead(localIsoDep, arrayOfString2[m]);
      if (localCreditCardNfcResult3 != null) {
        return localCreditCardNfcResult3;
      }
    }
    throw new TagReadException();
  }
  finally
  {
    localIsoDep.close();
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:46,代码来源:NfcReader.java

示例6: onUnlockAttempted

import android.nfc.tech.IsoDep; //导入方法依赖的package包/类
@Override
public boolean onUnlockAttempted(Tag tag) {
    Log.d(TAG, "Got unlock tag: " + tag);

    try {
        IsoDep isoDepTag = IsoDep.get(tag);
        if (isoDepTag == null) {
            Log.d(TAG, "Not an IsoDep tag: " + tag);

            return false;
        }
        isoDepTag.setTimeout(60 * 1000);

        MuscleCard msc = new MuscleCard(isoDepTag);

        msc.select();
        boolean pinValid = msc.verifyPin(pin);
        if (!pinValid) {
            Log.d(TAG, "Invalid PIN");

            return false;
        }

        // exportCertificate(msc);

        byte[] data = new byte[16];
        random.nextBytes(data);

        byte[] signature = msc.sign(data);

        Signature sig = Signature.getInstance("SHA512withRSA");
        sig.initVerify(pubKey);
        sig.update(data);
        boolean signatureValid = sig.verify(signature);
        Log.d(TAG, "Signature valid: " + signatureValid);

        if (signatureValid) {
            Log.d(TAG, "valided SC signature, granting trust");
            GhettoTrustAgent.sendGrantTrust(GhettoApp.getInstance(),
                    "GhettoTrustAgent::NFC::Signature",
                    GhettoTrustAgentSettings.TRUST_DURATION_30SECS,
                    false);

            return true;
        }

        return false;
    } catch (Exception e) {
        Log.e(TAG, "Error: " + e.getMessage(), e);

        return false;
    }
}
 
开发者ID:nelenkov,项目名称:ghetto-unlock,代码行数:54,代码来源:GhettoNfcUnlockHandler.java


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