diff options
-rw-r--r-- | vcl/Library_vcl.mk | 5 | ||||
-rw-r--r-- | vcl/android/androidinst.cxx | 70 | ||||
-rw-r--r-- | vcl/headless/svpinst.cxx | 45 | ||||
-rw-r--r-- | vcl/inc/android/androidinst.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 3 |
5 files changed, 87 insertions, 42 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 39836080935b..fa6093ee6eca 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -431,6 +431,11 @@ $(eval $(call gb_Library_use_externals,vcl,\ endif ifeq ($(GUIBASE),android) +$(eval $(call gb_Library_add_libs,vcl,\ + -llog \ + -landroid \ + -llo-bootstrap \ +)) $(eval $(call gb_Library_add_defs,vcl,\ -DSAL_DLLPREFIX=\"$(gb_Library_SYSPRE)\" \ -DSAL_DLLPOSTFIX=\"$(gb_Library_OOOEXT)\" \ diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx index 6a1bbcd7a7a5..91971e66ee2b 100644 --- a/vcl/android/androidinst.cxx +++ b/vcl/android/androidinst.cxx @@ -30,11 +30,15 @@ #include <headless/svpdummies.hxx> #include <generic/gendata.hxx> #include <android/log.h> +#include <android/looper.h> +#include <osl/detail/android.h> AndroidSalInstance::AndroidSalInstance( SalYieldMutex *pMutex ) : SvpSalInstance( pMutex ) { - fprintf (stderr, "created Android Sal Instance\n"); + fprintf (stderr, "created Android Sal Instance for app %p window %p\n", + global_android_app, + global_android_app ? global_android_app->window : NULL); } AndroidSalInstance::~AndroidSalInstance() @@ -42,6 +46,34 @@ AndroidSalInstance::~AndroidSalInstance() fprintf (stderr, "destroyed Android Sal Instance\n"); } +void AndroidSalInstance::Wakeup() +{ + if (global_android_app && global_android_app->looper) + ALooper_wake (global_android_app->looper); + else + fprintf (stderr, "busted - no global looper\n"); +} + +void AndroidSalInstance::DoReleaseYield (int nTimeoutMS) +{ + // release yield mutex + sal_uLong nAcquireCount = ReleaseYieldMutex(); + + fprintf (stderr, "DoReleaseYield for %d ms\n", nTimeoutMS); +// int ALooper_pollOnce(timeoutMs, int* outFd, int* outEvents, void** outData); + + // acquire yield mutex again + AcquireYieldMutex(nAcquireCount); +} + +bool AndroidSalInstance::AnyInput( sal_uInt16 nType ) +{ + // FIXME: ideally we should check the input queue to avoid being busy ... + fprintf (stderr, "FIXME: AnyInput returns true\n"); + // global_android_app->inputQueue ? ... + return true; +} + class AndroidSalSystem : public SvpSalSystem { public: AndroidSalSystem() : SvpSalSystem() {} @@ -52,14 +84,9 @@ public: int nDefButton ) { (void)rButtons; (void)nDefButton; -#if 0 __android_log_print(ANDROID_LOG_INFO, "LibreOffice - dialog '%s': '%s'", rtl::OUStringToOString(rTitle, RTL_TEXTENCODING_ASCII_US).getStr(), rtl::OUStringToOString(rMessage, RTL_TEXTENCODING_ASCII_US).getStr()); -#endif - fprintf (stderr, "LibreOffice - dialog '%s': '%s'", - rtl::OUStringToOString(rTitle, RTL_TEXTENCODING_ASCII_US).getStr(), - rtl::OUStringToOString(rMessage, RTL_TEXTENCODING_ASCII_US).getStr()); return 0; } }; @@ -77,19 +104,6 @@ public: virtual bool ErrorTrapPop( bool ) { return false; } }; -SalInstance *CreateSalInstance() -{ - AndroidSalInstance* pInstance = new AndroidSalInstance( new SalYieldMutex() ); - new AndroidSalData( pInstance ); - return pInstance; -} - -void DestroySalInstance( SalInstance *pInst ) -{ - pInst->ReleaseYieldMutex(); - delete pInst; -} - // All the interesting stuff is slaved from the AndroidSalInstance void InitSalData() {} void DeInitSalData() {} @@ -103,12 +117,8 @@ void SalAbort( const rtl::OUString& rErrorText, bool bDumpCore ) aError = rtl::OUString::createFromAscii("Unknown application error"); ::fprintf( stderr, "%s\n", rtl::OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() ); -#if 0 __android_log_print(ANDROID_LOG_INFO, "SalAbort: '%s'", rtl::OUStringToOString(aError, RTL_TEXTENCODING_ASCII_US).getStr()); -#endif - fprintf( stderr, "SalAbort: '%s'", - rtl::OUStringToOString(aError, RTL_TEXTENCODING_ASCII_US).getStr() ); if( bDumpCore ) abort(); else @@ -132,4 +142,18 @@ SalData::~SalData() { } +// This is our main entry point: +SalInstance *CreateSalInstance() +{ + AndroidSalInstance* pInstance = new AndroidSalInstance( new SalYieldMutex() ); + new AndroidSalData( pInstance ); + return pInstance; +} + +void DestroySalInstance( SalInstance *pInst ) +{ + pInst->ReleaseYieldMutex(); + delete pInst; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 9de3f8259968..56ea818af6bc 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -325,25 +325,32 @@ void SvpSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) else nTimeoutMS = -1; // wait until something happens - // release yield mutex - nAcquireCount = ReleaseYieldMutex(); - // poll - struct pollfd aPoll; - aPoll.fd = m_pTimeoutFDS[0]; - aPoll.events = POLLIN; - aPoll.revents = 0; - poll( &aPoll, 1, nTimeoutMS ); - - // acquire yield mutex again - AcquireYieldMutex( nAcquireCount ); - - // clean up pipe - if( (aPoll.revents & POLLIN) != 0 ) - { - int buffer; - while (read (m_pTimeoutFDS[0], &buffer, sizeof(buffer)) > 0) - continue; - } + DoReleaseYield(nTimeoutMS); + } +} + +void SvpSalInstance::DoReleaseYield( int nTimeoutMS ) +{ + // poll + struct pollfd aPoll; + aPoll.fd = m_pTimeoutFDS[0]; + aPoll.events = POLLIN; + aPoll.revents = 0; + + // release yield mutex + sal_uLong nAcquireCount = ReleaseYieldMutex(); + + poll( &aPoll, 1, nTimeoutMS ); + + // acquire yield mutex again + AcquireYieldMutex( nAcquireCount ); + + // clean up pipe + if( (aPoll.revents & POLLIN) != 0 ) + { + int buffer; + while (read (m_pTimeoutFDS[0], &buffer, sizeof(buffer)) > 0) + continue; } } diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx index fda916baadcc..a5c69b0f419a 100644 --- a/vcl/inc/android/androidinst.hxx +++ b/vcl/inc/android/androidinst.hxx @@ -39,6 +39,12 @@ public: virtual ~AndroidSalInstance(); virtual SalSystem* CreateSalSystem(); + + // mainloop pieces + virtual void Wakeup(); + virtual bool AnyInput( sal_uInt16 nType ); +protected: + virtual void DoReleaseYield( int nTimeoutMS ); }; #endif // ANDROID_SALINST_H diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index 605f0ae53bed..92b989f80dc0 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -95,6 +95,9 @@ class SvpSalInstance : public SalGenericInstance bool isFrameAlive( const SalFrame* pFrame ) const; +protected: + virtual void DoReleaseYield( int nTimeoutMS ); + public: static SvpSalInstance* s_pDefaultInstance; |