mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
update device info
should fill up sentry basic device and os info for mobile builds
This commit is contained in:
@@ -15,7 +15,7 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GuiBase.setInterface(new GuiMobile(Files.exists(Paths.get("./res"))?"./":"../forge-gui/"));
|
||||
GuiBase.setDeviceInfo("", "", 0, 0);
|
||||
GuiBase.setDeviceInfo(null, 0, 0);
|
||||
new EditorMainWindow(Config.instance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ import com.badlogic.gdx.backends.android.AndroidAudio;
|
||||
import com.badlogic.gdx.backends.android.AsynchronousAndroidAudio;
|
||||
import com.getkeepsafe.relinker.ReLinker;
|
||||
import de.cketti.fileprovider.PublicFileProvider;
|
||||
import forge.util.HWInfo;
|
||||
import forge.Forge;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.ThreadUtil;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.protocol.Device;
|
||||
import io.sentry.protocol.OperatingSystem;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -195,8 +195,6 @@ public class Main extends AndroidApplication {
|
||||
boolean permissiongranted = checkPermission();
|
||||
Gadapter = new AndroidAdapter(getContext());
|
||||
|
||||
// Get Basic Device and OS info for scope
|
||||
Sentry.configureScope(scope -> {
|
||||
// Device Info
|
||||
Device device = new Device();
|
||||
device.setId(Build.ID);
|
||||
@@ -205,18 +203,16 @@ public class Main extends AndroidApplication {
|
||||
device.setBrand(Build.BRAND);
|
||||
device.setManufacturer(Build.MANUFACTURER);
|
||||
device.setMemorySize(memInfo.totalMem);
|
||||
device.setChipset(Build.SOC_MANUFACTURER + " " + Build.SOC_MODEL);
|
||||
String cpuDesc = Build.VERSION.SDK_INT > Build.VERSION_CODES.R ? Build.SOC_MANUFACTURER + " " + Build.SOC_MODEL : Build.UNKNOWN;
|
||||
device.setCpuDescription(cpuDesc);
|
||||
device.setChipset(Build.HARDWARE + " " + Build.BOARD);
|
||||
// OS Info
|
||||
OperatingSystem os = new OperatingSystem();
|
||||
os.setName("Android");
|
||||
os.setName("Android " + Build.VERSION.RELEASE);
|
||||
os.setVersion(Build.VERSION.RELEASE);
|
||||
os.setBuild(Build.DISPLAY);
|
||||
// Set Contexts
|
||||
scope.getContexts().setDevice(device);
|
||||
scope.getContexts().setOperatingSystem(os);
|
||||
});
|
||||
|
||||
initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(getContext()));
|
||||
initForge(Gadapter, new HWInfo(device, os), permissiongranted, totalMemory, isTabletDevice(getContext()));
|
||||
}
|
||||
|
||||
private void crossfade(View contentView, View previousView) {
|
||||
@@ -350,13 +346,13 @@ public class Main extends AndroidApplication {
|
||||
crossfade(TL, previousView);
|
||||
}
|
||||
|
||||
private void loadGame(final String title, final String steps, boolean isLandscape, AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, AndroidApplicationConfiguration config, boolean exception, String msg) {
|
||||
private void loadGame(final HWInfo hwInfo, final String title, final String steps, boolean isLandscape, AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, AndroidApplicationConfiguration config, boolean exception, String msg) {
|
||||
try {
|
||||
final Handler handler = new Handler();
|
||||
forgeLogo = findViewById(resId("id", "logo_id"));
|
||||
activeView = findViewById(resId("id", "mainview"));
|
||||
activeView.setBackgroundColor(Color.WHITE);
|
||||
forgeView = initializeForView(Forge.getApp(getAndroidClipboard(), adapter, ASSETS_DIR, false, !isLandscape, totalRAM, isTabletDevice, Build.VERSION.SDK_INT, Build.VERSION.RELEASE, getDeviceName()), config);
|
||||
forgeView = initializeForView(Forge.getApp(hwInfo, getAndroidClipboard(), adapter, ASSETS_DIR, false, !isLandscape, totalRAM, isTabletDevice, Build.VERSION.SDK_INT), config);
|
||||
|
||||
getAnimator(ObjectAnimator.ofFloat(forgeLogo, "alpha", 1f, 1f).setDuration(800), ObjectAnimator.ofObject(activeView, "backgroundColor", new ArgbEvaluator(), Color.WHITE, Color.BLACK).setDuration(1600), new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -490,7 +486,7 @@ public class Main extends AndroidApplication {
|
||||
}
|
||||
}
|
||||
|
||||
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice) {
|
||||
private void initForge(AndroidAdapter adapter, HWInfo hwInfo, boolean permissiongranted, int totalRAM, boolean isTabletDevice) {
|
||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||
config.useAccelerometer = false;
|
||||
config.useCompass = false;
|
||||
@@ -502,14 +498,14 @@ public class Main extends AndroidApplication {
|
||||
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't access external storage";
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
loadGame("", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
loadGame(hwInfo, "", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
return;
|
||||
}
|
||||
ASSETS_DIR = Build.VERSION.SDK_INT > Build.VERSION_CODES.Q ? getContext().getObbDir() + "/Forge/" : Environment.getExternalStorageDirectory() + "/Forge/";
|
||||
if (!FileUtil.ensureDirectoryExists(ASSETS_DIR)) {
|
||||
String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't access external storage\nPath: " + ASSETS_DIR;
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
loadGame("", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
loadGame(hwInfo, "", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
return;
|
||||
}
|
||||
//ensure .nomedia file exists in Forge directory so its images
|
||||
@@ -521,7 +517,7 @@ public class Main extends AndroidApplication {
|
||||
} catch (Exception e) {
|
||||
String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't read/write to storage";
|
||||
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
|
||||
loadGame("", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
loadGame(hwInfo, "", "", false, adapter, permissiongranted, totalRAM, isTabletDevice, config, true, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -538,7 +534,7 @@ public class Main extends AndroidApplication {
|
||||
if (landscapeMode && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { //Android 11 onwards
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
}
|
||||
loadGame(info, lowV + lowM, landscapeMode, adapter, permissiongranted, totalRAM, isTabletDevice, config, false, "");
|
||||
loadGame(hwInfo, info, lowV + lowM, landscapeMode, adapter, permissiongranted, totalRAM, isTabletDevice, config, false, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Main extends IOSApplication.Delegate {
|
||||
final IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
config.useAccelerometer = false;
|
||||
config.useCompass = false;
|
||||
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, false, false, 0, false, 0, "", "");
|
||||
final ApplicationListener app = Forge.getApp(null, new IOSClipboard(), new IOSAdapter(), assetsDir, false, false, 0, false, 0);
|
||||
final IOSApplication iosApp = new IOSApplication(app, config);
|
||||
return iosApp;
|
||||
}
|
||||
|
||||
@@ -239,5 +239,10 @@
|
||||
<version>1.13.5</version>
|
||||
<classifier>natives-desktop</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>6.8.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -7,9 +7,13 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowAdapter;
|
||||
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
import forge.util.HWInfo;
|
||||
import forge.Forge;
|
||||
import forge.adventure.util.Config;
|
||||
import io.sentry.protocol.Device;
|
||||
import io.sentry.protocol.OperatingSystem;
|
||||
import org.lwjgl.system.Configuration;
|
||||
import oshi.SystemInfo;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@@ -27,8 +31,31 @@ public class GameLauncher {
|
||||
//increase MemoryStack to 1MB, default is 64kb
|
||||
Configuration.STACK_SIZE.set(1024);
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
ApplicationListener start = Forge.getApp(new Lwjgl3Clipboard(), new Main.DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
|
||||
assetsDir, false, false, 0, false, 0, "", "");
|
||||
HWInfo hw = null;
|
||||
int totalRAM = 0;
|
||||
try {
|
||||
SystemInfo si = new SystemInfo();
|
||||
// Device Info
|
||||
Device device = new Device();
|
||||
device.setId(si.getHardware().getComputerSystem().getHardwareUUID());
|
||||
device.setName(si.getHardware().getComputerSystem().getManufacturer() + " - " + si.getHardware().getComputerSystem().getModel());
|
||||
device.setModel(si.getHardware().getComputerSystem().getModel());
|
||||
device.setManufacturer(si.getHardware().getComputerSystem().getManufacturer());
|
||||
device.setMemorySize(si.getHardware().getMemory().getTotal());
|
||||
device.setChipset(si.getHardware().getComputerSystem().getBaseboard().getManufacturer() + " " + si.getHardware().getComputerSystem().getBaseboard().getModel());
|
||||
device.setCpuDescription(si.getHardware().getProcessor().getProcessorIdentifier().getName());
|
||||
// OS Info
|
||||
OperatingSystem os = new OperatingSystem();
|
||||
os.setName(si.getOperatingSystem() + " x" + si.getOperatingSystem().getBitness());
|
||||
os.setVersion(si.getOperatingSystem().getVersionInfo().getVersion());
|
||||
os.setBuild(si.getOperatingSystem().getVersionInfo().getBuildNumber());
|
||||
totalRAM = Math.round(si.getHardware().getMemory().getTotal() / 1024f / 1024f);
|
||||
hw = new HWInfo(device, os);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ApplicationListener start = Forge.getApp(hw, new Lwjgl3Clipboard(), new Main.DesktopAdapter(switchOrientationFile),
|
||||
assetsDir, false, false, totalRAM, false, 0);
|
||||
|
||||
int windowWidth = Config.instance().getSettingData().width;
|
||||
int windowHeight = Config.instance().getSettingData().height;
|
||||
|
||||
@@ -47,6 +47,8 @@ import forge.sound.MusicPlaylist;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.toolbox.*;
|
||||
import forge.util.*;
|
||||
import io.sentry.ScopeType;
|
||||
import io.sentry.Sentry;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@@ -126,13 +128,14 @@ public class Forge implements ApplicationListener {
|
||||
public static boolean createNewAdventureMap = false;
|
||||
private static Localizer localizer;
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean propertyConfig, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
|
||||
public static ApplicationListener getApp(HWInfo hwInfo, Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean propertyConfig, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI) {
|
||||
if (app == null) {
|
||||
app = new Forge();
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
GuiBase.setUsingAppDirectory(assetDir0.contains("forge.app")); //obb directory on android uses the package name as entrypoint
|
||||
//obb directory on android uses the package name as entrypoint
|
||||
GuiBase.setUsingAppDirectory(assetDir0.contains("forge.app"));
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
GuiBase.enablePropertyConfig(propertyConfig);
|
||||
isPortraitMode = androidOrientation;
|
||||
@@ -140,7 +143,20 @@ public class Forge implements ApplicationListener {
|
||||
isTabletDevice = isTablet;
|
||||
androidVersion = AndroidAPI;
|
||||
}
|
||||
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI, totalRAM);
|
||||
if (hwInfo != null) {
|
||||
Sentry.configureScope(ScopeType.GLOBAL, scope -> {
|
||||
scope.getContexts().setDevice(hwInfo.device());
|
||||
scope.getContexts().setOperatingSystem(hwInfo.os());
|
||||
});
|
||||
//init hwInfo to log
|
||||
System.out.println(
|
||||
"---------------------------------------\n" + "APP: Forge v." + GuiBase.getInterface().getCurrentVersion() +
|
||||
" (" + GuiBase.getInterface() + ")" + "\nDEV: " + hwInfo.device().getName() +
|
||||
"\nCPU: " + hwInfo.device().getCpuDescription() + "\nRAM: " + totalRAM + " MB" + "\nOS: " + hwInfo.os().getName() +
|
||||
"\n---------------------------------------"
|
||||
);
|
||||
}
|
||||
GuiBase.setDeviceInfo(hwInfo, AndroidAPI, totalRAM);
|
||||
}
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.gui;
|
||||
|
||||
import forge.util.HWInfo;
|
||||
import forge.gui.interfaces.IGuiBase;
|
||||
import forge.localinstance.properties.ForgePreferences;
|
||||
|
||||
@@ -10,12 +11,11 @@ public class GuiBase {
|
||||
private static boolean isAndroidport = false;
|
||||
private static boolean isAdventureMode = false;
|
||||
private static boolean interrupted = false;
|
||||
private static String deviceName = "";
|
||||
private static String androidRelease = "";
|
||||
private static int androidAPI = 0;
|
||||
private static int deviceRAM = 0;
|
||||
private static boolean usingAppDirectory = false;
|
||||
private static ForgePreferences forgePrefs;
|
||||
private static HWInfo hwInfo;
|
||||
|
||||
public static IGuiBase getInterface() { return guiInterface; }
|
||||
public static void setInterface(IGuiBase i0) { guiInterface = i0; }
|
||||
@@ -34,16 +34,14 @@ public class GuiBase {
|
||||
public static void setUsingAppDirectory(boolean value) { usingAppDirectory = value; }
|
||||
public static boolean isUsingAppDirectory() { return usingAppDirectory; }
|
||||
|
||||
public static void setDeviceInfo(String DeviceName, String AndroidName, int AndroidAPI, int RAM) {
|
||||
deviceName = DeviceName;
|
||||
androidRelease = AndroidName;
|
||||
public static void setDeviceInfo(HWInfo hw, int AndroidAPI, int RAM) {
|
||||
hwInfo = hw;
|
||||
androidAPI = AndroidAPI;
|
||||
deviceRAM = RAM;
|
||||
}
|
||||
public static String getDeviceName() { return deviceName; }
|
||||
public static String getAndroidRelease() { return androidRelease; }
|
||||
public static int getAndroidAPILevel() { return androidAPI; }
|
||||
public static int getDeviceRAM() { return deviceRAM; }
|
||||
public static HWInfo getHWInfo() { return hwInfo; }
|
||||
|
||||
public static boolean isNetworkplay() { return networkplay; }
|
||||
public static void setNetworkplay(boolean value) { networkplay = value; }
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
package forge.model;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import forge.CardStorageReader;
|
||||
import forge.*;
|
||||
import forge.CardStorageReader.ProgressObserver;
|
||||
import forge.ImageKeys;
|
||||
import forge.MulliganDefs;
|
||||
import forge.StaticData;
|
||||
import forge.ai.AiProfileUtil;
|
||||
import forge.card.CardRulesPredicates;
|
||||
import forge.card.CardType;
|
||||
@@ -107,14 +104,9 @@ public final class FModel {
|
||||
avatarPool, conspiracyPool, dungeonPool, attractionPool, contraptionPool;
|
||||
|
||||
public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) {
|
||||
//init version to log
|
||||
System.out.println("Forge v." + GuiBase.getInterface().getCurrentVersion() + " (" + GuiBase.getInterface() + ")");
|
||||
//Device
|
||||
if (GuiBase.isAndroid()) //todo get device on other mobile platforms
|
||||
System.out.println(GuiBase.getDeviceName() + " (RAM: " + GuiBase.getDeviceRAM() + "MB, Android " + GuiBase.getAndroidRelease() + " API Level " + GuiBase.getAndroidAPILevel() + ")");
|
||||
else {
|
||||
System.out.println(System.getProperty("os.name") + " (" + System.getProperty("os.version") + " " + System.getProperty("os.arch") + ")\n" + System.getProperty("java.vendor") + " (Java " + System.getProperty("java.runtime.version") + ", " + System.getProperty("java.vm.name") + ")");
|
||||
initialize(progressBar, adjustPrefs, false);
|
||||
}
|
||||
public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs, boolean isSimTest) {
|
||||
ImageKeys.initializeDirs(
|
||||
ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR,
|
||||
ForgeConstants.CACHE_TOKEN_PICS_DIR, ForgeConstants.CACHE_ICON_PICS_DIR,
|
||||
|
||||
7
forge-gui/src/main/java/forge/util/HWInfo.java
Normal file
7
forge-gui/src/main/java/forge/util/HWInfo.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package forge.util;
|
||||
|
||||
import io.sentry.protocol.Device;
|
||||
import io.sentry.protocol.OperatingSystem;
|
||||
|
||||
public record HWInfo(Device device, OperatingSystem os) {
|
||||
}
|
||||
Reference in New Issue
Block a user