Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ All notable changes to this project will be documented in this file. Take a look

* EPUB HREFs that are not percent-encoded but carry a fragment or query (e.g. `chapter one.xhtml#section`, with a space in the filename) now keep their `#fragment`/`?query` instead of encoding the separators into the path. This fixes table of contents and Media Overlays links failing to resolve and navigate in poorly-authored EPUBs.

#### LCP

* [#796](https://github.com/readium/kotlin-toolkit/issues/796) Fixed a crash (`UnsatisfiedLinkError`) when the `liblcp` native library cannot be loaded, for example on some rooted devices. `LcpService()` now returns `null` in this case too, and logs the cause with Timber.


## [3.3.0] - 2026-06-02

Expand Down
17 changes: 12 additions & 5 deletions readium/lcp/src/main/java/org/readium/r2/lcp/service/LcpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.lang.reflect.InvocationTargetException
import org.readium.r2.lcp.LcpError
import org.readium.r2.lcp.LcpException
import org.readium.r2.shared.InternalReadiumApi
import org.readium.r2.shared.extensions.tryOr
import timber.log.Timber

internal object LcpClient {

Expand Down Expand Up @@ -47,10 +47,17 @@ internal object LcpClient {
Class.forName("org.readium.lcp.sdk.Lcp")
}

fun isAvailable(): Boolean = tryOr(false) {
instance
true
}
fun isAvailable(): Boolean =
try {
instance
true
} catch (e: Throwable) {
// We catch any Throwable instead of Exception, because loading the liblcp native
// library can fail with an UnsatisfiedLinkError, which is an Error.
// See https://github.com/readium/kotlin-toolkit/issues/796
Timber.e(e, "The Readium LCP library is unavailable")
false
}

fun createContext(jsonLicense: String, hashedPassphrases: String, pemCrl: String): Context =
try {
Expand Down