Foreground

An instance of TorServiceConfig which indicates to TorService that it should start itself as a Foreground Service.

This instance provides additional newEnvironment functions which enable the passing of per-environment based configurations for the declared factory. They are entirely optional and the regular newEnvironment functions provided by TorServiceConfig will simply default to what was declared for TorServiceUI.Factory.defaultConfig.

NOTE: No matter the implementation of TorServiceUI.Factory being utilized, this requires permissions. Otherwise, TorService will fail to start. See AndroidManifest.xml

e.g. (A Foreground Service using the kmp-tor:runtime-service-ui dependency)

val factory = KmpTorServiceUI.Factory(
    iconReady = R.drawable.my_icon_ready,
    iconNotReady = R.drawable.my_icon_not_ready,
    info = TorServiceUI.NotificationInfo(
        // ...
    ),
    block = {
        // configure...

        defaultConfig {
            // configure ...
        }
    },
)

val serviceConfig = TorServiceConfig.Foreground.Builder(factory) {
    // configure...
}

val environment = serviceConfig.newEnvironment { resourceDir ->
    // Assuming use of `kmp-tor-resource` dependency, for example
    // the `exec` type.
    ResourceLoaderTorExec.getOrCreate(resourceDir)
}

val runtime = TorRuntime.Builder(environment) {
    // configure...
}

See also

Types

Link copied to clipboard

Extended builder options for TorServiceConfig.Builder, specific to Foreground operations.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
@JvmField
val factory: F
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun newEnvironment(loader: (File) -> ResourceLoader.Tor): TorRuntime.Environment
fun newEnvironment(dirName: String, loader: (File) -> ResourceLoader.Tor): TorRuntime.Environment
fun newEnvironment(dirName: String, loader: (File) -> ResourceLoader.Tor, block: ThisBlock<TorRuntime.Environment.BuilderScope>): TorRuntime.Environment
fun newEnvironment(instanceConfig: C, loader: (File) -> ResourceLoader.Tor): TorRuntime.Environment
fun newEnvironment(instanceConfig: C, loader: (File) -> ResourceLoader.Tor, block: ThisBlock<TorRuntime.Environment.BuilderScope>): TorRuntime.Environment
fun newEnvironment(dirName: String, instanceConfig: C, loader: (File) -> ResourceLoader.Tor): TorRuntime.Environment
fun newEnvironment(dirName: String, instanceConfig: C, loader: (File) -> ResourceLoader.Tor, block: ThisBlock<TorRuntime.Environment.BuilderScope>): TorRuntime.Environment

Android implementation which creates the TorRuntime.Environment using the provided TorServiceConfig.