//clika-runtime/io.clika.runtime/ClikaRtAndroid
ClikaRtAndroid
[android]
object ClikaRtAndroid
The Android entry over ClikaRt: pins the runtime's cache root to the app's own cache directory, then loads the binding.
The runtime keeps small per-device records (the evidence its GPU probes leave behind, so a driver fault is not repeated on the next start) under the first writable root of XDG_CACHE_HOME, then, on Android, the app's own cache directory as the runtime derives it from the process's package name, then HOME/.cache, then the temp directory. load sets XDG_CACHE_HOME to Context.getCacheDir before the runtime library initializes, so the root is the platform's own answer for this app, first in that order and independent of how the process is named (a process whose name is not its package name, or one with no readable name, would otherwise fall past the Android rung); the records then live where the app's other cache files do (cleared with them by the platform and by the user).
Call load before any other member of the binding (the first touch of ClikaRt loads the runtime library). The pin is idempotent, and a value already set for XDG_CACHE_HOME (by the host app, or by an earlier pin) is kept as it is.
load also places the runtime's license credential when the app passes one. The runtime reads CLIKA_RT_LICENSE from its own process, and an Android app has no shell and no per-user license file to set it from, so the license argument sets the variable before the binding loads. An explicit value replaces one already present; null (the default) leaves the environment as it is. The credential's text is never logged.
The CPU worker count, CLIKA_RT_NUM_THREADS, is read once at the first compute: an app that sets it does so in its own process (Os.setenv) before load. A phone with a few large cores and several small ones runs best at the large cores' count; measure on the device.
load then hands the runtime this app's state: the application Context, through which the runtime reads the Android facts only the framework exposes (the per-device identity a license binds). The Context itself never leaves the process.
This file lives in an Android-only source directory (src/main/kotlin): the desktop module compiles src/main/java alone, and android.system.Os has no desktop counterpart.
Properties
| Name | Summary |
|---|---|
| isTrimRegistered | [android] @JvmStatic val isTrimRegistered: Boolean True once trimOnMemoryPressure has registered its listener. |
Functions
| Name | Summary |
|---|---|
| bridgeLogs | [android] @JvmStatic @JvmOverloads fun bridgeLogs(tag: String = TAG, level: LogLevel = LogLevel.INFO) Route the runtime's log lines to logcat under tag, at the runtime's own severity (trace and debug as Log.DEBUG, info / warn / error as their logcat twins), and set the runtime's threshold to level (the default keeps info and above). Call it after load; a second call replaces the sink. |
| load | [android] @JvmStatic @JvmOverloads fun load(context: Context, license: String? = null) pinCacheRoot, place license when given, then ClikaRt.load: one call readies the binding on Android. license is the runtime's license credential (the CLIKA1-... text, or the path of a file holding it): a non-null value is set as CLIKA_RT_LICENSE for this process before the binding loads, replacing a value already present, and null leaves the environment as it is. Without a valid credential the runtime's calls fail (ClikaRtException.codeNameLICENSE_FAILED, or LICENSE_EXPIRED for a license past its end date). While the license server cannot be reached they fail with LICENSE_SERVER_UNREACHABLE instead, and succeed again once the server answers. |
| pinCacheRoot | [android] @JvmStatic fun pinCacheRoot(context: Context) Set XDG_CACHE_HOME to Context.getCacheDir for this process unless the variable already carries a value, which is kept as it is (the host app's choice, or an earlier pin; this is what makes the call idempotent). One debug-tier log line names which root class is in effect, never the path. |
| trimOnMemoryPressure | [android] @JvmStatic fun trimOnMemoryPressure(context: Context) Give the runtime's idle device memory back when the platform asks for memory. Registers ONE listener on the application for the system's memory-pressure signals; when the process reaches the running-low level or any level above it (running-critical, the UI hidden, the app in the background), the runtime releases the memory it keeps cached for reuse on every device it has loaded, so a low-memory phone keeps the app alive instead of killing it. Memory still in use is never touched, and below running-low nothing is released. A second call is a no-op. Call it after load. |