Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Samples added
Browse files Browse the repository at this point in the history
  • Loading branch information
Norne9 committed Dec 30, 2022
1 parent e1f785a commit a174ae5
Show file tree
Hide file tree
Showing 11 changed files with 3,207 additions and 25 deletions.
1 change: 0 additions & 1 deletion Runtime/IWatchdog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ internal interface IWatchdog
{
public float Timeout { get; set; }
public void StartWatchdog(float timeout);
public void RestartApp();
public string GetStacktrace();
}
}
5 changes: 0 additions & 5 deletions Runtime/Implementations/AndroidWatchdog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public void StartWatchdog(float timeout)
_watchdog.Call("startWatchdog", (long) (timeout * 1000f));
}

public void RestartApp()
{
_watchdog.Call("restartApp");
}

public string GetStacktrace()
{
return _watchdog.Call<string>("getStacktrace");
Expand Down
23 changes: 14 additions & 9 deletions Runtime/Implementations/DefaultWatchdog.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
using System.Diagnostics;
using Debug = UnityEngine.Debug;
using UnityEngine;

namespace Norne.Implementations
{
internal class DefaultWatchdog : IWatchdog
{
public float Timeout { get; set; }
private float _timeout;

public void StartWatchdog(float timeout)
public float Timeout
{
Timeout = timeout;
Debug.Log("[Watchdog] ANR Watchdog started.");
get => _timeout;
set
{
Debug.Log($"[Watchdog] Timeout set to {_timeout:F2}s");
_timeout = value;
}
}

public void RestartApp()
public void StartWatchdog(float timeout)
{
Process.GetCurrentProcess().Kill();
Timeout = timeout;

Debug.Log("[Watchdog] ANR Watchdog started.");
}

public string GetStacktrace()
{
return "";
return string.Empty;
}
}
}
15 changes: 13 additions & 2 deletions Runtime/Norne.ANRWatchdog.asmdef
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"name": "Norne.ANRWatchdog"
}
"name": "Norne.ANRWatchdog",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
Binary file modified Runtime/Plugins/Android/ANRWatchdog-release.aar
Binary file not shown.
6 changes: 3 additions & 3 deletions Runtime/Watchdog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class Watchdog
{
private static IWatchdog _watchdog;

public static float ANRTimeout
public static float Timeout
{
get
{
Expand All @@ -23,7 +23,7 @@ public static float ANRTimeout
return;
}

_watchdog.Timeout = value;
if (Mathf.Abs(value - _watchdog.Timeout) > 0.01f) _watchdog.Timeout = value;
}
}

Expand All @@ -37,7 +37,7 @@ private static void Start()
#else
_watchdog = new DefaultWatchdog();
#endif
_watchdog.StartWatchdog(7f);
_watchdog.StartWatchdog(9f);
}

public static bool TryGetStacktrace(out string stacktrace)
Expand Down
Loading

0 comments on commit a174ae5

Please sign in to comment.