-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Microsoft.Android.Sdk.ILLink] fix crash when TZ changes
Fixes: #7953 When a timezone changes in a `Release` app, it can crash with: [monodroid] Unable to find Android.Runtime.AndroidEnvironment.NotifyTimeZoneChanged()! In 11f0e1b, we removed the line: <?xml version="1.0" encoding="utf-8" ?> <linker> <assembly fullname="Mono.Android"> -- <type fullname="Android.Runtime.AndroidEnvironment" /> Unfortunately, this method is called from native code, so we need to *always* preserve it. Added a test for this scenario, we may want to audit all `mono_class_get_method_from_name` calls and add more tests cases. I also cleaned up the tests a bit with a `getResource()` local function.
- Loading branch information
1 parent
ecb207b
commit f1bbe36
Showing
4 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/MSBuildDeviceIntegration/Resources/LinkDescTest/PreserveTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
public class PreserveTest | ||
{ | ||
// [Test] | ||
public static string MethodsArePreserved () | ||
{ | ||
try { | ||
// See src/monodroid/jni/timezones.cc for usage | ||
var androidEnvironment = Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", throwOnError: true); | ||
var notifyTimeZoneChanged = androidEnvironment.GetMethod ("NotifyTimeZoneChanged", BindingFlags.Static | BindingFlags.NonPublic); | ||
if (notifyTimeZoneChanged == null) { | ||
return $"[FAIL] {nameof (PreserveTest)}.{nameof (MethodsArePreserved)} FAILED: {nameof (notifyTimeZoneChanged)} is null)"; | ||
} | ||
notifyTimeZoneChanged.Invoke (null, null); | ||
return $"[PASS] {nameof (PreserveTest)}.{nameof (MethodsArePreserved)}"; | ||
} catch (Exception ex) { | ||
return $"[FAIL] {nameof (PreserveTest)}.{nameof (MethodsArePreserved)} FAILED: {ex}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters