From 1aca29e0d598632e96f28de8c94bcbd1984fabe4 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Mon, 9 Nov 2026 18:23:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor(security):=20=E6=95=8F=E6=84=9F?= =?UTF-8?q?=E5=AF=86=E9=92=A5=E4=B8=8E=E8=B0=83=E8=AF=95=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=87=B3=20native=20=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 11 ++ app/src/main/cpp/CMakeLists.txt | 8 + app/src/main/cpp/native_guard.cpp | 101 ++++++++++++ app/src/main/cpp/sha256.h | 146 ++++++++++++++++++ .../sn/core/common/config/CommonConfig.java | 2 - .../fuying/sn/core/common/util/CXAESUtil.java | 31 +++- .../common/util/DebugPasswordVerifier.java | 54 +++++++ .../sn/core/common/util/NativeSecrets.java | 57 +++++++ .../fuying/sn/feature/home/HomeActivity.java | 11 +- .../fuying/sn/feature/home/HomeViewModel.java | 9 +- .../fuying/sn/feature/main/MainActivity.java | 21 +-- .../fuying/sn/feature/main/MainViewModel.java | 11 +- .../sn/feature/qrcode/QRCodeFragment.java | 3 +- 13 files changed, 430 insertions(+), 35 deletions(-) create mode 100644 app/src/main/cpp/CMakeLists.txt create mode 100644 app/src/main/cpp/native_guard.cpp create mode 100644 app/src/main/cpp/sha256.h create mode 100644 app/src/main/java/com/fuying/sn/core/common/util/DebugPasswordVerifier.java create mode 100644 app/src/main/java/com/fuying/sn/core/common/util/NativeSecrets.java diff --git a/app/build.gradle b/app/build.gradle index cd5ec0c..c1df146 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,6 +16,9 @@ android { compileSdkVersion 29 buildToolsVersion "36.0.0" + // 调试密码校验改用 native 实现,避免明文进入 dex。 + ndkVersion "26.3.11579264" + defaultConfig { minSdkVersion 26 targetSdkVersion 29 @@ -49,6 +52,14 @@ android { aidl true } + // native 产物走 CMake,所有 buildType 共用;ABI 由 defaultConfig.ndk.abiFilters 限定。 + externalNativeBuild { + cmake { + path "src/main/cpp/CMakeLists.txt" + version "3.22.1" + } + } + //多版本 productFlavors { official { diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..9dff832 --- /dev/null +++ b/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.22.1) + +project(fsguard CXX) + +add_library(fsguard SHARED native_guard.cpp) + +# 只导出 JNI 符号,其余符号隐藏,减少可被直接定位的线索。 +target_compile_options(fsguard PRIVATE -fvisibility=hidden -O2) diff --git a/app/src/main/cpp/native_guard.cpp b/app/src/main/cpp/native_guard.cpp new file mode 100644 index 0000000..da06114 --- /dev/null +++ b/app/src/main/cpp/native_guard.cpp @@ -0,0 +1,101 @@ +// 敏感常量(调试密码、AES 密钥)的 native 存储与校验。 +// 目的是让明文不出现在 dex 与 .so 的可读字符串中,提高静态逆向成本。 +// 注意:本地校验无法抵御 hook,真正的边界仍是"谁能拿到设备 root 权限"。 +#include +#include + +#include "sha256.h" + +namespace { + +// 盐值与期望摘要,两者都无法反推原文。 + const char kSalt[] = "FSN$dbg#2026"; + +// SHA-256(kSalt + 密码) 的结果。 + const uint8_t kExpected[32] = { + 0x06, 0x0a, 0x05, 0x09, 0x0b, 0x4a, 0x6c, 0x3c, + 0x68, 0xe7, 0xa4, 0x46, 0xe0, 0x55, 0x29, 0xc0, + 0xc5, 0xfd, 0x36, 0x98, 0x94, 0xc5, 0xd2, 0x11, + 0x41, 0xaa, 0xb8, 0xa9, 0xbf, 0xc3, 0xa9, 0x39}; + +// AES 密钥(16 字节)以"掩码 + 异或值"两段存储, +// 单独看任意一段都不是明文,避免 strings 直接扫出密钥。 +// +// 必须加 volatile:两个数组都是 const 且初值已知,-O2 会在编译期把 +// kAesMasked[i] ^ kAesMask[i] 折叠成常量,把明文重新写回 .rodata, +// 掩码就完全失去意义。加 volatile 后异或只能推迟到运行时进行。 + volatile const uint8_t kAesMask[16] = { + 0x7e, 0x2b, 0x91, 0xc4, 0x5d, 0xe8, 0x13, 0x6f, + 0xa2, 0x47, 0xba, 0x0c, 0xd5, 0x38, 0x9e, 0x61}; + + volatile const uint8_t kAesMasked[16] = { + 0x4e, 0x1a, 0xa3, 0xf7, 0x69, 0xdd, 0x25, 0x58, + 0x9a, 0x7e, 0xfb, 0x4e, 0x96, 0x7c, 0xdb, 0x27}; + +// 定长比较,避免逐字节提前返回带来的时序差异。 + bool constantTimeEquals(const uint8_t *left, const uint8_t *right, size_t length) { + uint8_t diff = 0; + size_t i; + for (i = 0; i < length; i++) { + diff |= (uint8_t) (left[i] ^ right[i]); + } + return diff == 0; + } + + void computeDigest(const char *input, size_t inputLength, uint8_t out[32]) { + Sha256Ctx ctx; + sha256_init(&ctx); + sha256_update(&ctx, (const uint8_t *) kSalt, sizeof(kSalt) - 1); + sha256_update(&ctx, (const uint8_t *) input, inputLength); + sha256_final(&ctx, out); + } + +} // namespace + +extern "C" JNIEXPORT jboolean JNICALL +Java_com_fuying_sn_core_common_util_DebugPasswordVerifier_verifyNative( + JNIEnv *env, jclass clazz, jstring input) { + if (input == nullptr) { + return JNI_FALSE; + } + + const char *chars = env->GetStringUTFChars(input, nullptr); + if (chars == nullptr) { + return JNI_FALSE; + } + + // 调试密码长度有限,超长输入直接判失败,避免无意义的哈希开销。 + jsize length = env->GetStringUTFLength(input); + bool matched = false; + if (length > 0 && length <= 64) { + uint8_t digest[32]; + computeDigest(chars, (size_t) length, digest); + matched = constantTimeEquals(digest, kExpected, sizeof(kExpected)); + } + + env->ReleaseStringUTFChars(input, chars); + return matched ? JNI_TRUE : JNI_FALSE; +} + +extern "C" JNIEXPORT jbyteArray JNICALL +Java_com_fuying_sn_core_common_util_NativeSecrets_nativeAesKey( + JNIEnv *env, jclass clazz) { + const size_t keyLength = sizeof(kAesMasked); + jbyteArray result = env->NewByteArray((jsize) keyLength); + if (result == nullptr) { + return nullptr; + } + + uint8_t key[16]; + size_t i; + for (i = 0; i < keyLength; i++) { + key[i] = (uint8_t) (kAesMasked[i] ^ kAesMask[i]); + } + env->SetByteArrayRegion(result, 0, (jsize) keyLength, (const jbyte *) key); + + // 栈上的明文用完即清,减少内存转储时的暴露面。 + for (i = 0; i < keyLength; i++) { + key[i] = 0; + } + return result; +} diff --git a/app/src/main/cpp/sha256.h b/app/src/main/cpp/sha256.h new file mode 100644 index 0000000..519f578 --- /dev/null +++ b/app/src/main/cpp/sha256.h @@ -0,0 +1,146 @@ +#ifndef FLYSN_SHA256_H +#define FLYSN_SHA256_H + +#include +#include + +// 轻量 SHA-256 实现,仅在 native 层用于校验调试密码,避免在 APK 中留下明文。 +// 不依赖任何第三方库,避免给工程新增依赖。 + +typedef struct { + uint32_t state[8]; + uint64_t bitlen; + uint8_t buf[64]; + size_t buflen; +} Sha256Ctx; + +static const uint32_t kSha256K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; + +#define SHA256_ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) +#define SHA256_CH(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) +#define SHA256_MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) +#define SHA256_EP0(x) (SHA256_ROTR(x, 2) ^ SHA256_ROTR(x, 13) ^ SHA256_ROTR(x, 22)) +#define SHA256_EP1(x) (SHA256_ROTR(x, 6) ^ SHA256_ROTR(x, 11) ^ SHA256_ROTR(x, 25)) +#define SHA256_SIG0(x) (SHA256_ROTR(x, 7) ^ SHA256_ROTR(x, 18) ^ ((x) >> 3)) +#define SHA256_SIG1(x) (SHA256_ROTR(x, 17) ^ SHA256_ROTR(x, 19) ^ ((x) >> 10)) + +static void sha256_transform(Sha256Ctx *ctx, const uint8_t block[64]) { + uint32_t m[64]; + int i; + for (i = 0; i < 16; i++) { + m[i] = ((uint32_t) block[i * 4] << 24) + | ((uint32_t) block[i * 4 + 1] << 16) + | ((uint32_t) block[i * 4 + 2] << 8) + | ((uint32_t) block[i * 4 + 3]); + } + for (i = 16; i < 64; i++) { + m[i] = SHA256_SIG1(m[i - 2]) + m[i - 7] + SHA256_SIG0(m[i - 15]) + m[i - 16]; + } + + uint32_t a = ctx->state[0]; + uint32_t b = ctx->state[1]; + uint32_t c = ctx->state[2]; + uint32_t d = ctx->state[3]; + uint32_t e = ctx->state[4]; + uint32_t f = ctx->state[5]; + uint32_t g = ctx->state[6]; + uint32_t h = ctx->state[7]; + + for (i = 0; i < 64; i++) { + uint32_t t1 = h + SHA256_EP1(e) + SHA256_CH(e, f, g) + kSha256K[i] + m[i]; + uint32_t t2 = SHA256_EP0(a) + SHA256_MAJ(a, b, c); + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + ctx->state[0] += a; + ctx->state[1] += b; + ctx->state[2] += c; + ctx->state[3] += d; + ctx->state[4] += e; + ctx->state[5] += f; + ctx->state[6] += g; + ctx->state[7] += h; +} + +static void sha256_init(Sha256Ctx *ctx) { + ctx->bitlen = 0; + ctx->buflen = 0; + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + ctx->state[7] = 0x5be0cd19; +} + +static void sha256_update(Sha256Ctx *ctx, const uint8_t *data, size_t len) { + size_t i; + for (i = 0; i < len; i++) { + ctx->buf[ctx->buflen++] = data[i]; + if (ctx->buflen == 64) { + sha256_transform(ctx, ctx->buf); + ctx->bitlen += 512; + ctx->buflen = 0; + } + } +} + +static void sha256_final(Sha256Ctx *ctx, uint8_t out[32]) { + size_t i = ctx->buflen; + if (ctx->buflen < 56) { + ctx->buf[i++] = 0x80; + while (i < 56) { + ctx->buf[i++] = 0x00; + } + } else { + ctx->buf[i++] = 0x80; + while (i < 64) { + ctx->buf[i++] = 0x00; + } + sha256_transform(ctx, ctx->buf); + for (i = 0; i < 56; i++) { + ctx->buf[i] = 0x00; + } + } + + ctx->bitlen += (uint64_t) ctx->buflen * 8; + ctx->buf[63] = (uint8_t) (ctx->bitlen); + ctx->buf[62] = (uint8_t) (ctx->bitlen >> 8); + ctx->buf[61] = (uint8_t) (ctx->bitlen >> 16); + ctx->buf[60] = (uint8_t) (ctx->bitlen >> 24); + ctx->buf[59] = (uint8_t) (ctx->bitlen >> 32); + ctx->buf[58] = (uint8_t) (ctx->bitlen >> 40); + ctx->buf[57] = (uint8_t) (ctx->bitlen >> 48); + ctx->buf[56] = (uint8_t) (ctx->bitlen >> 56); + sha256_transform(ctx, ctx->buf); + + for (i = 0; i < 4; i++) { + out[i] = (uint8_t) (ctx->state[0] >> (24 - i * 8)); + out[i + 4] = (uint8_t) (ctx->state[1] >> (24 - i * 8)); + out[i + 8] = (uint8_t) (ctx->state[2] >> (24 - i * 8)); + out[i + 12] = (uint8_t) (ctx->state[3] >> (24 - i * 8)); + out[i + 16] = (uint8_t) (ctx->state[4] >> (24 - i * 8)); + out[i + 20] = (uint8_t) (ctx->state[5] >> (24 - i * 8)); + out[i + 24] = (uint8_t) (ctx->state[6] >> (24 - i * 8)); + out[i + 28] = (uint8_t) (ctx->state[7] >> (24 - i * 8)); + } +} + +#endif // FLYSN_SHA256_H diff --git a/app/src/main/java/com/fuying/sn/core/common/config/CommonConfig.java b/app/src/main/java/com/fuying/sn/core/common/config/CommonConfig.java index 13ad0ec..97c530a 100644 --- a/app/src/main/java/com/fuying/sn/core/common/config/CommonConfig.java +++ b/app/src/main/java/com/fuying/sn/core/common/config/CommonConfig.java @@ -36,8 +36,6 @@ public class CommonConfig { public static final String LAST_SYNC_TIME_KEY = "last_sync_time_key"; public static final String isLogined = "isLogined"; - public static final String AES_KEY = "0123456789ABCDEF"; - public static final String HTTP_KEY = "YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI="; public static final String UserName = "USERINFO_NAME"; public static final String UserSchool = "USERINFO_SCHOOL"; public static final String UserGrade = "USERINFO_GRADE"; diff --git a/app/src/main/java/com/fuying/sn/core/common/util/CXAESUtil.java b/app/src/main/java/com/fuying/sn/core/common/util/CXAESUtil.java index 719f60e..1fa7ad4 100644 --- a/app/src/main/java/com/fuying/sn/core/common/util/CXAESUtil.java +++ b/app/src/main/java/com/fuying/sn/core/common/util/CXAESUtil.java @@ -1,23 +1,31 @@ package com.fuying.sn.core.common.util; +import android.util.Log; + import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; public class CXAESUtil { - public final static String HEX = "0123456789ABCDEF"; + private static final String TAG = "CXAESUtil"; private static final int keyLenght = 16; private static final String defaultV = "0"; /** * 加密 * - * @param key 密钥 + *

密钥来自 native 层({@link NativeSecrets#getAesKey()}),不再以常量形式存在于源码与 dex 中。 + * * @param src 加密文本 - * @return + * @return 十六进制密文;密钥不可用或加密失败时返回空串 * @throws Exception */ - public static String encrypt(String key, String src) { + public static String encrypt(String src) { + String key = NativeSecrets.getAesKey(); + if (key == null || key.length() == 0) { + Log.e(TAG, "encrypt: 密钥不可用,加密中止"); + return ""; + } // /src = Base64.encodeToString(src.getBytes(), Base64.DEFAULT); byte[] rawKey = toMakekey(key, keyLenght, defaultV).getBytes();// key.getBytes(); try { @@ -88,7 +96,20 @@ public class CXAESUtil { } private static void appendHex(StringBuffer sb, byte b) { - sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f)); + sb.append(toHexChar((b >> 4) & 0x0f)).append(toHexChar(b & 0x0f)); + } + + /** + * 把 0-15 转成大写十六进制字符。 + * + *

原先用一张十六进制字符常量表,那张表的内容与本应用 AES 密钥完全相同, + * 会把密钥明文一并带进 dex,因此改为算术生成。输出字符集不变,密文与改造前完全一致。 + */ + private static char toHexChar(int value) { + if (value < 10) { + return (char) ('0' + value); + } + return (char) ('A' + value - 10); } } diff --git a/app/src/main/java/com/fuying/sn/core/common/util/DebugPasswordVerifier.java b/app/src/main/java/com/fuying/sn/core/common/util/DebugPasswordVerifier.java new file mode 100644 index 0000000..68a3075 --- /dev/null +++ b/app/src/main/java/com/fuying/sn/core/common/util/DebugPasswordVerifier.java @@ -0,0 +1,54 @@ +package com.fuying.sn.core.common.util; + +import android.util.Log; + +/** + * 调试入口密码校验。 + * + *

明文密码与盐值都只存在于 native 层(libdebugguard.so),dex 与源码中不再出现, + * 用于降低静态逆向的门槛。native 库缺失或调用异常时一律返回失败(fail-closed), + * 避免"加载失败即放行"。 + */ +public final class DebugPasswordVerifier { + + private static final String TAG = "DebugPasswordVerifier"; + private static final String LIB_NAME = "fsguard"; + + private static boolean sLibraryLoaded = false; + + static { + try { + System.loadLibrary(LIB_NAME); + sLibraryLoaded = true; + } catch (Throwable e) { + Log.e(TAG, "静态代码块: native 库加载失败 " + e.getMessage()); + } + } + + private DebugPasswordVerifier() { + } + + /** + * 校验用户输入的调试密码。 + * + * @param input 用户输入,允许为 null + * @return 校验通过返回 true;库未加载、输入为空或校验异常均返回 false + */ + public static boolean verify(String input) { + if (!sLibraryLoaded) { + Log.e(TAG, "verify: native 库未加载,拒绝校验"); + return false; + } + if (input == null || input.length() == 0) { + return false; + } + try { + return verifyNative(input); + } catch (Throwable e) { + Log.e(TAG, "verify: native 校验异常 " + e.getMessage()); + return false; + } + } + + private static native boolean verifyNative(String input); +} diff --git a/app/src/main/java/com/fuying/sn/core/common/util/NativeSecrets.java b/app/src/main/java/com/fuying/sn/core/common/util/NativeSecrets.java new file mode 100644 index 0000000..4e448e3 --- /dev/null +++ b/app/src/main/java/com/fuying/sn/core/common/util/NativeSecrets.java @@ -0,0 +1,57 @@ +package com.fuying.sn.core.common.util; + +import android.util.Log; + +import java.nio.charset.Charset; + +/** + * 敏感常量的 native 来源。 + * + *

密钥只存在于 libfsguard.so 中,dex 与源码不再保留明文; + * native 库加载失败时返回 null,由调用方中止使用密钥的业务(fail-closed)。 + */ +public final class NativeSecrets { + + private static final String TAG = "NativeSecrets"; + private static final String LIB_NAME = "fsguard"; + private static final Charset UTF_8 = Charset.forName("UTF-8"); + + private static boolean sLibraryLoaded = false; + + static { + try { + System.loadLibrary(LIB_NAME); + sLibraryLoaded = true; + } catch (Throwable e) { + Log.e(TAG, "静态代码块: native 库加载失败 " + e.getMessage()); + } + } + + private NativeSecrets() { + } + + /** + * 获取 AES 密钥。 + * + * @return 16 位密钥字符串;native 库不可用或取值为空时返回 null + */ + public static String getAesKey() { + if (!sLibraryLoaded) { + Log.e(TAG, "getAesKey: native 库未加载,返回 null"); + return null; + } + try { + byte[] keyBytes = nativeAesKey(); + if (keyBytes == null || keyBytes.length == 0) { + Log.e(TAG, "getAesKey: native 返回空密钥"); + return null; + } + return new String(keyBytes, UTF_8); + } catch (Throwable e) { + Log.e(TAG, "getAesKey: 读取密钥异常 " + e.getMessage()); + return null; + } + } + + private static native byte[] nativeAesKey(); +} diff --git a/app/src/main/java/com/fuying/sn/feature/home/HomeActivity.java b/app/src/main/java/com/fuying/sn/feature/home/HomeActivity.java index fb93b67..866e0e5 100644 --- a/app/src/main/java/com/fuying/sn/feature/home/HomeActivity.java +++ b/app/src/main/java/com/fuying/sn/feature/home/HomeActivity.java @@ -17,20 +17,21 @@ import com.blankj.utilcode.util.NetworkUtils; import com.fuying.sn.BuildConfig; import com.fuying.sn.R; import com.fuying.sn.core.base.mvvm.BaseMvvmActivity; +import com.fuying.sn.core.common.config.CommonConfig; +import com.fuying.sn.core.common.util.DebugPasswordVerifier; +import com.fuying.sn.core.common.util.ToastUtil; import com.fuying.sn.core.data.dto.BaseResponse; import com.fuying.sn.core.data.dto.SnInfo; -import com.fuying.sn.core.common.config.CommonConfig; +import com.fuying.sn.core.data.local.prefs.SPUtils; import com.fuying.sn.databinding.ActivityHomeBinding; import com.fuying.sn.feature.debug.UserDebugDialog; -import com.fuying.sn.feature.qrcode.BaseFragmentPagerAdapter; import com.fuying.sn.feature.device.DeviceFragment; +import com.fuying.sn.feature.qrcode.BaseFragmentPagerAdapter; import com.fuying.sn.feature.usage.UsageFragment; import com.fuying.sn.platform.control.ControlManager; import com.fuying.sn.platform.system.DeviceManager; import com.fuying.sn.platform.time.TimeManager; import com.fuying.sn.runtime.sync.AppUpdateCoordinator; -import com.fuying.sn.core.data.local.prefs.SPUtils; -import com.fuying.sn.core.common.util.ToastUtil; import java.util.ArrayList; import java.util.List; @@ -192,7 +193,7 @@ public class HomeActivity extends BaseMvvmActivity mQRCodeData = new MutableLiveData<>(); public void getQRCode() { - String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getIMEI(getApplication())); + String encryptString = CXAESUtil.encrypt(Utils.getIMEI(getApplication())); Log.e("getQRCode", "setImageAndText: " + encryptString); Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 400, 400); mQRCodeData.setValue(bitmap); diff --git a/app/src/main/java/com/fuying/sn/feature/main/MainActivity.java b/app/src/main/java/com/fuying/sn/feature/main/MainActivity.java index 0c25713..c415621 100644 --- a/app/src/main/java/com/fuying/sn/feature/main/MainActivity.java +++ b/app/src/main/java/com/fuying/sn/feature/main/MainActivity.java @@ -26,31 +26,32 @@ import com.blankj.utilcode.util.NetworkUtils; import com.fuying.sn.BuildConfig; import com.fuying.sn.R; import com.fuying.sn.core.base.mvvm.BaseMvvmActivity; +import com.fuying.sn.core.common.config.CommonConfig; +import com.fuying.sn.core.common.gson.GsonUtils; +import com.fuying.sn.core.common.util.DebugPasswordVerifier; +import com.fuying.sn.core.common.util.ReceiverCompat; +import com.fuying.sn.core.common.util.ToastUtil; +import com.fuying.sn.core.common.util.Utils; import com.fuying.sn.core.data.dto.AppInfo; import com.fuying.sn.core.data.dto.BaseResponse; import com.fuying.sn.core.data.dto.SnInfo; -import com.fuying.sn.core.common.config.CommonConfig; +import com.fuying.sn.core.data.local.prefs.SPUtils; import com.fuying.sn.core.data.repository.DeviceRepository; import com.fuying.sn.databinding.ActivityMainBinding; +import com.fuying.sn.feature.common.RestartFragment; import com.fuying.sn.feature.debug.UserDebugDialog; import com.fuying.sn.feature.qrcode.AppletQRCodeFragment; import com.fuying.sn.feature.qrcode.BaseFragmentPagerAdapter; import com.fuying.sn.feature.qrcode.QRCodeFragment; -import com.fuying.sn.feature.common.RestartFragment; -import com.fuying.sn.core.common.gson.GsonUtils; import com.fuying.sn.platform.control.ControlManager; import com.fuying.sn.platform.system.DeviceManager; +import com.fuying.sn.platform.system.JgyUtils; +import com.fuying.sn.platform.time.TimeUtils; import com.fuying.sn.runtime.service.DownloadService; import com.fuying.sn.runtime.service.ManagerService; import com.fuying.sn.runtime.service.SocketService; import com.fuying.sn.runtime.service.main.MainService; import com.fuying.sn.runtime.sync.AppUpdateCoordinator; -import com.fuying.sn.platform.system.JgyUtils; -import com.fuying.sn.core.common.util.ReceiverCompat; -import com.fuying.sn.core.data.local.prefs.SPUtils; -import com.fuying.sn.platform.time.TimeUtils; -import com.fuying.sn.core.common.util.ToastUtil; -import com.fuying.sn.core.common.util.Utils; import java.util.ArrayList; import java.util.List; @@ -338,7 +339,7 @@ public class MainActivity extends BaseMvvmActivity mQRCodeData = new MutableLiveData<>(); public void getQRCode() { - String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getIMEI(getAppContext())); + String encryptString = CXAESUtil.encrypt(Utils.getIMEI(getAppContext())); Log.e("getQRCode", "setImageAndText: " + encryptString); Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 400, 400); mQRCodeData.setValue(bitmap); diff --git a/app/src/main/java/com/fuying/sn/feature/qrcode/QRCodeFragment.java b/app/src/main/java/com/fuying/sn/feature/qrcode/QRCodeFragment.java index 00cffc6..a6f6221 100644 --- a/app/src/main/java/com/fuying/sn/feature/qrcode/QRCodeFragment.java +++ b/app/src/main/java/com/fuying/sn/feature/qrcode/QRCodeFragment.java @@ -11,7 +11,6 @@ import android.widget.ImageView; import androidx.fragment.app.Fragment; import com.fuying.sn.R; -import com.fuying.sn.core.common.config.CommonConfig; import com.fuying.sn.core.common.util.BitmapUtils; import com.fuying.sn.core.common.util.CXAESUtil; import com.fuying.sn.core.common.util.Utils; @@ -71,7 +70,7 @@ public class QRCodeFragment extends Fragment { mView = inflater.inflate(R.layout.fragment_qrcode, container, false); qr_code =mView.findViewById(R.id.qr_code); try { - String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial()); + String encryptString = CXAESUtil.encrypt(Utils.getSerial()); Bitmap bitmap = BitmapUtils.createQRImage(encryptString, 300, 300); qr_code.setImageBitmap(bitmap); } catch (Exception e) {