-
Notifications
You must be signed in to change notification settings - Fork 561
Add local date time offset monovm prop #7331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |
|
|
||
| import java.io.*; | ||
| import java.lang.String; | ||
| import java.time.OffsetDateTime; | ||
| import java.time.ZoneOffset; | ||
| import java.util.Calendar; | ||
| import java.util.Locale; | ||
| import java.util.HashSet; | ||
| import java.util.zip.*; | ||
|
|
@@ -42,6 +45,14 @@ public static void LoadApplication (Context context, ApplicationInfo runtimePack | |
| String dataDir = getNativeLibraryPath (context); | ||
| ClassLoader loader = context.getClassLoader (); | ||
| String runtimeDir = getNativeLibraryPath (runtimePackage); | ||
| int localDateTimeOffset; | ||
|
|
||
| if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { | ||
| localDateTimeOffset = OffsetDateTime.now().getOffset().getTotalSeconds(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have we tested this on an API-21 device or emulator? We may need to move this expression into a separate method; I am not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| else { | ||
| localDateTimeOffset = (Calendar.getInstance ().get (Calendar.ZONE_OFFSET) + Calendar.getInstance ().get (Calendar.DST_OFFSET)) / 1000; | ||
| } | ||
|
|
||
| // | ||
| // Should the order change here, src/monodroid/jni/SharedConstants.hh must be updated accordingly | ||
|
|
@@ -106,6 +117,7 @@ public static void LoadApplication (Context context, ApplicationInfo runtimePack | |
| apks, | ||
| runtimeDir, | ||
| appDirs, | ||
| localDateTimeOffset, | ||
| loader, | ||
| MonoPackageManager_Resources.Assemblies, | ||
| Build.VERSION.SDK_INT, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,11 @@ using namespace xamarin::android::internal; | |
| MonoVMProperties::property_array MonoVMProperties::_property_keys { | ||
| RUNTIME_IDENTIFIER_KEY, | ||
| APP_CONTEXT_BASE_DIRECTORY_KEY, | ||
| LOCAL_DATE_TIME_OFFSET_KEY, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope that one day we can replace this dynamically allocated property with a field in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much are we saving if we could leverage There isn't any convenient way to put any of the Since populating AppContext is necessary for startup to finish, would the savings done by leveraging MonoCoreRuntimeProperties over adding a new key/value pair here be greater than the cost of needing to convert it to a string property in the runtime and any possible filtering before its added to the App Context? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The biggest savings on XA side come from not having to convert an integer into a string and not duplicating that string with Also, looking at On desktop these string operations may not matter, on mobile it's an entirely different matter - every nanosecond saved counts. |
||
| }; | ||
|
|
||
| MonoVMProperties::property_array MonoVMProperties::_property_values { | ||
| SharedConstants::runtime_identifier, | ||
| nullptr, | ||
| nullptr, | ||
| }; | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grendello Is this api level bump ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is just for build time, so that the code which uses API 26 interfaces can be compiled. At runtime a check is made whether the API in question can be called. Bumping it here doesn't prevent running on older devices.