← Back to overview

Kahlali: details for engineers

For engineers who will evaluate or integrate Kahlali: how it works, the rules behind each capability, how to get it, its limits and platform status. For the product overview, fit, licensing and how to work together, see the overview.

How it works and how you build

Built around Device Owner, developed the Android way

Kahlali is built on AOSP, with the Android™ Device Owner feature at its core: the device management role a device can have only one of, which can do for the user what would otherwise need someone to confirm, such as installing, granting permissions and locking. Kahlali itself is the Device Owner and, with changes at the system level, supervises the apps you hand over from power-on to shutdown.

Which parts are standard Android, and which are Kahlali's own system-layer work

The standard Device Owner interface can do this (Kahlali sets it up in advance)

  • Lock mode
  • Granting runtime permissions in advance
  • Installing apps
  • Turning off the crash and "not responding" dialogs
  • Opening the app at boot

What Kahlali adds in the system layer

  1. The supervisor that restarts your app is a resident system program; if it ends, Android restarts it at once. If it hangs, a Kahlali system service started by init deals with it: the service regularly checks a liveness mark the supervisor's main thread writes, and if the mark has not been updated for too long, or the supervisor has been paused, it first lets it continue and, if it still does not respond, ends it so that Android restarts it.
  2. Kahlali learns that an app has crashed or is not responding from inside the system (not through the public Device Owner interface), so your app does not have to be part of the management app; a management app you write has to notice it from outside, for example by binding to your app and noticing when the connection drops.
  3. The Device Owner is placed in the system image and set up again by itself after a factory reset; on your own, that means building your own system image.

A Device Owner management app you write yourself can do the standard-interface items too. Either way, every new Android version has to be checked again; with Kahlali, that is the maintainer's job.

How you build

Build your app the usual Android way; prototype it on an Android phone you already have, then evaluate the same app on a Kahlali-powered board such as RUBIK Pi 3.

The sample app can be made to crash or hang on purpose, so you can watch how Kahlali brings it back.

Capabilities

