2020-08-18 20:46:26 +00:00
|
|
|
// Copyright 2020, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Functions for Android-specific global state.
|
|
|
|
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
|
2020-10-13 20:09:37 +00:00
|
|
|
* @ingroup aux_android
|
2020-08-18 20:46:26 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-19 20:56:38 +00:00
|
|
|
#include "android_globals.h"
|
2020-08-18 20:46:26 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @todo Do we need locking here? Do we need to create global refs for the
|
|
|
|
* supplied jobjects?
|
|
|
|
*/
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
struct _JavaVM *vm;
|
|
|
|
void *activity;
|
|
|
|
void *context;
|
|
|
|
} android_globals = {NULL, NULL, NULL};
|
|
|
|
|
|
|
|
void
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_store_vm_and_activity(struct _JavaVM *vm, void *activity)
|
2020-08-18 20:46:26 +00:00
|
|
|
{
|
|
|
|
android_globals.vm = vm;
|
|
|
|
android_globals.activity = activity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_store_vm_and_context(struct _JavaVM *vm, void *context)
|
2020-08-18 20:46:26 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
android_globals.vm = vm;
|
|
|
|
android_globals.context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct _JavaVM *
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_get_vm()
|
2020-08-18 20:46:26 +00:00
|
|
|
{
|
|
|
|
return android_globals.vm;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_get_activity()
|
2020-08-18 20:46:26 +00:00
|
|
|
{
|
|
|
|
return android_globals.activity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_get_context()
|
2020-08-18 20:46:26 +00:00
|
|
|
{
|
|
|
|
void *ret = android_globals.context;
|
|
|
|
if (ret == NULL) {
|
|
|
|
ret = android_globals.activity;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|