-
Notifications
You must be signed in to change notification settings - Fork 541
/
Copy pathRuntime.cs
51 lines (42 loc) · 1.25 KB
/
Runtime.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Android.Runtime;
namespace Java.Interop {
public static class Runtime {
[Obsolete ("Please use Java.Interop.JniEnvironment.Runtime.ValueManager.GetSurfacedPeers()")]
public static List<WeakReference> GetSurfacedObjects ()
{
var peers = JNIEnvInit.ValueManager!.GetSurfacedPeers ();
var r = new List<WeakReference> (peers.Count);
foreach (var p in peers) {
if (p.SurfacedPeer.TryGetTarget (out var target))
r.Add (new WeakReference (target, trackResurrection: true));
}
return r;
}
public static int MaxGlobalReferenceCount {
get {return RuntimeNativeMethods._monodroid_max_gref_get ();}
}
public static int GlobalReferenceCount {
get {return RuntimeNativeMethods._monodroid_gref_get ();}
}
public static int LocalReferenceCount {
#if JAVA_INTEROP
get {return JniEnvironment.LocalReferenceCount;}
#else // !JAVA_INTEROP
get {return JNIEnv.lref_count;}
#endif // !JAVA_INTEROP
}
public static bool IsGCUserPeer (IJavaObject value)
{
if (value == null)
return false;
return IsGCUserPeer (value.Handle);
}
public static bool IsGCUserPeer (IntPtr value)
{
return JNIEnv.IsGCUserPeer (value);
}
}
}