What Kahlali does for your apps in the system layer

  1. 01 (An app you hand over to Kahlali to monitor and manage. Glossary): automatic restartAfter a crash, or when it is flagged as not responding, the app is restarted without a dialog; in lock mode it is also restarted when it is closed. When it keeps crashing:
    • the wait before each restart grows longer each time ( (Waiting longer after each failure before restarting the app, so it is not restarted endlessly. Glossary));
    • after a set number of crashes in a row, Kahlali pauses for a while ( (Pausing for a while after too many failures in a row before trying again. Glossary)) and by default tries again when it ends; cool-downs are recorded;
    • in lock mode, too many crashes within a period restart Android itself (see the next item).
    The counts and times are settings; the rules and defaults are in the documentation, published with the first public release.
  2. 02Restarting Android itself in lock modeIn lock mode, if a managed app crashes too often within a period, restarting just the app may not be enough (for example when the problem lies in the state of the system), so Kahlali restarts Android itself: on the integrated version, the whole device reboots (through the Device Owner reboot call; the evaluation system image follows the same design, which is confirmed when it is prepared for your device); in the community edition (container), the container stops and Docker's restart policy (--restart unless-stopped in the README install command) starts it again.
    • How many crashes within how long a period trigger it are settings, and it can be turned off.
    • There is a daily limit (adjustable); once it is used up, Android is not restarted again that day, and back-off and cool-down go on as usual.
    • Every restart of Android is recorded in the event log.
    • When the device is unlocked, Android is not restarted this way by default.
  3. 03Lock modeBuilt on the standard Android (A built-in Android feature that keeps the device on the chosen apps, so the user cannot leave them. Official page Glossary), with the restrictions preset; one switch in the console locks it. In lock mode one foreground app is shown; the other managed apps run in the background (see the next item). Unlock it for maintenance or another purpose and you are back to regular Android with a home screen.
  4. 04Several managed appsYou can have several managed apps:
    • There is one foreground app, by default the first in the list of managed apps; at boot it starts last and is shown on screen.
    • The others are background apps. Kahlali does not open their screens; it binds to one of the app's Services and so starts it in the background. Which one, in this order:
      1. the Service named in a system property (which can also say: bind none);
      2. a Service that declares Kahlali's keep-alive intent action;
      3. the app's VpnService;
      4. the first enabled Service that runs in the app's main process (it need not be exported).
    • No Service to bind to: Kahlali sends the boot-completed broadcast (BOOT_COMPLETED) instead, and the app's own receiver starts its work. This only starts the app and does not keep it resident; if the system ends it, Kahlali starts it again.
    • Neither: the app cannot be started without opening its screen. Kahlali marks it as unstartable (API state unstartable), leaves an alert in the system log and tries again later; it never opens the app's screen instead.
    • When a background app crashes, Kahlali first unbinds it, then restarts it in the background under the same back-off and cool-down, without covering the foreground app.
    • Back-off and cool-down apply to each app; the threshold for restarting Android itself counts the failures of all managed apps together (crashes, not responding, and unexpected exits while locked).
    • When Android itself restarts, the background apps start first and the foreground app last.
    How to choose the foreground app: described in the documentation, published with the first public release.
  5. 05Permissions granted in advanceThe runtime permissions (PROTECTION_DANGEROUS, such as camera, microphone and location) a managed app declares in its manifest are granted by Kahlali, as the Device Owner, when the app is made managed, so no "Allow" dialog appears; permissions it does not declare are not granted. Special access such as "Display over other apps", "All files access" or "Ignore battery optimisation" is not a runtime permission and is not part of this; how it is handled in the community edition has not been tested yet, so please check it when you evaluate.
  6. 06Local web consoleManage the device in a browser: device information and network status, the managed apps (upload an APK, make it managed, lock), a record of when apps were closed, a log of the actions taken, and accounts. The console listens only on the device itself; the community edition's quick start binds it to 127.0.0.1:8080 on the host. From another computer, open an (A way to open, from another computer and over an encrypted connection, a page that listens only on the device itself. Glossary) first:
    ssh -L 8080:127.0.0.1:8080 <host>
    then open http://127.0.0.1:8080 in a browser.
  7. 07Built-in browserBased on the LineageOS Jelly browser; it is included in the community edition; whether the evaluation system image and the integrated version include it is confirmed when you write. When a web page asks for the camera, microphone or location, the answer is no by default; in the console you allow them per website, each of the three separately, and only an admin can change this.
  8. 08First-boot welcome screen and sample appThe first boot shows three steps: sign in to the console, upload your app, make it managed. You can also install the sample app, press "crash on purpose" or "hang on purpose", and watch Kahlali restart it.
First-boot welcome screen: three steps to hand your app over to Kahlali to manage. (Actual community container screen)
First-boot welcome screen: three steps to hand your app over to Kahlali to manage. (Actual community container screen)
Kahlali home screen; the taskbar has the Kahlali, Settings and Kahlali Browser icons
Unlocked, it is regular Android with a home screen. (Actual community container screen)
Quick Settings tiles: Kahlali Console, managed app, network, maintenance
Quick Settings show the console address, the managed app, the network and the maintenance state. (Actual community container screen)

Before, and with Kahlali

Keeping your apps running from power-on to power-off: the work you would do yourself

On standard Android, without an existing management solution, your team writes and tests each of these itself. With Kahlali they are built into the system layer, as settings you can adjust; each device still needs its network set up, and your app uploaded and set up. Which parts are the standard Device Owner interface and which are Kahlali's own system-layer work: see How it works; for other limits, see Current limits.

