Skip to content

Commit

Permalink
Remove Kernel Monotonic Time app context key
Browse files Browse the repository at this point in the history
  • Loading branch information
mdh1418 committed Aug 23, 2022
1 parent 96bf37f commit 582c359
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,10 @@ internal static TimeSpan GetLocalUtcOffset(DateTime dateTime, TimeZoneInfoOption
}

object? localDateTimeOffset = AppContext.GetData("LOCAL_DATE_TIME_OFFSET");
int localDateTimeOffsetSeconds;
if (localDateTimeOffset != null)
localDateTimeOffsetSeconds = Convert.ToInt32(localDateTimeOffset);
else
{
throw new Exception ("LOCAL_DATE_TIME_OFFSET NOT SET");
}
long localDateTimeOffsetTicks = localDateTimeOffsetSeconds * 10000000; // 10^7 ticks per second
if (localDateTimeOffset == null)
throw new Exception("LOCAL_DATE_TIME_OFFSET NOT SET");
long localDateTimeOffsetTicks = Convert.ToInt32(localDateTimeOffset) * 10000000; // 10^7 ticks per second

TimeSpan offset = TimeSpan.FromSeconds(localDateTimeOffsetSeconds);
return offset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ typedef struct {

typedef struct {
uint64_t current_local_time;
uint64_t kernel_monotonic_clock;
} MonoCoreLocalTime;

typedef struct {
Expand Down
25 changes: 6 additions & 19 deletions src/tasks/AndroidAppBuilder/Templates/monodroid.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,33 +225,20 @@ mono_droid_runtime_init (const char* executable, int managed_argc, char* managed

// TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES

const char* appctx_keys[4];
const char* appctx_keys[3];
appctx_keys[0] = "RUNTIME_IDENTIFIER";
appctx_keys[1] = "APP_CONTEXT_BASE_DIRECTORY";
appctx_keys[2] = "LOCAL_DATE_TIME_OFFSET";
appctx_keys[3] = "KERNEL_MONOTONIC_CLOCK";

const char* appctx_values[4];
const char* appctx_values[3];
appctx_values[0] = ANDROID_RUNTIME_IDENTIFIER;
appctx_values[1] = bundle_path;
char buffer_one[32];
snprintf (buffer_one, sizeof(buffer_one), "%d", local_date_time_offset);
appctx_values[2] = strdup (buffer_one);
char buffer_two[64];
struct timespec ts;
int result = clock_gettime (CLOCK_MONOTONIC, &ts);
int64_t kernel_monotonic_clock;
if (result == 0)
{
kernel_monotonic_clock = (int64_t)(ts.tv_sec * (int64_t)(1000000000)) + (int64_t)(ts.tv_nsec);
snprintf (buffer_two, sizeof(buffer_two), "%ld", kernel_monotonic_clock);
}
const char* mitch_two = strdup (buffer_two);
appctx_values[3] = mitch_two;
char local_date_time_offset_buffer[32];
snprintf (local_date_time_offset_buffer, sizeof(local_date_time_offset_buffer), "%d", local_date_time_offset);
appctx_values[2] = strdup (local_date_time_offset_buffer);

MonoCoreLocalTime mclt = {
local_date_time_offset,
kernel_monotonic_clock,
};
MonoCoreRuntimeProperties mcrp = {
&mclt,
Expand All @@ -275,7 +262,7 @@ mono_droid_runtime_init (const char* executable, int managed_argc, char* managed
free (file_path);
}

monovm_initialize_preparsed(&mcrp, 4, appctx_keys, appctx_values);
monovm_initialize_preparsed(&mcrp, 3, appctx_keys, appctx_values);

mono_debug_init (MONO_DEBUG_FORMAT_MONO);
mono_install_assembly_preload_hook (mono_droid_assembly_preload_hook, NULL);
Expand Down

0 comments on commit 582c359

Please sign in to comment.