1 文件已重命名
2个文件已添加
13个文件已修改
2个文件已删除
New file |
| | |
| | | # For more information about using CMake with Android Studio, read the |
| | | # documentation: https://d.android.com/studio/projects/add-native-code.html |
| | | |
| | | # Sets the minimum version of CMake required to build the native library. |
| | | |
| | | cmake_minimum_required(VERSION 3.4.1) |
| | | |
| | | # Creates and names a library, sets it as either STATIC |
| | | # or SHARED, and provides the relative paths to its source code. |
| | | # You can define multiple libraries, and CMake builds them for you. |
| | | # Gradle automatically packages shared libraries with your APK. |
| | | |
| | | add_library( # Sets the name of the library. |
| | | native-lib |
| | | |
| | | # Sets the library as a shared library. |
| | | SHARED |
| | | |
| | | # Provides a relative path to your source file(s). |
| | | src/main/cpp/native-lib.cpp ) |
| | | |
| | | # Searches for a specified prebuilt library and stores the path as a |
| | | # variable. Because CMake includes system libraries in the search path by |
| | | # default, you only need to specify the name of the public NDK library |
| | | # you want to add. CMake verifies that the library exists before |
| | | # completing its build. |
| | | |
| | | find_library( # Sets the name of the path variable. |
| | | log-lib |
| | | |
| | | # Specifies the name of the NDK library that |
| | | # you want CMake to locate. |
| | | log ) |
| | | |
| | | # Specifies libraries CMake should link to your target library. You |
| | | # can link multiple libraries, such as libraries you define in this |
| | | # build script, prebuilt third-party libraries, or system libraries. |
| | | |
| | | target_link_libraries( # Specifies the target library. |
| | | native-lib |
| | | |
| | | # Links the target library to the log library |
| | | # included in the NDK. |
| | | ${log-lib} ) |
| | |
| | | android { |
| | | signingConfigs { |
| | | debug { |
| | | storeFile file('D:\\androidProject\\charge\\app\\dycz.jks') |
| | | storeFile file('../dycz.jks') |
| | | storePassword 'dycz@2023' |
| | | keyAlias 'dayu' |
| | | keyPassword 'dycz@2023' |
| | |
| | | // dirs 'libs' |
| | | // } |
| | | // } |
| | | externalNativeBuild { |
| | | cmake { |
| | | path "CMakeLists.txt" |
| | | } |
| | | } |
| | | } |
| | | //ps:dycz@2023 |
| | | //alias:dayu |
New file |
| | |
| | | #include <jni.h> |
| | | #include <string> |
| | | #include <android/log.h> |
| | | #include <string.h> |
| | | #include <jni.h> |
| | | |
| | | static jclass contextClass; |
| | | static jclass signatureClass; |
| | | static jclass packageNameClass; |
| | | static jclass packageInfoClass; |
| | | |
| | | const char* RELEASE_SIGN = "308202b8308201a0020101300d06092a864886f70d01010b05003022310f300d06035504030c06e5a4a7e7a6b9310f300d06035504070c06e5a4a9e6b4a5301e170d3233313132303035333131325a170d3438313131333035333131325a3022310f300d06035504030c06e5a4a7e7a6b9310f300d06035504070c06e5a4a9e6b4a530820122300d06092a864886f70d01010105000382010f003082010a0282010100a0924f3d618e4a622def691e16e54ce5bdfd035bd73e7cb947d2bf3bd0c00afa26e52963e0299fc06d76d153be696c5285d630577e1dcb2b740a72b6d904482217de308fb91c8435441ed05e844ced1e5c3446d82cb8f38751049df26a42adcfc33f1f12c2ce03f676e5d148aad800ace89670b87835e2c02a8570a0b6740d9c0669d4cb3c597d0b2dd49fc0904e885773b6d3a87d9f1e73eb526e0d1a9e9e3c48d986938286cd824151b5a6214faf89d3e699524511b23c86d3b110a7f0bb56a6d2436f69816538a62a38cb1fee6eb685d267cc200df8af51b936bd280beaa2023f75678d77a11ac6de734b30af63d394c8b63bccf2115a47ea15c9212c740d0203010001300d06092a864886f70d01010b05000382010100307cafa9b14be91ba6424cfcc6aed75b069a1c4d6eb646eab0de93f372f236f5f0a6097499df99391075d6ced18d419a2b15adb041890e2b56a3bfbd6be40efee99c5c713ba8ea1d45da09b67916106116e96eb735271c4d53e0739f753145cbc42e149ad3d9507d422ec1c6f1a7f792a4542f9a64f0de3d4f4af69f0fb3390ef3577dcf8844cf744426d173b0934d879148062c5ca64022dc99af370dbfeaf2b5d4a279b20c54a361bca12c25bf185c2885519bbbc36e46ddb083080f0cc5b1f2eafe964ebce5071b0ae7d92a34a9193861b996d2c0299b1993f41063a27038199365a6e3cb27a02ffa9facdc48a63713eb5fbf90e9fd73056aba16b28e5fee"; |
| | | const char *AUTH_KEY = "8b989c546f9ae3eb48ae977b4d4f11c99ae43217436200a0f6d0c4517150e0e6"; |
| | | |
| | | //extern "C" JNIEXPORT jstring |
| | | // |
| | | //JNICALL |
| | | //Java_com_yglx_testjni_MainActivity_getKey( |
| | | // JNIEnv *env, |
| | | // jobject /* this */) { |
| | | // return env->NewStringUTF(AUTH_KEY); |
| | | //} |
| | | |
| | | JNIEXPORT jint JNICALL JNI_OnLoad (JavaVM* vm,void* reserved){ |
| | | |
| | | JNIEnv* env = NULL; |
| | | jint result=-1; |
| | | if(vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) |
| | | return result; |
| | | |
| | | contextClass = (jclass)env->NewGlobalRef((env)->FindClass("android/content/Context")); |
| | | signatureClass = (jclass)env->NewGlobalRef((env)->FindClass("android/content/pm/Signature")); |
| | | packageNameClass = (jclass)env->NewGlobalRef((env)->FindClass("android/content/pm/PackageManager")); |
| | | packageInfoClass = (jclass)env->NewGlobalRef((env)->FindClass("android/content/pm/PackageInfo")); |
| | | |
| | | __android_log_print(ANDROID_LOG_DEBUG, "jw", "sss"); |
| | | return JNI_VERSION_1_4; |
| | | } |
| | | |
| | | |
| | | |
| | | extern "C" |
| | | JNIEXPORT jstring |
| | | Java_com_dayu_recharge_tools_BaseNFCHelper_getSafeKey(JNIEnv *env, jobject instance,jobject contextObject) { |
| | | jmethodID getPackageManagerId = (env)->GetMethodID(contextClass, "getPackageManager","()Landroid/content/pm/PackageManager;"); |
| | | jmethodID getPackageNameId = (env)->GetMethodID(contextClass, "getPackageName","()Ljava/lang/String;"); |
| | | jmethodID signToStringId = (env)->GetMethodID(signatureClass, "toCharsString","()Ljava/lang/String;"); |
| | | jmethodID getPackageInfoId = (env)->GetMethodID(packageNameClass, "getPackageInfo","(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;"); |
| | | jobject packageManagerObject = (env)->CallObjectMethod(contextObject, getPackageManagerId); |
| | | jstring packNameString = (jstring)(env)->CallObjectMethod(contextObject, getPackageNameId); |
| | | jobject packageInfoObject = (env)->CallObjectMethod(packageManagerObject, getPackageInfoId,packNameString, 64); |
| | | jfieldID signaturefieldID =(env)->GetFieldID(packageInfoClass,"signatures", "[Landroid/content/pm/Signature;"); |
| | | jobjectArray signatureArray = (jobjectArray)(env)->GetObjectField(packageInfoObject, signaturefieldID); |
| | | jobject signatureObject = (env)->GetObjectArrayElement(signatureArray,0); |
| | | |
| | | const char* signStrng = (env)->GetStringUTFChars((jstring)(env)->CallObjectMethod(signatureObject, signToStringId),0); |
| | | __android_log_print(ANDROID_LOG_DEBUG, "jw_sign","%s",signStrng); |
| | | __android_log_print(ANDROID_LOG_DEBUG, "jw_sign2","%s",signStrng+1023); |
| | | |
| | | __android_log_print(ANDROID_LOG_DEBUG,"jw_rels","%s",RELEASE_SIGN); |
| | | __android_log_print(ANDROID_LOG_DEBUG,"jw_","sdf:%zd,sfs:%zd",strlen(signStrng),strlen(RELEASE_SIGN)); |
| | | |
| | | if(strcmp(signStrng,RELEASE_SIGN)==0)//签名一致 返回合法的 api key,否则返回错误 |
| | | { |
| | | return (env)->NewStringUTF(AUTH_KEY); |
| | | }else |
| | | { |
| | | return (env)->NewStringUTF("error"); |
| | | } |
| | | } |
| | |
| | | package com.dayu.recharge; |
| | | |
| | | import android.app.Application; |
| | | import android.nfc.Tag; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import com.dayu.recharge.dao.BaseDaoSingleton; |
| | | import com.dayu.recharge.dbBean.DeviceNumber; |
| | | import com.dayu.recharge.dbBean.IpBean; |
| | | import com.dayu.recharge.utils.DeviceNumberUtils; |
| | | import com.dayu.recharge.utils.ToastUtil; |
| | | import com.easysocket.EasySocket; |
| | | import com.easysocket.config.EasySocketOptions; |
| | | import com.easysocket.entity.SocketAddress; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | import com.dayu.recharge.net.ScoketMessageProtocol; |
| | | import com.dayu.recharge.net.SocketCallBack; |
| | | import com.dayu.recharge.net.SocketData; |
| | |
| | | import com.dayu.recharge.tools.HexUtil; |
| | | import com.dayu.recharge.utils.AidlUtil; |
| | | import com.dayu.recharge.utils.CRC8; |
| | | import com.dayu.recharge.utils.DeviceNumberUtils; |
| | | import com.dayu.recharge.utils.SocketUtil; |
| | | import com.dayu.recharge.utils.TipUtil; |
| | | |
| | | import com.dayu.recharge.utils.ToastUtil; |
| | | import com.easysocket.EasySocket; |
| | | import com.easysocket.config.EasySocketOptions; |
| | | import com.easysocket.entity.SocketAddress; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.Arrays; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | public class MyApplication extends Application { |
| | | public static String TAG = "MyApplication"; |
| | |
| | | .setMaxWriteBytes(150) |
| | | .setMaxReadBytes(150) |
| | | .setRequestTimeout(5 * 1000) |
| | | |
| | | .setBackupAddress(new SocketAddress(backUpIp, backUpPort)) |
| | | .build(); |
| | | |
| | |
| | | |
| | | import android.app.Activity; |
| | | import android.app.PendingIntent; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.nfc.NdefMessage; |
| | | import android.nfc.NfcAdapter; |
| | | import android.nfc.NfcEvent; |
| | | import android.nfc.Tag; |
| | | import android.nfc.cardemulation.CardEmulation; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | |
| | | import com.dayu.recharge.card.UserCard; |
| | | import com.dayu.recharge.tools.LoyaltyCardReader; |
| | | import com.dayu.recharge.tools.NfcReadHelper; |
| | | import com.dayu.recharge.utils.LogUtil; |
| | | import com.dayu.recharge.utils.TipUtil; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Author:Created by Ricky on 2017/8/25. |
| | |
| | | * 启动Activity,界面可见时. |
| | | */ |
| | | |
| | | |
| | | |
| | | public static int READER_FLAGS = |
| | | NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK; |
| | | |
| | |
| | | |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.widget.Toast; |
| | | |
| | | import com.dayu.recharge.MyApplication; |
| | | |
| | | import com.dayu.recharge.R; |
| | | import com.dayu.recharge.card.CleanCard; |
| | | import com.dayu.recharge.card.CleanUserCard; |
| | |
| | | import com.dayu.recharge.socketBean.BalanceSelecteRequestBean; |
| | | import com.dayu.recharge.socketBean.RechargeRequestBean; |
| | | import com.dayu.recharge.tools.BcdUtil; |
| | | import com.dayu.recharge.tools.HexUtil; |
| | | import com.dayu.recharge.tools.NFCWriteHelper; |
| | | import com.dayu.recharge.tools.NfcReadHelper; |
| | | import com.dayu.recharge.tools.WriteCardUtils; |
| | |
| | | */ |
| | | private void checkHasUser() { |
| | | |
| | | String cardType = NfcReadHelper.getInstence(intent).getCradType(); |
| | | String cardType = NfcReadHelper.getInstence(intent, this).getCradType(); |
| | | Log.i("NFCWreatActivity", "cardType=" + cardType); |
| | | if (cardType.equals(MyCommon.USER_CARD_TYPE_1) || |
| | | cardType.equals(MyCommon.USER_CARD_TYPE_2) || |
| | |
| | | || configurationPowerCard != null) { |
| | | if (userCard != null && TextUtils.isEmpty(morny)) { |
| | | |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, this); |
| | | } |
| | | if (cleanCard != null) { |
| | | setClean(intent, cleanCard); |
| | |
| | | //用户卡 |
| | | startDetailActivity(userCardBean.getUserName(), "启用"); |
| | | } else if (!TextUtils.isEmpty(morny)) { |
| | | TipUtil.show(NFCWreatActivity.this, "充值成功", new TipUtil.TipListener() { |
| | | @Override |
| | | public void onCancle() { |
| | | NFCWreatActivity.this.finish(); |
| | | } |
| | | }); |
| | | TipUtil.show(NFCWreatActivity.this, "充值成功", () -> NFCWreatActivity.this.finish()); |
| | | } else { |
| | | TipUtil.show(NFCWreatActivity.this, "写卡成功", new TipUtil.TipListener() { |
| | | @Override |
| | | public void onCancle() { |
| | | NFCWreatActivity.this.finish(); |
| | | } |
| | | }); |
| | | TipUtil.show(NFCWreatActivity.this, "写卡成功", () -> NFCWreatActivity.this.finish()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | userCard.setRechargeTimes(userCard.getRechargeTimes() + 1); |
| | | } else if ("01".equalsIgnoreCase(state)) { |
| | | userCard.setState("01"); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, NFCWreatActivity.this); |
| | | NFCWreatActivity.this.finish(); |
| | | TipUtil.show("充值报文错误-禁用"); |
| | | } else if ("02".equalsIgnoreCase(state)) { |
| | |
| | | |
| | | //往卡内写充值后的数据 |
| | | private void rechargeWrratCard() { |
| | | UserCard userCardold = NfcReadHelper.getInstence(intent).getUserCardData(); |
| | | UserCard userCardold = NfcReadHelper.getInstence(intent, this).getUserCardData(); |
| | | if (userCardold != null) { |
| | | //判断是否充值的是一个卡 |
| | | if (userCard.getInitPeasantCode().equals(userCardold.getInitPeasantCode())) { |
| | | userCard.setState("00"); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, this); |
| | | // 打印相关 |
| | | if (userFlag) { |
| | | setPrinterData(rechargeBean); |
| | |
| | | } |
| | | |
| | | private void setmanageCard(Intent intent, final ManageCard manageCard) { |
| | | manageCardFlag = NFCWriteHelper.getInstence(intent).writeData(manageCard.toZeroByte(), 1, 0); |
| | | manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toZeroByte(), 1, 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param clearOrInitCard |
| | | */ |
| | | private void setClean(Intent intent, final CleanCard clearOrInitCard) { |
| | | cleanFlag = NFCWriteHelper.getInstence(intent).writeData(clearOrInitCard.toByte(), 1, 0); |
| | | cleanFlag = NFCWriteHelper.getInstence(intent, this).writeData(clearOrInitCard.toByte(), 1, 0); |
| | | } |
| | | |
| | | |
| | |
| | | * @param registeredCard |
| | | */ |
| | | private void setRegisteredCard(Intent intent, RegisteredCard registeredCard) { |
| | | registeredFlag = NFCWriteHelper.getInstence(intent).writeData(registeredCard.toByte(), 1, 0); |
| | | registeredFlag = NFCWriteHelper.getInstence(intent, this).writeData(registeredCard.toByte(), 1, 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param cleanUserCard |
| | | */ |
| | | private void setCleanUserCard(Intent intent, CleanUserCard cleanUserCard) { |
| | | cleanUserCardFlag = NFCWriteHelper.getInstence(intent).writeData(cleanUserCard.toByte(), 1, 0); |
| | | cleanUserCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(cleanUserCard.toByte(), 1, 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void setDomainCard(Intent intent, DomainCard domainCard) { |
| | | try { |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent).writeData(domainCard.getZeroByte(), 1, 0); |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getZeroByte(), 1, 0); |
| | | if (!domainCrdFlag) { |
| | | return; |
| | | } |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent).writeData(domainCard.getOneByte(), 1, 1); |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getOneByte(), 1, 1); |
| | | if (!domainCrdFlag) { |
| | | return; |
| | | } |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent).writeData(domainCard.getTwoByte(), 1, 2); |
| | | domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getTwoByte(), 1, 2); |
| | | } catch (Exception e) { |
| | | domainCrdFlag = false; |
| | | throw new RuntimeException(e); |
| | |
| | | } |
| | | |
| | | private void setTestCard(Intent intent, TestCard testCard) { |
| | | testCardFlag = NFCWriteHelper.getInstence(intent).writeData(testCard.toByte(), 1, 0); |
| | | testCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(testCard.toByte(), 1, 0); |
| | | } |
| | | |
| | | |
| | | private void setConfigDeviceRegiest(Intent intent, ConfigureDeviceRegistrationCrad configureDeviceRegistrationCrad) { |
| | | configDeviceRegiestFlag = NFCWriteHelper.getInstence(intent).writeData(configureDeviceRegistrationCrad.toByte(), 1, 0); |
| | | configDeviceRegiestFlag = NFCWriteHelper.getInstence(intent, this).writeData(configureDeviceRegistrationCrad.toByte(), 1, 0); |
| | | } |
| | | |
| | | private void setConfigurationPower(Intent intent, ConfigurationPowerCard configurationPowerCard) { |
| | | try { |
| | | configPowerFlag = NFCWriteHelper.getInstence(intent).writeData(configurationPowerCard.toByte(), 1, 0); |
| | | configPowerFlag = NFCWriteHelper.getInstence(intent, this).writeData(configurationPowerCard.toByte(), 1, 0); |
| | | } catch (Exception e) { |
| | | configPowerFlag = false; |
| | | throw new RuntimeException(e); |
| | |
| | | userCard.setBalance(balance); |
| | | userCard.setState("00"); |
| | | //补卡逻辑 |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, NFCWreatActivity.this); |
| | | if (userFlag) { |
| | | TipUtil.show(NFCWreatActivity.this, "补卡成功", new TipUtil.TipListener() { |
| | | @Override |
| | |
| | | stateText.append("禁用"); |
| | | userCard.setState("01"); |
| | | userCard.setBalance(balance); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, NFCWreatActivity.this); |
| | | startDetailActivity(name, stateText.toString()); |
| | | |
| | | } else if ("02".equals(state)) { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | nfcWreatActivity=null; |
| | | nfcWreatActivity = null; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.dayu.recharge.utils.DeviceNumberUtils; |
| | | import com.dayu.recharge.view.ProgressDialog; |
| | | import com.msd.ocr.idcard.LibraryInitOCR; |
| | | |
| | | import com.dayu.recharge.MyApplication; |
| | | import com.dayu.recharge.card.UserCard; |
| | | import com.dayu.recharge.databinding.ActivityNewCardBinding; |
| | |
| | | } |
| | | }); |
| | | |
| | | newCardBinding.newCardRegistBtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | newCardBinding.newCardRegistBtn.setOnClickListener(v -> { |
| | | |
| | | String userName = newCardBinding.newCardName.getText().toString(); |
| | | long date = System.currentTimeMillis(); |
| | | String phone = newCardBinding.newCardPhone.getText().toString(); |
| | | String userID = newCardBinding.newCardId.getText().toString().toUpperCase(); |
| | | String userName = newCardBinding.newCardName.getText().toString(); |
| | | long date = System.currentTimeMillis(); |
| | | String phone = newCardBinding.newCardPhone.getText().toString(); |
| | | String userID = newCardBinding.newCardId.getText().toString().toUpperCase(); |
| | | |
| | | |
| | | if (!TextUtils.isEmpty(userName) |
| | | && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(userID) |
| | | ) { |
| | | if (userName.length() <= 1 || !validateName(userName)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确姓名"); |
| | | return; |
| | | } else if (phone.length() < 11 || !isValidPhoneNumber(phone)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确手机号"); |
| | | return; |
| | | } else if (!Utils.check(userID)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确身份证号"); |
| | | return; |
| | | } else { |
| | | userCardBean = new UserCardBean(); |
| | | userCardBean.setUserName(userName); |
| | | userCardBean.setDate(date); |
| | | userCardBean.setSerial(adminData.getSerial()); |
| | | userCardBean.setPhone(phone); |
| | | userCardBean.setUserID(userID); |
| | | initCard(); |
| | | } |
| | | |
| | | if (!TextUtils.isEmpty(userName) |
| | | && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(userID) |
| | | ) { |
| | | if (userName.length() <= 1 || !validateName(userName)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确姓名"); |
| | | return; |
| | | } else if (phone.length() < 11 || !isValidPhoneNumber(phone)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确手机号"); |
| | | return; |
| | | } else if (!Utils.check(userID)) { |
| | | TipUtil.show(NewCardActivity.this, "请输入正确身份证号"); |
| | | return; |
| | | } else { |
| | | TipUtil.show(NewCardActivity.this, "请输入完整内容"); |
| | | userCardBean = new UserCardBean(); |
| | | userCardBean.setUserName(userName); |
| | | userCardBean.setDate(date); |
| | | userCardBean.setSerial(adminData.getSerial()); |
| | | userCardBean.setPhone(phone); |
| | | userCardBean.setUserID(userID); |
| | | initCard(); |
| | | } |
| | | |
| | | } else { |
| | | TipUtil.show(NewCardActivity.this, "请输入完整内容"); |
| | | } |
| | | }); |
| | | } |
| | |
| | | }) |
| | | .request((allGranted, grantedList, deniedList) -> { |
| | | if (allGranted) {//所有申请的权限都已通过 |
| | | startCamera(); |
| | | // startCamera(); |
| | | } else {//您拒绝了如下权限:$deniedList |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private void startCamera() { |
| | | |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putBoolean("saveImage", false); |
| | | bundle.putInt("requestCode", SCAN_IDCARD_REQUEST); |
| | | bundle.putInt("type", 0); //0身份证, 1驾驶证 |
| | | LibraryInitOCR.startScan(NewCardActivity.this, bundle); |
| | | } |
| | | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | |
| | | import android.content.Intent; |
| | | import android.nfc.NfcAdapter; |
| | | import android.os.Bundle; |
| | | import android.os.Message; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | |
| | |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Copyright (C), 2023, |
| | |
| | | redCardBinding.redRemainderBlance.setText("剩余金额:" + MornyUtil.changeF2Y(blance) + "元"); |
| | | redCardBinding.redStatu.setText("卡状态:" + statu); |
| | | if (userCard != null) { |
| | | redCardBinding.redInitCode.setText( userCard.getInitPeasantCode()); |
| | | redCardBinding.redInitCode.setText(userCard.getInitPeasantCode()); |
| | | Calendar calendar = userCard.getRechargeDate(); |
| | | if (calendar != null) { |
| | | int year = calendar.get(Calendar.YEAR); |
| | |
| | | */ |
| | | |
| | | public void readAllData(Intent intent) { |
| | | NfcReadHelper.getInstence(intent) |
| | | NfcReadHelper.getInstence(intent, this) |
| | | .getOneSectorData(new NfcReadHelper.NFCCallListback() { |
| | | @Override |
| | | public void callBack(List<byte[]> data) { |
| | |
| | | userCard.setBalance(balance); |
| | | userCard.setState("00"); |
| | | |
| | | WriteCardUtils.setUser(intent, userCard); |
| | | WriteCardUtils.setUser(intent, userCard, ReadCardAcitivy.this); |
| | | stateText.append("启用"); |
| | | } else if ("01".equals(state)) { |
| | | userCard.setBalance(balance); |
| | | userCard.setState("01"); |
| | | WriteCardUtils.setUser(intent, userCard); |
| | | WriteCardUtils.setUser(intent, userCard, ReadCardAcitivy.this); |
| | | stateText.append("禁用"); |
| | | } else if ("02".equals(state)) { |
| | | stateText.append("隶属信息不符"); |
| | |
| | | |
| | | try { |
| | | this.intent = intent; |
| | | userCard = NfcReadHelper.getInstence(intent).getUserCardData(); |
| | | userCard = NfcReadHelper.getInstence(intent, this).getUserCardData(); |
| | | if (userCard != null) { |
| | | ProgressDialog.show(this); |
| | | selectBalance(userCard.getInitPeasantCode()); |
| | |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | binding.rechargeRegistBtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String morny = binding.rechargeWater.getText().toString(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | String initCode = DeviceNumberUtils.getDeviceNumber(); |
| | | if (TextUtils.isEmpty(initCode)) { |
| | | TipUtil.show(RechargeActivity.this, "设备注册号为空,请先设置IP和管理员地址"); |
| | | return; |
| | | } |
| | | Intent intent = new Intent(RechargeActivity.this, NFCWreatActivity.class); |
| | | intent.putExtra("morny", morny); |
| | | intent.putExtra("userName", userName); |
| | | intent.putExtra("userCard", userCard); |
| | | startActivity(intent); |
| | | } else { |
| | | TipUtil.show(RechargeActivity.this, "请输入充值金额(元)"); |
| | | binding.rechargeRegistBtn.setOnClickListener(v -> { |
| | | String morny = binding.rechargeWater.getText().toString(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | String initCode = DeviceNumberUtils.getDeviceNumber(); |
| | | if (TextUtils.isEmpty(initCode)) { |
| | | TipUtil.show(RechargeActivity.this, "设备注册号为空,请先设置IP和管理员地址"); |
| | | return; |
| | | } |
| | | Intent intent = new Intent(RechargeActivity.this, NFCWreatActivity.class); |
| | | intent.putExtra("morny", morny); |
| | | intent.putExtra("userName", userName); |
| | | intent.putExtra("userCard", userCard); |
| | | startActivity(intent); |
| | | } else { |
| | | TipUtil.show(RechargeActivity.this, "请输入充值金额(元)"); |
| | | } |
| | | }); |
| | | } |
| | |
| | | if (!s.toString().substring(1, 2).equals(".")) { |
| | | editText.setText(s.subSequence(0, 1)); |
| | | editText.setSelection(1); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | |
| | | public void onSocketResponse(SocketData readData) { |
| | | ProgressDialog.dismiss(); |
| | | if (CRC8.isCRC8(readData.getOriginDataBytes())) { |
| | | StringBuffer stateText = null; |
| | | StringBuffer stateText ; |
| | | try { |
| | | stateText = new StringBuffer(); |
| | | String state = BcdUtil.bcdToStr(readData.getBodyBytes()[2]); //BCD码00启用 01禁用 02隶属信息不符 03无此卡信息 04其它s |
| | |
| | | stateText.append("该卡已被禁用"); |
| | | userCard.setState("01"); |
| | | userCard.setBalance(balance); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, RechargeActivity.this); |
| | | } else if ("02".equals(state)) { |
| | | stateText.append("隶属信息不符"); |
| | | } else if ("03".equals(state)) { |
| | |
| | | package com.dayu.recharge.tools; |
| | | |
| | | import android.app.Activity; |
| | | import android.util.Base64; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | String companyKeyB; |
| | | |
| | | |
| | | public BaseNFCHelper() { |
| | | static { |
| | | System.loadLibrary("native-lib"); |
| | | } |
| | | |
| | | public native String getSafeKey(Object object); |
| | | |
| | | public BaseNFCHelper(Activity activity) { |
| | | // 解密字符串 |
| | | try { |
| | | //初始密码 |
| | | byte[] encryptedBytes = Base64.decode("orDiGzvueQqPpU+VQ3NEzQ==", Base64.DEFAULT); |
| | | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
| | | byte[] encodedKey = {-117, -104, -100, 84, 111, -102, -29, -21, 72, -82, -105, 123, 77, 79, 17, -55, -102, -28, 50, 23, 67, 98, 0, -96, -10, -48, -60, 81, 113, 80, -32, -26}; |
| | | String data = getSafeKey(activity); |
| | | byte[] encodedKey = HexUtil.hexToByteArray(data); |
| | | // byte[] encodedKey = {-117, -104, -100, 84, 111, -102, -29, -21, 72, -82, -105, 123, 77, 79, 17, -55, -102, -28, 50, 23, 67, 98, 0, -96, -10, -48, -60, 81, 113, 80, -32, -26}; |
| | | cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(encodedKey, "AES")); |
| | | byte[] decryptedBytes = cipher.doFinal(encryptedBytes); |
| | | String decryptedText = new String(decryptedBytes, StandardCharsets.UTF_8); |
| | |
| | | //修改后的密码 |
| | | byte[] encryptedBytes3 = Base64.decode("n+SSZFb4DHsreVav/Z5ftg==", Base64.DEFAULT); |
| | | byte[] decryptedBytes3 = cipher.doFinal(encryptedBytes3); |
| | | |
| | | companyKeyB = new String(decryptedBytes3, StandardCharsets.UTF_8); |
| | | |
| | | |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (NoSuchPaddingException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (InvalidKeyException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (BadPaddingException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (IllegalBlockSizeException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | |
| | | BadPaddingException | IllegalBlockSizeException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.dayu.recharge.tools; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.nfc.NfcAdapter; |
| | | import android.nfc.Tag; |
| | | import android.nfc.tech.MifareClassic; |
| | | import android.util.Base64; |
| | | import android.util.Log; |
| | | |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import javax.crypto.SecretKey; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | |
| | | /** |
| | | * @author zx |
| | |
| | | private static NFCWriteHelper helper; |
| | | private static int PASSWORD_LENTH = 12; |
| | | |
| | | public NFCWriteHelper(Intent intent) { |
| | | public NFCWriteHelper(Intent intent, Activity activity) { |
| | | super(activity); |
| | | this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); |
| | | } |
| | | |
| | |
| | | * @param intent |
| | | * @return |
| | | */ |
| | | public static NFCWriteHelper getInstence(Intent intent) { |
| | | public static NFCWriteHelper getInstence(Intent intent, Activity activity) { |
| | | if (helper == null) { |
| | | helper = new NFCWriteHelper(intent); |
| | | helper = new NFCWriteHelper(intent, activity); |
| | | } |
| | | return helper; |
| | | } |
| | |
| | | /** |
| | | * 修改密码 |
| | | * |
| | | * @param a 书写的扇区 |
| | | * // * @param callback 返回监听 |
| | | * @param a 书写的扇区 |
| | | * // * @param callback 返回监听 |
| | | */ |
| | | public boolean changePasword(int a) { |
| | | MifareClassic mfc = MifareClassic.get(tag); |
| | |
| | | package com.dayu.recharge.tools; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.nfc.NfcAdapter; |
| | | import android.nfc.Tag; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private static NfcReadHelper helper; |
| | | |
| | | |
| | | public NfcReadHelper(Intent intent) { |
| | | public NfcReadHelper(Intent intent, Activity activity) { |
| | | super(activity); |
| | | this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); |
| | | |
| | | } |
| | |
| | | * @param intent |
| | | * @return |
| | | */ |
| | | public static NfcReadHelper getInstence(Intent intent) { |
| | | public static NfcReadHelper getInstence(Intent intent, Activity activity) { |
| | | if (helper == null) { |
| | | helper = new NfcReadHelper(intent); |
| | | helper = new NfcReadHelper(intent, activity); |
| | | } |
| | | return helper; |
| | | } |
| | |
| | | package com.dayu.recharge.tools; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | |
| | | import com.dayu.recharge.card.UserCard; |
| | |
| | | static boolean userFlag = false; |
| | | |
| | | //向卡写入用户信息 |
| | | public static boolean setUser(Intent intent, UserCard userCard) { |
| | | userFlag = NFCWriteHelper.getInstence(intent).writeData(userCard.getZeroBytes(), 1, 0); |
| | | public static boolean setUser(Intent intent, UserCard userCard, Activity activity) { |
| | | userFlag = NFCWriteHelper.getInstence(intent,activity).writeData(userCard.getZeroBytes(), 1, 0); |
| | | if (!userFlag) { |
| | | return false; |
| | | } |
| | | userFlag = NFCWriteHelper.getInstence(intent).writeData(userCard.getOneBytes(), 1, 1); |
| | | userFlag = NFCWriteHelper.getInstence(intent,activity).writeData(userCard.getOneBytes(), 1, 1); |
| | | if (!userFlag) { |
| | | return false; |
| | | } |
| | | userFlag = NFCWriteHelper.getInstence(intent).writeData(userCard.getTwoBytes(), 1, 2); |
| | | userFlag = NFCWriteHelper.getInstence(intent,activity).writeData(userCard.getTwoBytes(), 1, 2); |
| | | return userFlag; |
| | | } |
| | | } |
| | |
| | | */ |
| | | |
| | | public class ExcelUtil { |
| | | private static WritableFont arial14font = null; |
| | | |
| | | private static WritableCellFormat arial14format = null; |
| | | private static WritableFont arial10font = null; |
| | | private static WritableCellFormat arial10format = null; |
| | | private static WritableFont arial12font = null; |
| | | private static WritableCellFormat arial12format = null; |
| | | private final static String UTF8_ENCODING = "UTF-8"; |
| | | |
| | | public static String outPath = MyFileUtil.getSDPath() + "/" + "农业水价记录"; |
| | | public static String outRechargePathName = "水价充值记录.xls"; |
| | | public static String outUserPathName = "水价开户记录.xls"; |
| | | public static String outPath = MyFileUtil.getSDPath() + "/" + "大禹节水充值机记录"; |
| | | public static String outRechargePathName = "充值记录.xls"; |
| | | public static String outUserPathName = "开户记录.xls"; |
| | | |
| | | /** |
| | | * 单元格的格式设置 字体大小 颜色 对齐方式、背景颜色等... |
| | | */ |
| | | private static void format() { |
| | | try { |
| | | arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD); |
| | | WritableFont arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD); |
| | | arial14font.setColour(jxl.format.Colour.LIGHT_BLUE); |
| | | arial14format = new WritableCellFormat(arial14font); |
| | | arial14format.setAlignment(jxl.format.Alignment.CENTRE); |
| | | arial14format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); |
| | | arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW); |
| | | |
| | | arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD); |
| | | WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD); |
| | | arial10format = new WritableCellFormat(arial10font); |
| | | arial10format.setAlignment(jxl.format.Alignment.CENTRE); |
| | | arial10format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); |
| | |
| | | # Location of the SDK. This is only used by Gradle. |
| | | # For customization when using a Version Control System, please read the |
| | | # header note. |
| | | #Mon Dec 18 10:17:13 CST 2023 |
| | | #Tue Dec 19 11:21:25 CST 2023 |
| | | sdk.dir=D\:\\android\\sdk |
| | | ndk.dir=D\:\\android\\sdk\\ndk\\android-ndk-r21 |