Without Kahlali: you build itWith Kahlali: built into the system layer
01Open your app's screen at boot Without Kahlali: Write code that listens for the (The notice Android sends to apps when it has finished starting up, so an app can start itself. Official page Glossary), or make the app the home screen; an app that was force-stopped does not receive the boot broadcast. With Kahlali (built into the system layer): Kahlali opens the managed app's screen at boot.
02Restart after a crash or when flagged as not responding Without Kahlali: Write your own Device Owner management app. When the user taps close on the "not responding" dialog, Android ends the app; whether and when to open it again, and what to do about repeated failures, is yours to write. From Android 10, an ordinary app that is not the Device Owner cannot open screens freely from the background. With Kahlali (built into the system layer): No dialog; the app is restarted with back-off, and when needed it enters a cool-down. Unlocked, it is restarted after a crash or (The state in which Android has judged an app "not responding". Official page Glossary); locked, also when it is closed.
03Lock the device to your apps Without Kahlali: Write a Device Owner management app: lock task mode, turning off the notification shade, one restriction after another, and a way in for service staff. With Kahlali (built into the system layer): One switch in the console applies lock mode with its restrictions, and lifts them together.
04Every device Without Kahlali: Set a management app up as the Device Owner on each device when it is new or after a factory reset (QR code, an NFC tap or a cable); after a reset, do it again. At most one Device Owner per device. With Kahlali (built into the system layer): The Device Owner is already in the system image; after a factory reset, Kahlali becomes the managing app again by itself, with no device-by-device Device Owner setup.

Note: background work ( (The way an app keeps working in the background while showing a notification that stays in the notification shade. Official page Glossary)) follows the Android rules, and Kahlali does not bypass them; for example, from Android 15 the boot broadcast cannot start camera, microphone, media playback and other foreground service types.

How to get it

How to get it, and the conditions

