Skip to content

Commit c930321

Browse files
committed
[WIP] See if we can drop __Internal
The .NET5 version of the Mono runtime "hijacked" `__Internal` for its own purposes and the change causes us trouble when trying to resolve p/invokes from our managed code to our runtime. See if we can use `monodroid` for this purpose.
1 parent d97ae6a commit c930321

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/Mono.Android/Android.Runtime/AndroidEnvironment.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static string GetDefaultTimeZone ()
283283
}
284284
}
285285

286-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
286+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
287287
static extern IntPtr _monodroid_timezone_get_default_id ();
288288

289289
// This is invoked by
@@ -304,7 +304,7 @@ static string GetDefaultTimeZone ()
304304
// These are invoked by
305305
// System.dll!System.AndroidPlatform.getifaddrs
306306
// DO NOT REMOVE
307-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
307+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
308308
static extern int _monodroid_getifaddrs (out IntPtr ifap);
309309

310310
static int GetInterfaceAddresses (out IntPtr ifap)
@@ -315,15 +315,15 @@ static int GetInterfaceAddresses (out IntPtr ifap)
315315
// These are invoked by
316316
// System.dll!System.AndroidPlatform.freeifaddrs
317317
// DO NOT REMOVE
318-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
318+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
319319
static extern void _monodroid_freeifaddrs (IntPtr ifap);
320320

321321
static void FreeInterfaceAddresses (IntPtr ifap)
322322
{
323323
_monodroid_freeifaddrs (ifap);
324324
}
325325

326-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
326+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
327327
static extern void _monodroid_detect_cpu_and_architecture (ref ushort built_for_cpu, ref ushort running_on_cpu, ref byte is64bit);
328328

329329
static void DetectCPUAndArchitecture (out ushort builtForCPU, out ushort runningOnCPU, out bool is64bit)

src/Mono.Android/Android.Runtime/AndroidRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public AndroidRuntimeOptions (IntPtr jnienv,
100100

101101
class AndroidObjectReferenceManager : JniRuntime.JniObjectReferenceManager {
102102

103-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
103+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
104104
static extern int _monodroid_gref_get ();
105105

106106
public override int GlobalReferenceCount {

src/Mono.Android/Android.Runtime/JNIEnv.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ public static partial class JNIEnv {
6666

6767
internal static AndroidValueManager? AndroidValueManager;
6868

69-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
69+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
7070
extern static void monodroid_log (LogLevel level, LogCategories category, string message);
7171

72-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
72+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
7373
internal extern static IntPtr monodroid_timing_start (string? message);
7474

75-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
75+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
7676
internal extern static void monodroid_timing_stop (IntPtr sequence, string? message);
7777

78-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
78+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
7979
internal extern static void monodroid_free (IntPtr ptr);
8080

8181
public static IntPtr Handle {
@@ -292,7 +292,7 @@ internal static void PropagateUncaughtException (IntPtr env, IntPtr javaThreadPt
292292
}
293293
}
294294

295-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
295+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
296296
extern static void _monodroid_gc_wait_for_bridge_processing ();
297297

298298
#pragma warning disable CS0649 // Field is never assigned to. This field is assigned from monodroid-glue.cc.
@@ -306,7 +306,7 @@ public static void WaitForBridgeProcessing ()
306306
_monodroid_gc_wait_for_bridge_processing ();
307307
}
308308

309-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
309+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
310310
extern static IntPtr _monodroid_get_identity_hash_code (IntPtr env, IntPtr value);
311311

312312
internal static Func<IntPtr, IntPtr>? IdentityHash;
@@ -593,25 +593,25 @@ internal static void DeleteRef (IntPtr handle, JniHandleOwnership transfer)
593593
}
594594
}
595595

596-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
596+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
597597
internal static extern int _monodroid_gref_log (string message);
598598

599-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
599+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
600600
internal static extern int _monodroid_gref_log_new (IntPtr curHandle, byte curType, IntPtr newHandle, byte newType, string? threadName, int threadId, [In] StringBuilder? from, int from_writable);
601601

602-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
602+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
603603
internal static extern void _monodroid_gref_log_delete (IntPtr handle, byte type, string? threadName, int threadId, [In] StringBuilder? from, int from_writable);
604604

605-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
605+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
606606
internal static extern void _monodroid_weak_gref_new (IntPtr curHandle, byte curType, IntPtr newHandle, byte newType, string? threadName, int threadId, [In] StringBuilder? from, int from_writable);
607607

608-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
608+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
609609
internal static extern void _monodroid_weak_gref_delete (IntPtr handle, byte type, string? threadName, int threadId, [In] StringBuilder? from, int from_writable);
610610

611-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
611+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
612612
internal static extern int _monodroid_lref_log_new (int lrefc, IntPtr handle, byte type, string? threadName, int threadId, [In] StringBuilder from, int from_writable);
613613

614-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
614+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
615615
internal static extern void _monodroid_lref_log_delete (int lrefc, IntPtr handle, byte type, string? threadName, int threadId, [In] StringBuilder from, int from_writable);
616616

617617
public static IntPtr NewGlobalRef (IntPtr jobject)

src/Mono.Android/Android.Runtime/Logger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void Log (LogLevel level, string appname, string? log) {
6060
}
6161
}
6262

63-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
63+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
6464
extern static uint monodroid_get_log_categories ();
6565

6666
static Logger ()

src/Mono.Android/Java.Interop/Runtime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public static List<WeakReference> GetSurfacedObjects ()
2020
return r;
2121
}
2222

23-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
23+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
2424
static extern int _monodroid_max_gref_get ();
2525

2626
public static int MaxGlobalReferenceCount {
2727
get {return _monodroid_max_gref_get ();}
2828
}
2929

30-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
30+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
3131
static extern int _monodroid_gref_get ();
3232

3333
public static int GlobalReferenceCount {

src/Mono.Android/Java.Interop/TypeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static Dictionary<Type, string> ManagedToJni {
3838
}
3939

4040
public static partial class TypeManager {
41-
[DllImport ("__Internal", CallingConvention = CallingConvention.Cdecl)]
41+
[DllImport ("monodroid", CallingConvention = CallingConvention.Cdecl)]
4242
extern static IntPtr monodroid_TypeManager_get_java_class_name (IntPtr klass);
4343

4444
internal static string GetClassName (IntPtr class_ptr)

0 commit comments

Comments
 (0)