app/build.gradle | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/androidTest/java/com/dayu/recharge/ExampleInstrumentedTest.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/dayu/recharge/activity/BaseActivity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/dayu/recharge/tools/BaseNFCHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/dayu/recharge/tools/NFCWriteHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/build.gradle
@@ -16,8 +16,8 @@ applicationId "com.dayu.recharge" minSdk 23 targetSdk 26 versionCode 1 versionName "1.0" versionCode 14 versionName "1.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" app/src/androidTest/java/com/dayu/recharge/ExampleInstrumentedTest.java
@@ -2,25 +2,25 @@ import android.content.Context; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; //import androidx.test.platform.app.InstrumentationRegistry; //import androidx.test.ext.junit.runners.AndroidJUnit4; // //import org.junit.Test; //import org.junit.runner.RunWith; // //import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.dayu.recharge", appContext.getPackageName()); } } //@RunWith(AndroidJUnit4.class) //public class ExampleInstrumentedTest { // @Test // public void useAppContext() { // // Context of the app under test. // Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); // assertEquals("com.dayu.recharge", appContext.getPackageName()); // } //} app/src/main/java/com/dayu/recharge/activity/BaseActivity.java
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager; import android.content.pm.Signature; import android.os.Bundle; import android.util.Log; import android.view.View; import androidx.appcompat.app.AppCompatActivity; @@ -21,6 +22,7 @@ */ public class BaseActivity extends AppCompatActivity { private final String TAG = "BaseActivity"; public TitleBar titleBar = null; //z主线程查询 @@ -34,7 +36,9 @@ super.onCreate(savedInstanceState); baseDao = BaseDaoSingleton.getInstance(this); asynchBaseDao = BaseDaoSingleton.getAsynchInstance(this); Log.i(TAG, SIGN); if (!isMyApp()) { Log.i(TAG, "isMyApp"); this.finish(); } } app/src/main/java/com/dayu/recharge/tools/BaseNFCHelper.java
@@ -58,14 +58,15 @@ // byte[] encryptedBytes2 = Base64.decode("aYC9feYEOFOQHuzflLIXSw==", Base64.DEFAULT); byte[] encryptedBytes2 = Base64.decode("qeg4DUWf0ni9JfRWtD2krA==", Base64.DEFAULT); byte[] decryptedBytes2 = cipher.doFinal(encryptedBytes2); //decryptedBytes2 对应010203040506 companyKeyA = new String(decryptedBytes2, StandardCharsets.UTF_8); companyKey = HexUtil.hexToByteArray(companyKeyA); //修改后的密码 byte[] encryptedBytes3 = Base64.decode("n+SSZFb4DHsreVav/Z5ftg==", Base64.DEFAULT); byte[] decryptedBytes3 = cipher.doFinal(encryptedBytes3); companyKeyB = new String(decryptedBytes3, StandardCharsets.UTF_8); //decryptedBytes3 对应202311202048 companyKeyB = new String(decryptedBytes2, StandardCharsets.UTF_8); } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | app/src/main/java/com/dayu/recharge/tools/NFCWriteHelper.java
@@ -66,7 +66,7 @@ public boolean writeData(byte[] str, int a, int b) { Log.i("NFCWreatActivity", "writeData: a=" + a + " b=" + b); //写卡时修改所有密码 // changePasword(a); changePasword(a); if (str.length <= 16) { try { MifareClassic mfc = MifareClassic.get(tag); @@ -142,7 +142,7 @@ data[i] = dataA[i]; } //输入控制位 data[6] = (byte) 0xff; data[6] = (byte) 0xFF; data[7] = (byte) 0x07; data[8] = (byte) 0x80; data[9] = (byte) 0x69; @@ -155,6 +155,11 @@ int bCount = mfc.getBlockCountInSector(a); //写到扇区的最后一个块 mfc.writeBlock(bIndex + bCount - 1, data); // byte[] dataa = mfc.readBlock(bIndex + bCount - 1); // // 修改密码 A // mfc.writeBlock(mfc.sectorToBlock(a) + 3, dataA); // // 修改密码 B // mfc.writeBlock(mfc.sectorToBlock(a) + 7, dataB); } return true; } catch (Exception e) {