// native android overlay framework

OpenGL ES 2.0
on top of SurfaceFlinger

Fullscreen surface at INT_MAX layer. Raw evdev input. ~60fps render loop. No Activity, no framework, no JVM.

Architecture

surface

SurfaceComposerClient

Creates a native surface at INT_MAX z-order. Sits above lock screen, status bar, everything.

input

evdev — /dev/input/

MT Protocol A and B for touch. Separate key device for volume and power. Dedicated input thread with pipe-based stop signal.

render

EGL + GLES2

EGL window surface on the native window. Swap interval 1. Frame callback with monotonic clock delta.

config

Per-device headers

Touch ranges, event paths, sysfs nodes, SDK version and orientation defined per device in StratumConfig.h.


Quick start

#include "Stratum.h" #include "StratumText.h" #include <GLES2/gl2.h> #include <unistd.h> int main() { Stratum s; if (!s.init()) return 1; Text::init(s.aspect(), prog); s.onFrame([&](float t) { glClear(GL_COLOR_BUFFER_BIT); // draw here }); s.onKey([&](const KeyEvent& e) { if (e.code == KEY_POWER) s.stop(); }); s.onTouch([&](const TouchEvent& e) { // e.x, e.y normalised 0..1 }); s.run(); _exit(0); }

Stratum

methodreturnsdescription
init()boolConnect to SurfaceFlinger, init EGL, open input devices.
run()voidStart frame loop and input thread. Blocks until stop().
stop()voidSignal shutdown. Safe from any callback or thread.
width()intDisplay width in pixels after orientation swap.
height()intDisplay height in pixels after orientation swap.
aspect()floatwidth / height.
vibrate(ms)voidWrite to vibrator sysfs node.
setBrightness(v)voidSet panel brightness, clamped to configured range.
log(tag, fmt, ...)void__android_log_vprint to logcat.

KeyEvent

fieldtypenotes
codeintLinux keycode — KEY_POWER, KEY_VOLUMEUP, etc.
actionKeyActionDOWN, UP, REPEAT. Software repeat after 0.5s, then every ~33ms.
timefloatCLOCK_MONOTONIC seconds.

TouchEvent

fieldtypenotes
slotintMultitouch slot index.
idintTracking ID from the kernel.
actionTouchActionDOWN, MOVE, UP.
x, yfloatNormalised 0.0..1.0, adjusted for orientation.
timefloatCLOCK_MONOTONIC seconds.

StratumText

8x8 bitmap font, GL texture atlas, no external files.

functiondescription
Text::init(aspect, prog)Upload font atlas, bind to shader program.
Text::draw(str, x, y, size, r, g, b)Draw a string at normalised coordinates.
Text::drawWrapped(str, x, y, size, maxW, r, g, b)Word-wrap within maxW screen units.
Text::charW(size, aspect)Width of one character in screen units.

StratumConfig.h

Place this in devices/<model>/StratumConfig.h. All fields are constexpr.

namespace StratumConfig { // sdk version — selects correct AOSP headers at compile time constexpr int SDK_VERSION = 34; // input event nodes constexpr const char* TOUCH_DEVICE = "/dev/input/eventX"; constexpr const char* KEY_DEVICE = "/dev/input/eventY"; constexpr const char* KEY_DEVICE2 = ""; // optional second key device // touch: 0 = auto-detect protocol, 1 = proto A, 2 = proto B constexpr int TOUCH_PROTOCOL = 0; constexpr int TOUCH_SLOTS = 10; // axis ranges — 0 reads from EVIOCGABS at runtime constexpr int TOUCH_X_MIN = 0, TOUCH_X_MAX = 0; constexpr int TOUCH_Y_MIN = 0, TOUCH_Y_MAX = 0; // display orientation: 0 = portrait, 1 = landscape constexpr int ORIENTATION = 0; // sysfs constexpr const char* VIBRATOR = "/sys/class/timed_output/vibrator/enable"; constexpr const char* BRIGHTNESS = "/sys/class/backlight/panel/brightness"; constexpr int BRIGHTNESS_MIN = 0, BRIGHTNESS_MAX = 255; }

Adding a device

Fork the repo. Create devices/<model>/ with the three required items below.

required

StratumConfig.h

Device paths, touch config, SDK version, orientation.

required

app.cpp

Application entry point. Copy src/default.cpp as a base.

required

stratum-boot/

KernelSU module source — module.prop, post-fs-data.sh, system tree.

bash scripts/build.sh <model> // full build + module zip bash scripts/build.sh <model> -l // lib + stratum_binary only bash scripts/run.sh <model> // run on device over adb/su bash scripts/run_example.sh <model> <app> // run a bundled example

Projects

boot-menu

Bare-metal boot menu. Pre-framework launch, touch and hardware key nav, boot status tracking, extras menu.

→