Commit 837ca0d
committed
[Microsoft.Android.Sdk.ILLink] fix crash when TZ changes (#7956)
Fixes: #7953
Context: 11f0e1b
When a timezone changes in a `Release` config app, it can crash with:
[monodroid] Unable to find Android.Runtime.AndroidEnvironment.NotifyTimeZoneChanged()!
In commit 11f0e1b, we removed the line:
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="Mono.Android">
-- <type fullname="Android.Runtime.AndroidEnvironment" />
Unfortunately, `AndroidEnvironment.NotifyTimeZoneChanged()` is called
from non-managed code, via:
* The `NotifyTimeZoneChanges` broadcast receiver
(in `src/java-runtime/java/mono/android/app/NotifyTimeZoneChanges.java`)
which calls-
* The `Rutime.notifyTimeZoneChanged()` `native` method
(in `src/java-runtime/java/mono/android/Runtime.java`),
implemented in-
* `Java_mono_android_Runtime_notifyTimeZoneChanged()`
(in`src/monodroid/jni/timezones.cc`).
The managed linker cannot "see" any of these references, so we
need to *always* preserve this method, as it is always callable.
Update `src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml`
so that `Android.Runtime.AndroidEnvironment.NotifyTimeZoneChanged()`
is always preserved.
Added a test for this scenario.
TODO: 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.1 parent a693bc5 commit 837ca0d
File tree
4 files changed
+42
-20
lines changed- src/Microsoft.Android.Sdk.ILLink/PreserveLists
- tests/MSBuildDeviceIntegration
- Resources/LinkDescTest
- Tests
4 files changed
+42
-20
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 14 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
| 386 | + | |
390 | 387 | | |
391 | 388 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
| 389 | + | |
396 | 390 | | |
397 | 391 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
402 | 396 | | |
403 | 397 | | |
404 | 398 | | |
| |||
407 | 401 | | |
408 | 402 | | |
409 | 403 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 404 | + | |
414 | 405 | | |
415 | 406 | | |
416 | 407 | | |
| |||
433 | 424 | | |
434 | 425 | | |
435 | 426 | | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
| 427 | + | |
440 | 428 | | |
441 | 429 | | |
442 | 430 | | |
| |||
500 | 488 | | |
501 | 489 | | |
502 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
503 | 497 | | |
504 | 498 | | |
505 | 499 | | |
| |||
0 commit comments