TorServiceUI
Core androidMain
abstraction which enables implementors the ability to create a fully customized notification for the running instances of TorRuntime as they operate within TorService.
This class' API is designed as follows:
Factory: To be used for all TorRuntime.ServiceFactory instances and injected into TorService upon creation.
Context:
SINGLETON
TorServiceUI: To be created via Factory.createProtected upon TorService start.
Context:
SERVICE
InstanceState: To be created via AbstractTorServiceUI.createProtected for every instance of Lifecycle.DestroyableTorRuntime operating within TorService.
Context:
INSTANCE
NOTE: This is currently an ExperimentalKmpTorApi when extending to create your own implementation. Things may change (as the annotation states), so use at your own risk! Prefer using the stable implementation via the kmp-tor:runtime-service-ui
dependency.
See also
Throws
on instantiation if args were not those which were passed to Factory.create. See Args.
Types
androidMain
implementation for passing arguments in an encapsulated manner when instantiating new instances of TorServiceUI implementations.
Core androidMain
abstraction for a Factory class which is responsible for instantiating new instances of TorServiceUI when requested by TorService.
Holder for Foreground Service Notification and NotificationChannel configuration info used to instantiate Factory. Is validated upon invocation of TorServiceConfig.Foreground.Companion.Builder.
Callback for creating BroadcastReceiver that belong to the Service context, without exposing the Service to implementors of TorServiceUI.
Properties
Application Context for resolving android resources and creating Notification.Builder. This MUST NOT be utilized when posting Notification updates and registering BroadcastReceiver. Use post and register functions which will be executed within the context of the android.app.Service.
The NotificationInfo.channelId for instantiating Notification.Builder.
The default Config that was defined for Factory.defaultConfig
Returns the currently displayed InstanceState.
All InstanceState currently operating within this UI "container".
A CoroutineScope which is configured as a child to the service object's CoroutineScope which utilizes Dispatchers.Main
Functions
Implementors MUST utilize args to instantiate a new instance of the InstanceState implementation. If args were not consumed by the returned instance of InstanceState, an exception will be thrown by createProtected.
Posts the Notification to NotificationManager. This MUST be called upon first onRender invocation (or sooner) to ensure that the call to Service.startForeground is had, otherwise an ANR will result for Android API 26+.
Registers a BroadcastReceiver with the Service context and pipes the Intent from BroadcastReceiver.onReceive to Receiver.onReceive.
Shifts the pointer to the "right" and calls onRender with the new parameters. If no next InstanceState is available, then nothing occurs.
Shifts the pointer to the "left" and calls onRender with the new parameters. If no previous InstanceState is available, then nothing occurs.