From b8ed2b19e0aaf3c357e2f601d8304acdc525f4f9 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期五, 25 四月 2025 16:54:02 +0800 Subject: [PATCH] refactor(nfc): 优化 NFC 读卡工具类 --- baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java | 26 ++++++++++++++++++-------- 1 files changed, 18 insertions(+), 8 deletions(-) diff --git a/baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java b/baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java index c427898..22349c3 100644 --- a/baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java +++ b/baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java @@ -9,6 +9,7 @@ import com.dayu.baselibrary.bean.BaseUserCardCard; import com.dayu.baselibrary.tools.HexUtil; +import com.tencent.bugly.crashreport.CrashReport; import java.io.IOException; @@ -23,8 +24,6 @@ private static NativeNfcWriteHelper helper; - public NativeNfcWriteHelper(Intent intent, Activity activity) { - } public void setIntent(Intent intent) { this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); @@ -38,7 +37,7 @@ */ public static NativeNfcWriteHelper getInstence(Intent intent, Activity activity) { if (helper == null) { - helper = new NativeNfcWriteHelper(intent, activity); + helper = new NativeNfcWriteHelper(); } helper.setIntent(intent); return helper; @@ -125,7 +124,7 @@ @Override public boolean writeData(byte[] str, int a, int b, NFCCallBack callBack) { - return writeData(str, a, b, true,null); + return writeData(str, a, b, true, null); } @Override @@ -137,7 +136,7 @@ if (null != mfc) { try { //杩炴帴NFC - if (isConnect){ + if (isConnect) { mfc.connect(); } //鑾峰彇鎵囧尯鏁伴噺 @@ -172,11 +171,10 @@ } } } else if (listA_PS.size() != 0 && listA_PS.size() > a) { - if (mfc.authenticateSectorWithKeyA(a, defauleKey)){ - changePasword(a, mfc); + if (mfc.authenticateSectorWithKeyA(a, defauleKey)) { isOpen = true; - }else if (mfc.authenticateSectorWithKeyA(a, listA_PS.get(a))) { + } else if (mfc.authenticateSectorWithKeyA(a, listA_PS.get(a))) { isOpen = true; } } @@ -288,6 +286,18 @@ return false; } + + public boolean changePasword(int a,byte[] passWord, MifareClassic mfc) { + try { + + + } catch (Exception e) { + e.printStackTrace(); + CrashReport.postCatchedException(e); + } + return false; + } + /** * 鍒濆鍖栧崱 * -- Gitblit v1.8.0