diff --git a/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs b/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs index d59e341cc04..f3a3b6c3ea1 100644 --- a/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs +++ b/ProjectNLD/Assets/Editor/Common/BuildLauncher.cs @@ -707,6 +707,7 @@ internal class BatchBuild public CrashSightConfig CrashSight_Android { get; set; } public CrashSightConfig CrashSight_iOS { get; set; } + public CrashSightConfig CrashSight_Harmony{get; set;} public TalkingDataConfig TalkingData { get; set; } public ThinkingDataConfig ThinkingData { get; set; } } @@ -897,6 +898,23 @@ internal class BatchBuild Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key); } +#if UNITY_OPENHARMONY + // 处理CrashSight_Harmony配置 + if (config.CrashSight_Harmony != null && + EditorUserBuildSettings.activeBuildTarget == BuildTarget.OpenHarmony) + { + var crashSightData = new PhxhSDK.Data.CrashSightData + { + id = config.CrashSight_Harmony.Id, + key = config.CrashSight_Harmony.Key + }; + + var json = JsonUtility.ToJson(crashSightData); + WriteEncryptedJsonResource("CrashSightData", json); + Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key); + } +#endif + if (config.TalkingData != null) { var talkingDataInitTool = new TalkingDataInitTool diff --git a/Tool/Channels/OpenHarmonyDev/ChannelSetting.yaml b/Tool/Channels/OpenHarmonyDev/ChannelSetting.yaml index b1a2bd0942c..cb8aafefd86 100644 --- a/Tool/Channels/OpenHarmonyDev/ChannelSetting.yaml +++ b/Tool/Channels/OpenHarmonyDev/ChannelSetting.yaml @@ -43,10 +43,10 @@ ConfigURL: "http://yhpxkqgzatnrmbws.kedrgame.com" AppAccessKey: "0SoE48O9sayjkG8J" AppKey: "uUi_UI1oMKWo0VOSN1zme17Z70-FlAv3Lcx2mNhoYe4=" -# 崩溃监控配置(仅 Android) -CrashSight_Android: - id: "669a94ce69" # 崩溃上报的 App ID - key: "d9412717-2416-4270-b8bc-f7a0805f988f" # 崩溃上报的 Key +# 崩溃监控配置(仅鸿蒙) +CrashSight_Harmony: + id: "88625404e2" # 崩溃上报的 App ID + key: "bff9d9be-bbd7-4fc1-9176-653281f8ff51" # 崩溃上报的 Key # TalkingData初始化 TalkingData: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs new file mode 100644 index 00000000000..b814a5c8c3d --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs @@ -0,0 +1,116 @@ +#if SDK_CRASHSIGHT +using System; +using PhxhSDK.Data; +using UnityEngine; +using UnityEngine.Diagnostics; + +namespace PhxhSDK +{ + public class CrashSightSdkHelper : SdkHelper + { + // 设置上报的目标域名,请根据项目需求进行填写。(必填) + private const string crashServerUrl_Android = "https://android.crashsight.qq.com/pb/async"; + // 设置上报所指向的APP ID, 并进行初始化。APPID可以在管理端更多->产品设置->产品信息中找到。 + // private const string appId_Android = "669a94ce69"; + + private const string crashServerUrl_iOS = "https://ios.crashsight.qq.com/pb/sync"; + // private const string appId_iOS = "6ff03772f9"; + + private const string crashServerUrl_Harmony = "harmony.crashsight.qq.com"; + + public override void EarlyInit() + { + // Debug开关,Debug模式下会打印更多便于问题定位的Log. + var enableDebug = false; + #if DEBUG + enableDebug = true; + #endif + CrashSightAgent.ConfigDebugMode(enableDebug); + + var uploadUrl = ""; + switch (Application.platform) + { + case RuntimePlatform.Android: + uploadUrl = crashServerUrl_Android; + break; + case RuntimePlatform.IPhonePlayer: + uploadUrl = crashServerUrl_iOS; + break; +#if UNITY_OPENHARMONY + case RuntimePlatform.OpenHarmony: + uploadUrl = crashServerUrl_Harmony; + break; +#endif + default: + DebugUtil.LogError("CrashSightSdkHelper" + "Unsupported platform: " + Application.platform); + break; + } + if (!string.IsNullOrEmpty(uploadUrl)) + { + CrashSightAgent.ConfigCrashServerUrl(uploadUrl); + } + + var appId = ""; + if (!EncryptedResourceLoader.TryLoadJson("CrashSightData", out var data)) + { + DebugUtil.LogError("CrashSightSdkHelper", "CrashSightData resource load failed"); + return; + } + appId = data.id; + if (!string.IsNullOrEmpty(appId)) + { + CrashSightAgent.InitWithAppId(appId); + DebugUtil.Log("CrashSightSdkHelper", "CrashSight appId: " + appId); + } + else + { + DebugUtil.LogError("CrashSightSdkHelper" + "CrashSight appId is empty"); + } + + } + + public override void Init() + { + + } + + public override void AfterLoginInit() + { + } + + public override void Update() + { + } + + public override void Release() + { + + } + + public void TestCrashJava() + { + CrashSightAgent.TestJavaCrash(); + } + + public void TestOcCrash() + { + CrashSightAgent.TestOcCrash(); + } + + public void TestCrashException() + { + throw new Exception("测试模拟异常"); + } + + public void TestCrash() + { + UnityEngine.Diagnostics.Utils.ForceCrash(ForcedCrashCategory.AccessViolation); + } + + public void TestNativeCrash() + { + CrashSightAgent.TestNativeCrash(); + } + } +} +#endif diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs.meta new file mode 100644 index 00000000000..9c5f7c67185 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/Phxh/SDKHelper/CrashSight/CrashSightSdkHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f7558a87675ed9b4d8ddf26c290df6d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Editor/Mods/CrashSight/CrashSight.projmods b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Editor/Mods/CrashSight/CrashSight.projmods new file mode 100644 index 00000000000..a16c4d9da4c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Editor/Mods/CrashSight/CrashSight.projmods @@ -0,0 +1,24 @@ +{ + "group": "CrashSight", + "libs": [ + "libz.dylib", + "libc++.dylib" + ], + "frameworks": [ + "SystemConfiguration.framework", + "Security.framework", + "JavaScriptCore.framework", + "MetricKit.framework:weak", + "OSLog.framework:weak", + "CFNetwork.framework" + ], + "headerpaths": [], + "files": [], + "folders": [], + "excludes": ["^.*.meta$", "^.*.mdown$", "^.*.pdf$"], + "compiler_flags": [], + "linker_flags": [ + "-ObjC" + ] + +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/AndroidManifest.xml b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/AndroidManifest.xml new file mode 100644 index 00000000000..e0707c9d21b --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/CrashSight_crash_release.jar b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/CrashSight_crash_release.jar new file mode 100644 index 00000000000..0240ea19897 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/CrashSight_crash_release.jar differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/arm64-v8a/libCrashSight.so b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/arm64-v8a/libCrashSight.so new file mode 100644 index 00000000000..21d16849684 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/arm64-v8a/libCrashSight.so differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/armeabi-v7a/libCrashSight.so b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/armeabi-v7a/libCrashSight.so new file mode 100644 index 00000000000..a5aea1f7be0 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/armeabi-v7a/libCrashSight.so differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86/libCrashSight.so b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86/libCrashSight.so new file mode 100644 index 00000000000..b55003eeddb Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86/libCrashSight.so differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86_64/libCrashSight.so b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86_64/libCrashSight.so new file mode 100644 index 00000000000..66ca0db4fb0 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/libs/x86_64/libCrashSight.so differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/proguard-project.txt b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/proguard-project.txt new file mode 100644 index 00000000000..24a3c8f38fc --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/proguard-project.txt @@ -0,0 +1,4 @@ + # crashsight sdk +-keep public class com.uqm.crashsight.** { *; } +-dontwarn com.uqm.crashsight.core.** +-keep class com.uqm.crashsight.core.** { *; } \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/project.properties b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/project.properties new file mode 100644 index 00000000000..3a387fb86cc --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Android/CrashSight/project.properties @@ -0,0 +1,2 @@ +target=android-26 +android.library=true diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSightBridge.etslib b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSightBridge.etslib new file mode 100644 index 00000000000..97a91a700c6 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSightBridge.etslib @@ -0,0 +1,20 @@ +import { CrashSightMain} from 'crashsight'; +import { GetFromGlobalThis } from 'crashsight/../../src/main/ets/common/GlobalThisUtil' +import { common, Context } from '@kit.AbilityKit'; + +export function RegisterCrashSightBridge() { + let register: Record = {}; + register["CrashSightObj"] = new CrashSightClass(); + return register; +} + + +export class CrashSightClass { + + initContext(): number { + + let context = GetFromGlobalThis("context") as Context; + CrashSightMain.getInstance().initContextInJS(context); + return 1; + } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSight_OPL.xml b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSight_OPL.xml new file mode 100644 index 00000000000..3c7ab54f5f4 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/CrashSight_OPL.xml @@ -0,0 +1,62 @@ + + + + + + + ohos.permission.GET_NETWORK_INFO + ohos.permission.INTERNET + ohos.permission.GET_WIFI_INFO + + + + + + + + + + + + CrashSight + + + + + import { CrashSightMain } from "CrashSight"; + + + + + + import {CrashSightClass} from '../entryability/EntryAbility' + + + + + + + nativeRender.JSBind.bindFunction("CrashSightClass.initContext", CrashSightClass.initContext); + + + + + + + export class CrashSightClass { + + + static initContext() :number{ + let context = GlobalContext.loadGlobalThis(GlobalContextConstants.UE_ABILITY_CONTEXT) as Context; + CrashSightMain.getInstance().initContextInJS(context); + return 1; + } + + } + + + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/crashsight.har b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/crashsight.har new file mode 100644 index 00000000000..62d40020881 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/OpenHarmony/CrashSight/crashsight.har differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll new file mode 100644 index 00000000000..d0270554ff8 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6eea1c561719af50126f62775290d8b78a3ef3e8205c48e04364f7ee52fa70bb +size 5617152 diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll.meta new file mode 100644 index 00000000000..272b6a550e2 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/Win/CrashSight/X86_64/CrashSight64.dll.meta @@ -0,0 +1,81 @@ +fileFormatVersion: 2 +guid: bf5ae746b5b544136adfc380164166ce +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + : Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 0 + Exclude iOS: 1 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 0 + settings: + AddToEmbeddedBinaries: false + CPU: AnyCPU + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework.meta new file mode 100644 index 00000000000..f79212f704b --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework.meta @@ -0,0 +1,93 @@ +fileFormatVersion: 2 +guid: dade0c46327444572be5b78f63f416be +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: true + CompileFlags: + FrameworkDependencies: CoreTelephony;Security; + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/CrashSight b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/CrashSight new file mode 100644 index 00000000000..65a11cd2e69 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/CrashSight differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSight.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSight.h new file mode 100644 index 00000000000..1fb21d89fc4 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSight.h @@ -0,0 +1,245 @@ +// +// CrashSight.h +// +// Version: 4.3.8(1084) +// +// Copyright (c) 2017年 +// + +#import + +#import "CrashSightConfig.h" +#import "CrashSightLog.h" + +#define GCLOUD_VERSION_CRASHSIGHT "GCLOUD_VERSION_CRASHSIGHT_4.3.8.1084.sgprod" + + + +typedef NS_OPTIONS(uint32_t, CSExceptionReprotOption) { + CSExceptionReprotOptionNone = 0, + CSExceptionReprotOptionSystemLog = 1 << 0, + CSExceptionReprotOptionCustomLog = 1 << 1, + CSExceptionReprotOptionKV = 1 << 2, + CSExceptionReprotOptionCallback = 1 << 3, + CSExceptionReprotOptionDumpStack = 1 << 4, +}; + +@interface CrashSight : NSObject + +/** + * 初始化CrashSight,使用默认CrashSightConfigs + * + * @param appId 注册CrashSight分配的应用唯一标识 + */ ++ (void)startWithAppId:(NSString * CS_NULLABLE)appId; + +/** + * 使用指定配置初始化CrashSight + * + * @param appId 注册CrashSight分配的应用唯一标识 + * @param config 传入配置的 CrashSightConfig + */ ++ (void)startWithAppId:(NSString * CS_NULLABLE)appId + config:(CrashSightConfig * CS_NULLABLE)config; + +/** + * 使用指定配置初始化CrashSight + * + * @param appId 注册CrashSight分配的应用唯一标识 + * @param development 是否开发设备 + * @param config 传入配置的 CrashSightConfig + */ ++ (void)startWithAppId:(NSString * CS_NULLABLE)appId + developmentDevice:(BOOL)development + config:(CrashSightConfig * CS_NULLABLE)config; + +/** + * 设置用户标识 + * + * @param userId 用户标识 + */ ++ (void)setUserIdentifier:(NSString *)userId; + +/** + * 更新版本信息 + * + * @param version 应用版本信息 + */ ++ (void)updateAppVersion:(NSString *)version; + +/** + * 设置关键数据,随崩溃信息上报 + * + * @param value KEY + * @param key VALUE + */ ++ (void)setUserValue:(NSString *)value + forKey:(NSString *)key; + +/** + * 获取USER ID + * + * @return USER ID + */ ++ (NSString *)crashSightUserIdentifier; + +/** + * 获取关键数据 + * + * @return 关键数据 + */ ++ (NSDictionary * CS_NULLABLE)allUserValues; + + ++ (void)setUserSceneTag:(NSString *)userSceneTag isUpload:(bool)upload; + + ++ (NSString *)currentUserSceneTag; + +/** + * 获取设备ID + * + * @return 设备ID + */ ++ (NSString *)crashSightDeviceId; + +/** + * 上报自定义Objective-C异常 + * + * @param exception 异常信息 + */ ++ (void)reportException:(NSException *)exception; + +/** + * 上报错误 + * + * @param error 错误信息 + */ ++ (void)reportError:(NSError *)error; + +/** + * @brief 上报自定义错误 + * + * @param category 类型(Cocoa=3,CSharp=4,JS=5,Lua=6) + * @param aName 名称 + * @param aReason 错误原因 + * @param aStackArray 堆栈 + * @param info 附加数据 + * @param terminate 上报后是否退出应用进程 + */ ++ (void)reportExceptionWithCategory:(NSUInteger)category + name:(NSString *)aName + reason:(NSString *)aReason + callStack:(NSArray *)aStackArray + extraInfo:(NSDictionary *)info + terminateApp:(BOOL)terminate + dumpDataType:(int) dumpDataType + errorAttachmentPath:(NSString *)errorAttachmentPath; + + +/** + * @brief 上报自定义错误 + * + * @param category 类型(Cocoa=3,CSharp=4,JS=5,Lua=6) + * @param aName 名称 + * @param aReason 错误原因 + * @param aStackArray 堆栈 + * @param info 附加数据 + * @param terminate 上报后是否退出应用进程 + */ ++ (void)reportExceptionWithCategory:(NSUInteger)category + name:(NSString *)aName + reason:(NSString *)aReason + callStack:(NSArray *)aStackArray + extraInfoJSONString:(NSString *)info + terminateApp:(BOOL)terminate + dumpDataType:(int) dumpDataType + errorAttachmentPath:(NSString *)errorAttachmentPath; + + ++ (void) reportLogInfo:(NSString *)messageType message:(NSString *)message; + + ++ (void)reportJankWithName:(NSString *)name message:(NSString *)message stack:(NSArray *)stack extraInfo:(NSDictionary *)extraInfo option:(CSExceptionReprotOption)option attachmentPath:(nullable NSString *)attachmentPath; + +/** + * SDK 版本信息 + * + * @return SDK版本号 + */ ++ (NSString *)sdkVersion; + +/** + * APP 版本信息 + * + * @return SDK版本号 + */ ++ (NSString *)appVersion; + +/** + * App 是否发生了连续闪退 + * 如果 启动SDK 且 5秒内 闪退,且次数达到 3次 则判定为连续闪退 + * + * @return 是否连续闪退 + */ ++ (BOOL)isAppCrashedOnStartUpExceedTheLimit; + +/** + * 关闭crashSight监控 + */ ++ (void)closeCrashReport; + +/** + * 再次注册CrashSight对Crash监听 + */ ++ (void)reregisterCrashHandler; + +/** + * 设置上报URL,可在初始化CrashSight后动态设置 + */ ++ (void)setServerUrl:(NSString *)url; + +/** + * 设置上报附件的绝对路径 + */ ++ (void)setAttachmentPath:(NSString *)path; + ++ (int)getCrashThreadId; + + ++ (NSString *)crashSightSessionId; + ++ (BOOL)isLastSessionCrash; + ++ (NSString *)getLastSessionUserId; + ++ (NSDictionary *)ccConifg; + ++ (int)getExceptionType:(NSString *)name; + ++ (void)setServerEnv:(NSString *)serverEnv; + ++ (void)setEngineInfo:(NSString *)version buildConfig:(NSString *)buildConfig language:(NSString *)language locale:(NSString *)locale; + ++ (void)enableDetailedPageTracing:(bool)enable; + ++ (void)useSavedUserId:(bool)enable; + ++ (void)reportStuckWithThreadIndex:(int)threadIndex + maxChecks:(int)maxChecks + checkInterval:(NSTimeInterval)checkInterval + name:(NSString *)name + message:(NSString *)message + extraInfo:(NSString *)extraInfo + dumpNativeType:(int)dumpNativeType + attachPath:(NSString *)attachPath; + + + + +// 必须在lua线程调用, 否则捕获lua堆栈时会崩溃 ++ (void)setLuaState:(nonnull void*)lua; + ++ (void)setLuaFuncGetglobal:(nonnull void *)getglobal getfield:(nonnull void *)getfield pushstring:(nonnull void *)pushstring pushinteger:(nonnull void *)pushinteger pcallk:(nonnull void *)pcallk tolstring:(nonnull void *)tolstring settop:(nonnull void *)settop; + +@end diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightConfig.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightConfig.h new file mode 100644 index 00000000000..0a6ba362e2e --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightConfig.h @@ -0,0 +1,195 @@ +// +// CrashSightConfig.h +// CrashSight +// +// Copyright (c) 2016年 +// + +#pragma once + +#define CS_UNAVAILABLE(x) __attribute__((unavailable(x))) + +#if __has_feature(nullability) +#define CS_NONNULL __nonnull +#define CS_NULLABLE __nullable +#define CS_START_NONNULL _Pragma("clang assume_nonnull begin") +#define CS_END_NONNULL _Pragma("clang assume_nonnull end") +#else +#define CS_NONNULL +#define CS_NULLABLE +#define CS_START_NONNULL +#define CS_END_NONNULL +#endif + +#import + +#import "CrashSightLog.h" + +#define CS_CALLBACK_FLAGS_LUA 0x1 +#define CS_CALLBACK_FLAGS_JS (0x1 << 1) +#define CS_CALLBACK_FLAGS_CSHARP (0x1 << 2) +#define CS_CALLBACK_FLAGS_CRASH (0x1 << 4) +#define CS_CALLBACK_FLAGS_CUSTOM (0x1 << 5) + + +typedef NS_ENUM(NSInteger, CSCallbackType) { + CSCallbackTypeNone = 0, + CSCallbackTypeCrash = 2, + CSCallbackTypeCShap = 3, + CSCallbackTypeJS = 5, + CSCallbackTypeLua = 6, + CSCallbackTypeCustom = 8, + CSCallbackTypeJank = 9, +}; +typedef CSCallbackType CSExceptionType; + +@protocol CrashSightDelegate + +@optional +/** + * 发生异常时回调 + * + * @param exception 异常信息 + * + * @return 返回需上报记录,随异常上报一起上报 + */ +- (NSString * CS_NULLABLE)attachmentForException:(NSException * CS_NULLABLE)exception callbackType:(CSCallbackType)callbackType; + +/** + * 设置UQM的崩溃时触发回调的方法 + * @return 返回崩溃时需要上报的日志路径 + */ +- (NSString * CS_NULLABLE)attachmentLogPathForExceptionType:(CSExceptionType)exceptionType; + + /** + * 设置UQM的崩溃时触发回调的方法 + * 通知日志上报结果 + */ +- (void)attachmentLogUploadResultForExceptionType:(CSExceptionType)exceptionType result:(int) result; + + +/** + * 策略激活时回调 + * + * @param tacticInfo + * + * @return app是否弹框展示 + */ +- (BOOL) h5AlertForTactic:(NSDictionary *)tacticInfo; + +@end + +@interface CrashSightConfig : NSObject + +/** + * SDK Debug信息开关, 默认关闭 + */ +@property (nonatomic, assign) BOOL debugMode; + +/** + * 设置自定义渠道标识 + */ +@property (nonatomic, copy) NSString *channel; + +/** + * 设置自定义版本号 + */ +@property (nonatomic, copy) NSString *version; + +/** + * 设置自定义设备唯一标识 + */ +@property (nonatomic, copy) NSString *deviceIdentifier; + +/** + * 卡顿监控开关,默认关闭 + */ +@property (nonatomic) BOOL blockMonitorEnable; + +/** + * 卡顿监控判断间隔,单位为秒 + */ +@property (nonatomic) NSTimeInterval blockMonitorTimeout; + +/** + * 设置 App Groups Id (如有使用 CrashSight iOS Extension SDK,请设置该值) + */ +@property (nonatomic, copy) NSString *applicationGroupIdentifier; + +/** + * 进程内还原开关,默认开启 + */ +@property (nonatomic) BOOL symbolicateInProcessEnable; + +/** + * @deprecate + * 已经改为云控控制,用户配置无效 + * 非正常退出事件记录开关,默认关闭 + */ +@property (nonatomic) BOOL unexpectedTerminatingDetectionEnable; + +/** + * 页面信息记录开关,默认开启 + */ +@property (nonatomic) BOOL viewControllerTrackingEnable; + +/** + * CrashSight Delegate + */ +@property (nonatomic, assign) id delegate; + +/** + * 控制自定义日志上报,默认值为CrashSightLogLevelSilent,即关闭日志记录功能。 + * 如果设置为CrashSightLogLevelWarn,则在崩溃时会上报Warn、Error接口打印的日志 + */ +@property (nonatomic, assign) CrashSightLogLevel reportLogLevel; + +/** + * 崩溃数据过滤器,如果崩溃堆栈的模块名包含过滤器中设置的关键字,则崩溃数据不会进行上报 + * 例如,过滤崩溃堆栈中包含搜狗输入法的数据,可以添加过滤器关键字SogouInputIPhone.dylib等 + */ +@property (nonatomic, copy) NSArray *excludeModuleFilter; + +/** + * 控制台日志上报开关,默认开启 + */ +@property (nonatomic, assign) BOOL consolelogEnable; + +/** + * @deprecate + * 崩溃退出超时,如果监听到崩溃后,App一直没有退出,则到达超时时间后会自动abort进程退出 + * 默认值 5s, 单位 秒 + * 当赋值为0时,则不会自动abort进程退出 + */ +@property (nonatomic, assign) NSUInteger crashAbortTimeout; + +/** + * 设置自定义联网、crash上报域名 + */ +@property (nonatomic, copy) NSString *crashServerUrl; + + + +/// CS_CALLBACK_FLAGS_LUA(0x1) | CS_CALLBACK_FLAGS_JA(0x1 << 1) | CS_CALLBACK_FLAGS_CSHARP(0x1 << 2) | CS_CALLBACK_FLAGS_CRASH(0x1 << 4), default: 0xFFFF +@property (nonatomic, assign) uint32_t callbackFlags; + +/** + * 崩溃处理超时时间,单位秒 + * defalut:2秒, 小于等于0:不限制(20秒) + * + */ +@property (nonatomic, assign) int crashProcessTimeout; + +/** + * 配置崩溃上报COS文件绝对路径,必须是文件路径,不支持文件夹路径, 文件最大10MB, 超过部分忽略。 + * + */ +@property (nonatomic, copy) NSString *uploadUserAttchmentFilePath; + +@property (nonatomic, copy) NSString *oomAttchmentFilePath; + + +@property (nonatomic, assign) BOOL ignoreCallSigaltstackFunctionFailed; + + +@end diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightLog.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightLog.h new file mode 100644 index 00000000000..ae5405fa19e --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Headers/CrashSightLog.h @@ -0,0 +1,78 @@ +// +// CrashSightLog.h +// CrashSight +// +// Copyright (c) 2017年 +// + +#import + +// Log level for CrashSight Log +typedef NS_ENUM(NSUInteger, CrashSightLogLevel) { + CrashSightLogLevelSilent = 0, + CrashSightLogLevelError = 1, + CrashSightLogLevelWarn = 2, + CrashSightLogLevelInfo = 3, + CrashSightLogLevelDebug = 4, + CrashSightLogLevelVerbose = 5, +}; +#pragma mark - + +OBJC_EXTERN void CSLog(CrashSightLogLevel level, NSString *format, ...) NS_FORMAT_FUNCTION(2, 3); + +OBJC_EXTERN void CSLogv(CrashSightLogLevel level, NSString *format, va_list args) NS_FORMAT_FUNCTION(2, 0); + +#pragma mark - +#define CRASHSIGHT_LOG_MACRO(_level, fmt, ...) [CrashSightLog level:_level tag:nil log:fmt, ##__VA_ARGS__] + +#define CSLogError(fmt, ...) CRASHSIGHT_LOG_MACRO(CrashSightLogLevelError, fmt, ##__VA_ARGS__) +#define CSLogWarn(fmt, ...) CRASHSIGHT_LOG_MACRO(CrashSightLogLevelWarn, fmt, ##__VA_ARGS__) +#define CSLogInfo(fmt, ...) CRASHSIGHT_LOG_MACRO(CrashSightLogLevelInfo, fmt, ##__VA_ARGS__) +#define CSLogDebug(fmt, ...) CRASHSIGHT_LOG_MACRO(CrashSightLogLevelDebug, fmt, ##__VA_ARGS__) +#define CSLogVerbose(fmt, ...) CRASHSIGHT_LOG_MACRO(CrashSightLogLevelVerbose, fmt, ##__VA_ARGS__) + +#pragma mark - Interface +@interface CrashSightLog : NSObject + +/** + * @brief 初始化日志模块 + * + * @param level 设置默认日志级别,默认CSLogLevelSilent + * + * @param printConsole 是否打印到控制台,默认NO + */ ++ (void)initLogger:(CrashSightLogLevel) level consolePrint:(BOOL)printConsole; + +/** + * @brief 打印CSLogLevelInfo日志 + * + * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 + */ ++ (void)log:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2); + +/** + * @brief 打印日志 + * + * @param level 日志级别 + * @param message 日志内容 总日志大小限制为:字符串长度30k,条数200 + */ ++ (void)level:(CrashSightLogLevel) level logs:(NSString *)message; + +/** + * @brief 打印日志 + * + * @param level 日志级别 + * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 + */ ++ (void)level:(CrashSightLogLevel) level log:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3); + +/** + * @brief 打印日志 + * + * @param level 日志级别 + * @param tag 日志模块分类 + * @param format 日志内容 总日志大小限制为:字符串长度30k,条数200 + */ ++ (void)level:(CrashSightLogLevel) level tag:(NSString *) tag log:(NSString *)format, ... NS_FORMAT_FUNCTION(3, 4); + +@end diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Info.plist b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Info.plist new file mode 100644 index 00000000000..519968de1bd Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Info.plist differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Modules/module.modulemap b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Modules/module.modulemap new file mode 100644 index 00000000000..a7592487578 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module CrashSight { + umbrella header "CrashSight.h" + + export * + module * { export * } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/PrivacyInfo.xcprivacy b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/PrivacyInfo.xcprivacy new file mode 100644 index 00000000000..8185dbaaa39 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSight.framework/PrivacyInfo.xcprivacy @@ -0,0 +1,92 @@ + + + + + NSPrivacyCollectedDataTypes + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypePerformanceData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAnalytics + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeCrashData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAnalytics + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeDeviceID + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAnalytics + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeUserID + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAnalytics + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryDiskSpace + NSPrivacyAccessedAPITypeReasons + + E174.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework.meta new file mode 100644 index 00000000000..8b04c1d9f6a --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: 865fe01356f9247b7878748577677c77 +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: true + CompileFlags: + FrameworkDependencies: Security; + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/CrashSightAdapter b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/CrashSightAdapter new file mode 100644 index 00000000000..ec9b1f1115b Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/CrashSightAdapter differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityBridge.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityBridge.h new file mode 100644 index 00000000000..71d37ec4eea --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityBridge.h @@ -0,0 +1,48 @@ +// +// Created by joyfyzhang on 2021/10/18. +// + +#ifndef ANDROID_UQMUNITYBRIDGE_H +#define ANDROID_UQMUNITYBRIDGE_H + +#ifdef ANDROID +#include "UQMDefine.h" +#include "UQM.h" +#include "UQMUtils.h" +#include "CSLogger.h" +#include +#endif + +#ifdef __APPLE__ +#include +#endif + +NS_UQM_BEGIN + +typedef char* (*UQMRetJsonCallback)(int methodId, int callbackType, int logUploadResult); + +class UQMUnityBridge { +public: + static UQMRetJsonCallback SendToUnity; + static void SetBridge(UQMRetJsonCallback bridge); + static char *pInvokeHandleCallback(int methodId, int callbackType, int logUploadResult = 0) { + if (UQMUnityBridge::SendToUnity == NULL) { + UQM_LOG_DEBUG("No callback for unity, please do UQM.Init(); first !"); + return NULL; + } else { + return UQMUnityBridge::SendToUnity(methodId, callbackType, logUploadResult); + } + } +}; + +extern "C" { +void UQM_EXPORT cs_setUnityCallback(UQMRetJsonCallback bridge); +int UQM_EXPORT cs_unityForceCrash(); +int UQM_EXPORT cs_unityCrashCallback(); +int UQM_EXPORT cs_unityCrashLogCallback(); +int UQM_EXPORT cs_unregisterUnityCrashCallback(); +} + +NS_UQM_END + +#endif //ANDROID_UQMUNITYBRIDGE_H diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityExtra.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityExtra.h new file mode 100644 index 00000000000..c2829f26db5 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Headers/UQMUnityExtra.h @@ -0,0 +1,142 @@ +// +// Created by joyfyzhang on 2021/10/19. +// + +#ifndef ANDROID_UQMUNITYEXTRA_H +#define ANDROID_UQMUNITYEXTRA_H + +#include "UQMUnityBridge.h" + +extern "C" +{ + ///----- UQMCrash + void UQM_EXPORT cs_configCallbackTypeAdapter(int32_t callbackType); + + void UQM_EXPORT cs_configGameTypeAdapter(int gameType); + + void UQM_EXPORT cs_configAutoReportLogLevelAdapter(int level); + + void UQM_EXPORT cs_configDefaultAdapter(const char *channel, const char *version, const char *user, int64_t delay); + + void UQM_EXPORT cs_configCrashServerUrlAdapter(const char *serverUrl); + + void UQM_EXPORT cs_configDebugModeAdapter(bool enable); + + void UQM_EXPORT cs_setDeviceIdAdapter(const char *deviceId); + + /** + * 设置业务的deviceId,仅用于页面搜索,不影响后台统计 + * @param deviceId + */ + void UQM_EXPORT cs_setCustomizedDeviceIDAdapter(const char *deviceId); + + const char* UQM_EXPORT cs_getSDKDefinedDeviceIDAdapter(); + + void UQM_EXPORT cs_setCustomizedMatchIDAdapter(const char *matchId); + + const char* UQM_EXPORT cs_getSDKSessionIDAdapter(); + + const char* UQM_EXPORT cs_getCrashUuidAdapter(); + + void UQM_EXPORT cs_setDeviceModelAdapter(const char *deviceModel); + + void UQM_EXPORT cs_setCallbackMsgAdapter(const char *msg); + + void UQM_EXPORT cs_initWithAppIdAdapter(const char *appId, bool forceOnUiThread); + + void UQM_EXPORT cs_logRecordAdapter(int level, const char *message); + + void UQM_EXPORT cs_addSceneDataAdapter(const char *key, const char *value); + + void UQM_EXPORT cs_reportExceptionAdapter(int type, const char *exceptionName, const char *exceptionMsg, + const char *exceptionStack, const char *extras, const char *paramsJson, + bool quitProgram, int dumpNativeType, const char* errorAttachmentPath); + + void UQM_EXPORT cs_setUserIdAdapter(const char *userId); + + void UQM_EXPORT cs_setSceneAdapter(const char *sceneId, bool upload); + + void UQM_EXPORT cs_setLogPathAdapter(const char *logPath); + + void UQM_EXPORT cs_reRegistAllMonitorsAdapter(); + + void UQM_EXPORT cs_closeAllMonitorsAdapter(); + + void UQM_EXPORT cs_setAppVersionAdapter(const char *appVersion); + + void UQM_EXPORT cs_crashObserverAdapter(); + + void UQM_EXPORT cs_unregisterCrashObserverAdapter(); + + void UQM_EXPORT cs_crashLogObserverAdapter(); + + void UQM_EXPORT cs_reportLogInfo(const char *msgType, const char *msg); + + // test api + void UQM_EXPORT cs_testOomCrashAdapter(); + + void UQM_EXPORT cs_testJavaCrashAdapter(); + + void UQM_EXPORT cs_testOcCrashAdapter(); + + void UQM_EXPORT cs_testNativeCrashAdapter(); + + void UQM_EXPORT cs_testANRAdapter(); + + void UQM_EXPORT cs_setCatchMultiSignal(bool enable); + + void UQM_EXPORT cs_setUnwindExtraStack(bool enable); + + long UQM_EXPORT cs_getCrashThreadId(); + + void UQM_EXPORT cs_setLogcatBufferSize(int size); + + void UQM_EXPORT cs_startDumpRoutine(int dumpMode, int startTimeMode, long startTime, long dumpInterval, + int dumpTimes, bool saveLocal, const char *savePath); + + void UQM_EXPORT cs_startMonitorFdCount(int interval, int limit, int dumpType); + + int UQM_EXPORT cs_getExceptionType(const char *name); + + void UQM_EXPORT cs_testUseAfterFreeAdapter(); + + void UQM_EXPORT cs_setEnableGetPackageInfo(bool enable); + + void UQM_EXPORT cs_setServerEnv(const char *serverEnv); + + void UQM_EXPORT cs_setEngineInfo(const char *version, const char *buildConfig, const char *language, const char *locale); + + void UQM_EXPORT cs_setGpuInfo(const char *version, const char *vendor, const char *renderer); + + void UQM_EXPORT cs_enableDetailedPageTracing(bool enable); + + void UQM_EXPORT cs_useSavedUserId(bool enable); + + bool UQM_EXPORT cs_isLastSessionCrash(); + + const char* UQM_EXPORT cs_getLastSessionUserId(); + + bool UQM_EXPORT cs_checkFdCount(int limit, int dumpType, bool upload); + + void UQM_EXPORT cs_setOomLogPath(const char *logPath); + + void UQM_EXPORT cs_reportJank(int type, const char* exceptionName, + const char* exceptionMsg, const char* exceptionStack, + const char* extInfoJsonStr, int reportInfoOption, const char* jankAttachmentPath); + + void UQM_EXPORT cs_processEngineAnr(int type); + + void UQM_EXPORT cs_setEngineMainThread(); + + void UQM_EXPORT cs_reportStuck(int threadId, int maxChecks, int checkInterval, + const char *name, const char *message, const char *extraInfo, + int dumpNativeType, const char *attachPath); + + +#if __APPLE__ + bool cs_showRatingAlertAdapter(); + void cs_showAppStoreProductViewAdapter(const char* appid); + #endif +} + +#endif //ANDROID_UQMUNITYEXTRA_H diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Info.plist b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Info.plist new file mode 100644 index 00000000000..0a628391244 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightAdapter.framework/Info.plist differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework.meta new file mode 100644 index 00000000000..02b391546eb --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: 19fc057f016ee4b3495e1f3f53003a19 +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: true + CompileFlags: + FrameworkDependencies: Security; + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/CrashSightCore b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/CrashSightCore new file mode 100644 index 00000000000..4beaa895ae9 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/CrashSightCore differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CSLogger.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CSLogger.h new file mode 100644 index 00000000000..22a9921893c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CSLogger.h @@ -0,0 +1,46 @@ +#ifndef CSLogger_hpp +#define CSLogger_hpp + +#include "UQMMacros.h" +#include + +#ifndef CS_LOG_TAG +#define CS_LOG_TAG "[CrashSightPlugin-Native]" +#endif + +// your convenient logger macro +#define CSLoggerDebug(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelDebug, CS_LOG_TAG, fmt, ##__VA_ARGS__); +#define UQM_LOG_DEBUG(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelDebug, CS_LOG_TAG, fmt, ##__VA_ARGS__) + +#define CSLoggerInfo(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelInfo, CS_LOG_TAG, fmt, ##__VA_ARGS__); +#define CSLoggerWarn(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelWarn, CS_LOG_TAG, fmt, ##__VA_ARGS__); +#define CSLoggerError(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelError, CS_LOG_TAG, fmt, ##__VA_ARGS__); +#define UQM_LOG_ERROR(fmt, ...) CSLogger::log(CSLoggerLevel::CSLoggerLevelError, CS_LOG_TAG, fmt, ##__VA_ARGS__) + +NS_UQM_BEGIN + +typedef enum +{ + CSLoggerLevelDebug = 0, + CSLoggerLevelInfo, + CSLoggerLevelWarn, + CSLoggerLevelError, + CSLoggerLevelSilent +} CSLoggerLevel; + +class UQM_EXPORT CSLogger +{ +private: + static CSLoggerLevel _loggerLevel; + +public: + static void setLoggerLevel(CSLoggerLevel loggerLevel); + + static void log(CSLoggerLevel loggerLevel, const char *tag, const char *fmt, ...); + + static void logv(CSLoggerLevel loggerLevel, const char *tag, const char *fmt, va_list args); +}; + +NS_UQM_END + +#endif /* CSLogger_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightBridge.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightBridge.h new file mode 100644 index 00000000000..d9557e82a78 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightBridge.h @@ -0,0 +1,64 @@ +// +// Created by joyfyzhang on 2021/6/13. +// + +#ifndef UQM_CRASH_INTERFACE_H +#define UQM_CRASH_INTERFACE_H + +#include "UQMMacros.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * 初始化函数 + * @param app_id CrashSight平台注册的AppID. + * @param unexpected_terminating_detection_enable iOS异常退出检测,Android无效 + * @param debug_mode 是否开启调试模式,线上建议关闭 + * @param server_url 崩溃上报地址 + */ + void UQM_EXPORT cs_init(const char* app_id, bool unexpected_terminating_detection_enable, bool debug_mode, const char* server_url); + + + /** + * 打印日志 + * @param level 日志级别 0-silent, 1-error, 2-warning, 3-info, 4-debug, 5-verbose + * @param tag 日志标签 + * @param log 日志内容 + */ + void UQM_EXPORT cs_log_info(int level, const char* tag, const char* log); + + /** + * 添加用户数据,崩溃时上报 + * @param key 键 + * @param value 值 + */ + void UQM_EXPORT cs_set_user_value(const char* key, const char* value); + + /** + * 设置用户ID + * @param user_id 用户ID + */ + void UQM_EXPORT cs_set_user_id(const char* user_id); + + /** + * 上报捕获到的异常 + * @param type 异常类型 + * @param exception_name 异常名 + * @param exception_msg 异常消息 + * @param exception_stack 异常堆栈 + */ + void UQM_EXPORT cs_report_exception(int type, const char* exception_name, const char* exception_msg, const char* exception_stack, bool is_dump_nativeStack= false); + + + /** + * 测试崩溃 + */ + void UQM_EXPORT cs_trigger_crash(); + +#ifdef __cplusplus +} +#endif + +#endif //UQM_CRASH_INTERFACE_H diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightCore.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightCore.h new file mode 100644 index 00000000000..6a8dff954ee --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightCore.h @@ -0,0 +1,28 @@ +// +// CrashSightCore.h +// CrashSightCore +// +// Created by 张飞阳 on 2021/6/17. +// Copyright © 2021 joyfyzhang. All rights reserved. +// + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightMobileAgent.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightMobileAgent.h new file mode 100644 index 00000000000..3a610c539b5 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/CrashSightMobileAgent.h @@ -0,0 +1,223 @@ +#pragma once + +#ifndef GCLOUD_VERSION_CRASHSIGHT +#define GCLOUD_VERSION_CRASHSIGHT "GCLOUD_VERSION_CRASHSIGHT_4.3.8.1084" //用于编译时传入 +#endif + +#include "UQMMacros.h" + +//using namespace UQM; + +namespace GCloud { + namespace CrashSight { + + enum LogSeverity + { + LogSilent, + LogError, + LogWarning, + LogInfo, + LogDebug, + LogVerbose + }; + + class UQM_EXPORT CrashSightMobileAgent + { + public: + + /// Set game type for Android + /// @param gameType COCOS=1, UNITY=2, UNREAL=3 + static void SetGameType(int gameType); + + /// configs callback type. + /// @param callbackType 目前是5种类型,用5位表示。第一位表示crash,第二位表示anr,第三位表示u3d c# error,第四位表示js,第五位表示lua + static void ConfigCallbackType(int32_t callbackType); + + /// Configs the default. + /// @param channel channel + /// @param version version + /// @param user user + /// @param delay delay + static void ConfigDefault(const char* channel, const char* version, const char* user, long delay); + + /// Configs the crashServerUrl. + /// @param crashServerUrl crashServerUrl + static void ConfigCrashServerUrl(const char* crashServerUrl); + + /// Configs the type of the crash reporter and customized log level to upload + /// @param logLevel Off=0,Error=1,Warn=2,Info=3,Debug=4 + static void ConfigCrashReporter(int logLevel); + + /// configs the debug mode. + /// @param enable If set to true< debug mode. + static void ConfigDebugMode(bool enable); + + /// Set deviceId. + /// @param deviceId 设备唯一标识 + static void SetDeviceId(const char* deviceId); + + /// Set app deviceId. + /// @param deviceId + static void SetCustomizedDeviceID(const char* deviceId); + + static void GetSDKDefinedDeviceID(void* data, int len); + + static void SetCustomizedMatchID(const char* matchId); + + static void GetSDKSessionID(void* data, int len); + + /// Set deviceModel. + /// @param deviceModel 手机型号 + static void SetDeviceModel(const char* deviceModel); + + /// 设置日志绝对路径. + /// @param logPath 日志路径 + static void SetLogPath(const char* logPath); + + /// Init sdk with the specified appId. + /// @param appId App identifier. + static void InitWithAppId(const char* appId, bool forceOnUiThread); + + static void ReportExceptionPRV(int type, const char* exceptionName, const char* exceptionMsg, const char* exceptionStack, const char *extInfo, const char* extInfoJsonStr, bool quit = false, int dumpNativeType = 0, const char* errorAttachmentPath = ""); + + /// Report Exception + /// @param type type + /// @param name name + /// @param reason reason + /// @param stackTrace stackTrace + /// @param extras extras, json对象序列化字符串 + /// @param quit quit + /// @param dumpNativeType 0:关闭,1:调用系统接口dump,3:minidump + static void ReportException(int type, const char* name, const char* reason, const char* stackTrace, const char* extras, bool quit, int dumpNativeType = 0, const char* errorAttachmentPath = ""); + + /// Report Exception + /// @param type + /// @param exceptionName + /// @param exceptionMsg + /// @param exceptionStack + /// @param paramsJson map序列化后的JSON字符串 + /// @param dumpNativeType 0:关闭,1:调用系统接口dump,3:minidump + static void ReportExceptionJson(int type, const char* exceptionName, const char* exceptionMsg, const char* exceptionStack, const char* paramsJson, int dumpNativeType = 0, const char* errorAttachmentPath = ""); + + /// Report log statistics + /// @msgType 消息类型 + /// @msg 消息详情 + static void ReportLogInfo(const char* msgType, const char* msg); + + /// Sets the user identifier. + /// @param userId User identifier. + static void SetUserId(const char* userId); + + /// Sets the scene. + /// @param sceneId Scene identifier. + static void SetScene(const char *sceneId, bool upload = false); + + /// Adds the scene data. + /// @param key Key + /// @param value Value + static void AddSceneData(const char* key, const char* value); + + /// Prints the log. + /// @param level level + /// @param format format + static void PrintLog(LogSeverity level, const char* format, ...); + + // unity android + static void CloseCrashReport(); + + // unity android + static void StartCrashReport(); + + // unity android + static void RestartCrashReport(); + + /// Set app version. + /// @param appVersion app version + static void SetAppVersion(const char* appVersion); + + + /// Catch multiple signal from different thread, and upload information of first signal. + /// @param SetCatchMultiSignal enable + static void SetCatchMultiSignal(bool enable); + + /// Unwind at most 256 stack frame, and report last frame even if stack string is full. + /// @param SetUnwindExtraStack enable + static void SetUnwindExtraStack(bool enable); + + /// Get crash thread id when crash happens. Return -1 while failed. + static long GetCrashThreadId(); + + static bool IsLastSessionCrash(); + + static void GetLastSessionUserId(void* data, int len); + + /// Set upload thread num, default 3 + static void SetUploadThreadNum(int num); + + static void TestOomCrash(); + + static void TestJavaCrash(); + + static void TestOcCrash(); + + static void TestNativeCrash(); + + static void TestANR(); + + static void GetCrashUuid(void* data, int len); + + static void SetLogcatBufferSize(int size); + + static void startDumpRoutine(int dumpMode, int startTimeMode, long startTime, long dumpInterval, + int dumpTimes, bool saveLocal, const char *savePath); + + static void startMonitorFdCount(int interval, int limit, int dumpType); + + static int getExceptionType(const char *name); + + static void testUseAfterFree(); + + static void setEnableGetPackageInfo(bool enable); + + static void setServerEnv(const char *serverEnv); + + static void setEngineInfo(const char *version, const char *buildConfig, const char *language, const char *locale); + + static void setGpuInfo(const char *version, const char *vendor, const char *renderer); + + static void setIsOpengles(bool isOpengles); + + static void enableDetailedPageTracing(bool enable); + + static void useSavedUserId(bool enable); + + static bool checkFdCount(int limit, int dumpType, bool upload); + + static void SetOomLogPath(const char *logPath); + + static void ReportJank(int type, const char* exceptionName, + const char* exceptionMsg, const char* exceptionStack, + const char* extInfoJsonStr, int reportInfoOption, const char* jankAttachmentPath = nullptr); + + static void processEngineAnr(int type); + + static void setEngineMainThread(); + + static void ReportStuck(int threadId, int maxChecks, long checkInterval, + const char *name, const char *message, const char *extraInfo, + int dumpNativeType, const char *attachPath); + + private: + static bool mIsInitialized; + + static const char* GetCsVersion(); + }; + + + } +} + + + + + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQM.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQM.h new file mode 100644 index 00000000000..fbfd1cd70f5 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQM.h @@ -0,0 +1,57 @@ +// +// UQM.h +// CrashSight +// +// Created by joyfyzhang on 2020/9/4. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQM_h +#define UQM_h + +#include "UQMMacros.h" +#include "UQMSingleton.h" + +#ifdef ANDROID +#include +#endif + +NS_UQM_BEGIN + +//暂未弄清楚此处的具体用途,故不做替换修改 +#ifdef _WIN32 +#define UQM_ITOP_DEPRECATED(_version) +#else +#define UQM_ITOP_DEPRECATED(_version) __attribute__((deprecated)) +#endif + + +class UQM : public UQMSingleton +{ + friend class UQMSingleton; + +private: + UQM() { + initialized = false; + }; + virtual ~UQM(); +public: + //JavaVM 是Android JNI使用,iOS这里定义一个,保证编译通过 +#if UQM_PLATFORM_WINDOWS +#define JavaVM void +#else +#ifdef __APPLE__ +#define JavaVM void +#endif +#endif + + void Initialize(JavaVM *vm); + +private: + bool initialized; +}; + +NS_UQM_END +// #include "UQMRename.h" + +#endif /* UQM_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCompatLayer.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCompatLayer.h new file mode 100644 index 00000000000..cd8fb5cd804 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCompatLayer.h @@ -0,0 +1,515 @@ +// +// UQMCompatLayer.hpp +// Crashot +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMCompatLayer_hpp +#define UQMCompatLayer_hpp + +#include +#include "UQMMacros.h" +#include "UQMMacroExpand.h" + +#if UQM_PLATFORM_WINDOWS +#define uqm_strncpy(deestination,source,sourceLen) \ +do { \ +strncpy_s(deestination, sourceLen+1, source, sourceLen); \ +} while (0) +#define uqm_strncat(deestination,source,sourceLen) \ +do {\ +strncat_s(deestination, sourceLen+1, source, sourceLen); \ +} while (0) +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4996) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" +#endif + +NS_UQM_BEGIN + +class UQMString +{ +private: + char *data; + unsigned long len; + +public: + UQMString() : len(0) + { + data = UQM_SAFE_MALLOC(1, char); + data[0] = '\0'; + } + + UQMString(const std::string &str) + { + len = str.size(); + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, str.c_str(), len); + data[len] = '\0'; + } + + UQMString(const char *strPtr) + { + if (strPtr == NULL) + { + len = 0; + data = UQM_SAFE_MALLOC(1, char); + data[0] = '\0'; + return; + } + + len = (unsigned int) strlen(strPtr); + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, strPtr, len); + data[len] = '\0'; + } + + UQMString(const UQMString &str) + { + len = (unsigned int) str.size(); + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, str.c_str(), len); + data[len] = '\0'; + } + + // 析构函数 + ~UQMString() + { + UQM_SAFE_FREE(data); + len = 0; + } + + // 重载+ + UQMString operator+(const UQMString &str) const + { + UQMString newStr; + UQM_SAFE_FREE(newStr.data); + newStr.len = len + (unsigned int) str.size(); + newStr.data = UQM_SAFE_MALLOC(newStr.len + 1, char); + strncpy(newStr.data, data, len); + strncat(newStr.data, str.data, str.length()); + newStr.data[newStr.len] = '\0'; + + return newStr; + } + + // 重载= + UQMString &operator=(const UQMString &str) + { + if (this == &str) + { + return *this; + } + + UQM_SAFE_FREE(data); + len = str.len; + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, str.c_str(), len); + data[len] = '\0'; + + return *this; + } + + // 重载= + UQMString &operator=(const char *strPtr) + { + if (strPtr == NULL) + { + len = 0; + data = UQM_SAFE_MALLOC(1, char); + data[0] = '\0'; + return *this; + } + UQM_SAFE_FREE(data); + len = (unsigned int) strlen(strPtr); + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, strPtr, len); + data[len] = '\0'; + + return *this; + } + + // 重载= + UQMString &operator=(const std::string &str) + { + UQM_SAFE_FREE(data); + len = str.length(); + data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(data, str.c_str(), len); + data[len] = '\0'; + + return *this; + } + + // 重载+= + UQMString &operator+=(const UQMString &str) + { + len += str.len; + char *new_data = UQM_SAFE_MALLOC(len + 1, char); + strncpy(new_data, data, len); + strncat(new_data, str.data,str.size()); + UQM_SAFE_FREE(data); + data = new_data; + data[len] = '\0'; + + return *this; + } + + // 重载== + inline bool operator==(const UQMString &str) const + { + if (len != str.len) + { + return false; + } + return strcmp(data, str.data) == 0; + } + + // 获取长度 + inline size_t size() const + { + return len; + } + + inline size_t length() const + { + return len; + } + + const std::string toString() const + { + if (data) + { + return data; + } + + return ""; + } + + bool empty() const + { + return size() <= 0; + } + + // 获取C字符串 + inline const char *c_str() const + { + return data; + } + +}; + +class UQMKVPair +{ +public: + UQMString key; + UQMString value; +#if UQM_PLATFORM_WINDOWS +#else + UQM_AutoParser("", O(key, value)); +#endif +}; + +// 重新定义vector +template +class UQMVector +{ +public: + //将构造函数声明为explicit ,是为了抑制由构造函数定义的隐式转换 + explicit UQMVector(unsigned long initSize = 0) : vectorSize(0), vectorCapacity( + (unsigned int) initSize + SPARE_CAPACITY), objects(NULL) + { + objects = UQM_SAFE_MALLOC(initSize + SPARE_CAPACITY, T); + + } + + UQMVector(const UQMVector &rhs) : objects(NULL) + { + vectorSize = rhs.vectorSize; + vectorCapacity = rhs.vectorCapacity; + + objects = UQM_SAFE_MALLOC(vectorCapacity, T); + for (unsigned int k = 0; k < vectorSize; k++) + { + objects[k] = rhs.objects[k]; + } + } + + ~UQMVector() + { + for (unsigned int i = 0; i < vectorSize; i++) + { + objects[i].~T(); + } + UQM_SAFE_FREE(objects); + } + + const UQMVector &operator=(const UQMVector &rhs) + { + if (this != &rhs) + { + for (unsigned int i = 0; i < vectorSize; i++) + { + objects[i].~T(); + } + UQM_SAFE_FREE(objects); + vectorSize = rhs.vectorSize; + vectorCapacity = rhs.vectorCapacity; + + objects = UQM_SAFE_MALLOC(vectorCapacity, T); + for (unsigned int k = 0; k < vectorSize; k++) + { + objects[k] = rhs.objects[k]; + } + } + + return *this; + } + + const UQMVector &operator=(const typename std::vector &rhs) + { + if (!rhs.empty()) + { + for (unsigned int i = 0; i < vectorSize; i++) + { + objects[i].~T(); + } + UQM_SAFE_FREE(objects); + vectorSize = rhs.size(); + vectorCapacity = rhs.capacity(); + + objects = UQM_SAFE_MALLOC(vectorCapacity, T); + for (unsigned int k = 0; k < vectorSize; k++) + { + objects[k] = rhs[k]; + } + } + + return *this; + } + + // 如果index错误,直接返回0的数据 + T &operator[](int index) + { + if (index < 0 || index >= vectorSize) + { + return objects[0]; + } + return objects[index]; + } + + const T &operator[](int index) const + { + return objects[index]; + } + + //检测是否需要扩容 + void reserve() + { + reserve(vectorSize); + } + + // 扩容数据 + void reserve(unsigned int newSize) + { + if (vectorCapacity > newSize) + { + return; + } + unsigned int newCapacity = newSize * 2 + 1; + T *oldArr = objects; + + objects = UQM_SAFE_MALLOC(newCapacity, T); + for (unsigned int k = 0; k < vectorSize; k++) + { + objects[k] = oldArr[k]; + } + vectorCapacity = newCapacity; + for (unsigned int i = 0; i < vectorSize; i++) + { + oldArr[i].~T(); + } + UQM_SAFE_FREE(oldArr); // 删除原来的数据 + } + + unsigned int size() const + { + return vectorSize; + } + + unsigned int capacity() const + { + return vectorCapacity; + } + + bool empty() const + { + return vectorSize == 0; + } + + bool find(const T &t) const + { + for (int i = 0; i < vectorSize; i++) + { + if (objects[i] == t) + { + return true; + } + } + + return false; + } + + void resize(unsigned int newSize) + { + reserve(newSize); + vectorSize = newSize; + } + + void push_back(const T &obj) + { + reserve(); // 检测容器大小 + objects[vectorSize++] = obj; + } + + void pop_back() + { + objects[vectorSize].~T(); + vectorSize--; + } + + const T &back() const + { + return objects[vectorSize - 1]; + } + + const T *begin() + { + return &objects[0]; + } + + T *end() + { + return &objects[vectorSize]; + } + + bool clear() + { + for (int i = 0; i < vectorSize; i++) + { + objects[i].~T(); + } + vectorSize = 0; + UQM_SAFE_FREE(objects); + objects = UQM_SAFE_MALLOC(SPARE_CAPACITY, T); + vectorCapacity = SPARE_CAPACITY; + + return true; + } + + const T *end() const + { + return &objects[vectorSize]; + } + + std::string toString() + { + std::stringstream out; + out << "Vector length:" << size() << ",capacity:" << capacity() << std::endl; + for (int i = 0; i < vectorSize; i++) + { + out << "objects[" << i << "]:" << objects[i] << std::endl; + } + + return out.str(); + } + + typedef T *iterator; +private: + unsigned int vectorSize; + unsigned int vectorCapacity; + T *objects; +}; + +class UQMRetAdapter +{ +public: + + void convert(bool &val, const bool &innerVal); + + void convert(double &val, const double &innerVal); + + void convert(float &val, const float &innerVal); + + void convert(int &val, const int &innerVal); + + // void convert(long &val, const long &innerVal); + + void convert(int64_t &val, const int64_t &innerVal); + + void convert(std::string &val, const UQMString &innerVal) + { + val = innerVal.c_str(); + } + + void convert(UQMString &innerVal, const std::string &val) + { + innerVal = val; + } + + void convert(std::map &val, const UQMVector &innerVal) + { + for (unsigned int i = 0; i < innerVal.size(); i++) + { + val.insert(std::make_pair(innerVal[i].key.c_str(), innerVal[i].value.c_str())); + } + } + + template + void convert(std::vector &val, const UQMVector &innerVal) + { + size_t s = innerVal.size(); + val.resize(s); + for (unsigned int i = 0; i < s; ++i) + { + convert(val[i], innerVal[i]); // operator[](size_t) + } + } + + template + void convert(OutTypeRet &outTypeRet, const InnerTypeRet &innerTypeRet) + { +#if UQM_PLATFORM_WINDOWS +#else + outTypeRet.innerRetConvert(*this, innerTypeRet); +#endif + }; +}; + +class UQM_EXPORT UQMCompatManager +{ +public: + template + static bool compatConvert(OutTypeRet &outTypeRet, const InnerTypeRet &innerTypeRet) + { + UQMRetAdapter ret; + ret.convert(outTypeRet, innerTypeRet); + return true; + } +}; + +NS_UQM_END + +#ifdef _MSC_VER +#pragma warning(pop) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif +#endif /* UQMCompatLayer_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrash.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrash.h new file mode 100644 index 00000000000..20ac3207cde --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrash.h @@ -0,0 +1,243 @@ +// +// UQMCrash.hpp +// Version: 4.3.8(1084) +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMCrash_h +#define UQMCrash_h + +#include "UQMDefine.h" +#include "CrashSightMobileAgent.h" + +NS_UQM_BEGIN + + typedef enum { + CRASH_TYPE_NATIVE = 2, + CRASH_TYPE_U3D = 3, + CRASH_TYPE_ANR = 4, + CRASH_TYPE_JS = 5, + CRASH_TYPE_LUA = 6, + }UQMCrashType; + + class UQM_EXPORT UQMCrashRet : public UQMBaseRet { + public: + int maxDataLen; + char* data; + }; + + class UQM_EXPORT UQMCrashObserver + { + public: + //新增一个虚析构函数 不然 UE4 报错 + virtual ~UQMCrashObserver() {}; + + virtual long OnCrashExtraDataNotify(const UQMInnerCrashRet& crashRet) { + return 0; + }; + + virtual const char* OnCrashExtraMessageNotify(int crashType) { + return NULL; + }; + }; + + class UQM_EXPORT UQMCrashLogObserver + { + public: + //新增一个虚析构函数 不然 UE4 报错 + virtual ~UQMCrashLogObserver() {}; + + // 设置日志路径回调 + virtual const char* OnCrashSetLogPathNotify(int crashType) { + return NULL; + }; + + // 通知日志上传结果回调 + virtual void OnCrashLogUploadResultNotify(int crashType, int result) { + }; + }; + + class UQM_EXPORT UQMCrash : public GCloud::CrashSight::CrashSightMobileAgent + { + private: + static std::map retMsg; +#if !UQM_PLATFORM_WINDOWS + static pthread_mutex_t mutex; +#endif + + static void CrashDataObserver(const UQMInnerCrashRet& crashRet, const char* seqID); + + static void CrashMessageObserver(const UQMInnerCrashRet& crashRet, const char* seqID); + + static void CrashSetLogPathObserver(const UQMInnerCrashRet& crashRet, const char* seqID); + + static void CrashLogUploadResultObserver(const UQMInnerCrashRet& crashRet, const char* seqID); + + static UQMCrashObserver* mCrashObserver; + static UQMCrashLogObserver* mCrashLogObserver; + + ~UQMCrash(); + + static void SetPRVCrashObserver(UQMInnerRetCallbackClass::UQMInnerRetCallback crashObserver); + static void SetExtraMessageCrashObserver(UQMInnerRetCallbackClass::UQMInnerRetCallback crashObserver); + static void SetLogPathObserver(UQMInnerRetCallbackClass::UQMInnerRetCallback crashObserver); + static void SetLogUploadResultObserver(UQMInnerRetCallbackClass::UQMInnerRetCallback crashObserver); + + public: + static void SetCrashObserver(UQMCrashObserver* crashObserver); + + static void SetCrashLogObserver(UQMCrashLogObserver* crashObserver); + + /** + * 配置回调类型 + * @param callbackType 目前是5种类型,用5位表示。第一位表示crash,第二位表示anr,第三位表示u3d c# error,第四位表示js,第五位表示lua + * 示例:关闭u3d c# error上报(type=4)的回调, callbackType=0b11011 + */ + static void ConfigCallbackTypeBeforeInit(int32_t callbackType); + + /** + * 崩溃处理函数处理超时限制 + * @param timeout <=0 表示不限制 + */ + static void ConfigCrashHandleTimeout(int32_t timeout); + + static void Init(const UQMString& appId, bool unexpectedTerminatingDetectionEnable, bool debugMode, const UQMString& serverUrl); + /** + * 自定义日志打印接口,用于记录一些关键的业务调试信息, 可以更全面地反应APP发生崩溃或异常的上下文环境. + * + * @param level 日志级别,0-silent, 1-error,2-warning,3-info,4-debug,5-verbose + * @param tag 日志模块分类 + * @param log 日志内容 + */ + static void LogInfo(int level, const UQMString& tag, const UQMString& log); + + /** + * 设置关键数据,随崩溃信息上报 + * @param key 键值 + * @param value 键值对 + */ + static void SetUserValue(const UQMString& key, const UQMString& value); + + /** + * 设置用户 ID + * @param userId 用户ID + */ + static void SetUserId(const UQMString& userId); + + /** + * 设置App ID + * @param appId 项目ID + */ + static void SetAppId(const UQMString& appId); + + /** + * 进入子地图 + * @param appId 项目ID + */ + static void EntrySubMap(const UQMString& appId); + + /** + * 设置场景 + * @param userSceneTag 场景标签 + */ + static void SetUserSceneTag(const UQMString& userSceneTag, bool upload = false); + + static void SetCurrentScene(int sceneId); + + static void ReportExceptionPRV(int type, const UQMString& exceptionName, const UQMString& exceptionMsg, const UQMString& exceptionStack, const UQMVector& extInfo, const UQMString& extInfoJsonStr, bool quit = false, int dumpNativeType = 0); + + /** + * 设置UQM的上报异常堆栈 + * @param type 3-cocoa 4-c# 5-JS 6-Lua, 7-统计信息上报 + * 当type=7时,exceptionName是统计的字段,exceptionMsg是统计字段的值 + * @param exceptionName 异常名称 + * @param exceptionMsg 异常消息 + * @param exceptionStack 异常堆栈内容 + * @param extInfo 异常的附加额外信息 + * @param dumpNativeType 0:关闭,1:调用系统接口dump,3:minidump + */ + static void ReportException(int type, const UQMString& exceptionName, const UQMString& exceptionMsg, const UQMString& exceptionStack, std::map& extInfo, int dumpNativeType = 0) + { + UQMVector tmp; + std::map::iterator it = extInfo.begin(); + for (; it != extInfo.end(); it++) + { + UQMKVPair kvPair; + kvPair.key = (*it).first; + kvPair.value = (*it).second; + tmp.push_back(kvPair); + } + ReportExceptionPRV(type, exceptionName, exceptionMsg, exceptionStack, tmp, + nullptr, false, dumpNativeType); + } + + /** + * 设置UQM的上报异常堆栈: c接口版本,不支持map + * @param type 3-cocoa 4-c# 5-JS 6-Lua + * @param exceptionName 异常名称 + * @param exceptionMsg 异常消息 + * @param exceptionStack 异常堆栈内容 + * @param dumpNativeType 0:关闭,1:调用系统接口dump,3:minidump + */ + static void ReportException(int type, const UQMString& exceptionName, const UQMString& exceptionMsg, const UQMString& exceptionStack, int dumpNativeType = 0) + { + UQMVector extInfo; + ReportExceptionPRV(type, exceptionName, exceptionMsg, exceptionStack, extInfo, nullptr, false, dumpNativeType); + } + + /** + * 设置前后台 + * @param isAppForeground 是否前台 + */ + static void SetIsAppForeground(bool isAppForeground); + + static void SetAppVersion(const UQMString& appVersion); + + static void SetCallBackMsg(const UQMString &data); + + // GameAgent + static void InitWithAppId(const UQMString& appId); + + static void ConfigDefaultBeforeInit(const UQMString& channel, const UQMString& version, const UQMString& user, long delay); + + static void ConfigCrashServerUrlBeforeInit(const UQMString& crashServerUrl); + + static void ConfigCrashReporterLogLevelBeforeInit(int logLevel); + + static void ConfigDebugModeBeforeInit(bool enable); + + static void SetDeviceId(const UQMString& deviceId); + + static void SetCustomizedDeviceID(const UQMString& deviceId); + + static void SetCustomizedMatchID(const UQMString& matchId); + + static void SetDeviceModel(const UQMString& deviceModel); + + static void SetLogPath(const UQMString& logPath); + + static void ReportException(int type, const UQMString& name, const UQMString& reason, const UQMString& stackTrace, const UQMString& extras, bool quit, int dumpNativeType = 0) + { + UQMVector tmp; + UQMKVPair kvPair; + kvPair.key = "Extra"; + kvPair.value = extras; + tmp.push_back(kvPair); + ReportExceptionPRV(type, name, reason, stackTrace, tmp, nullptr, quit, dumpNativeType); + } + + static void ReportExceptionJson(int type, const UQMString& exceptionName, const UQMString& exceptionMsg, const UQMString& exceptionStack, const UQMString& paramsJson, int dumpNativeType = 0) + { + UQMVector tmp; + ReportExceptionPRV(type, exceptionName, exceptionMsg, exceptionStack, tmp, paramsJson, + false, dumpNativeType); + } + + static void LogRecord(int level, const UQMString& message); + + }; + +NS_UQM_END + +#endif /* UQMCrash_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashDelegate.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashDelegate.h new file mode 100644 index 00000000000..4a445591d29 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashDelegate.h @@ -0,0 +1,109 @@ +// +// UQMCrashDelegate.h +// UQMCore +// +// Created by joyfyzhang on 2021/1/8. +// Copyright © 2021 joyfyzhang. All rights reserved. +// + +#ifndef UQMCrashDelegate_h +#define UQMCrashDelegate_h + +#import + +@protocol UQMCrashDelegate + +@required + +- (void)configCallbackTypeBeforeInit: (int32_t)callbackType; + +- (void)configCrashHandleTimeout: (int32_t)timeout; + +- (void)initCrashReport:(NSString *)appId unexpectedTerminatingDetectionEnable:(bool)unexpectedTerminatingDetectionEnable debugMode:(bool)debugMode serverUrl:(NSString *)serverUrl; + +@optional + +- (void)reportLog:(int)level tag:(NSString *)tag log:(NSString *)log; + +- (void)setUserData:(NSString *)key value:(NSString *)value; + +- (void)setUserId: (NSString *)userId; + +- (void)setAppId: (NSString *)appId; + +- (void)setUserSceneTag: (NSString *)userSceneTag isUpload:(bool)upload; + +- (void)reportException:(int)type exceptionName:(NSString *)exceptionName + exceptionMsg:(NSString *)exceptionMsg + exceptionStack:(NSString *)exceptionStack + extInfo:(NSDictionary *)extInfo + extInfoJsonStr:(NSString *)extInfoJsonStr + quit:(bool)quit + dumpNativeType:(int)dumpNativeType + errorAttachmentPath:(NSString *)errorAttachmentPath; + +-(void)reportLogInfo:(NSString*)msgType msg:(NSString*)msg; + +- (void)setIsAppForeground: (bool)isAppForeground; + +- (void)setAppVersion: (NSString *)appVersion; + +// agent +- (void)initWithAppId:(NSString *) appId; + +- (void)configCrashServerUrlBeforeInit: (NSString *)serverUrl; + +- (void)configDefaultBeforeInit: (NSString *)channel version:(NSString *)version user:(NSString *)user delay:(long)delay; + +- (void)configCrashReporterLogLevelBeforeInit: (int)logLevel; + +- (void)configDebugModeBeforeInit: (bool) enable; + +- (void)logRecord: (int)level message: (NSString *)message; + +- (void)setLogPath: (NSString *)logPath; + +-(void)closeCrashReport; + +-(void)reregisterCrashHandler; + +- (long)getCrashThreadId; + +- (void)setAppDeviceId: (NSString *)deviceId; + +-(NSString*)getBackendDeviceId; + +- (void)setCustomizedMatchID: (NSString *)matchId; + +-(NSString*)getSDKSessionID; + +-(BOOL)isLastSessionCrash; + +-(NSString*)getLastSessionUserId; + +-(int)getExceptionType:(NSString *)name; + +-(void)setServerEnv:(NSString *)serverEnv; + +-(void)setEngineInfo:(NSString *)version buildConfig:(NSString *)buildConfig language:(NSString *)language locale:(NSString *)locale; + +- (void)enableDetailedPageTracing: (bool) enable; + +- (void)useSavedUserId: (bool) enable; + +- (void)setOomLogPath: (NSString *)logPath; + +-(void)reportJank:(int)type exceptionName:(NSString *)name exceptionMsg:(NSString *) msg exceptionStack:(NSString *)stack extInfoJsonStr:(NSString *)extra reportInfoOption:(int)reportInfoOption jankAttachmentPath:(NSString *)attachPath; + +-(void)reportStuckWithThreadIndex:(int)threadIndex + maxChecks:(int)maxChecks + checkInterval:(NSTimeInterval)checkInterval + name:(NSString *)name + message:(NSString *)message + extraInfo:(NSString *)extraInfo + dumpNativeType:(int)dumpNativeType + attachPath:(NSString *)attachPath; + +@end + +#endif /* UQMCrashDelegate_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashIMPL.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashIMPL.h new file mode 100644 index 00000000000..92c9f04267f --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMCrashIMPL.h @@ -0,0 +1,158 @@ +// +// UQMCrashIMPL.h +// CrashSight +// +// Created by joyfyzhang on 2020/9/4. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMCrashIMPL_h +#define UQMCrashIMPL_h + +#include "UQMDefine.h" +#include "UQMSingleton.h" + +NS_UQM_BEGIN + +class UQMCrashIMPL : public UQMSingleton +{ + friend class UQMSingleton; + +public: + + static void ConfigCallbackTypeBeforeInit(const std::string& channel, int32_t callbackType); + + static void ConfigCrashHandleTimeout(const std::string& channel, int32_t timeout); + + static bool Init(const std::string& channel, const std::string& appId, bool unexpectedTerminatingDetectionEnable, bool debugMode, const std::string& serverUrl); + + static void LogInfo(const std::string& channel, int level, const std::string& tag, const std::string& log); + + static void SetUserValue(const std::string& channel, const std::string& key, const std::string& value); + + static void SetUserId(const std::string& channel, const std::string& userId); + + static void SetAppId(const std::string& channel, const std::string& appId); + + static void SetUserSceneTag(const std::string& channel, const std::string& userSceneTag, bool upload); + + static void ReportException(const std::string& channel, int type, const std::string& exceptionName, const std::string& exceptionMsg, const std::string& exceptionStack, const UQMVector &extInfo, const std::string& extInfoJsonStr, bool quit= false, int dumpNativeType= 0, const std::string& errorAttachmentPath = ""); + + static void ReportLogInfo(const std::string& msgType, const std::string& msg); + +#ifdef ANDROID + static jobject convert(const std::map &data); +#endif + + static void SetIsAppForeground(const std::string& channel, bool isAppForeground); + + static void SetAppVersion(const std::string& channel, const std::string& appVersion); + + //测试接口 + static void TestOomCrash(const std::string& channel); + static void TestJavaCrash(const std::string& channel); + static void TestOcCrash(const std::string& channel); + static void TestNativeCrash(std::string channel) { + UQM_LOG_DEBUG("TestNativeCrash channel = %s", channel.c_str()); + abort(); + } + static void TestANR(const std::string& channel); + + //agent + static bool InitWithAppId (const std::string& channel, const std::string& appId, bool forceOnUiThread); + + static void SetGameType(const std::string& channel, int gameType); + + static void ConfigDefaultBeforeInit(const std::string& channel, const std::string& appChannel, const std::string& version, const std::string& user, long delay); + + static void ConfigCrashServerUrlBeforeInit(const std::string& channel, const std::string& serverUrl); + + static void ConfigCrashReporterLogLevelBeforeInit(const std::string& channel, int logLevel); + + static void ConfigDebugModeBeforeInit(const std::string& channel, bool enable); + + static void SetDeviceId(const std::string& channel, const std::string& deviceId); + + static void SetAppDeviceId(const std::string& channel, const std::string& deviceId); + + static std::string GetBackendDeviceId(const std::string& channel); + + static void SetCustomizedMatchID(const std::string& channel, const std::string& matchId); + + static std::string GetSDKSessionID(const std::string& channel); + + static void SetDeviceModel(const std::string& channel, const std::string& deviceModel); + + static void SetLogPath(const std::string& channel, const std::string& logPath); + + static void LogRecord (const std::string& channel, int level, const std::string& message); + + static void CloseCrashReport(const std::string& channel); + + static void StartCrashReport(const std::string& channel); + + static void SetCatchMultiSignal(const std::string& channel, bool enable); + + static void SetUnwindExtraStack(const std::string& channel, bool enable); + + static long GetCrashThreadId(const std::string& channel); + + static std::string GetCrashUuid(const std::string &channel); + + static bool IsLastSessionCrash(const std::string& channel); + + static std::string GetLastSessionUserId(const std::string& channel); + + static void SetUploadThreadNum(const std::string& channel, int num); + + static void SetLogcatBufferSize(const std::string &channel, int size); + + static void startDumpRoutine(const std::string& channel, int dumpMode, int startTimeMode, long startTime, + long dumpInterval, int dumpTimes, bool saveLocal, const std::string& savePath); + + static void startMonitorFdCount(const std::string& channel, int interval, int limit, int dumpType); + + static int getExceptionType(const std::string& channel, const std::string& name); + + static void testUseAfterFree(const std::string &channel); + + static void setEnableGetPackageInfo(const std::string& channel, bool enable); + + static void setServerEnv(const std::string& channel, const std::string& serverEnv); + + static void setEngineInfo(const std::string& channel, const std::string& version, const std::string& buildConfig, const std::string& language, const std::string& locale); + + static void setGpuInfo(const std::string& channel, const std::string& version, const std::string& vendor, const std::string& renderer); + + static void setIsOpengles(const std::string& channel, bool isOpengles); + + static void enableDetailedPageTracing(const std::string& channel, bool enable); + + static void useSavedUserId(const std::string& channel, bool enable); + + static bool checkFdCount(const std::string& channel, int limit, int dumpType, bool upload); + + static void SetOomLogPath(const std::string& channel, const std::string& logPath); + + static void ReportJank(const std::string& channel, int type, const std::string& exceptionName, + const std::string& exceptionMsg, const std::string& exceptionStack, + const std::string& extInfoJsonStr, int reportInfoOption, const std::string& jankAttachmentPath); + + static void processEngineAnr(const std::string& channel, int type); + + static void setEngineMainThread(const std::string& channel); + + static void ReportStuck(const std::string& channel, int threadId, int maxChecks, long checkInterval, + const std::string& name, const std::string& message, const std::string& extraInfo, + int dumpNativeType, const std::string& attachPath); + + private: + UQMCrashIMPL() {} + static void CallFunction(const std::string& channel, const std::string& functionName, bool enable); + static long CallLongFunction(const std::string& channel, const std::string& functionName); + + }; + +NS_UQM_END + +#endif /* UQMCrashIMPL_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMDefine.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMDefine.h new file mode 100644 index 00000000000..80538fe29e6 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMDefine.h @@ -0,0 +1,269 @@ +// +// UQMDefine.hpp +// CrashSight +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMDefine_hpp +#define UQMDefine_hpp + +#include +#include +#include +#include +#include "UQMMacros.h" +#include "UQMMacroExpand.h" +#include "UQMCompatLayer.h" +#include "CSLogger.h" + +#define CS_SDK_DEVICE_ID_LEN 64 +#define CS_SDK_USER_ID_LEN 64 + +NS_UQM_BEGIN + +typedef enum UQMMethodName { + kUQMMethodNameUndefine = 000, + kUQMMethodNameCrashExtraData = 1011, + kUQMMethodNameCrashExtraMessage = 1012, + kUQMMethodNameCrashSetLogPath = 1013, + kUQMMethodNameCrashLogUploadResult = 1014, +} UQMMethodName; + +typedef enum UQMObserverID +{ + kUQMObserverIDWakeUp = 107, +}UQMObserverID; + +class UQM_EXPORT UQMBaseRet { +public: + // 标记是从哪个方法过来 + int methodNameID; + // UQM 返回码,详情可参考 UQMError.h + int retCode; + // UQM 描述信息 + std::string retMsg; + // 第三方渠道返回码 + int thirdCode; + // 第三方渠道描述信息 + std::string thirdMsg; + // 扩展字段,保留 + std::string extraJson; + + // 构造函数对外使用,必须包含在外部调用,否则会 crash + UQMBaseRet(); + + // 构造函数对外使用,必须包含在外部调用,否则会 crash + UQMBaseRet(int code); + + // 构造函数对外使用,必须包含在外部调用,否则会 crash + UQMBaseRet(int code, int tCode, std::string tMsg); + +#if UQM_PLATFORM_WINDOWS +#else +UQM_AutoParser("com.uqm.crashsight.core.api.UQMRet", A(thirdCode, "ret"), A(thirdMsg, "msg"), + O(methodNameID, retCode, retMsg, extraJson)); +#endif + +}; + +/** + * 基础结构类 + */ +class UQM_EXPORT UQMInnerBaseRet +{ +public: + + // 标记是从哪个方法过来 + int methodNameID; + + // UQM 返回码,详情可参考 UQMError.h + int retCode; + + // UQM 描述信息 + UQMString retMsg; + + // 第三方渠道返回码 + int thirdCode; + + // 第三方渠道描述信息 + UQMString thirdMsg; + + // 扩展字段,保留 + UQMString extraJson; + + // 回调类型 + int crashType{}; + + // 构造函数 + UQMInnerBaseRet(); + + UQMInnerBaseRet(int retCode); + + UQMInnerBaseRet(int retCode, int methodID); + + UQMInnerBaseRet(int retCode, int thirdCode, const UQMString& thirdMsg); + + UQMInnerBaseRet(int retCode, UQMString retMsg, int thirdCode, const UQMString& thirdMsg); +#if UQM_PLATFORM_WINDOWS +#else + UQM_AutoParser("com.uqm.crashsight.core.api.UQMRet", A(thirdCode, "ret"), + A(thirdMsg, "msg"), O(methodNameID, retCode, retMsg, extraJson)); +#endif + +}; + +class UQMInnerCrashRet : public UQMInnerBaseRet +{ +public: + char *data{}; + int maxDataLen{}; + int *dataLen{}; + UQMInnerCrashRet(); +#if UQM_PLATFORM_WINDOWS +#else +UQM_AutoParser("com.uqm.crashsight.core.api.crash.UQMCrashRet", + A(thirdCode, "ret"), A(thirdMsg, "msg"), + A(extraJson, "extra"), O(retCode, retMsg, methodNameID), + O(methodNameID)); +#endif +}; + +template +class UQMInnerRetCallbackClass +{ +public: + typedef void (*UQMInnerRetCallback)(const RetType &ret, const char *seqID); +}; + +template +class UQMCallBackParams +{ +public: + RetType mRet; + unsigned int mObserverID; + UQMString mSeqID; + UQMCallBackParams(const RetType &ret, unsigned int observerID, UQMString seqID): mRet(ret), mObserverID(observerID), mSeqID(seqID){}; +}; + +void UQMInnerObserverHolderDispatch(void (*callback)(int result, void *args), void *context); + + +template +class UQMInnerObserverHolder +{ +private : + static std::map::UQMInnerRetCallback> mObserverHolder; + static std::map > mTaskParamsHolder; + static void cacheTask(std::string mSeqID, UQMCallBackParams taskParams) + { + if (mSeqID.empty()){ + UQM_LOG_DEBUG("cacheTask failed for mSeqID is empty"); + return; + } + mTaskParamsHolder.insert(std::make_pair(mSeqID, taskParams)); + UQM_LOG_DEBUG("mTaskParamsHolder after insert %s", mSeqID.c_str()); + } + static void commitCacheTask() + { + typename std::map >::iterator iter; + for (iter = mTaskParamsHolder.begin(); iter != mTaskParamsHolder.end(); ){ + UQMCallBackParams taskParam = iter->second; + if(CommitCacheToTaskQueue(taskParam.mRet, taskParam.mObserverID, taskParam.mSeqID)){ + mTaskParamsHolder.erase(iter++); + UQM_LOG_DEBUG("mTaskParamsHolder size: %lu, after erase %s", (unsigned long)mTaskParamsHolder.size(), taskParam.mSeqID.c_str()); + } else { + ++iter; + } + } + // UQM_LOG_DEBUG("mTaskParamsHolder size: %lu, after commitCacheTask", (unsigned long)mTaskParamsHolder.size()); + } +public: + static void CacheObserver(const unsigned int mObserverID, typename UQMInnerRetCallbackClass::UQMInnerRetCallback observer) + { + if (mObserverHolder.find(mObserverID) != mObserverHolder.end()) + { + // 如果已经存在就删除原来的 key,保证 key 对应的 value 是最新 + mObserverHolder.erase(mObserverID); + } + + mObserverHolder.insert(std::make_pair(mObserverID, observer)); + commitCacheTask(); + } + + static void CommitToTaskQueueBackRet(const RetType &ret, const unsigned int observerID, const UQMString &seqID) + { + if (mObserverHolder.find(observerID) != mObserverHolder.end()) + { + UQMInnerCrashRet innerCrashRet = static_cast(ret); + + //UQM_LOG_DEBUG("innerCrashRet %d %s %p %d", observerID, seqID.c_str(), innerCrashRet.data, innerCrashRet.maxDataLen); + + mObserverHolder[observerID](ret, seqID.c_str()); + } + } + + static void CommitToTaskQueue(const RetType &ret, const unsigned int observerID, const UQMString &seqID) + { + UQMCallBackParams *params = new UQMCallBackParams(ret, observerID, seqID); + + if(mObserverHolder.find(params->mObserverID) == mObserverHolder.end()){ // 当前没有setObserver,缓存回调 + UQM_LOG_DEBUG("Cache ObserverID %d", observerID); + UQMCallBackParams taskParams(params->mRet, params->mObserverID, params->mSeqID); + cacheTask(params->mSeqID.toString(), taskParams); + UQM_SAFE_DELETE(params); + } else if (kUQMObserverIDWakeUp == observerID){ //wakeup 回调直接回调 + UQM_LOG_DEBUG("CallbackOnMainThread %d", observerID); + CallbackOnMainThread(-1, params); + } else { + UQM_LOG_DEBUG("DispatchAsyncMainThread %d", observerID); + UQMInnerObserverHolderDispatch(CallbackOnMainThread, params); + } + } + + static bool CommitCacheToTaskQueue(const RetType &ret, const unsigned int observerID, const UQMString &seqID){ + UQMCallBackParams *params = new UQMCallBackParams(ret, observerID, seqID); + if(mObserverHolder.find(params->mObserverID) != mObserverHolder.end()){ + UQM_LOG_DEBUG("DispatchAsyncMainThread %d", observerID); + UQMInnerObserverHolderDispatch(CallbackOnMainThread, params); + return true; + } + UQM_SAFE_DELETE(params); + return false; + } + + + static void CallbackOnMainThread(int ret, void *args) + { + UQMCallBackParams *params = (UQMCallBackParams *)args; + + if (mObserverHolder.find(params->mObserverID) != mObserverHolder.end()) + { + UQM_LOG_DEBUG("observer address %p of observerID : %d", mObserverHolder[params->mObserverID], params->mObserverID); + mObserverHolder[params->mObserverID](params->mRet, params->mSeqID.c_str()); + } + else + { + UQM_LOG_DEBUG("can not get inner callback for %u, make sure you have define", params->mObserverID); + } + + UQM_SAFE_DELETE(params); + } + +}; + + +template std::map::UQMInnerRetCallback> UQMInnerObserverHolder::mObserverHolder; +template std::map > UQMInnerObserverHolder::mTaskParamsHolder; + +#ifdef ANDROID + +typedef void (*FuncRunOnUIDelegate)(void *args); + +#endif + + +NS_UQM_END + +#endif /* UQMDefine_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMError.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMError.h new file mode 100644 index 00000000000..30245dacf2e --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMError.h @@ -0,0 +1,88 @@ +// +// UQMLog.hpp +// Crashot +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMError_hpp +#define UQMError_hpp + +#include "UQMMacros.h" + +NS_UQM_BEGIN + +class UQMError +{ +public: + /** 未知错误 */ + static const int UNKNOWN = -1; + static const int SUCCESS = 0; + static const int NO_ASSIGN = 1; /** 没有赋值 */ + static const int CANCEL = 2; + static const int SYSTEM_ERROR = 3; + static const int NETWORK_ERROR = 4; + static const int UQM_SERVER_ERROR = 5; // UQM 后台返回错误,参考第三方错误码 + static const int TIMEOUT = 6; + static const int NOT_SUPPORT = 7; + static const int OPERATION_SYSTEM_ERROR = 8; + static const int NEED_PLUGIN = 9; + static const int NEED_LOGIN = 10; + static const int INVALID_ARGUMENT = 11; + static const int NEED_SYSTEM_PERMISSION = 12; + static const int NEED_CONFIG = 13; + static const int SERVICE_REFUSE = 14; + static const int NEED_INSTALL_APP = 15; + static const int APP_NEED_UPGRADE = 16; + static const int INITIALIZE_FAILED = 17; + static const int EMPTY_CHANNEL = 18; + static const int FUNCTION_DISABLE = 19; + static const int NEED_REALNAME = 20; // 需实名认证 + static const int REALNAME_FAIL = 21; // 实名认证失败 + static const int IN_PROGRESS = 22; // 上次操作尚未完成,稍后再试 + static const int API_DEPRECATED = 23; + static const int LIBCURL_ERROR = 24; + static const int FREQUENCY_LIMIT = 25; //频率限制 + static const int DINED_BY_APP = 26; // 被三方拒绝,需要查看具体的错误 + + /** 1000 ~ 1099 字段是 LOGIN 模块相关的错误码 */ + static const int LOGIN_UNKNOWN_ERROR = 1000; + static const int LOGIN_NO_CACHED_DATA = 1001; // 本地没有登录缓存数据 + static const int LOGIN_CACHED_DATA_EXPIRED = 1002; //本地有缓存,但是该缓存已经失效 + static const int LOGIN_KEY_STORE_VERIFY_ERROR = 1004; + static const int LOGIN_NEED_USER_DATA = 1005; + + static const int LOGIN_NEED_USER_DATA_SERVER = 1010; + static const int LOGIN_URL_USER_LOGIN = 1011; // 异账号:使用URL登陆成功 + static const int LOGIN_NEED_LOGIN = 1012; // 异账号:需要进入登陆页 + static const int LOGIN_NEED_SELECT_ACCOUNT = 1013; // 异账号:需要弹出异帐号提示 + static const int LOGIN_ACCOUNT_REFRESH = 1014; // 异账号:通过URL将票据刷新 + + static const int CONNECT_NO_CACHED_DATA = 1021; // 本地没有关联渠道登录缓存数据 + static const int CONNECT_CACHED_DATA_EXPIRED = 1022; //本地有缓存,但是该缓存已经失效 + static const int CONNECT_NO_MATCH_MAIN_OPENID = 1023; //关联账号与主账号不一致 + + /** 1100 ~ 1199 字段是 FRIEND 模块相关的错误码 */ + static const int FRIEND_UNKNOWN_ERROR = 1100; + + /** 1200 ~ 1299 字段是 GROUP 模块相关的错误码 */ + static const int GROUP_UNKNOWN_ERROR = 1200; + + /** 1300 ~ 1399 字段是 NOTICE 模块相关的错误码 */ + static const int NOTICE_UNKNOWN_ERROR = 1300; + + /** 1400 ~ 1499 字段是 Push 模块相关的错误码 */ + static const int PUSH_RECEIVER_TEXT = 1400; // 收到推送消息 + static const int PUSH_NOTIFICATION_CLICK = 1401; // 在通知栏点击收到的消息 + static const int PUSH_NOTIFICATION_SHOW = 1402; // 收到通知之后,通知栏显示 + + /** 1500 ~ 1599 字段是 WEBVIEW 模块相关的错误码 */ + static const int WEBVIEW_UNKNOWN_ERROR = 1500; + + static const int THIRD_ERROR = 9999;// 第三方错误情况,参考第三方错误码 +}; + +NS_UQM_END + +#endif /* UQMError_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMLog.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMLog.h new file mode 100644 index 00000000000..b983f9503fe --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMLog.h @@ -0,0 +1,147 @@ +// +// UQMLog.hpp +// CrashSight +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMLog_hpp +#define UQMLog_hpp + +#include +#include +#include +#include +#include + +#include "UQMMacros.h" +#include "UQMCompatLayer.h" +#include "CSLogger.h" +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX +#else +#include +#include +#include +#include "zlib.h" +#endif + + +// 定义此宏 会在 release 日志宏中打印日志到控制台 +#ifndef DEBUG +#define DEBUG +#endif + +#ifndef UQM_LOG_TAG +#define UQM_LOG_TAG "[CrashSightPlugin-Native]" +#endif + +#ifdef ANDROID +#define UQM_LOG_MAX_LENGTH 1023 //冗余一位,用于解决最后一个是汉字导致被截断的问题 +#elif defined(__APPLE__) +#define UQM_LOG_MAX_LENGTH 4096 +#endif + + +//#define __UQM_FILENAME1__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1):__FILE__) +//#define __UQM_FILENAME2__ (strrchr(__FILE__, '\\') ? (strrchr(__FILE__, '\\') + 1):__FILE__) +//#define __UQM_FILENAME__ (strrchr(__FILE__, '/') ? (__UQM_FILENAME1__):(__UQM_FILENAME2__)) + +//#ifdef UQM_NO_LOG_DEBUG +//#define UQM_LOG_DEBUG(...) +//#define UQM_LOG_ERROR(...) +//#define UQM_LOG_JSON(level, ...) +//#else +//#define UQM_LOG_DEBUG(...) UQMLogger(kUQMLevelDebug, UQM_LOG_TAG, __UQM_FILENAME__, __FUNCTION__, __LINE__).console().writeLog(__VA_ARGS__) +//#define UQM_LOG_ERROR(...) UQMLogger(kUQMLevelError, UQM_LOG_TAG, __UQM_FILENAME__, __FUNCTION__, __LINE__).console().writeLog(__VA_ARGS__) +//#endif + + +NS_UQM_BEGIN + + typedef enum { + kUQMLevelDebug = 0, // 调试使用日志 精简日志,kLevelVerbose、kLevelInfo、kLevelWarn 都合并成Debug + kUQMLevelError, // 错误日志 + } UQMLogLevel; + + typedef struct { + UQMLogLevel level; + const char *tag; + const char *fileName; + const char *funcName; + int line; +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX +#else + struct timeval timeval; +#endif + long long pid; + long long tid; + long long mainTid; + } UQMLogInfo; + + + + + + class UQM_EXPORT UQMLogger { + public: + + UQMLogger(UQMLogLevel level, const char *tag, const char *fileName, const char *funcName, int line); + + ~UQMLogger(); + + // 是否打印日志到控制台 + UQMLogger &console(); + +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX + UQMLogger &writeLog(const char *fmt, ...); +#else + // 此接口独立出来 - 方便后续格式化 + UQMLogger &writeLog(const char *fmt, ...)__attribute__((format(printf, 2, 3))); +#endif + + static void consoleFormatLogVA(const UQMLogInfo *info, const char *message); + static void consoleFormatLog(const UQMLogInfo *info, const char *format); + static void consoleLog(const int level, const char *resultLog, ...); + + static long long getPid() { +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX + return -1; +#else + return getpid(); +#endif + } + + static long long getTid() { +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX + return -1; +#else +#ifdef __APPLE__ + return -1; +#else + return pthread_self(); +#endif +#endif + } + + static long long getMainTid() { +#if UQM_PLATFORM_WINDOWS || PLATFORM_LINUX + return -1; +#else +#ifdef __APPLE__ + return -1; +#else + return gettid(); +#endif +#endif + } + + private: + UQMLogInfo info; + bool isConsole; + UQMString curLogMsg; + }; + +NS_UQM_END + +#endif /* UQMLog_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacroExpand.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacroExpand.h new file mode 100644 index 00000000000..4bd6835fa6c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacroExpand.h @@ -0,0 +1,250 @@ +// +// UQMMacroExpand.hpp +// Crashot +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMMacroExpand_hpp +#define UQMMacroExpand_hpp + +#include "UQMMacros.h" + +#ifdef ANDROID +#include "jni.h" +#endif + +NS_UQM_BEGIN + +#ifdef ANDROID //Android 才需要 JNI 到 struct 的互转 +// Java 到 struct 的代码模板 +#define JNI_2_STRUCT_FUNC_BEGIN(clazzName) \ +public: \ +template \ +void jni2Struct(JObject& obj, jobject src, char const* cn = clazzName) { + +#define CONVERTER_JNI_2_STRUCT_OPTIONAL(M) \ +obj.convert(#M, M, src, cn); + +// 设置别名 +#define CONVERTER_JNI_2_STRUCT_ALIAS(M, A_NAME) CONVERTER_JNI_2_STRUCT_OPTIONAL(M) +//obj.convert(A_NAME,M, src, cn); + +// call father jni2Struct add by yuanchengsu +#define CONVERTER_JNI_2_STRUCT_BASE(M) M::jni2Struct(obj,src,cn); + +#define JNI_2_STRUCT_FUNC_END() } + + +// struct 到 JNI 的代码模板 +#define STRUCT_2_JNI_FUNC_BEGIN(clazzName) \ +template \ +void struct2JNI(CLASS& obj, const char *root, char const* cn = clazzName) const { \ + +#define CONVERTER_STRUCT_2_JNI_OPTIONAL(M) \ +obj.convert(#M, M, cn); + +#define CONVERTER_STRUCT_2_JNI_ALIAS(M, A_NAME) CONVERTER_STRUCT_2_JNI_OPTIONAL(M) +//obj.convert(A_NAME, M, cn); + +//call father struct2JNI add by yuanchengsu +#define CONVERTER_STRUCT_2_JNI_BASE(M) M::struct2JNI(obj,root,cn); + +#define STRUCT_2_JNI_FUNC_END() } +#endif + +// json 到 struct 的代码模板 +#define JSON_2_STRUCT_FUNC_BEGIN() \ +public: \ +template \ +void json2Struct(Doc& obj) { + +#define CONVERTER_JSON_2_STRUCT_OPTIONAL(M) \ +obj[#M].convert(M); + +// 设置别名 +#define CONVERTER_JSON_2_STRUCT_ALIAS(M, A_NAME) \ +obj[A_NAME].convert(M); + +// call father json2Struct by yuanchengsu +#define CONVERTER_JSON_2_STRUCT_BASE(M) M::json2Struct(obj); + +// struct 到 json 的代码模板 +#define STRUCT_2_JSON_FUNC_BEGIN() \ +template \ +void struct2Json(CLASS& obj, const char *root) const { + +#define CONVERTER_STRUCT_2_JSON_OPTIONAL(M) \ +obj.convert(#M,M); + +// 设置别名 +#define CONVERTER_STRUCT_2_JSON_ALIAS(M, A_NAME) \ +obj.convert(A_NAME,M); \ + +// call father struct2Json by yuanchengsu +#define CONVERTER_STRUCT_2_JSON_BASE(M) M::struct2Json(obj,root); + +#define STRUCT_AND_JSON_FUNC_END() } + + +// 兼容层转换代码 +#define RET_AND_INNER_FUNC_BEGIN() \ +template \ +void innerRetConvert(Doc& doc, const TypeRet &typeRet) { + +#define CONVERTER_RET_AND_INNER_OPTIONAL(M) \ +doc.convert(M, typeRet.M); + +// 设置别名 +#define CONVERTER_RET_AND_INNER_ALIAS(M, A_NAME) CONVERTER_RET_AND_INNER_OPTIONAL(M) + +//call father innerRetConvert by yuanchengsu +#define CONVERTER_RET_AND_INNER_BASE(M) M::innerRetConvert(doc,typeRet); + +#define RET_AND_INNER_FUNC_END() } + + +#define ARG_SEQ \ +_29,_28,_27,_26,_25,_24,_23,_22,_21,_20, \ +_19,_18,_17,_16,_15,_14,_13,_12,_11,_10, \ +_9, _8, _7, _6, _5, _4, _3, _2, _1 + +#define ARG_N(ACTION, \ +_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ +_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ +_21, _22, _23, _24, _25, _26, _27, _28, _29, NUMBER, ...) ACTION##NUMBER + +#define WRAP_LEVEL_ONE(ACT, LIST, ...) ARG_N(LEVEL_ONE, __VA_ARGS__, LIST)(ACT, __VA_ARGS__) +#define WRAP_LEVEL_TWO(ACT, LIST, ...) ARG_N(LEVEL_TWO, __VA_ARGS__, LIST)(ACT, __VA_ARGS__) + +#define LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_##ACT##M +#define LEVEL_ONE_1(ACT, M) LEVEL_ONE_DEF(ACT, M) +#define LEVEL_ONE_2(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_1(ACT, __VA_ARGS__) +#define LEVEL_ONE_3(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_2(ACT, __VA_ARGS__) +#define LEVEL_ONE_4(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_3(ACT, __VA_ARGS__) +#define LEVEL_ONE_5(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_4(ACT, __VA_ARGS__) +#define LEVEL_ONE_6(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_5(ACT, __VA_ARGS__) +#define LEVEL_ONE_7(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_6(ACT, __VA_ARGS__) +#define LEVEL_ONE_8(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_7(ACT, __VA_ARGS__) +#define LEVEL_ONE_9(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_8(ACT, __VA_ARGS__) +#define LEVEL_ONE_10(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_9(ACT, __VA_ARGS__) +#define LEVEL_ONE_11(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_10(ACT, __VA_ARGS__) +#define LEVEL_ONE_12(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_11(ACT, __VA_ARGS__) +#define LEVEL_ONE_13(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_12(ACT, __VA_ARGS__) +#define LEVEL_ONE_14(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_13(ACT, __VA_ARGS__) +#define LEVEL_ONE_15(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_14(ACT, __VA_ARGS__) +#define LEVEL_ONE_16(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_15(ACT, __VA_ARGS__) +#define LEVEL_ONE_17(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_16(ACT, __VA_ARGS__) +#define LEVEL_ONE_18(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_17(ACT, __VA_ARGS__) +#define LEVEL_ONE_19(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_18(ACT, __VA_ARGS__) +#define LEVEL_ONE_20(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_19(ACT, __VA_ARGS__) +#define LEVEL_ONE_21(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_20(ACT, __VA_ARGS__) +#define LEVEL_ONE_22(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_21(ACT, __VA_ARGS__) +#define LEVEL_ONE_23(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_22(ACT, __VA_ARGS__) +#define LEVEL_ONE_24(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_23(ACT, __VA_ARGS__) +#define LEVEL_ONE_25(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_24(ACT, __VA_ARGS__) +#define LEVEL_ONE_26(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_25(ACT, __VA_ARGS__) +#define LEVEL_ONE_27(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_26(ACT, __VA_ARGS__) +#define LEVEL_ONE_28(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_27(ACT, __VA_ARGS__) +#define LEVEL_ONE_29(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_28(ACT, __VA_ARGS__) +#define LEVEL_ONE_30(ACT, M, ...) LEVEL_ONE_DEF(ACT, M) LEVEL_ONE_29(ACT, __VA_ARGS__) + +#define LEVEL_TWO_DEF(ACT, M) CONVERTER_##ACT(M) +#define LEVEL_TWO_1(ACT, M) LEVEL_TWO_DEF(ACT, M) +#define LEVEL_TWO_2(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_1(ACT, __VA_ARGS__) +#define LEVEL_TWO_3(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_2(ACT, __VA_ARGS__) +#define LEVEL_TWO_4(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_3(ACT, __VA_ARGS__) +#define LEVEL_TWO_5(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_4(ACT, __VA_ARGS__) +#define LEVEL_TWO_6(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_5(ACT, __VA_ARGS__) +#define LEVEL_TWO_7(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_6(ACT, __VA_ARGS__) +#define LEVEL_TWO_8(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_7(ACT, __VA_ARGS__) +#define LEVEL_TWO_9(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_8(ACT, __VA_ARGS__) +#define LEVEL_TWO_10(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_9(ACT, __VA_ARGS__) +#define LEVEL_TWO_11(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_10(ACT, __VA_ARGS__) +#define LEVEL_TWO_12(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_11(ACT, __VA_ARGS__) +#define LEVEL_TWO_13(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_12(ACT, __VA_ARGS__) +#define LEVEL_TWO_14(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_13(ACT, __VA_ARGS__) +#define LEVEL_TWO_15(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_14(ACT, __VA_ARGS__) +#define LEVEL_TWO_16(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_15(ACT, __VA_ARGS__) +#define LEVEL_TWO_17(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_16(ACT, __VA_ARGS__) +#define LEVEL_TWO_18(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_17(ACT, __VA_ARGS__) +#define LEVEL_TWO_19(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_18(ACT, __VA_ARGS__) +#define LEVEL_TWO_20(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_19(ACT, __VA_ARGS__) +#define LEVEL_TWO_21(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_20(ACT, __VA_ARGS__) +#define LEVEL_TWO_22(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_21(ACT, __VA_ARGS__) +#define LEVEL_TWO_23(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_22(ACT, __VA_ARGS__) +#define LEVEL_TWO_24(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_23(ACT, __VA_ARGS__) +#define LEVEL_TWO_25(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_24(ACT, __VA_ARGS__) +#define LEVEL_TWO_26(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_25(ACT, __VA_ARGS__) +#define LEVEL_TWO_27(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_26(ACT, __VA_ARGS__) +#define LEVEL_TWO_28(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_27(ACT, __VA_ARGS__) +#define LEVEL_TWO_29(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_28(ACT, __VA_ARGS__) +#define LEVEL_TWO_30(ACT, M, ...) LEVEL_TWO_DEF(ACT, M) LEVEL_TWO_29(ACT, __VA_ARGS__) + +// struct to string +#define LEVEL_ONE_STRUCT_2_JNI_O(...) WRAP_LEVEL_TWO(STRUCT_2_JNI_OPTIONAL, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_STRUCT_2_JNI_A(M, A) CONVERTER_STRUCT_2_JNI_ALIAS(M,A) +#define LEVEL_ONE_STRUCT_2_JSON_O(...) WRAP_LEVEL_TWO(STRUCT_2_JSON_OPTIONAL, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_STRUCT_2_JSON_A(M, A) CONVERTER_STRUCT_2_JSON_ALIAS(M,A) +#define LEVEL_ONE_RET_AND_INNER_O(...) WRAP_LEVEL_TWO(RET_AND_INNER_OPTIONAL, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_RET_AND_INNER_A(M, A) CONVERTER_RET_AND_INNER_ALIAS(M,A) + + + + +// string to struct +#define LEVEL_ONE_JNI_2_STRUCT_O(...) WRAP_LEVEL_TWO(JNI_2_STRUCT_OPTIONAL, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_JNI_2_STRUCT_A(M, A) CONVERTER_JNI_2_STRUCT_ALIAS(M,A) +#define LEVEL_ONE_JSON_2_STRUCT_O(...) WRAP_LEVEL_TWO(JSON_2_STRUCT_OPTIONAL, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_JSON_2_STRUCT_A(M, A) CONVERTER_JSON_2_STRUCT_ALIAS(M,A) + +// fix inherit by yuanchengsu +#define LEVEL_ONE_STRUCT_2_JSON_B(...) WRAP_LEVEL_TWO(STRUCT_2_JSON_BASE, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_RET_AND_INNER_B(...) WRAP_LEVEL_TWO(RET_AND_INNER_BASE, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_JSON_2_STRUCT_B(...) WRAP_LEVEL_TWO(JSON_2_STRUCT_BASE, ARG_SEQ, __VA_ARGS__) + +#define LEVEL_ONE_JNI_2_STRUCT_B(...) WRAP_LEVEL_TWO(JNI_2_STRUCT_BASE, ARG_SEQ, __VA_ARGS__) +#define LEVEL_ONE_STRUCT_2_JNI_B(...) WRAP_LEVEL_TWO(STRUCT_2_JNI_BASE, ARG_SEQ, __VA_ARGS__) + +#ifdef ANDROID + +#define UQM_AutoParser(clazzName, ...) \ +JNI_2_STRUCT_FUNC_BEGIN(clazzName) \ +WRAP_LEVEL_ONE(JNI_2_STRUCT_, ARG_SEQ, __VA_ARGS__) \ +JNI_2_STRUCT_FUNC_END() \ +\ +STRUCT_2_JNI_FUNC_BEGIN(clazzName) \ +WRAP_LEVEL_ONE(STRUCT_2_JNI_, ARG_SEQ, __VA_ARGS__) \ +STRUCT_2_JNI_FUNC_END() \ +\ +JSON_2_STRUCT_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(JSON_2_STRUCT_, ARG_SEQ, __VA_ARGS__) \ +STRUCT_AND_JSON_FUNC_END() \ +\ +STRUCT_2_JSON_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(STRUCT_2_JSON_, ARG_SEQ, __VA_ARGS__) \ +STRUCT_AND_JSON_FUNC_END() \ +\ +RET_AND_INNER_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(RET_AND_INNER_, ARG_SEQ, __VA_ARGS__) \ +RET_AND_INNER_FUNC_END() +#else + +#define UQM_AutoParser(clazzName, ...) \ +JSON_2_STRUCT_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(JSON_2_STRUCT_, ARG_SEQ, __VA_ARGS__) \ +STRUCT_AND_JSON_FUNC_END() \ +\ +STRUCT_2_JSON_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(STRUCT_2_JSON_, ARG_SEQ, __VA_ARGS__) \ +STRUCT_AND_JSON_FUNC_END() \ +\ +RET_AND_INNER_FUNC_BEGIN() \ +WRAP_LEVEL_ONE(RET_AND_INNER_, ARG_SEQ, __VA_ARGS__) \ +RET_AND_INNER_FUNC_END() + +#endif +NS_UQM_END + +#endif /* UQMMacroExpand_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacros.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacros.h new file mode 100644 index 00000000000..c087dff692d --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMMacros.h @@ -0,0 +1,171 @@ +// +// UQMMacros.hpp +// UQM +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMMacros_hpp +#define UQMMacros_hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus + #define NS_UQM_BEGIN namespace UQM \ + { + #define NS_UQM_END } + #define USING_NS_UQM using namespace UQM; +#else + #define NS_UQM_BEGIN + #define NS_UQM_END + #define USING_NS_UQM +#endif + + +#define UQM_UUID_KEY_NAME "uqm_uuid" +#define UQM_CONFIG_DEFAULT_GAME_ID "11" +#define UQM_SEQ_ID_PRIMARY_KEY_NAME "uqm_seq_id_primary_key" + +//适配 UE4 以及 Cocos 系统定义 + +#if PLATFORM_WINDOWS + #undef UQM_PLATFORM_WINDOWS + #define UQM_PLATFORM_WINDOWS 1 +#else + #if defined(_WIN32) || defined(_WIN64) + #undef UQM_PLATFORM_WINDOWS + #define UQM_PLATFORM_WINDOWS 1 + #elif defined(__APPLE__) + #include + #undef UQM_PLATFORM_WINDOWS + #define UQM_PLATFORM_WINDOWS 0 + #if TARGET_OS_IOS || TARGET_OS_IPHONE + #undef UQM_PLATFORM_MAC + #define UQM_PLATFORM_MAC 0 + #else + #undef UQM_PLATFORM_MAC + #define UQM_PLATFORM_MAC 1 + #endif + #else + #undef UQM_PLATFORM_WINDOWS + #define UQM_PLATFORM_WINDOWS 0 + #undef UQM_PLATFORM_MAC + #define UQM_PLATFORM_MAC 0 + #endif +#endif + +//UE4 环境 +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_IOS || PLATFORM_ANDROID +#undef UQM_UE4 + #define UQM_UE4 1 +#endif + + +////UE4 windows 游客登录需要做dll 函数导出的特殊处理 +#if UQM_PLATFORM_WINDOWS + #ifdef UQM_CORE + #define UQM_EXPORT_UE __declspec(dllexport) + #else + #define UQM_EXPORT_UE __declspec(dllimport) + #endif + #define UQM_EXPORT + #define UQM_HIDDEN +#else + #define UQM_EXPORT_UE + #if __GNUC__ >= 4 + #if defined(__APPLE__) + #ifdef UQM_UE4 +// #define UQM_EXPORT UQMCORE_API +// #define UQM_HIDDEN UQMCORE_API + #define UQM_EXPORT + #define UQM_HIDDEN + #else + #define UQM_EXPORT + #define UQM_HIDDEN + #endif + #elif defined(CRASHSIGHT_PS4) || defined(CRASHSIGHT_PS5) + #define UQM_EXPORT __declspec(dllimport) + #define UQM_HIDDEN + #else + #define UQM_EXPORT __attribute__ ((visibility ("default"))) + #define UQM_HIDDEN __attribute__ ((visibility ("hidden"))) + #endif + #else + #define UQM_EXPORT + #define UQM_HIDDEN + #endif +#endif + +//UE4 Mac/Windows + +#if UQM_PLATFORM_WINDOWS +#else + #ifdef ANDROID + #define UQM_VERSION "5.4.000.5057" + #define UQM_CUR_OS 1 + #elif defined(__APPLE__) + #define UQM_CUR_OS 2 + #define UQM_VERSION "5.4.000.5057" + #endif +#endif + +#if UQM_PLATFORM_WINDOWS +#else + #ifdef __APPLE__ + #define UQM_LABEL_KEYCHAIN_ENABLE "UQM_KEYCHAIN_ENABLE" + #endif +#endif + +// 删除单个指针和删除多个指针 +#define UQM_SAFE_DELETE(ptr) \ + do \ + { \ + if (ptr != NULL) \ + { \ + delete ptr; \ + ptr = NULL; \ + } \ +} while (0) + +#define UQM_SAFE_DELETE_ARR(ptr) \ + do \ + { \ + if (ptr != NULL) \ + { \ + delete[] ptr; \ + ptr = NULL; \ + } \ + } while (0) + +// 分配内存和释放内存 +#define UQM_SAFE_MALLOC(num, type) (type *) calloc((num) , sizeof(type)) +#define UQM_SAFE_FREE(ptr) \ + do \ + { \ + if (ptr != NULL) \ + { \ + free(ptr); \ + ptr = NULL; \ + } \ + } while (0) + +#if defined(__has_cpp_attribute) +# if __has_cpp_attribute(deprecated) +# define CS_DEPRECATED(msg) [[deprecated(msg)]] +# else +# define CS_DEPRECATED(msg) +# endif +#else +# define CS_DEPRECATED(msg) +#endif + +#endif /* UQMMacros_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMRename.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMRename.h new file mode 100644 index 00000000000..b0a865d76d9 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMRename.h @@ -0,0 +1,13 @@ +// +// UQMRename.h +// Crashot +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMRename_h +#define UQMRename_h + + +#endif /* UQMRename_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSingleton.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSingleton.h new file mode 100644 index 00000000000..1fb34cb53b9 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSingleton.h @@ -0,0 +1,66 @@ +// +// UQMSingleton.hpp +// Crashot +// +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMSingleton_hpp +#define UQMSingleton_hpp + +#include +#include "UQMMacros.h" + +template +class UQMSingleton +{ +protected: + UQMSingleton() {}; +private: + UQMSingleton(const UQMSingleton &) {}; + + UQMSingleton &operator=(const UQMSingleton &) {}; + static T *mInstance; +#if UQM_PLATFORM_WINDOWS +#else + static pthread_mutex_t mMutex; +#endif +public: + static T *GetInstance(); +}; + + +template +T *UQMSingleton::GetInstance() +{ + if (mInstance == NULL) + { +#if UQM_PLATFORM_WINDOWS +#else + pthread_mutex_lock(&mMutex); +#endif + if (mInstance == NULL) + { + T *tmp = new T(); + mInstance = tmp; + } +#if UQM_PLATFORM_WINDOWS +#else + pthread_mutex_unlock(&mMutex); +#endif + } + return mInstance; +} + +#if UQM_PLATFORM_WINDOWS +#else +template +pthread_mutex_t UQMSingleton::mMutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +template +T *UQMSingleton::mInstance = NULL; + + +#endif /* UQMSingleton_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSynthesizeSingleton.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSynthesizeSingleton.h new file mode 100644 index 00000000000..6dd92f15fce --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMSynthesizeSingleton.h @@ -0,0 +1,142 @@ +// +// UQMSynthesizeSingleton.h +// UQMCore +// +// Created by Hillson Song on 5/14/18. +// Copyright © 2018. All rights reserved. +// + +#ifndef SYNTHESIZE_SINGLETON_FOR_CLASS_H +#define SYNTHESIZE_SINGLETON_FOR_CLASS_H + +#import + + +#pragma mark - +#pragma mark Singleton + +/* Synthesize Singleton For Class + * + * Creates a singleton interface for the specified class with the following methods: + * + * + (MyClass*) sharedInstance; + * + (void) purgeSharedInstance; + * + * Calling sharedInstance will instantiate the class and swizzle some methods to ensure + * that only a single instance ever exists. + * Calling purgeSharedInstance will destroy the shared instance and return the swizzled + * methods to their former selves. + * + * + * Usage: + * + * MyClass.h: + * ======================================== + * #import "SynthesizeSingleton.h" + * + * @interface MyClass: SomeSuperclass + * { + * ... + * } + * SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(MyClass); + * + * @end + * ======================================== + * + * + * MyClass.m: + * ======================================== + * #import "MyClass.h" + * + * @implementation MyClass + * + * SYNTHESIZE_SINGLETON_FOR_CLASS(MyClass); + * + * ... + * + * @end + * ======================================== + * + * + * Note: Calling alloc manually will also initialize the singleton, so you + * can call a more complex init routine to initialize the singleton like so: + * + * [[MyClass alloc] initWithParam:firstParam secondParam:secondParam]; + * + * Just be sure to make such a call BEFORE you call "sharedInstance" in + * your program. + */ + +#define SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(__CLASSNAME__) \ +\ ++ (__CLASSNAME__*) sharedInstance; \ ++ (void) purgeSharedInstance; + + +#define SYNTHESIZE_SINGLETON_FOR_CLASS(__CLASSNAME__) \ +\ +static __CLASSNAME__* volatile _##__CLASSNAME__##_sharedInstance = nil; \ +\ ++ (__CLASSNAME__*) sharedInstanceNoSynch \ +{ \ +return (__CLASSNAME__*) _##__CLASSNAME__##_sharedInstance; \ +} \ +\ ++ (__CLASSNAME__*) sharedInstanceSynch \ +{ \ +@synchronized(self) \ +{ \ +if(nil == _##__CLASSNAME__##_sharedInstance) \ +{ \ +_##__CLASSNAME__##_sharedInstance = [[self alloc] init]; \ +} \ +else \ +{ \ +NSAssert2(1==0, @"SynthesizeSingleton: %@ ERROR: +(%@ *)sharedInstance method did not get swizzled.", self, self); \ +} \ +} \ +return (__CLASSNAME__*) _##__CLASSNAME__##_sharedInstance; \ +} \ +\ ++ (__CLASSNAME__*) sharedInstance \ +{ \ +return [self sharedInstanceSynch]; \ +} \ +\ ++ (id)allocWithZone:(NSZone*) zone \ +{ \ +@synchronized(self) \ +{ \ +if (nil == _##__CLASSNAME__##_sharedInstance) \ +{ \ +_##__CLASSNAME__##_sharedInstance = [super allocWithZone:zone]; \ +if(nil != _##__CLASSNAME__##_sharedInstance) \ +{ \ +Method newSharedInstanceMethod = class_getClassMethod(self, @selector(sharedInstanceNoSynch)); \ +method_setImplementation(class_getClassMethod(self, @selector(sharedInstance)), method_getImplementation(newSharedInstanceMethod)); \ +} \ +} \ +} \ +return _##__CLASSNAME__##_sharedInstance; \ +} \ +\ ++ (void)purgeSharedInstance \ +{ \ +@synchronized(self) \ +{ \ +if(nil != _##__CLASSNAME__##_sharedInstance) \ +{ \ +Method newSharedInstanceMethod = class_getClassMethod(self, @selector(sharedInstanceSynch)); \ +method_setImplementation(class_getClassMethod(self, @selector(sharedInstance)), method_getImplementation(newSharedInstanceMethod)); \ +_##__CLASSNAME__##_sharedInstance = nil; \ +} \ +} \ +} \ +\ +- (id)copyWithZone:(NSZone *)zone \ +{ \ +return self; \ +} \ +\ + +#endif diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMThread.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMThread.h new file mode 100644 index 00000000000..a265c2532ea --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMThread.h @@ -0,0 +1,43 @@ +/*! + * @header UQMThread.h + * @Version 2.0.0 + * @date 2018/4/25 + * @abstract + * thread 的简单封装声明 + * + * @copyright + * Copyright © 2018年. All rights reserved. + */ + +#ifndef UQM_THREAD_H +#define UQM_THREAD_H + +#include +#include "UQMLog.h" +#include "UQMMacros.h" + +NS_UQM_BEGIN +/* +* 设置当前线程名字 +* @param module 模块名称 +* 为使用iOS,只能在当前线程内调用 +*/ +bool thread_set_msdk_name(const std::string &module); + + +#ifdef ANDROID +/* + * 线程获取自己的名字 + * @return 当前线程名称 + */ +std::string thread_self_get_name(); + + +/* + * 线程设置自己的名称 + */ +bool thread_self_set_name(const std::string &name); +#endif +NS_UQM_END + +#endif //UQM_THREAD_H diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtils.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtils.h new file mode 100644 index 00000000000..2fa2cda0abc --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtils.h @@ -0,0 +1,29 @@ +// +// UQMUtils.hpp +// Crashot +//(内部使用)简单的工具类声明,目前包含: +// 1. 生成通用唯一识别码 +// 2. 格式化输出 Json 字符串 +// 3. 字符串跟数字连接工具 +// 4. 类型转换工具,将一个类型的值 转换为另一个类型 +// Created by joyfyzhang on 2020/9/3. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#ifndef UQMUtils_hpp +#define UQMUtils_hpp + +#include "UQMDefine.h" + +NS_UQM_BEGIN + +class UQM_EXPORT UQMUtils +{ +public: + // 移除空格 + static const char *Trim(const char *name); +}; + +NS_UQM_END + +#endif /* UQMUtils_hpp */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtilsIOS.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtilsIOS.h new file mode 100644 index 00000000000..4414178646d --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/UQMUtilsIOS.h @@ -0,0 +1,50 @@ +// +// UQMUtilsIOS.h +// Crashot +// +// Created by joyfyzhang on 2020/9/4. +// Copyright © 2020 joyfyzhang. All rights reserved. +// + +#import +#import "UQMDefine.h" + +#define GET_NSSTRING(cString) [NSString stringWithCString:(cString.c_str()?cString:"").c_str() encoding:NSUTF8StringEncoding] + +@interface UQMUtilsIOS : NSObject + +/** + * 将NSDictionary转为标准JSON字符串 + * + * @param dict 目标字典 + * @param prettyPrint 生成的JSON数据是否使用空格 + * + * @return 结果JSON字符串 + */ ++ (NSString *)jsonStringFromDict:(NSDictionary *)dict prettyPrint:(BOOL)prettyPrint; + +/** + * KVPair vector => NSDictionary + * + * @param kvVector KVPair vector + * + * @return 字典 + */ ++ (NSDictionary *)dictFromKVVector:(UQM::UQMVector)kvVector; + +/** + * c++ map => NSDictionary + * + * @param kvMap std::map + * + * @return 字典 + */ ++ (NSDictionary *)dictFromKVMap:(std::map &)kvMap; + +///** +// * 获取原始设备型号 +// * +// * @return 设备型号 +// */ +//+ (NSString *)getCurrentDeviceModel; +@end diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/cJSON.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/cJSON.h new file mode 100644 index 00000000000..7921d818af1 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Headers/cJSON.h @@ -0,0 +1,149 @@ +/* + Copyright (c) 2009 Dave Gamble + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef cJSON__h +#define cJSON__h + +#include "UQMMacros.h" + +NS_UQM_BEGIN + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* cJSON Types: */ +#define cJSON_False 0 +#define cJSON_True 1 +#define cJSON_NULL 2 +#define cJSON_Number 3 +#define cJSON_String 4 +#define cJSON_Array 5 +#define cJSON_Object 6 + +#define cJSON_IsReference 256 + +/* The cJSON structure: */ +typedef struct cJSON { + struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ + struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ + + int type; /* The type of the item, as above. */ + + char *valuestring; /* The item's string, if type==cJSON_String */ + int valueint; /* The item's number, if type==cJSON_Number */ + double valuedouble; /* The item's number, if type==cJSON_Number */ + + char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ +} cJSON; + +typedef struct cJSON_Hooks { + void *(*malloc_fn)(size_t sz); + void (*free_fn)(void *ptr); +} cJSON_Hooks; + +/* Supply malloc, realloc and free functions to cJSON */ +extern void cJSON_InitHooks(cJSON_Hooks* hooks); + + +/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ +extern cJSON *cJSON_Parse(const char *value); +/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ +extern char * UQM_EXPORT cJSON_Print(cJSON *item); +/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */ +extern char *cJSON_PrintUnformatted(cJSON *item); +/* Delete a cJSON entity and all subentities. */ +extern void UQM_EXPORT cJSON_Delete(cJSON *c); + +/* Returns the number of items in an array (or object). */ +extern int cJSON_GetArraySize(cJSON *array); +/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ +extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); +/* Get item "string" from object. Case insensitive. */ +extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); + +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ +extern const char *cJSON_GetErrorPtr(void); + +/* These calls create a cJSON item of the appropriate type. */ +extern cJSON * UQM_EXPORT cJSON_CreateNull(void); +extern cJSON * UQM_EXPORT cJSON_CreateTrue(void); +extern cJSON * UQM_EXPORT cJSON_CreateFalse(void); +extern cJSON * UQM_EXPORT cJSON_CreateBool(int b); +extern cJSON * UQM_EXPORT cJSON_CreateNumber(double num); +extern cJSON * UQM_EXPORT cJSON_CreateString(const char *string); +extern cJSON * UQM_EXPORT cJSON_CreateArray(void); +extern cJSON * UQM_EXPORT cJSON_CreateObject(void); + +/* These utilities create an Array of count items. */ +extern cJSON *cJSON_CreateIntArray(const int *numbers,int count); +extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count); +extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count); +extern cJSON * UQM_EXPORT cJSON_CreateStringArray(const char **strings,int count); + +/* Append item to the specified array/object. */ +extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); +extern void UQM_EXPORT cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); +/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ +extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); + +/* Remove/Detatch items from Arrays/Objects. */ +extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); +extern void cJSON_DeleteItemFromArray(cJSON *array,int which); +extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); +extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); + +/* Update array items. */ +extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); +extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); + +/* Duplicate a cJSON item */ +extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); +/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will +need to be released. With recurse!=0, it will duplicate any children connected to the item. +The item->next and ->prev pointers are always zero on return from Duplicate. */ + +/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ +extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); + +extern void cJSON_Minify(char *json); + +/* Macros for creating things quickly. */ +#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) +#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) +#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) +#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) +#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) +#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) + +/* When assigning an integer value, it needs to be propagated to valuedouble too. */ +#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) + +#ifdef __cplusplus +} +#endif + +NS_UQM_END + +#endif diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Info.plist b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Info.plist new file mode 100644 index 00000000000..3a945949e23 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Info.plist differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Modules/module.modulemap b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Modules/module.modulemap new file mode 100644 index 00000000000..5da0f68952c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightCore.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module CrashSightCore { + umbrella header "CrashSightCore.h" + + export * + module * { export * } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework.meta new file mode 100644 index 00000000000..89ef0e6bfd2 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: 4c6e924cfb5704911aeed9d27fd6722e +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: true + CompileFlags: + FrameworkDependencies: Security; + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/CrashSightPlugin b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/CrashSightPlugin new file mode 100644 index 00000000000..50dc3f362b9 Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/CrashSightPlugin differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Headers/CrashSightPlugin.h b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Headers/CrashSightPlugin.h new file mode 100644 index 00000000000..5f3229ce8de --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Headers/CrashSightPlugin.h @@ -0,0 +1,28 @@ +// +// CrashSight.h +// +// Created by joyfyzhang on 2021/1/8. +// Copyright © 2021 joyfyzhang. All rights reserved. +// + +#ifndef CrashSight_h +#define CrashSight_h + +#import +#import + +/** + * 异常上报模块 + * - 命名规则:固定为 UQMCrash + 渠道 + * - 必须实现 UQMCrashDelegate + */ +@interface CrashSightPlugin : NSObject + +/** 插件必须是的单例的,建议使用 UQM 提供的宏定义进行处理 + * 单例宏处理 - 头文件部分 + */ +SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(CrashSightPlugin) + +@end + +#endif /* CrashSight_h */ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Info.plist b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Info.plist new file mode 100644 index 00000000000..cf5aaa144dd Binary files /dev/null and b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Info.plist differ diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Modules/module.modulemap b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Modules/module.modulemap new file mode 100644 index 00000000000..bf93a9be018 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Plugins/iOS/CrashSight/CrashSightPlugin.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module CrashSightPlugin { + umbrella header "CrashSightPlugin.h" + + export * + module * { export * } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs new file mode 100644 index 00000000000..a8058269e42 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs @@ -0,0 +1,2294 @@ +// ---------------------------------------- +// +// CrashSightAgent.cs +// +// Author: +// Yeelik, +// +// Copyright (c) 2015 CrashSight. All rights reserved. +// +// ---------------------------------------- +// +using UnityEngine; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Globalization; + +using GCloud.UQM; + +/// +/// [EN] Defines the logType
+/// [ZH] 定义日志的级别 +///
+/// +/// [EN] We dont use LogType enum in Unity as the numerical order doesnt suit our purposes
+/// [ZH] 我们未使用 Unity 的 LogType 枚举,因其数值顺序不符合需求 +///
+public enum CSLogSeverity +{ + LogSilent, + LogError, + LogWarning, + LogInfo, + LogDebug, + LogVerbose +} + +/// +/// [EN] Defines the output type of the log report
+/// [ZH] 定义日志报告的输出方式类型 +///
+public enum CSReportType +{ + InterfaceReport, + LogCallback, + LogCallbackThreaded +} + +/// +/// [EN] Defines information options for jank report
+/// [ZH] 定义卡顿报告的信息选项 +///
+public enum JankReportInfoOption +{ + JankOnlyBasicInfo = 0, + JankSystemLog = 1, + JankCustomLog = 2, + JankCustomKv = 4, + JankCallbackInfo = 8, + JankAutoDumpStack = 16, + JankAndroidAllJavaStack = 32 +} + +/// +/// CrashSight agent. +/// +public sealed class CrashSightAgent +{ + private static string crashUploadUrl = string.Empty; + + public static List callbackThreads = new List(); + + public static object callbackThreadsLock = new object(); + + /// + /// [EN] Defines the log callback delegate
+ /// [ZH] 定义日志回调委托 + ///
+ /// + /// [EN] Defines delegate support multicasting to replace the 'Application.LogCallback'
+ /// [ZH] 定义支持多播的委托,用于替换'Application.LogCallback' + ///
+ public delegate void LogCallbackDelegate(string condition, string stackTrace, LogType type); + + private static event LogCallbackDelegate _LogCallbackEventHandler; + + private static bool _isInitialized = false; + + private static LogType _autoReportLogLevel = LogType.Error; + +#pragma warning disable 414 + private static bool _debugMode = false; + + private static bool _autoQuitApplicationAfterReport = false; + + private static Func> _LogCallbackExtrasHandler; + + private static bool _uncaughtAutoReportOnce = false; + + + /************************************全平台接口************************************/ + + /// + /// [EN] Initializes CrashSight
+ /// [ZH] 初始化CrashSight + ///
+ /// + /// [EN] Initializes as early as possible to enable crash detection and reporting features
+ /// [ZH] 在尽可能早的位置进行初始化以开启崩溃捕获和上报功能 + ///
+ /// + /// [EN] APPID of registered projects
+ /// [ZH] 已注册项目的APPID + /// + public static void InitWithAppId(string appId, bool forceOnUiThread = false) + { + if (IsInitialized) + { + DebugLog(null, "CrashSightAgent has already been initialized."); + + return; + } + + if (string.IsNullOrEmpty(appId)) + { + return; + } + + // init the sdk with app id + UQMCrash.InitWithAppId(appId, forceOnUiThread); + DebugLog(null, "Initialized with app id: " + appId + " crashUploadUrl: " + crashUploadUrl); + + // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) + _RegisterExceptionHandler(); + } + + /// + /// [EN] Actively reports errors
+ /// [ZH] 主动上报错误 + ///
+ /// + /// [EN] Used to report captured C# exceptions
+ /// [ZH] 用于上报捕获的c#异常 + ///
+ /// + /// [EN] Caught exception
+ /// [ZH] 捕获到的异常 + /// + /// + /// [EN] Exception message
+ /// [ZH] 异常信息 + public static void ReportException(System.Exception e, string message) + { + if (!IsInitialized) + { + return; + } + + DebugLog(null, "Report exception: " + message + "\n------------\n" + e + "\n------------"); + + _HandleException(e, message, false); + } + + /// + /// [EN] Actively reports errors
+ /// [ZH] 主动上报错误 + ///
+ /// + /// [EN] Can be called manually when an error is caught or needs to be reported, multi-threaded calls are supported
+ /// [ZH] 可以在捕获到错误或者需要上报的时候手动调用,支持多线程调用 + ///
+ /// + /// [EN] Exception Name, cannot be null
+ /// [ZH] 异常名称,不能为null + /// + /// + /// [EN] Exception message, cannot be null
+ /// [ZH] 异常信息,不能为null + /// + /// + /// [EN] Stack, cannot be null
+ /// [ZH] 堆栈,不能为null + /// + public static void ReportException(string name, string message, string stackTrace) + { + if (!IsInitialized) + { + return; + } + + DebugLog(null, "Report exception: " + name + " " + message + " \n" + stackTrace); + + _HandleException(LogType.Exception, name, message, stackTrace, false, CSReportType.InterfaceReport); + } + + /// + /// [EN] Actively reports errors
+ /// [ZH] 主动上报错误 + ///
+ /// + /// [EN] Can be called manually when an error is caught or needs to be reported, multi-threaded calls are supported
+ /// [ZH] 可以在捕获到错误或者需要上报的时候手动调用,支持多线程调用
+ ///
+ /// + /// [EN] Exception Type, 0~3 are internal reserved types and are invalid if passed in
+ /// [ZH] 异常类型, 0~3为内部保留类型传入无效, C#: 4, js: 5, lua: 6 + /// + /// + /// [EN] Exception Name, cannot be null
+ /// [ZH] 异常名称,不能为null + /// + /// + /// [EN] Exception message, cannot be null
+ /// [ZH] 异常信息,不能为null + /// + /// + /// [EN] Stack, cannot be null
+ /// [ZH] 堆栈,不能为null + /// + /// + /// [EN] Other Info
+ /// [ZH] 其他信息 + /// + /// + /// [EN] 0: close, 1: call system interface dump, 3: minidump (only valid for mobile)
+ /// [ZH] 0:关闭,1:调用系统接口dump,3:minidump(仅移动端有效) + /// + /// + /// [EN] Absolute path of log attachment (only valid for Android)
+ /// [ZH] 日志附件的绝对路径(仅Android有效) + /// + public static void ReportException(int type, string exceptionName, string exceptionMsg, string exceptionStack, Dictionary extInfo, int dumpNativeType = 0, string errorAttachmentPath = "") + { + if (!IsInitialized) + { + return; + } + UQMCrash.ReportException(type, exceptionName, exceptionMsg, exceptionStack, extInfo, dumpNativeType, errorAttachmentPath); + } + + /// + /// [EN] Sets user ID
+ /// [ZH] 设置用户ID + ///
+ /// + /// [EN] The user id defaults to unknown
+ /// [ZH] 用户ID默认为unknown + ///
+ /// + /// [EN] User ID
+ /// [ZH] 用户ID + /// + public static void SetUserId(string userId) + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "Set user id: " + userId); + + UQMCrash.SetUserId(userId); + } + + /// + /// [EN] Adds custom data
+ /// [ZH] 添加自定义数据 + ///
+ /// + /// [EN] Set the Key-Value data customized by the user. It will be reported together with exception info when sending the crash
+ /// [ZH] 设置用户自定义的 Key-Value 数据,将在发送 Crash 时随异常信息一起上报
+ /// [EN] View page: Crash Details->Download Attachments->valueMapOthers.txt
+ /// [ZH] 页面查看:崩溃详情页->附件下载->valueMapOthers.txt + ///
+ /// + /// + public static void AddSceneData(string key, string value) + { + if (!IsInitialized) + { + return; + } + + DebugLog(null, "Add scene data: [" + key + ", " + value + "]"); + + UQMCrash.AddSceneData(key, value); + } + + /// + /// [EN] Adds custom data
+ /// [ZH] 添加自定义数据 + ///
+ /// + /// [EN] Call to set the Key-Value data customized by the user, where the value is int type. + /// It will be reported together with exception info when sending the crash
+ /// [ZH] 调用 设置用户自定义的 Key-Value 数据,其中 value 为 int 类型,将在发送 Crash 时随异常信息一起上报
+ /// [EN] View page: Crash Details->Download Attachments->valueMapOthers.txt
+ /// [ZH] 页面查看:崩溃详情页->附件下载->valueMapOthers.txt + ///
+ /// + /// + public static void SetUserValue(string key, int value) + { + AddSceneData("I#" + key, "" + value); + } + + /// + /// [EN] Adds custom data
+ /// [ZH] 添加自定义数据 + ///
+ /// + /// [EN] Call to set the Key-Value data customized by the user, where the value is string type. + /// It will be reported together with exception info when sending the crash
+ /// [ZH] 调用 设置用户自定义的 Key-Value 数据,其中 value 为 string 类型,将在发送 Crash 时随异常信息一起上报
+ /// [EN] View page: Crash Details->Download Attachments->valueMapOthers.txt
+ /// [ZH] 页面查看:崩溃详情页->附件下载->valueMapOthers.txt + ///
+ /// + /// + public static void SetUserValue(string key, string value) + { + AddSceneData("K#" + key, value); + } + + /// + /// [EN] Adds custom data
+ /// [ZH] 添加自定义数据 + ///
+ /// + /// [EN] Call to set the Key-Value data customized by the user, where the value is string[] type. + /// It will be reported together with exception info when sending the crash
+ /// [ZH] 调用 设置用户自定义的 Key-Value 数据,其中 value 为 string[] 类型,将在发送 Crash 时随异常信息一起上报
+ /// [EN] View page: Crash Details->Download Attachments->valueMapOthers.txt
+ /// [ZH] 页面查看:崩溃详情页->附件下载->valueMapOthers.txt + ///
+ /// + /// + public static void SetUserValue(string key, string[] value) + { + string valueStr = string.Join("#", value); + AddSceneData("S#" + key, valueStr); + } + + /// + /// [EN] Sets application version
+ /// [ZH] 设置应用版本号 + ///
+ /// + /// [EN] Need to be called before interface
+ /// [ZH] 需要在 接口之前调用 + ///
+ /// + /// [EN] Version Number
+ /// [ZH] 版本号 + /// + public static void SetAppVersion(string appVersion) + { + DebugLog(null, "Set app version: " + appVersion); + + UQMCrash.SetAppVersion(appVersion); + } + + /// + /// [EN] Sets the reporting domain name
+ /// [ZH] 设置上报域名 + ///
+ /// + /// [EN] Need to be called before interface
+ /// [ZH] 需要在 接口之前调用 + ///
+ /// + /// [EN] Target domain name of reporting
+ /// [ZH] 要上报的域名 + /// + public static void ConfigCrashServerUrl(string crashServerUrl) + { + DebugLog(null, "Config crashServerUrl:" + crashServerUrl); + UQMCrash.ConfigCrashServerUrl(crashServerUrl); + } + + /// + /// [EN] Sets upload path for log after crash
+ /// [ZH] 设置崩溃后上传的日志路径 + ///
+ /// + /// [EN] Read permission is required. On Android and iOS, this interface has a lower priority than . + /// It is not available on Switch.
+ /// [ZH] 需要可读权限,在Android和iOS端上,该接口的优先级低于 , Switch暂不可用
+ ///
+ /// + /// [EN] Absolute path for log files
+ /// [ZH] 日志绝对路径 + /// + public static void SetLogPath(string logPath) + { + UQMCrash.SetLogPath(logPath); + } + + /// + /// [EN] Sets debug mode
+ /// [ZH] 设置debug模式 + ///
+ /// + /// [EN] Disabled by default. Need to be called before interface. + /// When enabled, more logs will be printed to facilitate problem location.
+ /// [ZH] 默认关闭, 需要在 接口之前调用,开启后会打印更多便于问题定位的Log + ///
+ /// + public static void ConfigDebugMode(bool enable) + { + _debugMode = enable; + UQMCrash.ConfigDebugMode(enable); + DebugLog(null, (enable ? "Enable" : "Disable") + " the log message print to console"); + } + + /// + /// [EN] Sets device id
+ /// [ZH] 设置设备Id + ///
+ /// + /// [EN] By default, uuid is used as the device ID. Need to be called before interface.
+ /// [ZH] 默认采用uuid作为设备ID, 需要在 接口之前调用 + ///
+ /// + /// [EN] Device ID
+ /// [ZH] 设备唯一标识 + /// + public static void SetDeviceId(string deviceId) + { + UQMCrash.SetDeviceId(deviceId); + } + + /// + /// [EN] Sets custom log reporting level
+ /// [ZH] 设置自定义日志上报级别 + ///
+ /// + /// [EN] Need to be called before interface.
+ /// [ZH] 需要在 接口之前调用 + ///
+ /// + /// [EN] Off=0, Error=1, Warn=2, Info=3, Debug=4, default is Info
+ /// [ZH] Off=0, Error=1, Warn=2, Info=3, Debug=4, 默认Info + /// + public static void ConfigCrashReporter(int logLevel) + { + UQMCrash.ConfigAutoReportLogLevel(logLevel); + } + + /// + /// [EN] Sets custom log reporting level
+ /// [ZH] 设置自定义日志上报级别 + ///
+ /// + /// [EN] Need to be called before interface.
+ /// [ZH] 需要在 接口之前调用 + ///
+ /// + /// [EN] Off=0, Error=1, Warn=2, Info=3, Debug=4, default is Info,
+ /// [ZH] Off=0, Error=1, Warn=2, Info=3, Debug=4, 默认Info, + /// + public static void ConfigCrashReporter(CSLogSeverity logLevel) + { + UQMCrash.ConfigAutoReportLogLevel((int)logLevel); + } + + /// + /// [EN] Adds custom logs
+ /// [ZH] 添加自定义日志 + ///
+ /// + /// [EN] The custom log shouldn't exceed 30KB. Custom log view:
+ /// Android, iOS, PS4, PS5, Switch: issue details->tracking log->custom log
+ /// Windows, Xbox, Linux: issue details -> custom log (from interface)
+ /// [ZH] 自定义日志,限制30KB。 自定义日志查看:
+ /// Android、iOS、PS4、PS5、Switch:问题详情->跟踪日志->custom log
+ /// Windows、Xbox、Linux:问题详情->自定义日志(来自接口) + ///
+ /// + /// [EN] Log level,
+ /// [ZH] 日志级别 + /// + /// + /// [EN] Log format
+ /// [ZH] 日志格式 + /// + /// + /// [EN] Variable parameter array
+ /// [ZH] 可变参数数组 + /// + public static void PrintLog(CSLogSeverity level, string format, params object[] args) + { + if (string.IsNullOrEmpty(format)) + { + return; + } + if (args == null || args.Length == 0) + { + UQMCrash.LogRecord((int)level, format); + } + else + { + UQMCrash.LogRecord((int)level, string.Format(format, args)); + } + } + + /// + /// [EN] Tests native crash
+ /// [ZH] 测试 native 崩溃 + ///
+ public static void TestNativeCrash() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test native crash"); + + UQMCrash.TestNativeCrash(); + } + + /// + /// [EN] Sets the distribution channel
+ /// [ZH] 设置发行渠道 + ///
+ /// + /// [EN] Each network connection or report can carry this field to collect statistics for different distribution channels. + /// It is not available on PS4、PS5、Switch and Linux.
+ /// [ZH] 每一个联网或者上报都可以携带该字段,可实现针对不同的发行渠道统计数据。 PS4、PS5、Switch、Linux暂不可用 + ///
+ /// + public static void SetEnvironmentName(string serverEnv) + { + UQMCrash.SetServerEnv(serverEnv); + } + + /// + /// [EN] Enables Unity ANR monitoring
+ /// [ZH] 启用 Unity ANR 监控 + ///
+ /// + /// [EN] Here ANR means that the Unity main thread is unresponsive, which is different from Android ANR
+ /// [ZH] 此处ANR是指Unity主线程无响应,区别于Android ANR + ///
+ /// + /// [EN] Timeout in milliseconds to trigger ANR report when main thread is unresponsive
+ /// [ZH] 主线程无响应多少毫秒触发上报 + /// + public static void EnableAnrMonitor(int timeoutMs = 5000) + { + CrashSightAnrMonitor.Start(timeoutMs); + } + + /// + /// [EN] Disables Unity ANR monitoring
+ /// [ZH] 停用 Unity ANR 监控 + ///
+ public static void DisableAnrMonitor() + { + CrashSightAnrMonitor.Stop(); + } + + /// + /// [EN] Registers crash callback
+ /// [ZH] 注册崩溃回调 + ///
+ /// + /// [EN] Callback is called when a crash occurs and the return value will be included in the crash report.
+ /// Create a custom class inheriting from CrashSightCallback and implement OnCrashBaseRetEvent method.
+ /// Not available on PS4, PS5, Switch, Linux and HarmonyOS.
+ /// [ZH] 回调在崩溃时调用,返回值随崩溃信息一起上报
+ /// 自定义CsCrashCallBack类,继承 CrashSightCallback,实现 OnCrashBaseRetEvent方法
+ /// PS4、PS5、Switch、Linux、鸿蒙暂不可用
+ ///
+ /// + /// + /// public class CsCrashCallBack: CrashSightCallback { + /// //Put you own code to implemente the callback func + /// public override string OnCrashBaseRetEvent(int methodId) + /// { + /// if (methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_EXTRA_MESSAGE) + /// { + /// // For Android/iOS: return extra message + /// return "this is extra message."; + /// } + /// else if (methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_NO_RET) + /// { + /// // For Win/Xbox: return value is ignored but you can perform operations here + /// } + /// return ""; + /// } + /// } + /// + /// + /// + /// [EN] Callback instance that inherits from CrashSightCallback
+ /// [ZH] 继承自 CrashSightCallback 的回调实例 + /// + public static void RegisterCrashCallback(CrashSightCallback callback) + { + if (callback != null) + { + // 使用包装方法,在调用前检查退出状态 + UQMCrash.CrashBaseRetEvent += (methodId, crashType) => + { + // 如果应用正在退出,直接返回空字符串,避免执行Unity相关操作 + if (CrashSightCallback.IsQuitting()) + { + return ""; + } + + try + { + // 调用原始回调方法 + return callback.OnCrashBaseRetEvent(methodId, crashType); + } + catch (System.Exception) + { + // 如果Unity已经退出,捕获异常并返回空字符串 + return ""; + } + }; + UQMCrash.ConfigCallBack(); + } + else + { + DebugLog(null, "RegisterCallback failed: callback is null."); + } + } + + /// + /// [EN] Unregisters the crash callback
+ /// [ZH] 注销崩溃回调 + ///
+ public static void UnregisterCrashCallback() + { + UQMCrash.UnregisterCallBack(); + } + + /// + /// [EN] Registers crash log upload callback
+ /// [ZH] 注册上传日志回调 + ///
+ /// + /// [EN] Called after handling a crash.
+ /// Customize the CsCrashLogCallback class, inherit CrashSightLogCallback, and use OnSetLogPathEvent and OnLogUploadResultEvent methods.
+ /// [ZH] 崩溃处理后调用,自定义CsCrashLogCallback类,继承CrashSightLogCallback,实现OnSetLogPathEvent、OnLogUploadResultEvent方法 + ///
+ /// + /// + /// public class CsCrashLogCallBack : CrashSightLogCallback + /// { + /// // Returns absolute path of log file to upload + /// // methodId: Method ID (can be ignored) + /// // crashType: Crash type (0: Java/OC crash, 2: Native crash) + /// public override string OnSetLogPathEvent(int methodId, int crashType) + /// { + /// return ""; + /// } + /// + /// // Notifies log upload result + /// // methodId: Method ID (can be ignored) + /// // crashType: Crash type (0: Java/OC crash, 2: Native crash) + /// // result: Upload result (0: success, others: failure) + /// public override void OnLogUploadResultEvent(int methodId, int crashType, int result) + /// { + /// + /// } + /// } + /// + /// + /// + /// [EN] Callback instance that inherits from CrashSightLogCallback
+ /// [ZH] 继承自CrashSightLogCallback的回调实例 + /// + public static void RegisterCrashLogCallback(CrashSightLogCallback callback) + { + if (callback != null) + { + // 使用包装方法,在调用前检查退出状态 + UQMCrash.CrashSetLogPathRetEvent += (methodId, crashType) => + { + // 如果应用正在退出,直接返回空字符串 + if (CrashSightLogCallback.IsQuitting()) + { + return ""; + } + + try + { + // 调用原始回调方法 + return callback.OnSetLogPathEvent(methodId, crashType); + } + catch (System.Exception) + { + // 如果Unity已经退出,捕获异常并返回空字符串 + return ""; + } + }; + + UQMCrash.CrashLogUploadRetEvent += (methodId, crashType, result) => + { + // 如果应用正在退出,直接返回 + if (CrashSightLogCallback.IsQuitting()) + { + return; + } + + try + { + // 调用原始回调方法 + callback.OnLogUploadResultEvent(methodId, crashType, result); + } + catch (System.Exception) + { + // 忽略异常 + } + }; + + UQMCrash.ConfigLogCallBack(); + } + else + { + DebugLog(null, "RegisterCallback failed: callback is null."); + } + } + + /// + /// [EN] Report Unity Log Error
+ /// [ZH] 上报Unity Log Error + ///
+ /// + /// [EN] Enables automatic reporting of Unity log errors to CrashSight.
+ /// The triggering frequency of Unity Log Error in the project should be kept low after enabling the feature.
+ /// [ZH] 调用该接口可以将Unity Log Error作为错误上报到CrashSight
+ /// 开启该功能后请尽量控制项目中Unity Log Error的触发频率 + ///
+ public static void EnableExceptionHandler() + { + if (IsInitialized) + { + DebugLog(null, "CrashSightAgent has already been initialized."); + return; + } + + DebugLog(null, "Only enable the exception handler, please make sure you has initialized the sdk in the native code in associated Android or iOS project."); + + // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) + _RegisterExceptionHandler(); + } + + /// + /// [EN] Registers log callback
+ /// [ZH] 注册日志回调 + ///
+ /// + /// [EN] Log callback delegate
+ /// [ZH] 日志回调委托 + /// + public static void RegisterLogCallback(LogCallbackDelegate handler) + { + if (handler != null) + { + DebugLog(null, "Add log callback handler: " + handler); + + _LogCallbackEventHandler += handler; + } + } + + /// + /// [EN] Unregisters log callback
+ /// [ZH] 注销日志回调 + ///
+ /// + /// [EN] Log callback delegate to unregister
+ /// [ZH] 要注销的日志回调委托 + /// + public static void UnregisterLogCallback(LogCallbackDelegate handler) + { + if (handler != null) + { + DebugLog(null, "Remove log callback handler"); + + _LogCallbackEventHandler -= handler; + } + } + + /// + /// [EN] Sets the extra data handler for log callbacks
+ /// [ZH] 设置日志回调的额外数据处理函数 + ///
+ /// + /// [EN] Function that returns extra data dictionary
+ /// [ZH] 返回额外数据的函数 + /// + public static void SetLogCallbackExtrasHandler(Func> handler) + { + if (handler != null) + { + _LogCallbackExtrasHandler = handler; + + DebugLog(null, "Add log callback extra data handler : " + handler); + } + } + + /// + /// [EN] Configures whether to automatically quit the application after crash reporting
+ /// [ZH] 配置崩溃上报后是否自动退出应用 + ///
+ /// + /// [EN] Whether to auto quit
+ /// [ZH] 是否自动退出 + /// + public static void ConfigAutoQuitApplication(bool autoQuit) + { + _autoQuitApplicationAfterReport = autoQuit; + } + + /// + /// [EN] Gets whether the application will auto quit after crash reporting
+ /// [ZH] 获取崩溃上报后是否自动退出应用的配置 + ///
+ /// + /// [EN] Current auto quit configuration
+ /// [ZH] 当前自动退出配置 + ///
+ public static bool AutoQuitApplicationAfterReport + { + get { return _autoQuitApplicationAfterReport; } + } + + /// + /// [EN] Outputs debug log messages
+ /// [ZH] 调试日志输出 + ///
+ /// + /// [EN] Only works when debugMode is enabled.
+ /// [ZH] 仅当debugMode为true时有效 + ///
+ /// + /// [EN] Log tag + /// [ZH] 日志标签 + /// + /// [EN] Format string with placeholders
+ /// [ZH] 带占位符的格式化字符串 + /// + public static void DebugLog(string tag, string format) + { + if (!_debugMode) + { + return; + } + + if (string.IsNullOrEmpty(format)) + { + return; + } + + UQMLog.Log(string.Format("{0}:{1}", tag, format)); + } + + /// + /// [EN] Checks if CrashSight has been initialized
+ /// [ZH] 获取CrashSight是否已初始化 + ///
+ /// + /// [EN] Initialization status
+ /// [ZH] 初始化状态 + ///
+ public static bool IsInitialized + { + get { return _isInitialized; } + } + + /// + /// [EN] Registers exception handler callbacks
+ /// [ZH] 注册异常处理回调 + ///
+ public static void _RegisterExceptionHandler() + { + try + { + // hold only one instance + +#if UNITY_5 || UNITY_5_3_OR_NEWER + Application.logMessageReceived += _OnLogCallbackHandlerMain; + Application.logMessageReceivedThreaded += _OnLogCallbackHandlerThreaded; +#else + Application.RegisterLogCallback(_OnLogCallbackHandlerMain); + Application.RegisterLogCallbackThreaded(_OnLogCallbackHandlerThreaded); +#endif + AppDomain.CurrentDomain.UnhandledException += _OnUncaughtExceptionHandler; + + string version = Application.unityVersion; +#if UNITY_EDITOR + string buildConfig = "editor"; +#elif DEVELOPMENT_BUILD + string buildConfig = "development"; +#else + string buildConfig = "release"; +#endif + SystemLanguage language = Application.systemLanguage; + CultureInfo locale = CultureInfo.CurrentCulture; + UQMCrash.SetEngineInfo(version, buildConfig, language.ToString(), locale.ToString()); + + _isInitialized = true; + + DebugLog(null, "Register the log callback in Unity " + Application.unityVersion); + } + catch + { + + } + } + + /// + /// [EN] Unregisters exception handler callbacks
+ /// [ZH] 注销异常处理回调 + ///
+ public static void _UnregisterExceptionHandler() + { + try + { +#if UNITY_5 || UNITY_5_3_OR_NEWER + Application.logMessageReceived -= _OnLogCallbackHandlerMain; + Application.logMessageReceivedThreaded -= _OnLogCallbackHandlerThreaded; +#else + Application.RegisterLogCallback(null); + Application.RegisterLogCallbackThreaded(null); +#endif + System.AppDomain.CurrentDomain.UnhandledException -= _OnUncaughtExceptionHandler; + DebugLog(null, "Unregister the log callback in unity " + Application.unityVersion); + } + catch + { + + } + } + + /// + /// [EN] Enables/disables CrashSight stack trace collection
+ /// [ZH] 设置是否启用CrashSight堆栈跟踪 + ///
+ /// + public static void SetCrashSightStackTraceEnable(bool enable) + { + CrashSightStackTrace.setEnable(enable); + } + + /************************************Android、iOS、Mac端接口************************************/ + + /// + /// [EN] Configures callback types for reports (Android, iOS, Mac)
+ /// [ZH] 设置各类上报的回调开关(Android、iOS、Mac) + ///
+ /// + /// [EN] There are currently 5 types of callback represented by 5 digits. The first digit represents crash, the second digit represents anr, + /// the third digit represents u3d c# error, the fourth digit represents js, and the fifth digit represents lua
+ /// [ZH] 目前是5种类型,用5位表示。第一位表示crash,第二位表示anr,第三位表示u3d c# error第四位表示js,第五位表示lua。默认全开 + /// + public static void ConfigCallbackType(Int32 callbackType) + { + UQMCrash.ConfigCallbackType(callbackType); + } + + /// + /// [EN] Sets device model (Android, iOS, Mac)
+ /// [ZH] 设置设备型号(Android、iOS、Mac) + ///
+ /// + /// [EN] Need to be called before interface.
+ /// [ZH] 需要在 接口之前调用 + ///
+ /// + /// [EN] Device model name
+ /// [ZH] 手机型号 + /// + public static void SetDeviceModel(string deviceModel) + { + UQMCrash.SetDeviceModel(deviceModel); + } + + /// + /// [EN] Reports lightweight log (Android, iOS, Mac)
+ /// [ZH] 上报轻量级日志(Android、iOS、Mac) + ///
+ /// + /// [EN] Message type
+ /// [ZH] 消息类型 + /// + /// + /// [EN] Message content
+ /// [ZH] 消息内容 + /// + public static void ReportLogInfo(string msgType, string msg) + { + UQMCrash.ReportLogInfo(msgType, msg); + } + + /// + /// [EN] Sets the scene field name(Android、iOS、Mac)
+ /// [ZH] 设置场景字段(Android、iOS、Mac) + ///
+ /// + /// [EN] Each network connection or report can carry this field to calculate crash rates and other data for different scenes. + /// It is not available on PS4、PS5、Switch and Linux.
+ /// [ZH] 每一个联网或者上报都可以携带该字段,实现针对不同的子场景计算崩溃率等数据。 PS4、PS5、Switch、Linux暂不可用 + ///
+ /// + /// + /// [EN] Whether to report the change of scene
+ /// [ZH] 是否上报场景变更 + /// + public static void SetScene(string sceneId, bool upload = false) + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "Set scene: " + sceneId + ", upload:" + upload); + + UQMCrash.SetScene(sceneId, upload); + } + + /// + /// [EN] Sets the scene field name(Android、iOS、Mac)
+ /// [ZH] 设置场景字段(Android、iOS、Mac) + ///
+ /// + /// [EN] Each network connection or report can carry this field to calculate crash rates and other data for different scenes. + /// It is not available on PS4、PS5、Switch and Linux.
+ /// [ZH] 每一个联网或者上报都可以携带该字段,实现针对不同的子场景计算崩溃率等数据。 PS4、PS5、Switch、Linux暂不可用 + ///
+ /// + /// + /// [EN] Whether to report the change of scene
+ /// [ZH] 是否上报场景变更 + /// + public static void SetScene(int sceneId, bool upload = false) + { + SetScene(sceneId.ToString(), upload); + } + + /// + /// [EN] Gets crash thread ID (Android, iOS, Mac)
+ /// [ZH] 获取崩溃线程ID(Android、iOS、Mac) + ///
+ /// + /// [EN] Can be called in callback
+ /// [ZH] 可在回调中调用 + ///
+ /// + /// [EN] Crash thread ID, returns -1 on failure
+ /// [ZH] 崩溃线程ID,失败时返回-1 + ///
+ public static long GetCrashThreadId() + { + if (!IsInitialized) + { + return -1; + } + DebugLog(null, "GetCrashThreadId"); + + return UQMCrash.GetCrashThreadId(); + } + + /// + /// [EN] Sets customized device ID (Android, iOS, Mac)
+ /// 设置自定义device ID(Android、iOS、Mac) + ///
+ /// + /// [EN] Custom device id
+ /// [ZH] 自定义device ID + /// + public static void SetCustomizedDeviceID(string deviceId) + { + UQMCrash.SetCustomizedDeviceID(deviceId); + } + + /// + /// [EN] Gets SDK generated device ID (Android, iOS, Mac)
+ /// [ZH] 获取SDK生成的device ID(Android、iOS、Mac) + ///
+ /// + /// [EN] SDK generated device ID
+ /// [ZH] SDK生成的device ID + ///
+ public static string GetSDKDefinedDeviceID() + { + return UQMCrash.GetSDKDefinedDeviceID(); + } + + /// + /// [EN] Sets customized match ID (Android, iOS, Mac)
+ /// [ZH] 设置自定义 match ID(Android、iOS、Mac) + ///
+ /// + /// [EN] Match ID can be used to search crashes and errors in "Advanced Search"
+ /// [ZH] match id可用于在"高级搜索"中查找崩溃和错误 + ///
+ /// match ID + public static void SetCustomizedMatchID(string matchId) + { + UQMCrash.SetCustomizedMatchID(matchId); + } + + /// + /// [EN] Gets SDK generated session ID (Android, iOS, Mac)
+ /// [ZH] 获取SDK生成的session ID(Android、iOS、Mac) + ///
+ /// + /// [EN] Session ID uniquely marks a launch session, typically used in callbacks to determine if it's the same launch.
+ /// [ZH] session ID用于唯一标记一次启动,一般用于在回调中确定是否为同一次启动。 + ///
+ /// + /// [EN] SDK generated session ID
+ /// [ZH] SDK生成的session ID + ///
+ public static string GetSDKSessionID() + { + return UQMCrash.GetSDKSessionID(); + } + + /// + /// [EN] Triggers test OOM crash (Android, iOS, Mac)
+ /// [ZH] 测试OOM崩溃(Android、iOS、Mac) + ///
+ public static void TestOomCrash() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test oom crash"); + + UQMCrash.TestOomCrash(); + } + + /// + /// [EN] Triggers test Java crash (Android)
+ /// [ZH] 测试java崩溃(Android) + ///
+ public static void TestJavaCrash() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test java crash"); + + UQMCrash.TestJavaCrash(); + } + + /// + /// [EN] Triggers test ANR (Android only)
+ /// [ZH] 测试ANR(仅Android) + ///
+ public static void TestANR() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test ANR"); + + UQMCrash.TestANR(); + } + + /// + /// [EN] Gets crash UUID
+ /// [ZH] 获取崩溃UUID + ///
+ /// + /// [EN] This UUID is used to uniquely identify a report and is generally used in callbacks.
+ /// [ZH] 该UUID用于唯一标识一次上报,一般在回调中使用 + ///
+ /// + public static string GetCrashUuid() + { + return UQMCrash.GetCrashUuid(); + } + + /// + /// [EN] Sets the logcat buffer size(Android)
+ /// [ZH] 设置logcat缓存大小(Android) + ///
+ /// + /// [EN] Default is 10KB in non-debug mode, 128KB in debug mode
+ /// [ZH] 默认非debug模式下10KB,debug模式下128KB + ///
+ /// + /// [EN] Buffer size in KB
+ /// [ZH] logcat缓存大小(单位:KB) + /// + public static void SetLogcatBufferSize(int size) + { + UQMCrash.SetLogcatBufferSize(size); + } + + /// + /// [EN] Tests Objective-C crash (iOS, Mac)
+ /// [ZH] 测试Objective-C崩溃(iOS、Mac) + ///
+ public static void TestOcCrash() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test oc crash"); + + UQMCrash.TestOcCrash(); + } + + /// + /// [EN] Starts scheduled dump routine
+ /// [ZH] 启动定时dump任务 + ///
+ /// + /// [EN] Starts a thread to periodically capture and report dumps. + /// Performance overhead depends on dump interval and count settings. + /// Mainly for testing purposes. Disable before release.
+ /// [ZH] 启动一个线程定时获取dump并上报。根据dump间隔和次数会产生性能开销。一般用于测试,正式发布前请关闭。 + ///
+ /// + /// [EN] 0: close, 1: call system interface dump, 3: minidump (only valid for mobile)
+ /// [ZH] 0:关闭,1:调用系统接口dump,3:minidump(仅移动端有效) + /// + /// + /// [EN] Start time mode: 0=absolute time, 1=relative time (ms)
+ /// [ZH] 启动时间模式:0=绝对时间,1=相对时间(毫秒) + /// + /// + /// [EN] Start time
+ /// [ZH] 启动时间 + /// + /// + /// [EN] Dump interval in milliseconds
+ /// [ZH] dump间隔(毫秒) + /// + /// + /// [EN] Number of dumps to perform
+ /// [ZH] dump执行次数 + /// + /// + /// [EN] Whether to save dump locally
+ /// [ZH] 是否本地保存dump + /// + /// + /// [EN] Local save path for dumps
+ /// [ZH] dump本地保存路径 + /// + public static void StartDumpRoutine(int dumpMode, int startTimeMode, long startTime, + long dumpInterval, int dumpTimes, bool saveLocal, string savePath) + { + if (!IsInitialized) + { + return; + } + UQMCrash.StartDumpRoutine(dumpMode, startTimeMode, startTime, dumpInterval, dumpTimes, saveLocal, savePath); + } + + /// + /// [EN] Starts monitoring file descriptor count
+ /// [ZH] 监控FD数量 + ///
+ /// + /// [EN] Scan interval in milliseconds
+ /// [ZH] 扫描间隔,单位:毫秒 + /// + /// FD数量限制
+ /// [EN] Maximum allowed FD count + /// [ZH] FD数量限制 + /// + /// + /// [EN] 0: close, 1: call system interface dump, 3: minidump (only valid for mobile)
+ /// [ZH] 0:关闭,1:调用系统接口dump,3:minidump(仅移动端有效) + /// + public static void StartMonitorFdCount(int interval, int limit, int dumpType) + { + if (!IsInitialized) + { + return; + } + UQMCrash.StartMonitorFdCount(interval, limit, dumpType); + } + + /// + /// [EN] Gets exception type code
+ /// [ZH] 获取异常类型编号 + ///
+ /// + /// [EN] Exception type name (e.g. "c#", "js", "lua", "custom1")
+ /// [ZH] 异常类型名(如"c#","js","lua","custom1"等) + /// + /// + /// [EN] Exception type code for ReportException
+ /// [ZH] 用于ReportException接口的异常类型编号 + ///
+ public static int getExceptionType(string name) + { + if (!IsInitialized) + { + return 0; + } + return UQMCrash.getExceptionType(name); + } + + /// + /// [EN] Tests use-after-free memory error (Android)
+ /// [ZH] 测试释放后使用内存错误(Android) + ///
+ /// + /// [EN] Only works when GWP-Asan or MTE is enabled
+ /// [ZH] 仅当GWP-Asan或MTE功能启用时有效 + ///
+ public static void TestUseAfterFree() + { + if (!IsInitialized) + { + return; + } + DebugLog(null, "test UseAfterFree"); + + UQMCrash.TestUseAfterFree(); + } + + /// + /// [EN] Restarts CrashSight monitoring (Android, iOS)
+ /// [ZH] 重启CrashSight监控(Android, iOS) + ///
+ /// + /// [EN] Used in native Android integration scenarios
+ /// [ZH] 用于Android原生接入场景 + ///
+ public static void ReRegistAllMonitors() + { + _isInitialized = true; + UQMCrash.ReRegistAllMonitors(); + DebugLog(null, "ReRegistAllMonitors"); + } + + /// + /// [EN] Stops CrashSight monitoring (Android, iOS, Mac)
+ /// [ZH] 关闭CrashSight监控(Android, iOS, Mac) + ///
+ public static void CloseAllMonitors() + { + UQMCrash.CloseAllMonitors(); + DebugLog(null, "CloseAllMonitors"); + } + + /// + /// [EN] Toggles getPackageInfo system API (Android)
+ /// [ZH] 设置getPackageInfo系统接口调用开关(Android) + ///
+ /// + /// [EN] Enabled by default, can be disabled if rejected by Google Play
+ /// [ZH] 默认开启,谷歌审核不通过时可关闭 + ///
+ /// + public static void setEnableGetPackageInfo(bool enable) + { + DebugLog(null, "setEnableGetPackageInfo: " + enable); + + UQMCrash.setEnableGetPackageInfo(enable); + } + + /// + /// [EN] Sets multi-thread signal handling switch (Android)
+ /// [ZH] 设置安卓多线程信号处理开关(仅Android) + ///
+ /// + public static void setCatchMultiSignal(bool enable) + { + DebugLog(null, "setCatchMultiSignal: " + enable); + + UQMCrash.setCatchMultiSignal(enable); + } + + /// + /// [EN] Sets Android Fragment Tracking, iOS Page Tracking Switch
+ /// [ZH] 设置安卓Fragment追踪、iOS页面追踪开关 + ///
+ /// + public static void enableDetailedPageTracing(bool enable) + { + DebugLog(null, "enableDetailedPageTracing: " + enable); + + UQMCrash.enableDetailedPageTracing(enable); + } + + /// + /// [EN] Checks if last session crashed
+ /// [ZH] 判断上次启动会话是否发生崩溃 + ///
+ /// + public static bool IsLastSessionCrash() + { + if (!IsInitialized) + { + return false; + } + DebugLog(null, "IsLastSessionCrash"); + + return UQMCrash.IsLastSessionCrash(); + } + + /// + /// [EN] Gets user ID of last session
+ /// [ZH] 获取上次会话的用户ID + ///
+ /// + public static string GetLastSessionUserId() + { + if (!IsInitialized) + { + return ""; + } + DebugLog(null, "GetLastSessionUserId"); + + return UQMCrash.GetLastSessionUserId(); + } + + /// + /// [EN] Checks if file descriptor count exceeds limit
+ /// [ZH] 检查文件描述符(FD)数量是否超过限制 + ///
+ /// + /// [EN] Maximum FD count
+ /// [ZH] FD数量限制 + /// + /// + /// [EN] 0: close, 1: call system interface dump, 3: minidump (only valid for mobile)
+ /// [ZH] 0:关闭,1:调用系统接口dump,3:minidump(仅移动端有效) + /// + /// + /// [EN] Whether to upload report
+ /// [ZH] 是否上报 + /// + /// + /// [EN] true if FD count exceeds limit, false otherwise
+ /// [ZH] FD数量超过限制返回true,否则返回false + ///
+ public static bool CheckFdCount(int limit, int dumpType, bool upload) + { + if (!IsInitialized) + { + return false; + } + return UQMCrash.CheckFdCount(limit, dumpType, upload); + } + + /// + /// [EN] Sets OOM log path (Android, iOS)
+ /// [ZH] 设置OOM日志路径(Android、iOS) + ///
+ /// + /// [EN] Path for OOM logs
+ /// [ZH] OOM日志路径 + /// + public static void SetOomLogPath(string logPath) + { + UQMCrash.SetOomLogPath(logPath); + } + + /// + /// [EN] Reports jank
+ /// [ZH] 上报卡顿事件 + ///
+ /// + /// [EN] Jank type (reserved for future use)
+ /// [ZH] 卡顿类型(保留字段,暂未使用) + /// + /// + /// [EN] Name of the jank exception
+ /// [ZH] 卡顿异常名称 + /// + /// + /// [EN] Description of the jank event
+ /// [ZH] 卡顿事件描述信息 + /// + /// + /// [EN] Stack trace of jank
+ /// [ZH] 卡顿堆栈内容 + /// + /// + /// [EN] Additional information in JSON format
+ /// [ZH] 额外信息,JSON格式 + /// + /// + /// [EN] Collection options for jank reporting information, represented by 6 binary bits for different options, 0 indicating no collection of additional information.
+ /// The 1st bit: Collect system logs, the 2nd bit: Collect custom logs, the 3rd bit: Collect user-defined key-value pairs, + /// the 4th bit: Trigger user callbacks, the 5th bit: Automatically dump stack traces, the 6th bit:Automatically collect full-thread Java stack.
+ /// [ZH] jank上报信息收集选项,用6位二进制位表示不同选项,0表示不收集任何额外信息
+ /// 第1位:收集系统日志,第2位:收集自定义日志,第3位:收集用户自定义键值对,第4位:触发用户回调,第5位:自动dump堆栈,第6位:自动采集全线程Java堆栈 + /// + /// + /// [EN] Path to attachment file for jank report
+ /// [ZH] 卡顿报告附件文件路径 + /// + public static void ReportJank(int type, string exceptionName, + string exceptionMsg, string exceptionStack, + string paramsJson, int reportInfoOption, + string jankAttachmentPath) + { + UQMCrash.ReportJank(type, exceptionName, exceptionMsg, exceptionStack, paramsJson, reportInfoOption, jankAttachmentPath); + } + + public static void ReportStuck(int threadId, int maxChecks, long checkInterval, + string name, string message, Dictionary extInfo, + int dumpNativeType, string attachPath) + { + UQMCrash.ReportStuck(threadId, maxChecks, checkInterval, name, message, extInfo, dumpNativeType, attachPath); + } + + /************************************PC、Xbox端接口************************************/ + + /// + /// [EN] Sets VEH(Vectored Exception Handling) enable status (Win, Xbox)
+ /// [ZH] 设置VEH(向量化异常处理)捕获开关(Win、Xbox) + ///
+ /// + /// [EN] Enabled by default. Recommended to disable for Unity projects to avoid false crash reports.
+ /// [ZH] 默认开启,建议所有Unity项目关闭此开关,否则可能产生crash误报。 + ///
+ /// + public static void SetVehEnable(bool enable) + { + UQMCrash.SetVehEnable(enable); + DebugLog(null, "SetVehEnable"); + } + + /// + /// [EN] Manually reports a crash (Win, Xbox)
+ /// [ZH] 主动上报崩溃信息(Win、Xbox) + ///
+ /// + /// [EN] Reports a crash manually. Normally not needed, use only when necessary.
+ /// [ZH] 主动上报一条崩溃信息,一般没有使用场景,可根据项目需要酌情使用。 + ///
+ public static void ReportCrash() + { + UQMCrash.ReportCrash(); + DebugLog(null, "ReportCrash"); + } + + /// + /// [EN] Manually reports dump file(Win, Xbox)
+ /// [ZH] 主动上报dump文件(Win、Xbox) + ///
+ /// + /// [EN] Directory containing dump files
+ /// [ZH] dump文件所在目录 + /// + /// + /// [EN] Whether to report asynchronously
+ /// [ZH] 是否异步上报 + /// + public static void ReportDump(string dump_path, bool is_async) + { + UQMCrash.ReportDump(dump_path, is_async); + DebugLog(null, "ReportDump"); + } + + /// + /// [EN] Sets extra exception handler (Win, Xbox)
+ /// [ZH] 设置额外异常捕获开关(Win、Xbox) + ///
+ /// + /// [EN] Disabled by default for backward compatibility.
+ /// When enabled, can catch illegal parameter crashes from security functions like strcpy_s, + /// and purecall errors from virtual function calls.
+ /// [ZH] 默认为关闭,与旧版保持一致。
+ /// 开启后,可以捕获上报strcpy_s一类的安全函数抛出的非法参数崩溃,以及虚函数调用purecall错误导致的崩溃。 + ///
+ /// + public static void SetExtraHandler(bool extra_handle_enable) + { + UQMCrash.SetExtraHandler(extra_handle_enable); + DebugLog(null, "SetExtraHandler"); + } + + /// + /// [EN] Uploads dump files from specified path (Win, Xbox)
+ /// [ZH] 上传指定路径下的dump文件(Win、Xbox) + ///
+ /// + /// [EN] Directory containing dump files
+ /// [ZH] dump文件所在目录 + /// + /// + /// [EN] Extra validation check, set to false by default
+ /// [ZH] 额外校验检查,默认填false即可 + /// + public static void UploadGivenPathDump(string dump_dir, bool is_extra_check) + { + UQMCrash.UploadGivenPathDump(dump_dir, is_extra_check); + DebugLog(null, "UploadGivenPathDump"); + } + + /// + /// [EN] Sets dump type (Win, Xbox)
+ /// [ZH] 设置dump类型(Win、Xbox) + ///
+ /// + /// [EN] Dump type value: see Windows documentation for valid values.
+ /// [ZH] dump类型值,有效值请参考Windows官方文档 + /// + public static void SetDumpType(int dump_type) + { + UQMCrash.SetDumpType(dump_type); + } + + /// + /// [EN] Adds valid exception code (Win, Xbox)
+ /// [ZH] 添加可用的异常类型(Win、Xbox) + ///
+ /// + /// [EN] Consult CrashSight developers before using
+ /// [ZH] 使用前请咨询CrashSight开发人员 + ///
+ /// + /// [EN] Exception code: see Windows documentation
+ /// [ZH] 异常代码: 参考Windows官方文档 + /// + public static void AddValidExpCode(ulong exp_code) + { + UQMCrash.AddValidExpCode(exp_code); + } + + /// + /// [EN] Uploads crash with specified GUID (Win, Xbox)
+ /// [ZH] 上报指定GUID的错误(Win、Xbox) + ///
+ /// + /// [EN] GUID identifying the specific issue, an be obtained through callback.
+ /// [ZH] 唯一问题的代码,可通过回调获取 + /// + public static void UploadCrashWithGuid(string guid) + { + UQMCrash.UploadCrashWithGuid(guid); + } + + /// + /// [EN] Sets crash upload enable status (Win, Xbox)
+ /// [ZH] 设置崩溃上报开关(Win、Xbox) + ///
+ /// + public static void SetCrashUploadEnable(bool enable) + { + UQMCrash.SetCrashUploadEnable(enable); + } + + /// + /// [EN] Sets workspace path (Win, Xbox)
+ /// [ZH] 设置工作空间路径(Win、Xbox) + ///
+ /// + /// [EN] Absolute path to workspace directory
+ /// [ZH] 工作空间的绝对路径 + /// + public static void SetWorkSpace(string workspace) + { + UQMCrash.SetWorkSpace(workspace); + } + + /// + /// [EN] Sets custom attachment directory (Win, Xbox)
+ /// [ZH] 设置自定义附件目录(Win、Xbox) + ///
+ /// + /// [EN] Absolute path to attachment directory
+ /// [ZH] 附件的绝对路径 + /// + public static void SetCustomAttachDir(string path) + { + UQMCrash.SetCustomAttachDir(path); + } + + /************************************PS4、PS5、Switch端接口************************************/ + + /// + /// [EN] Sets error report interval (PS4, PS5, Switch)
+ /// [ZH] 设置错误上报间隔(PS4、PS5、Switch) + ///
+ /// + /// [EN] Report interval in seconds
+ /// [ZH] 错误上报间隔(单位:秒) + /// + public static void SetErrorUploadInterval(int interval) + { + UQMCrash.SetErrorUploadInterval(interval); + DebugLog(null, "SetErrorUploadInterval"); + } + + /// + /// [EN] Enables/disables error reporting (PS4, PS5, Switch)
+ /// [ZH] 设置错误上报开关(PS4、PS5、Switch) + ///
+ /// + public static void SetErrorUploadEnable(bool enable) + { + UQMCrash.SetErrorUploadEnable(enable); + DebugLog(null, "SetErrorUploadEnable"); + } + + /************************************Linux端接口************************************/ + + /// + /// [EN] Sets directory for all record files (Linux)
+ /// [ZH] 设置所有记录文件的路径(Linux) + ///
+ /// + /// [EN] Includes SDK logs and dump files, defaults to executable directory
+ /// [ZH] 包括SDK日志和dump文件,默认为当前可执行文件的目录下 + ///
+ /// + /// [EN] Path to record files directory
+ /// [ZH] 记录文件的路径 + /// + public static void SetRecordFileDir(string record_dir) + { + UQMCrash.SetRecordFileDir(record_dir); + DebugLog(null, "SetRecordFileDir"); + } + + /************************************已废弃接口************************************/ + + /// + /// [EN] Initializes CrashSight (Windows/Xbox) - DEPRECATED, use instead
+ /// [ZH] 初始化CrashSight(Windows/Xbox平台)- 已废弃,请使用 替代 + ///
+ /// + /// + /// + [Obsolete("该接口已废弃,请使用 InitWithAppId 进行初始化")] + public static void InitContext(string userId, string version, string key) + { + if (IsInitialized) + { + DebugLog(null, "CrashSightAgent has already been initialized."); + + return; + } + + if (userId == null || string.IsNullOrEmpty(version) || string.IsNullOrEmpty(key)) + { + return; + } + + _isInitialized = true; + // init the sdk with app id + UQMCrash.InitContext(userId, version, key); + DebugLog(null, "Initialized with userId: " + userId +" version: " + version + " key: " + key); + + // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) + _RegisterExceptionHandler(); + } + + /// + /// [EN] Initializes CrashSight (Linux) - DEPRECATED, use instead
+ /// [ZH] 初始化CrashSight(Linux平台)- 已废弃,请使用 替代 + ///
+ /// + /// + /// + [Obsolete("该接口已废弃,请使用 InitWithAppId 进行初始化")] + public static void Init(string app_id, string app_key, string app_version) + { + if (IsInitialized) + { + DebugLog(null, "CrashSightAgent has already been initialized."); + + return; + } + + if (string.IsNullOrEmpty(app_id) || string.IsNullOrEmpty(app_key) || string.IsNullOrEmpty(app_version)) + { + return; + } + + _isInitialized = true; + // init the sdk with app id + UQMCrash.Init(app_id, app_key, app_version); + DebugLog(null, "Initialized with app_id: " + app_id + " app_key: " + app_key + " app_version: " + app_version); + + // Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback) + _RegisterExceptionHandler(); + } + + /// + /// [EN] Configures default settings (Android/iOS/Switch) - DEPRECATED
+ /// [ZH] 配置默认设置(Android/iOS/Switch平台)- 已废弃 + ///
+ /// + /// + /// + /// + [Obsolete("该接口已废弃")] + public static void ConfigDefault(string channel, string version, string user, long delay) + { + DebugLog(null, "Config default channel:" + channel + ", version:" + version + ", user:" + user + ", delay:" + delay); + UQMCrash.ConfigDefault(channel, version, user, delay); + } + + #region Privated Fields and Methods + /************************************private部分************************************/ + + private static void _OnLogCallbackHandlerMain(string condition, string stackTrace, LogType type) + { + _OnLogCallbackHandler(condition, stackTrace, type, CSReportType.LogCallback); + } + + private static void _OnLogCallbackHandlerThreaded(string condition, string stackTrace, LogType type) + { + _OnLogCallbackHandler(condition, stackTrace, type, CSReportType.LogCallbackThreaded); + } + + private static void _OnLogCallbackHandler(string condition, string stackTrace, LogType type, CSReportType rType) + { + if (_LogCallbackEventHandler != null) + { + _LogCallbackEventHandler(condition, stackTrace, type); + } + + if (!IsInitialized) + { + return; + } + + if (!string.IsNullOrEmpty(condition) && condition.Contains("[CrashSightAgent] ")) + { + return; + } + + if (_uncaughtAutoReportOnce) + { + return; + } + + if (callbackThreads.Contains(Thread.CurrentThread.ManagedThreadId)) + { + return; + } + + _HandleException(type, null, condition, stackTrace, true, rType); + } + + private static void _OnUncaughtExceptionHandler(object sender, System.UnhandledExceptionEventArgs args) + { + if (args == null || args.ExceptionObject == null) + { + return; + } + + try + { + if (args.ExceptionObject.GetType() != typeof(System.Exception)) + { + return; + } + } + catch + { + if (UnityEngine.Debug.isDebugBuild == true) + { + UnityEngine.Debug.Log("CrashSightAgent: Failed to report uncaught exception"); + } + + return; + } + + if (!IsInitialized) + { + return; + } + + if (_uncaughtAutoReportOnce) + { + return; + } + + _HandleException((System.Exception)args.ExceptionObject, null, true); + } + + private static void _HandleException(System.Exception e, string message, bool uncaught) + { + if (e == null) + { + return; + } + + if (!IsInitialized) + { + return; + } + + string name = e.GetType().Name; + string reason = e.Message; + + if (!string.IsNullOrEmpty(message)) + { + reason = string.Format("{0}{1}***{2}", reason, Environment.NewLine, message); + } + + StringBuilder stackTraceBuilder = new StringBuilder(512); + + StackTrace stackTrace = new StackTrace(e, true); + int count = stackTrace.FrameCount; + for (int i = 0; i < count; i++) + { + StackFrame frame = stackTrace.GetFrame(i); + + stackTraceBuilder.AppendFormat("{0}.{1}", frame.GetMethod().DeclaringType.Name, frame.GetMethod().Name); + + ParameterInfo[] parameters = frame.GetMethod().GetParameters(); + if (parameters == null || parameters.Length == 0) + { + stackTraceBuilder.Append(" () "); + } + else + { + stackTraceBuilder.Append(" ("); + + int pcount = parameters.Length; + + ParameterInfo param = null; + for (int p = 0; p < pcount; p++) + { + param = parameters[p]; + stackTraceBuilder.AppendFormat("{0} {1}", param.ParameterType.Name, param.Name); + + if (p != pcount - 1) + { + stackTraceBuilder.Append(", "); + } + } + param = null; + + stackTraceBuilder.Append(") "); + } + + string fileName = frame.GetFileName(); + if (!string.IsNullOrEmpty(fileName) && !fileName.ToLower().Equals("unknown")) + { + fileName = fileName.Replace("\\", "/"); + + int loc = fileName.ToLower().IndexOf("/assets/"); + if (loc < 0) + { + loc = fileName.ToLower().IndexOf("assets/"); + } + + if (loc > 0) + { + fileName = fileName.Substring(loc); + } + + stackTraceBuilder.AppendFormat("(at {0}:{1})", fileName, frame.GetFileLineNumber()); + } + stackTraceBuilder.AppendLine(); + } + + // report + _reportException(uncaught, name, reason, stackTraceBuilder.ToString()); + } + + private static bool ShouldSkipFrame(string frame) + { + string[] skipPatterns = { "System.Collections.Generic.", "ShimEnumerator", "CrashSight" }; + + foreach (var pattern in skipPatterns) + { + if (frame.StartsWith(pattern, StringComparison.Ordinal)) + { + return true; + } + } + + return false; + } + + private static void _reportException(bool uncaught, string name, string reason, string stackTrace) + { + if (string.IsNullOrEmpty(name)) + { + return; + } + + if (string.IsNullOrEmpty(stackTrace)) + { + stackTrace = StackTraceUtility.ExtractStackTrace(); + } + + if (string.IsNullOrEmpty(stackTrace)) + { + stackTrace = "Empty"; + } + else + { + + try + { + string[] frames = stackTrace.Split('\n'); + + if (frames != null && frames.Length > 0) + { + + StringBuilder trimFrameBuilder = new StringBuilder(512); + + string frame = null; + int count = frames.Length; + for (int i = 0; i < count; i++) + { + frame = frames[i]; + + if (string.IsNullOrEmpty(frame) || string.IsNullOrEmpty(frame.Trim())) + { + continue; + } + + frame = frame.Trim(); + + if (string.IsNullOrEmpty(frame) || ShouldSkipFrame(frame) || frame.Contains("..ctor")) + { + continue; + } + + int start = -1; + int end = -1; + if (frame.Contains("(at") && frame.Contains("/assets/")) + { + start = frame.IndexOf("(at", StringComparison.OrdinalIgnoreCase); + end = frame.IndexOf("/assets/", StringComparison.OrdinalIgnoreCase); + + } + if (start > 0 && end > 0) + { + trimFrameBuilder.AppendFormat("{0}(at {1}", frame.Substring(0, start).Replace(":", "."), frame.Substring(end)); + } + else + { + trimFrameBuilder.Append(frame.Replace(":", ".")); + } + + trimFrameBuilder.AppendLine(); + } + + stackTrace = trimFrameBuilder.ToString(); + } + } + catch + { + PrintLog(CSLogSeverity.LogWarning, "{0}", "Error to parse the stack trace"); + } + + } + +// PrintLog(CSLogSeverity.LogError, "ReportException: " + name + " " + reason + "\n*********\n" + stackTrace + "\n*********"); + + _uncaughtAutoReportOnce = uncaught && _autoQuitApplicationAfterReport; + + string extraInfo = string.Empty; + Dictionary extras = null; + if (_LogCallbackExtrasHandler != null) + { + extras = _LogCallbackExtrasHandler(); + } + + if (extras != null && extras.Count > 0) + { + StringBuilder builder = new StringBuilder(128); + foreach (KeyValuePair kvp in extras) + { + builder.AppendFormat("\"{0}\" : \"{1}\", ", kvp.Key, kvp.Value); + } + builder.Length -= 2; // 去掉最后一个逗号和空格 + extraInfo = "{" + builder.ToString() + "}"; + } + UQMCrash.ReportException(4, name, reason, stackTrace, extraInfo, uncaught && AutoQuitApplicationAfterReport); + } + + private static int valueOf(LogType logLevel) + { + switch(logLevel) + { + case LogType.Exception: + return 1; + case LogType.Error: + return 2; + case LogType.Assert: + return 3; + case LogType.Warning: + return 4; + case LogType.Log: + return 5; + default: + return 6; + } + } + + private static bool isEnableAutoReport(LogType logLevel) + { + return valueOf(logLevel) <= valueOf(_autoReportLogLevel); + } + + private static void _HandleException(LogType logLevel, string name, string message, string stackTrace, bool uncaught, CSReportType rType) + { + if (!IsInitialized) + { + DebugLog(null, "It has not been initialized."); + return; + } + + if ((uncaught && !isEnableAutoReport(logLevel))) + { + DebugLog(null, "Not report exception for level " + logLevel.ToString()); + return; + } + + string type = null; + string reason = ""; + + if (!string.IsNullOrEmpty(message)) + { + try + { + if ((LogType.Exception == logLevel) && message.Contains("Exception")) + { + + Match match = new Regex(@"^(?\S+):\s*(?.*)", RegexOptions.Singleline).Match(message); + + if (match.Success) + { + if (stackTrace.Contains("UnityEngine.Debug:LogException")) + { + if (rType == CSReportType.LogCallback) + { + return; + } + } + else + { + if (rType == CSReportType.LogCallbackThreaded) + { + return; + } + } + type = match.Groups["errorType"].Value.Trim(); + reason = match.Groups["errorMessage"].Value.Trim(); + } + else if (rType == CSReportType.LogCallback) + { + return; + } + } + else if ((LogType.Error == logLevel) && message.StartsWith("Unhandled Exception:", StringComparison.Ordinal)) + { + + Match match = new Regex(@"^Unhandled\s+Exception:\s*(?\S+):\s*(?.*)", RegexOptions.Singleline).Match(message); + + if (match.Success) + { + if (rType == CSReportType.LogCallbackThreaded) + { + return; + } + string exceptionName = match.Groups["exceptionName"].Value.Trim(); + string exceptionDetail = match.Groups["exceptionDetail"].Value.Trim(); + + // + int dotLocation = exceptionName.LastIndexOf("."); + if (dotLocation > 0 && dotLocation != exceptionName.Length) + { + type = exceptionName.Substring(dotLocation + 1); + } + else + { + type = exceptionName; + } + + int stackLocation = exceptionDetail.IndexOf(" at "); + if (stackLocation > 0) + { + // + reason = exceptionDetail.Substring(0, stackLocation); + // substring after " at " + string callStacks = exceptionDetail.Substring(stackLocation + 3).Replace(" at ", "\n").Replace("in :0", string.Empty).Replace("[0x00000]", string.Empty); + // + stackTrace = stackTrace + "\n" + callStacks.Trim(); + + } + else + { + reason = exceptionDetail; + } + + // for LuaScriptException + if (type.Equals("LuaScriptException") && exceptionDetail.Contains(".lua") && exceptionDetail.Contains("stack traceback:")) + { + stackLocation = exceptionDetail.IndexOf("stack traceback:"); + if (stackLocation > 0) + { + reason = exceptionDetail.Substring(0, stackLocation); + // substring after "stack traceback:" + string callStacks = exceptionDetail.Substring(stackLocation + 16).Replace(" [", " \n["); + + // + stackTrace = stackTrace + "\n" + callStacks.Trim(); + } + } + } + else if (rType == CSReportType.LogCallback) + { + return; + } + } + else if (rType == CSReportType.LogCallback) + { + return; + } + } + catch + { + + } + + if (string.IsNullOrEmpty(reason)) + { + reason = message; + } + } + + if (string.IsNullOrEmpty(name)) + { + if (string.IsNullOrEmpty(type)) + { + string sLogLevel = "Log"; + switch (logLevel) + { + case LogType.Log: + sLogLevel = "Log"; + break; + case LogType.Warning: + sLogLevel = "LogWarning"; + break; + case LogType.Assert: + sLogLevel = "LogAssert"; + break; + case LogType.Error: + sLogLevel = "LogError"; + break; + case LogType.Exception: + sLogLevel = "LogException"; + break; + } + type = "Unity" + sLogLevel; + if (CrashSightStackTrace.enable) + { + try + { + stackTrace = CrashSightStackTrace.ExtractStackTrace(); + //去掉前三行 + if (stackTrace.Contains("CrashSightAgent:_HandleException(LogType, String, String, String, Boolean)") + && stackTrace.Contains("CrashSightAgent:_OnLogCallbackHandler(String, String, LogType)") + && stackTrace.Contains("UnityEngine.Application:CallLogCallback(String, String, LogType, Boolean)")) + { + int count = stackTrace.IndexOf("\n"); + count = stackTrace.IndexOf("\n", count + 1); + count = stackTrace.IndexOf("\n", count + 1); + stackTrace = stackTrace.Substring(count + 1); + } + } + catch + { + } + } + } + } + else + { + type = name; + } + + _reportException(uncaught, type, reason, stackTrace); + } + + #endregion +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs.meta new file mode 100644 index 00000000000..ad89be9b853 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/CrashSightAgent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34047571c56b3c94f92a828719fbabce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore.meta new file mode 100644 index 00000000000..90685f142cb --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 81a06a3bb7606664d93044a9c50eb28e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM.meta new file mode 100644 index 00000000000..7a8c1050c26 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bca1e29d2ac885d428e49570f70a71c0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs new file mode 100644 index 00000000000..7f89f8f95b9 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs @@ -0,0 +1,63 @@ +using UnityEngine; + +namespace GCloud.UQM +{ + #region UQM + /// + /// 回调的范型 + /// + public delegate void OnUQMRetEventHandler (T ret); + public delegate string OnUQMStringRetEventHandler (T ret, T crashType); + + public delegate string OnUQMStringRetSetLogPathEventHandler(T ret, T crashType); + public delegate void OnUQMRetLogUploadEventHandler(T ret, T crashType, T result); + + + public class UQM + { +#if UNITY_ANDROID + public const string LibName = "CrashSight"; +#elif UNITY_IOS + public const string LibName = "__Internal"; +#elif UNITY_STANDALONE_WIN +#if UNITY_64//win64 + public const string LibName = "CrashSight64"; +#else//win32 + public const string LibName = "CrashSight"; +#endif +#elif UNITY_STANDALONE_OSX + public const string LibName = "CrashSight"; +#elif UNITY_XBOXONE + public const string LibName = "CrashSightXbox"; +#elif UNITY_PS4 || UNITY_PS5 + public const string LibName = "libcs"; +#elif UNITY_SWITCH + public const string LibName = "__Internal"; +#elif UNITY_STANDALONE_LINUX + public const string LibName = "CrashSight"; +#elif UNITY_OPENHARMONY + public const string LibName = "CrashSight"; +#else + public const string LibName = "__Internal"; +#endif + private static bool initialized; + + public static bool isDebug = true; + + /// + /// UQM init,游戏开始的时候设置 + /// + public static void Init() + { + if (initialized) return; + initialized = true; + if (isDebug) + UQMLog.SetLevel(UQMLog.Level.Log); + else + UQMLog.SetLevel(UQMLog.Level.Error); + UQMLog.Log ("UQM initialed !"); + } + } + + #endregion +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs.meta new file mode 100644 index 00000000000..6855f26cdb1 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQM.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28b1e81b8fa4086468b902ed1d439949 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs new file mode 100644 index 00000000000..77038cd997a --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs @@ -0,0 +1,1707 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace GCloud.UQM +{ + public enum UQMCrashLevel + { + CSLogLevelSilent = 0, //关闭日志记录功能 + CSLogLevelError = 1, + CSLogLevelWarn = 2, + CSLogLevelInfo = 3, + CSLogLevelDebug = 4, + CSLogLevelVerbose = 5, + } + + public static class UQMCrash + { +#if !UNITY_EDITOR +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configAutoReportLogLevelAdapter(int level); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configGameTypeAdapter(int gameType); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configCallbackTypeAdapter(Int32 callbackType); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configDefaultAdapter([MarshalAs(UnmanagedType.LPStr)] string channel, + [MarshalAs(UnmanagedType.LPStr)] string version, + [MarshalAs(UnmanagedType.LPStr)] string user, + long delay); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configCrashServerUrlAdapter([MarshalAs(UnmanagedType.LPStr)] string serverUrl); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_configDebugModeAdapter(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_initWithAppIdAdapter([MarshalAs(UnmanagedType.LPStr)] string appId, bool forceOnUiThread); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_logRecordAdapter(int level, [MarshalAs(UnmanagedType.LPStr)] string message); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_addSceneDataAdapter([MarshalAs(UnmanagedType.LPStr)] string k, [MarshalAs(UnmanagedType.LPStr)] string v); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reportExceptionAdapter(int type, [MarshalAs(UnmanagedType.LPStr)] string exceptionName, + [MarshalAs(UnmanagedType.LPStr)] string exceptionMsg, [MarshalAs(UnmanagedType.LPStr)] string exceptionStack, [MarshalAs(UnmanagedType.LPStr)] string extras, + [MarshalAs(UnmanagedType.LPStr)] string paramsJson, bool quitProgram, int dumpNativeType, [MarshalAs(UnmanagedType.LPStr)] string errorAttachmentPath); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setUserIdAdapter([MarshalAs(UnmanagedType.LPStr)] string userId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setSceneAdapter([MarshalAs(UnmanagedType.LPStr)] string sceneId, bool upload); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_unityCrashCallback(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_unregisterUnityCrashCallback(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_unityCrashLogCallback(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reRegistAllMonitorsAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_closeAllMonitorsAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reportLogInfo([MarshalAs(UnmanagedType.LPStr)] string msgType,[MarshalAs(UnmanagedType.LPStr)] string msg); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setAppVersionAdapter([MarshalAs(UnmanagedType.LPStr)] string appVersion); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setDeviceIdAdapter([MarshalAs(UnmanagedType.LPStr)] string deviceId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setCustomizedDeviceIDAdapter([MarshalAs(UnmanagedType.LPStr)] string deviceId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr cs_getSDKDefinedDeviceIDAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setCustomizedMatchIDAdapter([MarshalAs(UnmanagedType.LPStr)] string matchId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr cs_getSDKSessionIDAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr cs_getCrashUuidAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setDeviceModelAdapter([MarshalAs(UnmanagedType.LPStr)] string deviceModel); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setLogPathAdapter([MarshalAs(UnmanagedType.LPStr)] string logPath); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testOomCrashAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testJavaCrashAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testOcCrashAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testNativeCrashAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testANRAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern long cs_getCrashThreadId(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setLogcatBufferSize(int size); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setCallbackMsgAdapter([MarshalAs(UnmanagedType.LPStr)] string deviceModel); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_startDumpRoutine(int dumpMode, int startTimeMode, long startTime, + long dumpInterval, int dumpTimes, bool saveLocal, [MarshalAs(UnmanagedType.LPStr)] string savePath); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_startMonitorFdCount(int interval, int limit, int dumpType); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern int cs_getExceptionType(string name); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_testUseAfterFreeAdapter(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setEnableGetPackageInfo(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setServerEnv([MarshalAs(UnmanagedType.LPStr)] string serverEnv); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setEngineInfo([MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string buildConfig, [MarshalAs(UnmanagedType.LPStr)] string language, [MarshalAs(UnmanagedType.LPStr)] string locale); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setGpuInfo([MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string vendor, [MarshalAs(UnmanagedType.LPStr)] string renderer); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setCatchMultiSignal(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_enableDetailedPageTracing(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_useSavedUserId(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern bool cs_isLastSessionCrash(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr cs_getLastSessionUserId(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern bool cs_checkFdCount(int limit, int dumpType, bool upload); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setOomLogPath([MarshalAs(UnmanagedType.LPStr)] string logPath); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reportJank(int type, [MarshalAs(UnmanagedType.LPStr)] string exceptionName, + [MarshalAs(UnmanagedType.LPStr)] string exceptionMsg, [MarshalAs(UnmanagedType.LPStr)] string exceptionStack, + [MarshalAs(UnmanagedType.LPStr)] string paramsJson, int reportInfoOption, + [MarshalAs(UnmanagedType.LPStr)] string jankAttachmentPath); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_processEngineAnr(int type); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setEngineMainThread(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reportStuck(int threadId, int maxChecks, int checkInterval, + [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string message, + [MarshalAs(UnmanagedType.LPStr)] string extraInfo, int dumpNativeType, + [MarshalAs(UnmanagedType.LPStr)] string attachPath); +#elif UNITY_STANDALONE_WIN || UNITY_XBOXONE + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_InitContext([MarshalAs(UnmanagedType.LPStr)] string id, [MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string key); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportExceptionW(int type,[MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string message,[MarshalAs(UnmanagedType.LPStr)] string stack_trace, + [MarshalAs(UnmanagedType.LPStr)] string extras, bool is_async, [MarshalAs(UnmanagedType.LPWStr)] string attachmentPath = ""); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserValue([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetVehEnable(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetExtraHandler(bool extra_handle_enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetCustomLogDirW([MarshalAs(UnmanagedType.LPWStr)] string log_path); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserId([MarshalAs(UnmanagedType.LPStr)] string user_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_MonitorEnable(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_PrintLog(int level, [MarshalAs(UnmanagedType.LPStr)] string tag, [MarshalAs(UnmanagedType.LPStr)] string format, [MarshalAs(UnmanagedType.LPStr)] string arg); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_UploadGivenPathDump([MarshalAs(UnmanagedType.LPStr)] string dump_dir, bool is_extra_check); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportCrash(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportDump([MarshalAs(UnmanagedType.LPStr)] string dump_dir, bool is_async); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetEnvironmentName([MarshalAs(UnmanagedType.LPStr)] string name); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_InitWithAppId([MarshalAs(UnmanagedType.LPStr)] string app_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetAppVersion([MarshalAs(UnmanagedType.LPStr)] string app_version); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigCrashServerUrl([MarshalAs(UnmanagedType.LPStr)] string crash_server_url); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigDebugMode(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetDeviceId([MarshalAs(UnmanagedType.LPStr)] string device_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigCrashReporter(int log_level); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_TestNativeCrash(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetDumpType(int dump_type); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_AddValidExpCode(ulong exp_code); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_UploadCrashWithGuid([MarshalAs(UnmanagedType.LPStr)] string guid); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetCrashUploadEnable(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetWorkSpaceW([MarshalAs(UnmanagedType.LPWStr)] string workspace); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetEngineInfo([MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string buildConfig, [MarshalAs(UnmanagedType.LPStr)] string language, [MarshalAs(UnmanagedType.LPStr)] string locale); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetCustomAttachDirW([MarshalAs(UnmanagedType.LPWStr)] string log_path); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_UseSavedUserId(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportStuck(int threadId, int maxChecks, int checkInterval, + [MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string message, + [MarshalAs(UnmanagedType.LPStr)] string extraInfo, int dumpNativeType, + [MarshalAs(UnmanagedType.LPStr)] string attachPath); +#elif UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_InitWithAppId([MarshalAs(UnmanagedType.LPStr)] string appId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetAppVersion([MarshalAs(UnmanagedType.LPStr)] string appVersion); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportException(int type, [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.LPStr)] string message, [MarshalAs(UnmanagedType.LPStr)] string stack_trace, + [MarshalAs(UnmanagedType.LPStr)] string extras, bool quit); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserId([MarshalAs(UnmanagedType.LPStr)] string userId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_EnableDebugMode(bool isDebug); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetErrorUploadInterval(int interval); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetCrashServerUrl([MarshalAs(UnmanagedType.LPStr)] string crashServerUrl); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserValue([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetErrorUploadEnable(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_PrintLog(int level, [MarshalAs(UnmanagedType.LPStr)] string tag, [MarshalAs(UnmanagedType.LPStr)] string data); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetDeviceId([MarshalAs(UnmanagedType.LPStr)] string deviceId); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigCrashReporter(int logLevel); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_TestNativeCrash(); +#if UNITY_PS4 || UNITY_PS5 + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetLogPath([MarshalAs(UnmanagedType.LPStr)] string path); +#endif +#elif UNITY_STANDALONE_LINUX + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigCrashServerUrl([MarshalAs(UnmanagedType.LPStr)] string user_id); //需要传入Uid + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_Init([MarshalAs(UnmanagedType.LPStr)] string app_id, [MarshalAs(UnmanagedType.LPStr)] string app_key, + [MarshalAs(UnmanagedType.LPStr)] string app_version); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserId([MarshalAs(UnmanagedType.LPStr)] string user_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetDeviceId([MarshalAs(UnmanagedType.LPStr)] string device_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetAppVersion([MarshalAs(UnmanagedType.LPStr)] string app_version); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_PrintLog(int level, [MarshalAs(UnmanagedType.LPStr)] string format, [MarshalAs(UnmanagedType.LPStr)] string arg); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetRecordFileDir([MarshalAs(UnmanagedType.LPStr)] string record_dir); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetUserValue([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_SetLogPath([MarshalAs(UnmanagedType.LPStr)] string log_path); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ReportException(int type, [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.LPStr)] string reason, [MarshalAs(UnmanagedType.LPStr)] string stackTrace, + [MarshalAs(UnmanagedType.LPStr)] string extras, bool quit, int dumpNativeType = 0); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_InitWithAppId([MarshalAs(UnmanagedType.LPStr)] string app_id); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigDebugMode(bool enable); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_ConfigCrashReporter(int log_level); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_TestNativeCrash(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_CloseCrashReport(); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setEngineInfo([MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string buildConfig, [MarshalAs(UnmanagedType.LPStr)] string language, [MarshalAs(UnmanagedType.LPStr)] string locale); + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void CS_PostLogStatics([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string message); +#endif +#endif + +#if UNITY_OPENHARMONY + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_reportExceptionV1Adapter(int type, [MarshalAs(UnmanagedType.LPStr)] string name, + [MarshalAs(UnmanagedType.LPStr)] string message, [MarshalAs(UnmanagedType.LPStr)] string stackTrace, + [MarshalAs(UnmanagedType.LPStr)] string extras, bool quitProgram); +#endif + + /// + /// Crash回调方法,提供上报用户数据能力 + /// + public static event OnUQMStringRetEventHandler CrashBaseRetEvent; + + public static event OnUQMStringRetSetLogPathEventHandler CrashSetLogPathRetEvent; + public static event OnUQMRetLogUploadEventHandler CrashLogUploadRetEvent; + + private static AndroidJavaClass _gameAgentClass = null; + private static bool _isLoadedSo = false; + private static int _gameType = 0; // COCOS=1, UNITY=2, UNREAL=3 + private static readonly string GAME_AGENT_CLASS = "com.uqm.crashsight.core.api.CrashSightPlatform"; + + public static AndroidJavaClass CrashSightPlatform + { + get + { + if (_gameAgentClass == null) + { + _gameAgentClass = new AndroidJavaClass(GAME_AGENT_CLASS); + } + return _gameAgentClass; + } + } + + private static void LoadCrashSightCoreSo() + { +#if UNITY_ANDROID && !UNITY_EDITOR + if (_isLoadedSo) + { + return; + } + try + { + CrashSightPlatform.CallStatic("loadCrashSightCoreSo"); + _isLoadedSo = true; + } + catch (Exception ex) + { + UQMLog.LogError("loadSo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } +#endif + } + + public static void ConfigCallbackType(Int32 callbackType) + { + try + { + UQMLog.Log("ConfigCallbackType callbackType=" + callbackType); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_configCallbackTypeAdapter(callbackType); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ConfigCallbackType with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ConfigGameType(int gameType) + { + try + { + UQMLog.Log("SetGameType gameType=" + gameType); + _gameType = gameType; + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_configGameTypeAdapter(gameType); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetGameType with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ConfigAutoReportLogLevel(int level) + { + try + { + UQMLog.Log("ConfigAutoReportLogLevel level=" + level); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_configAutoReportLogLevelAdapter(level); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ConfigCrashReporter(level); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_ConfigCrashReporter(level); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_ConfigCrashReporter(level); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ConfigAutoReportLogLevel with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ConfigCrashServerUrl(string serverUrl) + { + try + { + UQMLog.Log("ConfigCrashServerUrl serverUrl=" + serverUrl); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_configCrashServerUrlAdapter(serverUrl); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ConfigCrashServerUrl(serverUrl); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetCrashServerUrl(serverUrl); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_ConfigCrashServerUrl(serverUrl); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ConfigCrashServerUrl with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ConfigDebugMode(bool enable) + { + try + { + if (enable) + { + UQMLog.SetLevel(UQMLog.Level.Log); + } + LoadCrashSightCoreSo(); + UQMLog.Log("ConfigDebugMode enable=" + enable); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_configDebugModeAdapter(enable); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ConfigDebugMode(enable); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_EnableDebugMode(enable); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_ConfigDebugMode(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ConfigDebugMode with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ConfigDefault(string channel, string version, string user, long delay) + { + try + { + UQMLog.Log("ConfigDefault channel=" + channel + " version=" + version + " user=" + user + " delay=" + delay); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_configDefaultAdapter(channel, version, user, delay); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ConfigDefault with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void InitWithAppId(string appId, bool forceOnUiThread) + { + try + { + UQMLog.Log("InitWithAppId appId = " + appId); + LoadCrashSightCoreSo(); + if (_gameType == 0) { + ConfigGameType(2); // 默认Unity + } +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR +#if UNITY_5_3_OR_NEWER + string Vendor = SystemInfo.graphicsDeviceVendor; + string Render = SystemInfo.graphicsDeviceName; + string Version = SystemInfo.graphicsDeviceVersion; + cs_setGpuInfo(Version, Vendor, Render); +#endif + cs_initWithAppIdAdapter(appId, forceOnUiThread); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_InitWithAppId(appId); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_InitWithAppId(appId); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_InitWithAppId(appId); +#elif UNITY_OPENHARMONY && !UNITY_EDITOR + OpenHarmonyJSObject CrashSightObject = null; + CrashSightObject = new OpenHarmonyJSObject("CrashSightObj"); + CrashSightObject.Call("initContext"); + cs_initWithAppIdAdapter(appId, forceOnUiThread); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("InitWithAppId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void InitContext(string userId, string version, string key) + { + try + { + UQMLog.Log("InitContext user_id = " + userId); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_MonitorEnable(false); + CS_InitContext(userId,version, key ); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("InitWithAppId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + + public static void LogRecord(int level, string message) + { + try + { + UQMLog.Log("LogRecord level=" + level + " message=" + message); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_logRecordAdapter (level, message); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_PrintLog(level, "", "%s", message); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_PrintLog(level, "", message); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_PrintLog(level, "%s", message); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("LogRecord with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void AddSceneData(string k, string v) + { + try + { + UQMLog.Log("AddSceneData key=" + k + " value=" + v); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_addSceneDataAdapter(k, v); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetUserValue(k, v); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetUserValue(k, v); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_SetUserValue(k, v); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("AddSceneData with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportException(int type, string name, string message, string stackTrace, string extras, bool quitProgram) + { + try + { + UQMLog.Log("ReportException name=" + name + " quitProgram=" + quitProgram); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_reportExceptionAdapter (type, name, message, stackTrace, extras, null, quitProgram, 0, null); +#endif +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ReportExceptionW(type, name, message, stackTrace, extras, true, ""); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_ReportException(type, name, message, stackTrace, extras, quitProgram); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_ReportException(type, name, message, stackTrace, extras, quitProgram, 0); +#elif ( UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_reportExceptionV1Adapter (type, name, message, stackTrace, extras, quitProgram); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportException with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportException(int type, string exceptionName, string exceptionMsg, string exceptionStack, Dictionary extInfo, int dumpNativeType = 0, string errorAttachmentPath = "") + { + try + { + UQMLog.Log(string.Format("ReportException exceptionName={0} exceptionMsg={1} dumpNativeType={2}", exceptionName, exceptionMsg, dumpNativeType)); + LoadCrashSightCoreSo(); + string paramsJson = MiniJSON.Json.Serialize(extInfo); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_reportExceptionAdapter (type, exceptionName, exceptionMsg, exceptionStack, null, paramsJson, false, dumpNativeType, errorAttachmentPath); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ReportExceptionW(type, exceptionName, exceptionMsg, exceptionStack, paramsJson, true, errorAttachmentPath); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_ReportException(type, exceptionName, exceptionMsg, exceptionStack, paramsJson, false); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_ReportException(type, exceptionName, exceptionMsg, exceptionStack, paramsJson, false, dumpNativeType); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportException with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetUserId(string userId) + { + try + { + UQMLog.Log("SetUserId userId = " + userId); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_setUserIdAdapter(userId); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetUserId(userId); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetUserId(userId); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_SetUserId(userId); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetUserId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetScene(string sceneId, bool upload) + { + try + { + UQMLog.Log("SetScene sceneId = " + sceneId + ", upload = " + upload); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_setSceneAdapter(sceneId, upload); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetScene with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReRegistAllMonitors() + { + try + { + UQMLog.Log("ReRegistAllMonitors"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_reRegistAllMonitorsAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReRegistAllMonitors with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void CloseAllMonitors() + { + try + { + UQMLog.Log("CloseAllMonitors"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_closeAllMonitorsAdapter(); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_CloseCrashReport(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("CloseAllMonitors with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportLogInfo(string msgType, string msg) { + try + { + UQMLog.Log("ReportLogInfo"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_reportLogInfo(msgType, msg); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_PostLogStatics(msgType, msg); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportLogInfo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetAppVersion(string appVersion) + { + try + { + UQMLog.Log("SetAppVersion appVersion = " + appVersion); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_setAppVersionAdapter(appVersion); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetAppVersion(appVersion); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetAppVersion(appVersion); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetAppVersion with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetDeviceId(string deviceId) + { + try + { + UQMLog.Log("SetDeviceId deviceId = " + deviceId); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setDeviceIdAdapter(deviceId); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetDeviceId(deviceId); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetDeviceId(deviceId); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_SetDeviceId(deviceId); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetDeviceId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetCustomizedDeviceID(string deviceId) + { + try + { + UQMLog.Log("SetCustomizedDeviceID deviceId = " + deviceId); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setCustomizedDeviceIDAdapter(deviceId); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetCustomizedDeviceID with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static string GetSDKDefinedDeviceID() + { + try + { + UQMLog.Log("GetSDKDefinedDeviceID"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + IntPtr tranResult = cs_getSDKDefinedDeviceIDAdapter(); + return Marshal.PtrToStringAnsi(tranResult); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("GetSDKDefinedDeviceID with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return ""; + } + + + public static void SetCustomizedMatchID(string matchId) + { + try + { + UQMLog.Log("SetCustomizedMatchID matchId = " + matchId); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setCustomizedMatchIDAdapter(matchId); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetCustomizedMatchID with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static string GetSDKSessionID() + { + try + { + UQMLog.Log("GetSDKSessionID"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + IntPtr tranResult = cs_getSDKSessionIDAdapter(); + return Marshal.PtrToStringAnsi(tranResult); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("GetSDKSessionID with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return ""; + } + + public static string GetCrashUuid() + { + try + { + UQMLog.Log("GetCrashUuid"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + IntPtr tranResult = cs_getCrashUuidAdapter(); + return Marshal.PtrToStringAnsi(tranResult); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("GetCrashUuid with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return ""; + } + + public static void SetDeviceModel(string deviceModel) + { + try + { + UQMLog.Log("SetDeviceModel deviceModel = " + deviceModel); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setDeviceModelAdapter(deviceModel); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetDeviceModel with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetLogPath(string logPath) + { + try + { + UQMLog.Log("SetLogPath logPath = " + logPath); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_setLogPathAdapter(logPath); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetCustomLogDirW(logPath); +#elif (UNITY_PS4 || UNITY_PS5) && !UNITY_EDITOR + CS_SetLogPath(logPath); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_SetLogPath(logPath); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetLogPath with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetCrashCallback() + { + try + { + UQMLog.Log("SetCrashCallback"); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_unityCrashCallback(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetCrashCallback with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + + } + + public static void UnsetCrashCallback() + { + try + { + UQMLog.Log("UnsetCrashCallback"); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_unregisterUnityCrashCallback(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("UnsetCrashCallback with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + + } + + public static void SetCrashLogCallback() + { + try + { + UQMLog.Log("SetCrashLogCallback"); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_unityCrashLogCallback(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetCrashLogCallback with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + + } + + //callback + internal static string OnCrashCallbackMessage(int methodId, int crashType) + { + UQMLog.Log("OnCrashCallbackMessage methodId= " + methodId + " crashType=" + crashType); + if (CrashBaseRetEvent != null) + { + try + { + return CrashBaseRetEvent(methodId, crashType); + } + catch (Exception e) + { + UQMLog.LogError(e.StackTrace); + } + } + else + { + UQMLog.LogError("No callback for OnCrashCallbackMessage !"); + } + return ""; + } + + internal static string OnCrashCallbackData(int methodId, int crashType) + { + UQMLog.Log("OnCrashCallbackData methodId= " + methodId + " crashType=" + crashType); + if (CrashBaseRetEvent != null) + { + try + { + return CrashBaseRetEvent(methodId, crashType); + } + catch (Exception e) + { + UQMLog.LogError(e.StackTrace); + } + } + else + { + UQMLog.LogError("No callback for OnCrashCallbackData !"); + } + return ""; + } + + internal static string OnCrashSetLogPathMessage(int methodId, int crashType) + { + UQMLog.Log("OnCrashSetLogPathMessage methodId= " + methodId + " crashType=" + crashType); + if (CrashSetLogPathRetEvent != null) + { + try + { + return CrashSetLogPathRetEvent(methodId, crashType); + } + catch (Exception e) + { + UQMLog.LogError(e.StackTrace); + } + } + else + { + UQMLog.LogError("No callback for OnCrashSetLogPathMessage !"); + } + return ""; + } + + internal static string OnCrashLogUploadMessage(int methodId, int crashType, int result) + { + UQMLog.Log("OnCrashLogUploadMessage methodId= " + methodId + " crashType=" + crashType); + if (CrashLogUploadRetEvent != null) + { + try + { + CrashLogUploadRetEvent(methodId, crashType, result); + } + catch (Exception e) + { + UQMLog.LogError(e.StackTrace); + } + } + else + { + UQMLog.LogError("No callback for OnCrashLogUploadMessage !"); + } + return ""; + } + + internal static string OnCrashCallbackNoRet(int methodId, int crashType) + { + UQMLog.Log("OnCrashCallbackNoRet methodId= " + methodId + " crashType=" + crashType); + if (CrashBaseRetEvent != null) + { + try + { + return CrashBaseRetEvent(methodId, crashType); + } + catch (Exception e) + { + UQMLog.LogError(e.StackTrace); + } + } + else + { + UQMLog.LogError("No callback for OnCrashCallbackNoRet !"); + } + return ""; + } + + public static void ConfigCallBack() + { + SetCrashCallback(); + UQMMessageCenter.Instance.Init(); + } + + public static void UnregisterCallBack() + { + UnsetCrashCallback(); + UQMMessageCenter.Instance.Uninit(); + } + + public static void ConfigLogCallBack() + { + SetCrashLogCallback(); + UQMMessageCenter.Instance.Init(); + } + + // Test cases + public static void TestOomCrash() + { + try + { + UQMLog.Log("TestOomCrash"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_testOomCrashAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestOomCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void TestJavaCrash() + { + try + { + UQMLog.Log("TestJavaCrash"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_testJavaCrashAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestJavaCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void TestOcCrash() + { + try + { + UQMLog.Log("TestOcCrash"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_testOcCrashAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestOcCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void TestNativeCrash() + { + try + { + UQMLog.Log("TestNativeCrash"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_testNativeCrashAdapter(); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_TestNativeCrash(); +#elif (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_TestNativeCrash(); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_TestNativeCrash(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestNativeCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void TestANR() + { + try + { + UQMLog.Log("TestANR"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_testANRAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestANR with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + + public static long GetCrashThreadId() + { + long thread_id = -1; + try + { + UQMLog.Log("GetCrashThreadId"); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + thread_id = cs_getCrashThreadId(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("GetCrashThreadId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return thread_id; + } + + public static void SetLogcatBufferSize(int size) + { + try + { + UQMLog.Log("SetLogcatBufferSize:" + size); +#if UNITY_ANDROID && !UNITY_EDITOR + cs_setLogcatBufferSize(size); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetLogcatBufferSize with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetCallbackMsg(string data) + { + try + { + UQMLog.Log("SetCallBackMsg SetCallBackMsg = " + data); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setCallbackMsgAdapter(data); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetDeviceModel with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void StartDumpRoutine(int dumpMode, int startTimeMode, long startTime, + long dumpInterval, int dumpTimes, bool saveLocal, string savePath) + { + try + { + UQMLog.Log("StartDumpRoutine dumpMode = " + dumpMode + + ", startTimeMode = " + startTimeMode + + ", startTime = " + startTime + + ", dumpInterval = " + dumpInterval + + ", dumpTimes = " + dumpTimes + + ", saveLocal = " + saveLocal + + ", savePath = " + savePath); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_startDumpRoutine(dumpMode, startTimeMode, startTime, dumpInterval, dumpTimes, saveLocal, savePath); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("StartDumpRoutine with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void StartMonitorFdCount(int interval, int limit, int dumpType) + { + try + { + UQMLog.Log("StartMonitorFdCount interval = " + interval + + ", limit = " + limit + ", dumpType = " + dumpType); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_startMonitorFdCount(interval, limit, dumpType); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("StartMonitorFdCount with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static int getExceptionType(string name) + { + int type = 0; + try + { + UQMLog.Log("getExceptionType name = " + name); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + type = cs_getExceptionType(name); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("getExceptionType with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return type; + } + + public static void TestUseAfterFree() + { + try + { + UQMLog.Log("TestUseAfterFree"); + LoadCrashSightCoreSo(); +#if UNITY_ANDROID && !UNITY_EDITOR + cs_testUseAfterFreeAdapter(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("TestUseAfterFree with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetServerEnv(string serverEnv) + { + try + { + UQMLog.Log("SetServerEnv serverEnv = " + serverEnv); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setServerEnv(serverEnv); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetEnvironmentName(serverEnv); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetServerEnv with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetVehEnable(bool enable) + { + try + { + UQMLog.Log("SetVehEnable:" + enable); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetVehEnable(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetVehEnable with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportCrash() + { + try + { + UQMLog.Log("ReportCrash"); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ReportCrash(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportDump(string dump_path, bool is_async) + { + try + { + UQMLog.Log("ReportDump:" + dump_path + ", is_async:" + is_async); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ReportDump(dump_path, is_async); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportDump with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetExtraHandler(bool extra_handle_enable) + { + try + { + UQMLog.Log("SetExtraHandler:" + extra_handle_enable); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetExtraHandler(extra_handle_enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetExtraHandler with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void UploadGivenPathDump(string dump_dir, bool is_extra_check) + { + try + { + UQMLog.Log("UploadGivenPathDump:" + dump_dir + ", is_extra_check:" + is_extra_check); +#if (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_UploadGivenPathDump(dump_dir, is_extra_check); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("UploadGivenPathDump with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetErrorUploadInterval(int interval) + { + try + { + UQMLog.Log("SetErrorUploadInterval:" + interval); +#if (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetErrorUploadInterval(interval); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetErrorUploadInterval with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetErrorUploadEnable(bool enable) + { + try + { + UQMLog.Log("SetErrorUploadEnable:" + enable); +#if (UNITY_PS4 || UNITY_PS5 || UNITY_SWITCH) && !UNITY_EDITOR + CS_SetErrorUploadEnable(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetErrorUploadEnable with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetRecordFileDir(string record_dir) + { + try + { + UQMLog.Log("SetRecordFileDir:" + record_dir); +#if UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_SetRecordFileDir(record_dir); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetRecordFileDir with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void Init(string app_id, string app_key, string app_version) + { + try + { + UQMLog.Log("Init:" + app_id + ", app_key:" + app_key +", app_version:" + app_version); +#if UNITY_STANDALONE_LINUX && !UNITY_EDITOR + CS_Init(app_id, app_key, app_version); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("Init with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void setEnableGetPackageInfo(bool enable) + { + try + { + LoadCrashSightCoreSo(); + UQMLog.Log("setEnableGetPackageInfo enable=" + enable); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setEnableGetPackageInfo(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("setEnableGetPackageInfo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetDumpType(int dump_type) + { + try + { + UQMLog.Log("SetDumpType dump_type=" + dump_type); +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_SetDumpType(dump_type); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetDumpType with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void AddValidExpCode(ulong exp_code) + { + try + { + UQMLog.Log("AddValidExpCode exp_code=" + exp_code); +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_AddValidExpCode(exp_code); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("AddValidExpCode with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void UploadCrashWithGuid(string guid) + { + try + { + UQMLog.Log("UploadCrashWithGuid guid=" + guid); +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_UploadCrashWithGuid(guid); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("UploadCrashWithGuid with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetCrashUploadEnable(bool enable) + { + try + { + UQMLog.Log("SetCrashUploadEnable enable=" + enable); +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_SetCrashUploadEnable(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetCrashUploadEnable with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetWorkSpace(string workspace) + { + try + { + UQMLog.Log("SetWorkSpace workspace=" + workspace); +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_SetWorkSpaceW(workspace); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetWorkSpace with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetEngineInfo(string version, string buildConfig, string language, string locale) + { + try + { + UQMLog.Log("SetEngineInfo version = " + version + ", buildConfig = " + buildConfig + ", language = " + language + ", locale = " + locale); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setEngineInfo(version, buildConfig, language, locale); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_SetEngineInfo(version, buildConfig, language, locale); +#elif UNITY_STANDALONE_LINUX && !UNITY_EDITOR + cs_SetEngineInfo(version, buildConfig, language, locale); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetEngineInfo with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void setCatchMultiSignal(bool enable) + { + try + { + LoadCrashSightCoreSo(); + UQMLog.Log("setCatchMultiSignal enable=" + enable); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_setCatchMultiSignal(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("setCatchMultiSignal with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void enableDetailedPageTracing(bool enable) + { + try + { + LoadCrashSightCoreSo(); + UQMLog.Log("enableDetailedPageTracing enable=" + enable); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_enableDetailedPageTracing(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("enableDetailedPageTracing with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void useSavedUserId(bool enable) + { + try + { + LoadCrashSightCoreSo(); + UQMLog.Log("useSavedUserId enable=" + enable); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR + cs_useSavedUserId(enable); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_UseSavedUserId(enable); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("useSavedUserId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetCustomAttachDir(string path) + { +#if (UNITY_STANDALONE_WIN) && !UNITY_EDITOR + CS_SetCustomAttachDirW(path); +#endif + } + + + public static bool IsLastSessionCrash() + { + bool isCrash = false; + try + { + UQMLog.Log("IsLastSessionCrash"); +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR + isCrash = cs_isLastSessionCrash(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("IsLastSessionCrash with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return isCrash; + } + + public static string GetLastSessionUserId() + { + try + { + UQMLog.Log("GetLastSessionUserId"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR + IntPtr tranResult = cs_getLastSessionUserId(); + return Marshal.PtrToStringAnsi(tranResult); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("GetLastSessionUserId with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return ""; + } + + public static bool CheckFdCount(int limit, int dumpType, bool upload) + { + try + { + UQMLog.Log("CheckFdCount limit = " + limit + ", dumpType = " + dumpType + ", upload = " + upload); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR + return cs_checkFdCount(limit, dumpType, upload); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("CheckFdCount with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + return false; + } + + public static void SetOomLogPath(string logPath) + { + try + { + UQMLog.Log("SetOomLogPath logPath = " + logPath); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR + cs_setOomLogPath(logPath); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetOomLogPath with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportJank(int type, string exceptionName, + string exceptionMsg, string exceptionStack, + string paramsJson, int reportInfoOption, + string jankAttachmentPath) + { + try + { + UQMLog.Log("ReportJank type=" + type + + ", exceptionName=" + exceptionName + + ", exceptionMsg=" + exceptionMsg + + ", exceptionStack=" + exceptionStack + + ", paramsJson=" + paramsJson + + ", reportInfoOption=" + reportInfoOption + + ", jankAttachmentPath=" + jankAttachmentPath); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_reportJank(type, exceptionName, exceptionMsg, exceptionStack, paramsJson, reportInfoOption, jankAttachmentPath); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportJank with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ProcessEngineAnr(int type) + { + try + { + UQMLog.Log("ProcessEngineAnr type = " + type); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID) && !UNITY_EDITOR + cs_processEngineAnr(type); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ProcessEngineAnr with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void SetEngineMainThread() + { + try + { + UQMLog.Log("SetEngineMainThread"); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID) && !UNITY_EDITOR + cs_setEngineMainThread(); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("SetEngineMainThread with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + public static void ReportStuck(int threadId, int maxChecks, long checkInterval, + string name, string message, Dictionary extInfo, + int dumpNativeType, string attachPath) + { + try + { + string paramsJson = MiniJSON.Json.Serialize(extInfo); + UQMLog.Log("ReportStuck threadId=" + threadId + + ", maxChecks=" + maxChecks + + ", checkInterval=" + checkInterval + + ", name=" + name + + ", message=" + message + + ", extraInfo=" + paramsJson + + ", dumpNativeType=" + dumpNativeType + + ", attachPath=" + attachPath); + LoadCrashSightCoreSo(); +#if (UNITY_ANDROID || UNITY_IOS || UNITY_OPENHARMONY) && !UNITY_EDITOR + cs_reportStuck(threadId, maxChecks, (int)checkInterval, name, message, paramsJson, dumpNativeType, attachPath); +#elif (UNITY_STANDALONE_WIN || UNITY_XBOXONE) && !UNITY_EDITOR + CS_ReportStuck(threadId, maxChecks, (int)checkInterval, name, message, paramsJson, dumpNativeType, attachPath); +#endif + } + catch (Exception ex) + { + UQMLog.LogError("ReportStuck with unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs.meta new file mode 100644 index 00000000000..ea9c26a967d --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/UQMCrash.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23cacf0f55b6da543b1acb95f0e14ed3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils.meta new file mode 100644 index 00000000000..8b54f435101 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b52276a529d7da24182db01f818363b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs new file mode 100644 index 00000000000..a6309b9d7eb --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs @@ -0,0 +1,10 @@ +namespace GCloud.UQM +{ + public enum UQMMethodNameID + { + UQM_CRASH_CALLBACK_EXTRA_DATA = 1011, + UQM_CRASH_CALLBACK_EXTRA_MESSAGE = 1012, + UQM_CRASH_CALLBACK_SET_LOG_PATH = 1013, + UQM_CRASH_CALLBACK_LOG_UPLOAD_RESULT = 1014 + } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs.meta new file mode 100644 index 00000000000..e2900aadf23 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMDefine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 831d916e1a2a1e24abc60bb7258090ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs new file mode 100644 index 00000000000..b142462af80 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs @@ -0,0 +1,87 @@ +using System; +namespace GCloud.UQM +{ + /// + /// UQM log + /// + class UQMLog + { + /// + /// UQM SDK Log level + /// + public enum Level + { + None = 0, + Log, + Warning, + Error + } + + /// + /// The level, Error by default + /// + private static Level level = Level.Error; + + private const string header = "[CrashSightPlugin-Unity]"; + + /// + /// Sets the level. + /// + /// Level + public static void SetLevel (Level l) + { + level = l; + } + + /// + /// Log the specified message. + /// + /// Message. + public static void Log (string message) + { + if (level <= Level.Log) { + UnityEngine.Debug.Log (header + message); + } + } + + /// + /// Warning the specified message. + /// + /// Message. + public static void LogWarning (string message) + { + if (level <= Level.Warning) { + UnityEngine.Debug.LogWarning (header + message); + } + } + + /// + /// Error the specified message. + /// + /// Message. + public static void LogError (string message) + { + if (level <= Level.Error) { + UnityEngine.Debug.LogError (header + message); + } + } + + public static void FullLog (string message) + { + try { + var counter = 0; + const int step = 512; + var all = message.Length; + while (counter < all) { + var start = counter; + var length = start + step > all ? all - start : step; + //UnityEngine.Debug.LogError(header + "all : " + all + " start : " + start + " length : " + length); + UnityEngine.Debug.Log (header + message.Substring (start, length)); + counter += step; + } + } catch (Exception e) { + UnityEngine.Debug.LogWarning (e.Message); + } + } + } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs.meta new file mode 100644 index 00000000000..b36601ad3f0 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMLog.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2dacb082ac621aa4c9f4eedad0e683b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs new file mode 100644 index 00000000000..a785352413c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs @@ -0,0 +1,140 @@ +using AOT; +using System.Runtime.InteropServices; +using System.Threading; +using UnityEngine; + + +namespace GCloud.UQM +{ + public class RetArgsWrapper + { + private readonly int methodId; + private readonly int crashType; + private readonly int logUploadResult; + + public int MethodId + { + get { return methodId; } + } + + public int CrashType + { + get { return crashType; } + } + + public int LogUploadResult + { + get { return logUploadResult; } + } + + public RetArgsWrapper(int _methodId, int _crashType, int _logUploadResult) + { + methodId = _methodId; + crashType = _crashType; + logUploadResult = _logUploadResult; + } + } + + #region UQMMessageCenter + + public class UQMMessageCenter : MonoBehaviour + { + #region json ret and callback + + private static bool initialzed = false; + + private delegate string UQMRetJsonEventHandler(int methodId, int callType, int logUploadResult); + + [MonoPInvokeCallback(typeof(UQMRetJsonEventHandler))] + public static string OnUQMRet(int methodId, int crashType, int logUploadResult) + { + var argsWrapper = new RetArgsWrapper(methodId, crashType, logUploadResult); + UQMLog.Log("OnUQMRet, the methodId is ( " + methodId + " ) crashType=" + crashType); + if (methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_EXTRA_MESSAGE + || methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_EXTRA_DATA + || methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_SET_LOG_PATH + || methodId == (int)UQMMethodNameID.UQM_CRASH_CALLBACK_LOG_UPLOAD_RESULT + ) + { + lock (CrashSightAgent.callbackThreadsLock) { + CrashSightAgent.callbackThreads.Add(Thread.CurrentThread.ManagedThreadId); + } + string result = SynchronousDelegate(argsWrapper); + lock (CrashSightAgent.callbackThreadsLock) { + CrashSightAgent.callbackThreads.Remove(Thread.CurrentThread.ManagedThreadId); + } + return result; + } + return ""; + } + +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY || UNITY_STANDALONE_LINUX) && !UNITY_EDITOR + [DllImport(UQM.LibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void cs_setUnityCallback(UQMRetJsonEventHandler eventHandler); +#endif + #endregion + + static UQMMessageCenter instance; + + public static UQMMessageCenter Instance + { + get + { + if (instance != null) return instance; + var bridgeGameObject = new GameObject { name = "UQMMessageCenter" }; + DontDestroyOnLoad(bridgeGameObject); + instance = bridgeGameObject.AddComponent(typeof(UQMMessageCenter)) as UQMMessageCenter; + UQMLog.Log("UQMMessageCenter instance=" + instance); + return instance; + } + } + + public void Init() + { +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY || UNITY_STANDALONE_LINUX) && !UNITY_EDITOR + if (initialzed) { + return; + } + cs_setUnityCallback(OnUQMRet); + initialzed = true; +#endif + UQMLog.Log("UQM Init, set unity callback"); + } + + public void Uninit() + { +#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_OPENHARMONY || UNITY_STANDALONE_LINUX) && !UNITY_EDITOR + cs_setUnityCallback(null); +#endif + UQMLog.Log("UQM Uninit, set unity callback to null"); + } + + static string SynchronousDelegate(object arg) + { + var argsWrapper = (RetArgsWrapper)arg; + var methodId = argsWrapper.MethodId; + var crashType = argsWrapper.CrashType; + + UQMLog.Log("the methodId is ( " + methodId + " ) and crashType=" + crashType); + switch (methodId) + { +#if UNITY_WSA +#else + case (int)UQMMethodNameID.UQM_CRASH_CALLBACK_EXTRA_MESSAGE: + return UQMCrash.OnCrashCallbackMessage(methodId, crashType); + + case (int)UQMMethodNameID.UQM_CRASH_CALLBACK_EXTRA_DATA: + return UQMCrash.OnCrashCallbackData(methodId, crashType); + + case (int)UQMMethodNameID.UQM_CRASH_CALLBACK_SET_LOG_PATH: + return UQMCrash.OnCrashSetLogPathMessage(methodId, crashType); + + case (int)UQMMethodNameID.UQM_CRASH_CALLBACK_LOG_UPLOAD_RESULT: + return UQMCrash.OnCrashLogUploadMessage(methodId, crashType, argsWrapper.LogUploadResult); +#endif + } + return ""; + } +#endregion + } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs.meta new file mode 100644 index 00000000000..65d5ef079bf --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMessageCenter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 524f6583d96f8ef4ca16ac5cf1e72745 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs new file mode 100644 index 00000000000..e6a0dccc55c --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs @@ -0,0 +1,516 @@ +/* + * Copyright (c) 2013 Calvin Rien + * + * Based on the JSON parser by Patrick van Bergen + * http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html + * + * Simplified it so that it doesn't throw exceptions + * and can be used in Unity iOS with maximum code stripping. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace GCloud.UQM.MiniJSON +{ + + /// + /// This class encodes and decodes JSON strings. + /// Spec. details, see http://www.json.org/ + /// + /// JSON uses Arrays and Objects. These correspond here to the datatypes IList and IDictionary. + /// All numbers are parsed to doubles. + /// + public static class Json { + /// + /// Parses the string json into a value + /// + /// A JSON string. + /// An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false + public static object Deserialize(string json) { + // save the string for debug information + if (json == null) { + return null; + } + + return Parser.Parse(json); + } + + sealed class Parser : IDisposable { + const string WORD_BREAK = "{}[],:\""; + + public static bool IsWordBreak(char c) { + return Char.IsWhiteSpace(c) || WORD_BREAK.IndexOf(c) != -1; + } + + enum TOKEN { + NONE, + CURLY_OPEN, + CURLY_CLOSE, + SQUARED_OPEN, + SQUARED_CLOSE, + COLON, + COMMA, + STRING, + NUMBER, + TRUE, + FALSE, + NULL + }; + + StringReader json; + + Parser(string jsonString) { + json = new StringReader(jsonString); + } + + public static object Parse(string jsonString) { + using (var instance = new Parser(jsonString)) { + return instance.ParseValue(); + } + } + + public void Dispose() { + json.Dispose(); + json = null; + } + + Dictionary ParseObject() { + Dictionary table = new Dictionary(); + + // ditch opening brace + json.Read(); + + // { + while (true) { + switch (NextToken) { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.CURLY_CLOSE: + return table; + default: + // name + string name = ParseString(); + if (name == null) { + return null; + } + + // : + if (NextToken != TOKEN.COLON) { + return null; + } + // ditch the colon + json.Read(); + + // value + table[name] = ParseValue(); + break; + } + } + } + + List ParseArray() { + List array = new List(); + + // ditch opening bracket + json.Read(); + + // [ + var parsing = true; + while (parsing) { + TOKEN nextToken = NextToken; + + switch (nextToken) { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.SQUARED_CLOSE: + parsing = false; + break; + default: + object value = ParseByToken(nextToken); + + array.Add(value); + break; + } + } + + return array; + } + + object ParseValue() { + TOKEN nextToken = NextToken; + return ParseByToken(nextToken); + } + + object ParseByToken(TOKEN token) { + switch (token) { + case TOKEN.STRING: + return ParseString(); + case TOKEN.NUMBER: + return ParseNumber(); + case TOKEN.CURLY_OPEN: + return ParseObject(); + case TOKEN.SQUARED_OPEN: + return ParseArray(); + case TOKEN.TRUE: + return true; + case TOKEN.FALSE: + return false; + case TOKEN.NULL: + return null; + default: + return null; + } + } + + string ParseString() { + StringBuilder s = new StringBuilder(); + char c; + + // ditch opening quote + json.Read(); + + bool parsing = true; + while (parsing) { + + if (json.Peek() == -1) { + parsing = false; + break; + } + + c = NextChar; + switch (c) { + case '"': + parsing = false; + break; + case '\\': + if (json.Peek() == -1) { + parsing = false; + break; + } + + c = NextChar; + switch (c) { + case '"': + case '\\': + case '/': + s.Append(c); + break; + case 'b': + s.Append('\b'); + break; + case 'f': + s.Append('\f'); + break; + case 'n': + s.Append('\n'); + break; + case 'r': + s.Append('\r'); + break; + case 't': + s.Append('\t'); + break; + case 'u': + var hex = new char[4]; + + for (int i=0; i< 4; i++) { + hex[i] = NextChar; + } + + s.Append((char) Convert.ToInt32(new string(hex), 16)); + break; + } + break; + default: + s.Append(c); + break; + } + } + + return s.ToString(); + } + + object ParseNumber() { + string number = NextWord; + + if (number.IndexOf('.') == -1) { + long parsedInt; + Int64.TryParse(number, out parsedInt); + return parsedInt; + } + + double parsedDouble; + Double.TryParse(number, out parsedDouble); + return parsedDouble; + } + + void EatWhitespace() { + while (Char.IsWhiteSpace(PeekChar)) { + json.Read(); + + if (json.Peek() == -1) { + break; + } + } + } + + char PeekChar { + get { + return Convert.ToChar(json.Peek()); + } + } + + char NextChar { + get { + return Convert.ToChar(json.Read()); + } + } + + string NextWord { + get { + StringBuilder word = new StringBuilder(); + + while (!IsWordBreak(PeekChar)) { + word.Append(NextChar); + + if (json.Peek() == -1) { + break; + } + } + + return word.ToString(); + } + } + + TOKEN NextToken { + get { + EatWhitespace(); + + if (json.Peek() == -1) { + return TOKEN.NONE; + } + + switch (PeekChar) { + case '{': + return TOKEN.CURLY_OPEN; + case '}': + json.Read(); + return TOKEN.CURLY_CLOSE; + case '[': + return TOKEN.SQUARED_OPEN; + case ']': + json.Read(); + return TOKEN.SQUARED_CLOSE; + case ',': + json.Read(); + return TOKEN.COMMA; + case '"': + return TOKEN.STRING; + case ':': + return TOKEN.COLON; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + return TOKEN.NUMBER; + } + + switch (NextWord) { + case "false": + return TOKEN.FALSE; + case "true": + return TOKEN.TRUE; + case "null": + return TOKEN.NULL; + } + + return TOKEN.NONE; + } + } + } + + /// + /// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string + /// + /// A Dictionary<string, object> / List<object> + /// A JSON encoded string, or null if object 'json' is not serializable + public static string Serialize(object obj) { + return Serializer.Serialize(obj); + } + + sealed class Serializer { + StringBuilder builder; + + Serializer() { + builder = new StringBuilder(); + } + + public static string Serialize(object obj) { + var instance = new Serializer(); + + instance.SerializeValue(obj); + + return instance.builder.ToString(); + } + + void SerializeValue(object value) { + IList asList; + IDictionary asDict; + string asStr; + + if (value == null) { + builder.Append("null"); + } else if ((asStr = value as string) != null) { + SerializeString(asStr); + } else if (value is bool) { + builder.Append((bool) value ? "true" : "false"); + } else if ((asList = value as IList) != null) { + SerializeArray(asList); + } else if ((asDict = value as IDictionary) != null) { + SerializeObject(asDict); + } else if (value is char) { + SerializeString(new string((char) value, 1)); + } else { + SerializeOther(value); + } + } + + void SerializeObject(IDictionary obj) { + bool first = true; + + builder.Append('{'); + + foreach (object e in obj.Keys) { + if (!first) { + builder.Append(','); + } + + SerializeString(e.ToString()); + builder.Append(':'); + + SerializeValue(obj[e]); + + first = false; + } + + builder.Append('}'); + } + + void SerializeArray(IList anArray) { + builder.Append('['); + + bool first = true; + + foreach (object obj in anArray) { + if (!first) { + builder.Append(','); + } + + SerializeValue(obj); + + first = false; + } + + builder.Append(']'); + } + + void SerializeString(string str) { + builder.Append('\"'); + + char[] charArray = str.ToCharArray(); + foreach (var c in charArray) { + switch (c) { + case '"': + builder.Append("\\\""); + break; + case '\\': + builder.Append("\\\\"); + break; + case '\b': + builder.Append("\\b"); + break; + case '\f': + builder.Append("\\f"); + break; + case '\n': + builder.Append("\\n"); + break; + case '\r': + builder.Append("\\r"); + break; + case '\t': + builder.Append("\\t"); + break; + default: + int codepoint = Convert.ToInt32(c); + if ((codepoint >= 32) && (codepoint <= 126)) { + builder.Append(c); + } else { + builder.Append("\\u"); + builder.Append(codepoint.ToString("x4")); + } + break; + } + } + + builder.Append('\"'); + } + + void SerializeOther(object value) { + // NOTE: decimals lose precision during serialization. + // They always have, I'm just letting you know. + // Previously floats and doubles lost precision too. + if (value is float) { + builder.Append(((float) value).ToString("R")); + } else if (value is int + || value is uint + || value is long + || value is sbyte + || value is byte + || value is short + || value is ushort + || value is ulong) { + builder.Append(value); + } else if (value is double + || value is decimal) { + builder.Append(Convert.ToDouble(value).ToString("R")); + } else { + SerializeString(value.ToString()); + } + } + } + } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs.meta new file mode 100644 index 00000000000..228c58b33c4 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCcore/UQM/Utils/UQMMiniJSON.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5f7a61f19ec6f294a8c26f6050e199dd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight.meta new file mode 100644 index 00000000000..f1fa692ecaf --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23ccfd9225778c242b44692e9fa9540a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight.meta new file mode 100644 index 00000000000..fd0bea260c9 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e00bc6bd174cae4c869cf1b29186e43 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightAnrMonitor.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightAnrMonitor.cs new file mode 100644 index 00000000000..3e38edac514 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightAnrMonitor.cs @@ -0,0 +1,103 @@ +using GCloud.UQM; +using System; +using System.Collections; +using System.Threading; +using UnityEngine; + +public class CrashSightAnrMonitor +{ + private static CrashSightMonoBehaviour monoBehaviour = CrashSightMonoBehaviour.Instance; + private static int anrTimeoutMs = 5000; + private static int detectionTimeoutMs = 1000; + protected static bool Paused { get; private set; } = false; + private static int ticksSinceUiUpdate = 0; + private static bool reported = false; + private static bool running = false; + private static Thread thread; + + public static void Start(int timeoutMs = 5000) + { + if (running) + { + return; + } + else + { + running = true; + } + anrTimeoutMs = timeoutMs; + detectionTimeoutMs = Math.Max(1, anrTimeoutMs / 5); + + monoBehaviour.ApplicationPausing += () => Paused = true; + monoBehaviour.ApplicationResuming += () => Paused = false; + monoBehaviour.ApplicationQuitting += () => Stop(); + + thread = new Thread(Run) + { + Name = "CrashSight-ANR-Monitor", + IsBackground = true, + Priority = System.Threading.ThreadPriority.BelowNormal, + }; + thread.Start(); + + monoBehaviour.StartCoroutine(UpdateUiStatus()); + } + public static void Stop() + { + running = false; + } + + private static IEnumerator UpdateUiStatus() + { + UQMCrash.SetEngineMainThread(); + var waitForSeconds = new WaitForSecondsRealtime((float)detectionTimeoutMs / 1000); + + yield return waitForSeconds; + while (running) + { + ticksSinceUiUpdate = 0; + reported = false; + yield return waitForSeconds; + } + } + + private static void Run() + { + try + { + while (running) + { + ticksSinceUiUpdate += detectionTimeoutMs; + Thread.Sleep(detectionTimeoutMs); + + if (Paused) + { + ticksSinceUiUpdate = 0; + } + else if (ticksSinceUiUpdate >= anrTimeoutMs && !reported) + { + Report(); + reported = true; + } + } + } + catch (Exception ex) + { + UQMLog.LogError("CrashSightAnrMonitor meets an unknown error = \n" + ex.Message + "\n" + ex.StackTrace); + } + } + + private static void Report() + { + string message = $"Application not responding for at least {anrTimeoutMs} ms."; + UQMLog.Log(message); + UQMCrash.ProcessEngineAnr(1); + } +} + +public class UnityAnrException : Exception +{ + internal UnityAnrException() : base() { } + internal UnityAnrException(string message) : base(message) { } + internal UnityAnrException(string message, Exception innerException) : base(message, innerException) { } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs new file mode 100644 index 00000000000..ad3f94d2b4a --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs @@ -0,0 +1,89 @@ +// ---------------------------------------- +// +// CrashSightCallbackDelegate.cs +// +// Author: +// Yeelik, +// +// Copyright (c) 2015 CrashSight. All rights reserved. +// +// ---------------------------------------- +// +using UnityEngine; + +public abstract class CrashSightCallback +{ + private static volatile bool isQuitting = false; + private static object quitLocker = new object(); + + static CrashSightCallback() + { + // 注册应用退出事件监听器 + Application.quitting += OnApplicationQuitting; + } + + /// + /// 应用退出时的回调 + /// + private static void OnApplicationQuitting() + { + lock (quitLocker) + { + isQuitting = true; + } + } + + /// + /// 检查应用是否正在退出 + /// + public static bool IsQuitting() + { + lock (quitLocker) + { + return isQuitting; + } + } + + public abstract string OnCrashBaseRetEvent(int methodId, int crashType); + +} + +public abstract class CrashSightLogCallback +{ + private static volatile bool isQuitting = false; + private static object quitLocker = new object(); + + static CrashSightLogCallback() + { + // 注册应用退出事件监听器 + Application.quitting += OnApplicationQuitting; + } + + /// + /// 应用退出时的回调 + /// + private static void OnApplicationQuitting() + { + lock (quitLocker) + { + isQuitting = true; + } + } + + /// + /// 检查应用是否正在退出 + /// + public static bool IsQuitting() + { + lock (quitLocker) + { + return isQuitting; + } + } + + public abstract string OnSetLogPathEvent(int methodId, int crashType); + + public abstract void OnLogUploadResultEvent(int methodId, int crashType, int result); + +} + diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs.meta new file mode 100644 index 00000000000..92975eb36ce --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ba1b54454a2619141b38d419338ee9aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightMonoBehavior.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightMonoBehavior.cs new file mode 100644 index 00000000000..64bb93bd7cb --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightMonoBehavior.cs @@ -0,0 +1,59 @@ +using System; +using UnityEngine; + +[AddComponentMenu("")] +public partial class CrashSightMonoBehaviour : MonoBehaviour +{ + private static CrashSightMonoBehaviour _instance; + public static CrashSightMonoBehaviour Instance + { + get + { + if (_instance == null) + { + var gameObject = new GameObject("CrashSightMonoBehaviour") { hideFlags = HideFlags.HideAndDontSave }; + DontDestroyOnLoad(gameObject); + _instance = gameObject.AddComponent(); + } + + return _instance; + } + } + + public event Action ApplicationResuming; + + public event Action ApplicationPausing; + + public event Action ApplicationQuitting; + + internal bool _isRunning = true; + + public void UpdatePauseStatus(bool paused) + { + if (paused && _isRunning) + { + _isRunning = false; + ApplicationPausing?.Invoke(); + } + else if (!paused && !_isRunning) + { + _isRunning = true; + ApplicationResuming?.Invoke(); + } + } + + internal void OnApplicationPause(bool pauseStatus) => UpdatePauseStatus(pauseStatus); + + internal void OnApplicationFocus(bool hasFocus) => UpdatePauseStatus(!hasFocus); + + private void OnApplicationQuit() + { + ApplicationQuitting?.Invoke(); + Destroy(gameObject); + } + + private void Awake() + { + DontDestroyOnLoad(gameObject); + } +} diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs new file mode 100644 index 00000000000..d00ed5a1b82 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs @@ -0,0 +1,161 @@ +using AOT; +using System; +using System.Runtime.InteropServices; +using UnityEngine; + +// ʹǰȴENABLE_CRASHSIGHT_STACKTRACE +public class CrashSightStackTrace +{ + public static bool enable = false; + + //CrashSightStackTraceأil2cppʱ + public static void setEnable(bool enable) + { +#if ENABLE_IL2CPP && ENABLE_CRASHSIGHT_STACKTRACE + CrashSightStackTrace.enable = enable; +#endif + } + +#if UNITY_ANDROID + public const string lib = "il2cpp"; +#elif UNITY_IOS + public const string lib = "__Internal"; +#endif + +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR && ENABLE_IL2CPP && ENABLE_CRASHSIGHT_STACKTRACE + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern void il2cpp_current_thread_walk_frame_stack(Il2CppFrameWalkFunc func, IntPtr data); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_method_get_name(IntPtr method); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern int il2cpp_method_get_param_count(IntPtr method); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_method_get_class(IntPtr method); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_method_get_param(IntPtr method, int index); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_class_get_name(IntPtr klass); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_class_get_namespace(IntPtr klass); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_type_get_name(IntPtr type); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_class_get_declaring_type(IntPtr klass); + + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr il2cpp_class_from_il2cpp_type(IntPtr type); + +#if UNITY_2018_1_OR_NEWER + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern bool il2cpp_type_is_byref(IntPtr type); +#endif + + //typeṹ壬ֱӶȡָָݣܲãʹil2cppAPI + public struct Il2CppType + { + public IntPtr unionData; + public Int16 attrs; + public Byte type; + public Byte num_mods; + public bool byref() + { + return (num_mods & 64) != 0;//0b01000000 + } + }; + + public delegate void Il2CppFrameWalkFunc(IntPtr info, IntPtr user_data); + + //FrameWalkصÿδһ֡Ϣ + [MonoPInvokeCallback(typeof(Il2CppFrameWalkFunc))] + public static void Il2CppFrameWalkFuncImp(IntPtr info, IntPtr data) + { + string stackFrame = ""; + IntPtr method = (IntPtr)Marshal.PtrToStructure(info, typeof(IntPtr)); + string name = Marshal.PtrToStringAnsi(il2cpp_method_get_name(method)); + IntPtr klass = il2cpp_method_get_class(method); + string klassName = Marshal.PtrToStringAnsi(il2cpp_class_get_name(klass)); + string klassNamespaze = Marshal.PtrToStringAnsi(il2cpp_class_get_namespace(klass)); + + //ģȣִռ + if(string.IsNullOrEmpty(klassNamespaze)) + { + IntPtr declaring_type = il2cpp_class_get_declaring_type(klass); + if (declaring_type != IntPtr.Zero) + { + klassNamespaze = Marshal.PtrToStringAnsi(il2cpp_class_get_namespace(declaring_type)); + } + } + + if (!string.IsNullOrEmpty(klassNamespaze)) + stackFrame += klassNamespaze + "."; + stackFrame += klassName + ":" + name + "("; + + // + int paraCount = il2cpp_method_get_param_count(method); + for (int i = 0; i < paraCount; i++) + { + if (i != 0) + { + stackFrame += ", "; + } + IntPtr type = il2cpp_method_get_param(method, i); + IntPtr typeClass = il2cpp_class_from_il2cpp_type(type); + string typeName = Marshal.PtrToStringAnsi(il2cpp_class_get_name(typeClass)); + stackFrame += typeName; +#if UNITY_2018_1_OR_NEWER + //il2cpp_type_is_byrefʱֱʹжϲǷΪ + bool byref = il2cpp_type_is_byref(type); + if (byref) + { + stackFrame += "&"; + } +#else + //il2cpp_type_is_byrefʱָֻͨʽṹܲȫ + Il2CppType typeimpl = (Il2CppType)Marshal.PtrToStructure(type, typeof(Il2CppType)); + if (typeimpl.byref()) + { + stackFrame += "&"; + } +#endif + } + stackFrame += ")\n"; + stackTrace = stackFrame + stackTrace; + } +#endif + + static string stackTrace; + + //stacktraceڣĬʹStackTraceUtility.ExtractStackTrace()ҪsetEnableлCrashSightStackTrace + public static string ExtractStackTrace() + { + if (!enable) + { + return StackTraceUtility.ExtractStackTrace(); + } + stackTrace = string.Empty; +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR && ENABLE_IL2CPP && ENABLE_CRASHSIGHT_STACKTRACE + il2cpp_current_thread_walk_frame_stack(Il2CppFrameWalkFuncImp, new IntPtr()); + + //Щil2cpp汾il2cpp_current_thread_walk_frame_stackЩ򲻻ᣬжϲ + int line1 = stackTrace.IndexOf('\n'); + int line2 = stackTrace.IndexOf('\n', line1 + 1); + if (stackTrace.Substring(0, line1) == "CrashSightStackTrace:ExtractStackTrace()") + { + stackTrace = stackTrace.Substring(line1 + 1); + } + else + { + stackTrace = stackTrace.Substring(line2 + 1); + } +#endif + return stackTrace; + } +} \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs.meta b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs.meta new file mode 100644 index 00000000000..981cf9657d2 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/Assets/PhxhSDK/ThirdParty/CrashSight/Scripts/UQMCrashSight/CrashSight/CrashSightStackTrace.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 134a5ecbf5aa66d4d9214b3669828a24 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tool/sdk_packages/CrashSight/0.0.2/OtherConfig.yaml b/Tool/sdk_packages/CrashSight/0.0.2/OtherConfig.yaml new file mode 100644 index 00000000000..04f820cc826 --- /dev/null +++ b/Tool/sdk_packages/CrashSight/0.0.2/OtherConfig.yaml @@ -0,0 +1,2 @@ +Define_list: + - SDK_CRASHSIGHT \ No newline at end of file diff --git a/Tool/sdk_packages/CrashSight/latest.txt b/Tool/sdk_packages/CrashSight/latest.txt index 8a9ecc2ea99..7bcd0e3612d 100644 --- a/Tool/sdk_packages/CrashSight/latest.txt +++ b/Tool/sdk_packages/CrashSight/latest.txt @@ -1 +1 @@ -0.0.1 \ No newline at end of file +0.0.2 \ No newline at end of file