Improve: Lazy load xorg libraries

This commit is contained in:
zt515 2017-12-01 19:07:19 +08:00
parent 4516d9ee2a
commit 5015f9dcba

View File

@ -65,18 +65,21 @@ class SessionComponent : NeoComponent {
return result
}
}
override fun onServiceInit() {
if (!IS_LIBRARIES_LOADED) {
synchronized(SessionComponent::class.java) {
if (!IS_LIBRARIES_LOADED) {
IS_LIBRARIES_LOADED = loadLibraries()
private fun checkLibrariesLoaded() {
if (!IS_LIBRARIES_LOADED) {
synchronized(SessionComponent::class.java) {
if (!IS_LIBRARIES_LOADED) {
IS_LIBRARIES_LOADED = loadLibraries()
}
}
}
}
}
override fun onServiceInit() {
}
override fun onServiceDestroy() {
}
@ -85,6 +88,7 @@ class SessionComponent : NeoComponent {
fun createSession(context: Context, parameter: XParameter): XSession {
if (context is Activity) {
checkLibrariesLoaded()
return XSession(context, XSessionData())
}
throw RuntimeException("Creating X sessions requires Activity, but got Context")