From 738332db2dfb92cad6f926b64edd688a96444fd5 Mon Sep 17 00:00:00 2001 From: notify Date: Sun, 16 Jul 2023 21:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=8D=93=E8=AE=BE=E5=A4=87=E7=A0=81?= =?UTF-8?q?=20(#228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复安卓不可读取设备码的bug --------- Co-authored-by: Ho-spair --- android/src/org/notify/FreeKill/Helper.java | 9 +++++++++ src/core/util.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/android/src/org/notify/FreeKill/Helper.java b/android/src/org/notify/FreeKill/Helper.java index d084f4b4..335d83a9 100644 --- a/android/src/org/notify/FreeKill/Helper.java +++ b/android/src/org/notify/FreeKill/Helper.java @@ -2,6 +2,7 @@ package org.notify.FreeKill; +import android.provider.Settings; import android.app.Activity; import android.view.View; import android.view.WindowManager; @@ -43,4 +44,12 @@ public class Helper { } }); } + + public static String GetSerial() { + Activity activity = QtNative.activity(); + return Settings.Secure.getString( + activity.getContentResolver(), + Settings.Secure.ANDROID_ID + ); + } } diff --git a/src/core/util.cpp b/src/core/util.cpp index d4e7a1c9..c93eb496 100644 --- a/src/core/util.cpp +++ b/src/core/util.cpp @@ -205,7 +205,12 @@ QJsonDocument String2Json(const QString &str) { } QString GetDeviceUuid() { +#ifdef Q_OS_ANDROID + QJniObject string = QJniObject::callStaticObjectMethod("org/notify/FreeKill/Helper", "GetSerial", "()Ljava/lang/String;"); + return string.toString(); +#else return QSysInfo::machineUniqueId(); +#endif } QString Color(const QString &raw, fkShell::TextColor color,