diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-12-11 14:38:43 +0000 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-12-11 18:06:33 +0100 |
commit | 7241382ccc0a028c5f08304090a6344e582db068 (patch) | |
tree | 28b80b9622bc756b685a28346bd7b9e3b93b9d10 /vcl/android | |
parent | 23c8830da611d14dbffc2022efac28203352f6b9 (diff) |
android: add abstraction to allow us to DetachThread sensibly.
If we fail to do this after runLoop - some Android VMs can get really
upset if we quit a thread without doing this, also ensure that we
AttachThread to new polling loop threads as we come in for good
measure - duplicate Attach's are NOPs.
Change-Id: I32454773af4e02c97df0b6c02f61b1dc74df80b0
Reviewed-on: https://gerrit.libreoffice.org/84956
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'vcl/android')
-rw-r--r-- | vcl/android/androidinst.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx index da3889145bb7..1cb11bd7c1e5 100644 --- a/vcl/android/androidinst.cxx +++ b/vcl/android/androidinst.cxx @@ -58,10 +58,12 @@ AndroidSalInstance *AndroidSalInstance::getInstance() AndroidSalInstance::AndroidSalInstance( std::unique_ptr<SalYieldMutex> pMutex ) : SvpSalInstance( std::move(pMutex) ) { + // FIXME: remove when uniPoll & runLoop is the only android entry poit. int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL); LOGI("AttachCurrentThread res=%d env=%p", res, m_pJNIEnv); } +// This is never called on Android until app exit. AndroidSalInstance::~AndroidSalInstance() { int res = (lo_get_javavm())->DetachCurrentThread(); @@ -79,6 +81,21 @@ bool AndroidSalInstance::AnyInput( VclInputFlags nType ) return SvpSalInstance::s_pDefaultInstance->HasUserEvents(); } +void AndroidSalInstance::updateMainThread() +{ + int res = (lo_get_javavm())->AttachCurrentThread(&m_pJNIEnv, NULL); + LOGI("updateMainThread AttachCurrentThread res=%d env=%p", res, m_pJNIEnv); + SvpSalInstance::updateMainThread(); +} + +void AndroidSalInstance::releaseMainThread() +{ + int res = (lo_get_javavm())->DetachCurrentThread(); + LOGI("releaseMainThread DetachCurrentThread res=%d", res); + + SvpSalInstance::releaseMainThread(); +} + class AndroidSalSystem : public SvpSalSystem { public: AndroidSalSystem() : SvpSalSystem() {} |