mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Кеширование HWID, получение HWID в отдельном потоке
This commit is contained in:
parent
cf5867c131
commit
9af4145ab7
2 changed files with 7 additions and 1 deletions
|
@ -191,6 +191,7 @@ public void start(String... args) throws Throwable {
|
|||
// Load init.js script
|
||||
FunctionalBridge.worker = new RequestWorker();
|
||||
CommonHelper.newThread("FX Task Worker", true, FunctionalBridge.worker).start();
|
||||
CommonHelper.newThread("GetHWID Thread",true, FunctionalBridge::getHWID).start();
|
||||
loadScript(Launcher.API_SCRIPT_FILE);
|
||||
loadScript(Launcher.CONFIG_SCRIPT_FILE);
|
||||
LogHelper.debug("Dir: %s", DirBridge.dir);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SignatureException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class FunctionalBridge {
|
||||
@LauncherAPI
|
||||
|
@ -26,6 +27,8 @@ public class FunctionalBridge {
|
|||
public static RequestWorker worker;
|
||||
@LauncherAPI
|
||||
public static OshiHWIDProvider hwidProvider = new OshiHWIDProvider();
|
||||
@LauncherAPI
|
||||
public static AtomicReference<HWID> hwid = new AtomicReference<>();
|
||||
|
||||
@LauncherAPI
|
||||
public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder<HashedDir> hdir, FileNameMatcher matcher, boolean digest) throws Exception {
|
||||
|
@ -69,7 +72,9 @@ public static void startTask(@SuppressWarnings("rawtypes") Task task) {
|
|||
|
||||
@LauncherAPI
|
||||
public static HWID getHWID() {
|
||||
return hwidProvider.getHWID();
|
||||
HWID hhwid = hwid.get();
|
||||
if(hhwid == null) hwid.set(hwidProvider.getHWID());
|
||||
return hhwid;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
|
|
Loading…
Reference in a new issue