Package-level declarations

The stable, firmware-neutral API a plugin compiles against.

Getting started

A plugin is one class that extends mibsdk.api.MibPlugin. The runtime constructs it and calls onEnable on the plugin's own worker thread. The context is the only door to the SDK:


public class MyPlugin extends MibPlugin {
    
    protected void onEnable(PluginContext ctx) {
        ctx.log().info("hello");
    }
}

See the project documentation for the tutorial, guides and reference. This package summary covers the rules that apply to every plugin.

Lifecycle

The runtime reads the manifest and checks permissions before it loads the class. A plugin whose manifest is invalid is BLOCKED_INVALID; a plugin with an ungranted permission is BLOCKED_PERMISSIONS. Neither reaches onEnable.

Everything registered in onEnable belongs to that run: pages, Car rows, status items, timers, listeners, hooks and overrides. When the plugin is disabled, reloaded, quarantined or the HMI shuts down, the SDK cancels all of it, releases overrides, flushes storage, and then calls onDisable.

onDisable also runs after an onEnable that threw. Guard every field it touches: a field assigned after the failure point is still null. A plugin is constructed fresh for each run, so fields do not survive a reload; persistent state belongs in mibsdk.api.Storage.

One worker per plugin

All plugin code runs on one SDK-owned daemon thread, one task at a time: lifecycle hooks, page actions, scheduler tasks, event listeners and dialog answers. Callbacks never overlap, so shared fields need no synchronized or volatile.

Plugin code never runs on an HMI thread. A slow callback delays only its own plugin: the SDK logs a callback over 5 s and quarantines one that runs for 30 s.

Failures and quarantine

An exception in a callback is logged and counted. The third failure within 60 s quarantines the plugin. A callback still running after 30 s quarantines it as hung. Quarantine disables the plugin, cancels its registrations and releases its overrides; it stays off until the user re-enables it or the unit restarts.

Lifecycle hooks are different: a throwing onEnable disables the plugin as FAILED immediately, and a throwing onDisable is only logged.

Inert handles

When a feature is missing at this boot, UI calls still return handles, but they are inert: updates are accepted and show nothing. Argument and count checks still apply. Use has to tell the difference.

UI behaviour that surprises people

  • A toggle does not flip by itself. You receive the requested state and must update the page.
  • A slider shows its position, not its number. Show the number in a nearby row's value.
  • Dropdown and slider rows are drawn after the list rows, whatever order you add them in.
  • A toast needs ui.slot.statusbar, the same permission as the status item.
  • A Car row's new icon shows the next time the Car screen opens.

Language level

Source may use modern Java syntax (lambdas, generics, switch expressions, text blocks, try-with-resources); the build lowers it to class-file v48. Two limits follow from the car's Java 1.4 library: java.util.concurrent is unavailable (use mibsdk.api.Scheduler), and records are not supported. A record fails in compileJava with Jabel's "Must be annotated with @Desugar"; use a final class.

Since

api 1

Types

Link copied to clipboard
interface Events
Vehicle and hook events.
Link copied to clipboard
class Features
Features the running firmware adapter may support.
Link copied to clipboard
interface Listener<E>
A callback for an event or a hook observation.
Link copied to clipboard
interface Log
A plugin's log.
Link copied to clipboard
abstract class MibPlugin
Base class of every plugin.
Link copied to clipboard
A declared permission was not granted by the user.
Link copied to clipboard
Permission ids a plugin declares in plugin.json.
Link copied to clipboard
interface PluginContext
Everything a plugin may touch.
Link copied to clipboard
interface Scheduler
Delayed and periodic tasks, run on the plugin's single SDK worker thread: a task never overlaps another of the plugin's callbacks, and never runs on a stock HMI thread, on the runtime's timer thread, or on the thread that scheduled it.
Link copied to clipboard
class SdkInfo
The plugin API range this SDK implements.
Link copied to clipboard
interface Storage
Per-plugin persistent key/value storage.
Link copied to clipboard
interface Subscription
A registration that can be cancelled: a page, a Car row, a status item, a timer, an event listener, a veto or an override.