-
Notifications
You must be signed in to change notification settings - Fork 7
/
SharedObjectLoader.kt
35 lines (31 loc) · 1001 Bytes
/
SharedObjectLoader.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package io.embrace.android.embracesdk.internal
import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger
import java.util.concurrent.atomic.AtomicBoolean
/**
* Component to load native binaries
*/
internal class SharedObjectLoader {
val loaded = AtomicBoolean(false)
/**
* Load Embrace native binary if necessary
*/
fun loadEmbraceNative(): Boolean {
if (loaded.get()) {
return true
}
synchronized(loaded) {
if (!loaded.get()) {
try {
Systrace.traceSynchronous("load-embrace-native-lib") {
System.loadLibrary("embrace-native")
}
loaded.set(true)
} catch (exc: UnsatisfiedLinkError) {
InternalStaticEmbraceLogger.logError("Failed to load SO file embrace-native", exc)
return false
}
}
return true
}
}
}