Skip to content

Obsolete code referring to System.AndroidPlatform #10381

@filipnavara

Description

@filipnavara

Lot of the managed code still contains references to System.AndroidPlatform which was part of Mono Android runtime. This was never used in modern .NET and hence the APIs can be removed.

This includes the following managed code and it's dependencies, both native and managed:

// This is invoked by
// System.Drawing!System.Drawing.GraphicsAndroid.FromAndroidSurface ()
// DO NOT REMOVE
//
// Exception audit:
//
// Verdict
// No need to wrap thrown exceptions in a BCL class
//
// Rationale
// No longer called by the indicated caller, however we keep it for backward compatibility.
[global::System.Runtime.Versioning.ObsoletedOSPlatform ("android31.0")]
static void GetDisplayDPI (out float x_dpi, out float y_dpi)
{
var wm = Application.Context.GetSystemService (Context.WindowService).JavaCast <IWindowManager> ();
var metrics = new DisplayMetrics ();
#if ANDROID_17
wm?.DefaultDisplay?.GetRealMetrics (metrics);
#else
wm.DefaultDisplay.GetMetrics (metrics);
#endif
x_dpi = metrics.Xdpi;
y_dpi = metrics.Ydpi;
}
// This is invoked by
// System.Core!System.AndroidPlatform.GetDefaultTimeZone ()
// DO NOT REMOVE
//
// Exception audit:
//
// Verdict
// No need to wrap thrown exceptions in a BCL class
//
// Rationale
// Java code (invoked from our native runtime) will always return the default timezone and no
// exceptions are documented for the Java API.
//
static string GetDefaultTimeZone ()
{
IntPtr id = RuntimeNativeMethods._monodroid_timezone_get_default_id ();
try {
return Marshal.PtrToStringAnsi (id)!;
} finally {
RuntimeNativeMethods.monodroid_free (id);
}
}
// This is invoked by
// mscorlib.dll!System.AndroidPlatform.GetDefaultSyncContext()
// DO NOT REMOVE
static SynchronizationContext? GetDefaultSyncContext ()
{
var looper = Android.OS.Looper.MainLooper;
try {
if (Android.OS.Looper.MyLooper() == looper)
return Android.App.Application.SynchronizationContext;
} catch (System.Exception ex) {
Logger.Log (LogLevel.Warn, "MonoAndroid", $"GetDefaultSyncContext caught a Java exception: {ex}");
}
return null;
}
// These are invoked by
// System.dll!System.AndroidPlatform.getifaddrs
// DO NOT REMOVE
static int GetInterfaceAddresses (out IntPtr ifap)
{
return RuntimeNativeMethods._monodroid_getifaddrs (out ifap);
}
// These are invoked by
// System.dll!System.AndroidPlatform.freeifaddrs
// DO NOT REMOVE
static void FreeInterfaceAddresses (IntPtr ifap)
{
RuntimeNativeMethods._monodroid_freeifaddrs (ifap);
}

// This is invoked by
// System.dll!System.AndroidPlatform.GetDefaultProxy()
// DO NOT REMOVE
static IWebProxy GetDefaultProxy ()
{
#if ANDROID_14
return new _Proxy ();
#else
return null;
#endif
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions