安卓设备码 (#228)

修复安卓不可读取设备码的bug

---------

Co-authored-by: Ho-spair <linyuy@163.com>
This commit is contained in:
notify 2023-07-16 21:05:31 +08:00 committed by GitHub
parent c86c13cf20
commit 738332db2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,7 @@
package org.notify.FreeKill; package org.notify.FreeKill;
import android.provider.Settings;
import android.app.Activity; import android.app.Activity;
import android.view.View; import android.view.View;
import android.view.WindowManager; 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
);
}
} }

View File

@ -205,7 +205,12 @@ QJsonDocument String2Json(const QString &str) {
} }
QString GetDeviceUuid() { 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(); return QSysInfo::machineUniqueId();
#endif
} }
QString Color(const QString &raw, fkShell::TextColor color, QString Color(const QString &raw, fkShell::TextColor color,