Community edition (container)
A container image, run with Docker on a Linux host: an ordinary PC or a development board (such as RUBIK Pi 3) needs Linux installed (for example Ubuntu 24.04); a Mac with an Apple M-series chip runs it through (A free tool for running containers on a Mac. Project page Glossary), which starts a Linux virtual machine on the Mac for you, so the Mac does not have to be turned into a Linux machine. For how you may use it and which parts are open source, see How does licensing work? on the overview; this follows the draft image licence, and the final terms will be published with the release.
Conditions for flashing the system image yourself
You can flash the evaluation system image onto your own board or phone to test. It is not available for public download; it is prepared for your device individually: write with the model and its current Android version, and the maintainer first checks whether it is feasible, then replies with whether it can be provided; there is no committed preparation time yet, so if you are in a hurry, please say so in your email. It is a (A system image that replaces only the Android system part; the board maker's drivers are kept, and the screen, touch and other hardware are handled by the board's own drivers. Official page Glossary): it replaces only the Android system part; the board maker's drivers are kept, and the screen, touch and other hardware are handled by the board's own drivers. What actually works has to be confirmed on your board (the maintainer looks at your board model and version first). The conditions:
  • The bootloader can be unlocked.
  • The processor is 64-bit ARM (arm64).
  • The board or phone already runs the maker's Android 16. If the device was upgraded to 16 from an older Android, the board maker's driver part may still be the older version; in that case it may not work yet, and the maintainer checks this too.
  • It supports the Android (The Android architecture that keeps the system apart from the board maker's drivers; on a board that supports it, the system part can be replaced on its own. Official page Glossary) (it can take a GSI).
  • It is built on Android 16 today; other versions (older or newer Android) are not supported yet, and new versions come once the maintainer has verified them.
  • A phone works too, under the same conditions; unlocking erases the data on the phone, so a spare phone is best.
If you are not sure whether your device meets these conditions, you are welcome to write anyway, and the maintainer will help you check. Meeting these conditions does not guarantee it works; whether it can be provided is confirmed in the maintainer's reply.
Integrated version
Under a separate commercial licence. A non-disclosure agreement (NDA) can come first; you share your board and requirements, and the maintainer integrates Kahlali with your board's Android (The low-level software that lets Android drive the hardware of a particular board. Glossary). The system and updates of the integrated version are signed with your own keys: you keep the keys, and the maintainer provides the signing tools and process and never handles your private keys; which parts verified boot can check depends on the board's support.
Downloads
GitHub: coming soon, under github.com/kahlali.

Limits

Current limits

The same for every form

  • Google Play and GMS are not included.
  • It cannot be used on a device that needs another management system (MDM) as its Device Owner.
  • If your app has its own watchdog: keep the health checks in your app; turn off the part where the app restarts itself, and leave the restart to Kahlali.
  • If your app hangs but the system does not judge it "not responding", Kahlali cannot see it: Kahlali does not watch from inside your app. Instead, when the health checks in your app detect that it is stuck, let the app end itself (for example by throwing an uncaught exception); Kahlali then restarts it under the normal crash rules. The sample app's "crash on purpose" button does exactly this.

Community edition (container)

  • Free for evaluation, learning, development and non-commercial use; not for products you ship or paid services. The image is signed with the public AOSP test keys.
  • Nothing is shown on a screen connected to the host (HDMI, DisplayPort); you see it with scrcpy from a computer.
  • There are no automatic updates; you update by hand on the host.
  • AI inference runs on the CPU and graphics are drawn in software.
  • There is no location.

Evaluation system image

  • For evaluation only, signed with public test keys; the terms of use are given in the reply; shipping needs the integrated version.
  • The screen and other hardware are handled by the board's own drivers, and what actually works has to be confirmed on your board; only Android 16 is supported today.
  • Its other limits depend on the board; the maintainer explains them in the reply.

Platforms

Platforms and test status

PlatformFormStatus
RUBIK Pi 3 board (Linux host)Container on a Linux hostBefore the release, a development build was installed and run on the official Ubuntu 24.04 image by following the installation instructions; stability data: see below the table
Ordinary PC (x86_64, Ubuntu 24.04)ContainerTrial only, not for real deployments
Mac with an Apple M-series chip (using colima)ContainerTrial only, not for real deployments
Evaluation system image, integrated edition (runs natively on your board, AOSP-based)Runs on the device itselfChecked board by board
Other boards and chips—Discussed case by case

Measured data: the RUBIK Pi 3 install-and-run check in the table above was done before the official release with a development build, and confirms only that it installs and runs by following the installation instructions (published with the release). Measured stability (long-running and high-load operation) and AI performance data will be published once testing is done; no long-running test results have been published yet.

More capabilities

Edge AI and the porting kit

How AI actually runs on this device

The sample app runs an actual object-detection model on the device and shows on screen which (The software or hardware that actually does the AI computation. Glossary) it actually used and the time for each frame. The AI platform check in the console checks layer by layer and shows at which layer hardware acceleration cannot be used and why (for example, not supported or failed to load). On RUBIK Pi 3 the community edition currently runs inference on the CPU. Checking your own model is not part of the community edition; it is done after an NDA or a confirmed collaboration.

Already have a Python program running on Linux?

The (Tools that package a Python program already running on Linux as an Android app (APK) that Kahlali can manage. Glossary) packages a Python program from Linux (one that reads sensors, reports data or serves a small web page, for example) as an APK that Kahlali manages, with the same automatic restart and lock mode. It first scans the source code and lists what cannot move to Android as is (such as direct access to hardware, systemd services or needing root), with the Android way to do it; you make the changes yourself, then it packages the result. Only Python is supported today; the supported scope and the computers you can package on are in the documentation that comes with the porting kit.

SDK

Talking to Kahlali with the SDK (optional)

You do not need the (Developer tools that let your app call Kahlali features. Glossary): without it, your apps are still restarted, locked and granted their permissions in advance. The SDK is for apps that want to read the device's state, or that bring their own network settings screens (joining Wi-Fi, for example).

Two ways in
  • Android apps connect to Kahlali's services over (The Android Interface Definition Language, which lets one app call functions that another app or a system service provides. Official page Glossary). ICelNetwork reads network status, mobile network diagnostics and the state of connection recovery, and lets your app subscribe to changes; ICelLocation tells you whether this device can provide location at all (the coordinates themselves still come from the standard Android LocationManager).
  • Other programs (Python, C, a web page …) use the (A programming interface used through web addresses over HTTP to read data and send commands; any language that can make network requests can use it. Glossary) on the device itself (/api/v1), described in (A standard format that describes which addresses a REST API has, what to send and what comes back. Official page Glossary).
Identity
AIDL needs no password or (A temporary pass you get after signing in; later requests carry it, so the password does not have to be sent each time. Glossary): Kahlali decides by the calling app's package name and signature. Managed apps can call it by default; any other app has to be added to the allow list by an administrator. For REST, your program signs in with an account and gets a token (valid for 12 hours; your program renews it before it expires); give your program an account of its own with the user role.
On the community edition (container)
Every read call works, and capabilities the device lacks are reported as such. Network settings (such as joining Wi-Fi or changing Ethernet) belong to the host, so writing them returns "not supported". There is no location, so ICelLocation reports that the device has none, and your app can hide the features that need it.
Compatibility
AIDL interfaces are only ever added to, never taken away. With getInterfaceVersion() your app can tell which interface version the device has and fall back gracefully on an older one.
Licence
Your choice of Apache 2.0 or MIT, so it can go into apps that are not open source; the Kahlali name and logo are not covered by the licence.
Samples
Kotlin (network, location), Python, C, curl, and an HTML + JavaScript dashboard; the manual includes a 10-minute quick start. The SDK and manual are coming soon, under github.com/kahlali.

Questions

Frequently asked questions

What counts as a failure?
A crash or an ANR (the system judging the app "not responding") counts as one failure; in lock mode, the app ending unexpectedly in any other way counts too. Repeated failures lead to back-off and cool-down, and in lock mode Kahlali may restart Android itself; the thresholds and the daily limit are settings, described in the documentation. That is why an app should not restart itself: each of its own restarts ends the app, and in lock mode that counts as a failure. Keep the health checks in your app; turn off the part where the app restarts itself, and leave the restart to Kahlali. These do not count as failures:
  • updating the app (the default; a setting can make it count);
  • entering maintenance mode, which exists to pause supervision for servicing;
  • removing the app from the managed apps;
  • a stop command sent through the API.
Can it work with an MDM such as Intune?
Not as a second Device Owner. Kahlali itself is the Device Owner, and a device can have only one, so an (A service similar to MDM that organisations use to manage devices centrally. Glossary) or (A service that organisations use to manage many devices centrally and remotely. Glossary) that needs to be the Device Owner cannot also be one. Without GMS, devices cannot enroll in (Google's programme for organisations to manage Android devices. Official page Glossary) in GMS mode, and (Microsoft's device management service. Official page Glossary) cannot manage them directly today. If you need central management, please write first about integration. The integrated version can send events to your own server through the API, but that only sends events out; it is not an MDM.
Can it drive an HDMI screen?
Not the community container: its display is virtual and drawn in software; you see it with (A free computer program that shows the Android screen on your computer and lets you operate it. Project page Glossary) from a computer, and nothing is sent to an HDMI or DisplayPort screen connected to the host. For the device's own screen, ask by email about the evaluation system image (prepared for your device individually) and flash it onto your board; it then uses the board's own screen and drivers (conditions).
How is it updated, and can I go back?
By hand; the community edition has no automatic updates.
  • Each release is a container image with a fixed version.
  • An update program on the host first verifies the signature and backs up the data, then switches to the new image.
  • You can go back: the previous image is restored together with the data backup made before the update. Data written after the update is not kept.
  • The console can show a notice about a new release if you turn it on. It only notifies; it never downloads or installs anything.
For the evaluation system image, the maintainer explains how updates work when you write; for the integrated version, updates follow your product plans.
Do we write an Android app or a Linux program?
An Android app (APK), built with the usual Android tools. The community edition uses a container so you can try Kahlali on a Linux host; in a product, Kahlali is integrated with your board's Android BSP. Either way, your app does not need to know. An existing Python program on Linux can be packaged as an APK with the porting kit.
Can we develop on a phone without Kahlali?
Yes. The app itself is standard Android, so you can build and validate it on an ordinary Android phone; when the sample app does not find Kahlali, it switches to a simulated mode automatically. System-layer behaviour such as automatic restart and lock mode shows up once you install it on Kahlali.
Can I flash it onto my own board or phone to try it?
If your device meets the conditions, yes, with the evaluation system image (a GSI). It is not available for public download: it is prepared for your device individually, so write with the model and its current Android version, and the maintainer replies once feasibility is checked. There is no committed preparation time yet; if you are in a hurry, please say so in your email. It is for evaluation only and signed with public test keys. The conditions, phones included, are under Conditions for flashing the system image yourself.

Terms

Glossary

Terms used on this page, in order of first appearance; you can also tap any word with a dotted underline in the text to see its explanation.

Show all terms (29)
Device Owner
The built-in Android device management role; a device can have only one. The management app in this role can do the management work that would otherwise need someone to confirm, such as installing apps, granting permissions and locking the device. Official page
System layer
The part of Android beneath your app that boots the device and starts and manages every app.
Watchdog
A program that monitors your app and restarts it when it stops.
Managed app
An app you hand over to Kahlali to monitor and manage.
Back-off
Waiting longer after each failure before restarting the app, so it is not restarted endlessly.
Cool-down
Pausing for a while after too many failures in a row before trying again.
Lock task mode
A built-in Android feature that keeps the device on the chosen apps, so the user cannot leave them. Official page
SSH port forwarding
A way to open, from another computer and over an encrypted connection, a page that listens only on the device itself.
Boot broadcast
The notice Android sends to apps when it has finished starting up, so an app can start itself. Official page
ANR
The state in which Android has judged an app "not responding". Official page
Foreground service
The way an app keeps working in the background while showing a notification that stays in the notification shade. Official page
colima
A free tool for running containers on a Mac. Project page
Generic system image (GSI)
A system image that replaces only the Android system part; the board maker's drivers are kept, and the screen, touch and other hardware are handled by the board's own drivers. Official page
Treble architecture
The Android architecture that keeps the system apart from the board maker's drivers; on a board that supports it, the system part can be replaced on its own. Official page
BSP
The low-level software that lets Android drive the hardware of a particular board.
GMS
Google Mobile Services, which the Google Play Store and many Google apps need. Official page
MDM
A service that organisations use to manage many devices centrally and remotely.
Test-key signing
The system is signed with a public test signature that anyone can use, so it only suits evaluation.
scrcpy
A free computer program that shows the Android screen on your computer and lets you operate it. Project page
Backend
The software or hardware that actually does the AI computation.
Porting kit
Tools that package a Python program already running on Linux as an Android app (APK) that Kahlali can manage.
SDK
Developer tools that let your app call Kahlali features.
AIDL
The Android Interface Definition Language, which lets one app call functions that another app or a system service provides. Official page
REST API
A programming interface used through web addresses over HTTP to read data and send commands; any language that can make network requests can use it.
OpenAPI
A standard format that describes which addresses a REST API has, what to send and what comes back. Official page
Token
A temporary pass you get after signing in; later requests carry it, so the password does not have to be sent each time.
EMM
A service similar to MDM that organisations use to manage devices centrally.
Android Enterprise
Google's programme for organisations to manage Android devices. Official page
Microsoft Intune
Microsoft's device management service. Official page

Open source and thanks

Kahlali is built on these open-source projects

Each project has a different goal; this is what Kahlali uses from it or learned from it. For which parts of Kahlali itself are open source, see How does licensing work? on the overview.

Android Open Source Project (AOSP)
The base of Kahlali. The system image is built from AOSP source, and Kahlali adds the system layer a dedicated device (managing one or several apps) needs. Mostly Apache-2.0.
redroid
An open-source project that runs Android in containers on Linux hosts, aimed at running many copies on cloud servers. It showed that a full Android system can boot in an ordinary container, and the Kahlali community edition followed that path; the few source files derived from redroid are marked as such in the image NOTICE. Apache-2.0 (as stated in the redroid docs).
LineageOS
A community-maintained system based on Android, for people's everyday phones and tablets. The web browser built into Kahlali is based on the LineageOS Jelly browser, with a new name, colours and icon, and its copyright notice kept. Apache-2.0 (Jelly).

Project names are used only to identify those projects; Kahlali is not affiliated with or endorsed by any of them. Every component and its license is listed in the image NOTICE.

Contact

Working together and contact

To talk about integrating it into your board, asking about the evaluation system image, a commercial licence or other ways of working together, write to the project mailbox. Please include your board, your app and the conditions in the field; when you ask about the evaluation system image, please also include the model and its current Android version; there is no committed preparation time yet, so if you are in a hurry, please say so in your email.

Email the maintainer

Project mailbox
contact@kahlali.org
Every "Email the maintainer" button on these pages writes here.
GitHub
github.com/kahlali
Code repositories open with the first public release; none is public yet.
Maintainer
Hsin-Hsien Lee (who started and maintains Kahlali)