Headless provisioning and scripted deployments with secure PIN-based control
Docs Home • Installation • REST API • MQTT
Table of Contents
- Overview
- Security Model
- Quoting JSON values
- Quick Start
- Command Reference
- Waiting for Configuration Completion
- Examples
- JSON Configuration Format
- Complete Provisioning Script
- 💻 PowerShell Script (Windows)
- Troubleshooting
- Security Considerations
- See Also
Important
For production-grade app locking, pair ADB provisioning with Device Owner mode.
Overview
FreeKiosk supports configuration via Android Debug Bridge (ADB) intent extras, enabling:
| Capability | Description |
|---|---|
| Automated Device Provisioning | Configure without UI interaction |
| Mass Deployment | Scale across multiple devices |
| Dynamic Configuration | Change settings via scripts |
| CI/CD Integration | Automated testing workflows |
Security Model
| Device State | Requirements |
|---|---|
| Virgin setup (no PIN configured) | PIN must be provided in the command |
| Already configured | Existing PIN required to modify |
This security model ensures:
✅ First-time setup is scriptable with PIN protection
✅ Configured devices cannot be hijacked via ADB
✅ Factory reset re-enables ADB provisioning
Quoting JSON values
adb shell joins its arguments and the device's shell parses them a second time, which
strips the double quotes of a JSON value: --es dashboard_tiles '[{"label":"A"}]' typed as
is reaches FreeKiosk as [{label:A}], and the app logs Invalid dashboard tiles JSON (or
shows an "Invalid ... JSON" toast). Wrap the whole am start ... in double quotes, keep the
JSON in single quotes inside it, and put a backslash before each double quote of the JSON:
adb shell "am start -n com.freekiosk/.MainActivity --es pin 1234 --es config '{\"lock_package\":\"com.app\"}'"
Same line in bash, zsh, PowerShell and cmd.exe. In PowerShell it is easier to keep the JSON in
a variable that already carries the backslashes:
$tiles = '[{\"label\":\"A\",\"url\":\"https://a.eu\"}]' then
adb shell "am start -n com.freekiosk/.MainActivity --es dashboard_tiles '$tiles'".
Checked with the Android SDK platform-tools on Windows (Git Bash, PowerShell 5.1, cmd.exe);
Linux and macOS go through the same mechanism but were not tried. Also watch for curly quotes
(’ instead of ') when copying a command from an email or a word processor: the shell does
not read them as quotes. Simple values (--es url "https://...") need none of this.
Quick Start
First-Time Setup (New Device)
# Set Device Owner (one-time, requires no user accounts on the device)
adb shell dpm set-device-owner com.freekiosk/.DeviceAdminReceiver
# Configure and lock to external app
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "com.example.myapp" \
--es pin "1234"
Note
Setting Device Owner is highly recommended for external app locking as it allows FreeKiosk to automatically manage all required permissions including "Display over other apps". Without Device Owner, this permission must be granted manually through Settings.
Configure WebView Kiosk
adb shell am start -n com.freekiosk/.MainActivity \
--es url "https://your-dashboard.com" \
--es pin "1234"
Note
WebView mode doesn't require Device Owner as it doesn't need overlay permissions.
Command Reference
Basic Syntax
adb shell am start -n com.freekiosk/.MainActivity [OPTIONS]
Tip
Types are interchangeable. --es kiosk_enabled "true", --ez kiosk_enabled true and
--ei return_tap_count 5 all work; the value is stored as text either way. This was not
true before, and passing a boolean key with --es used to be silently ignored.
Unknown keys are reported. A key FreeKiosk does not recognize is now named in a toast
on the device and in logcat (adb logcat | grep FreeKiosk-ADB) instead of being dropped in
silence. If a setting did not apply, look there first.
Required Parameters
| Parameter | Type | Description |
|---|---|---|
--es pin "XXXX" |
String | Always required. PIN for authentication (new or existing) |
App Lock Parameters
| Parameter | Type | Description |
|---|---|---|
--es lock_package "com.app" |
String | Package name of app to lock device to |
--ez auto_start true |
Boolean | Auto-launch the locked app after config |
Multi-App Parameters
| Parameter | Type | Description |
|---|---|---|
--es external_app_mode "multi" |
String | App mode: single (default, classic) or multi (home screen grid) |
--es managed_apps '[...]' |
String (JSON) | JSON array of managed apps (see format below) |
Managed Apps JSON Format:
Each app in the array supports these fields:
| Field | Type | Default | Description |
|---|---|---|---|
packageName |
String | required | Android package name |
displayName |
String | auto-resolved | Display name (auto-detected from system if omitted) |
showOnHomeScreen |
Boolean | true |
Show in the multi-app home grid |
launchOnBoot |
Boolean | false |
Auto-launch on device boot |
keepAlive |
Boolean | false |
Monitor and restart if app crashes |
allowAccessibility |
Boolean | false |
Whitelist app's accessibility services |
Note: Uninstalled packages in the list are silently skipped with a warning in logcat.
WebView Parameters
| Parameter | Type | Description |
|---|---|---|
--es url "https://..." |
String | URL to display in kiosk WebView. A local file is a file:///... address (needs pdf_viewer_enabled); outside FreeKiosk's own folder it also needs All files access: adb shell appops set com.freekiosk MANAGE_EXTERNAL_STORAGE allow (not in the Play Store build). See the FAQ |
Dashboard Parameters
The dashboard is a grid of tiles, each opening its own URL. It lives inside the WebView
display mode, so --ez dashboard_mode true sets display_mode to webview on its own
unless lock_package says otherwise.
| Parameter | Type | Description |
|---|---|---|
--ez dashboard_mode true |
Boolean | Show the tile grid instead of a single URL |
--es dashboard_tiles '[...]' |
String (JSON) | JSON array of tiles (see format below) |
Tile format:
| Field | Type | Default | Description |
|---|---|---|---|
url |
String | required | URL the tile opens. A tile without one is skipped |
label |
String | the URL | Text shown under the icon |
id |
String | generated | Unique tile id. Let FreeKiosk generate it unless you are updating a specific tile |
iconMode |
String | favicon |
favicon, image, or letter. An unknown value falls back to favicon |
iconValue |
String | - | Image URL, used when iconMode is image |
order |
Number | list position | Display order in the grid |
adb shell "am start -n com.freekiosk/.MainActivity --es pin 1234 --ez dashboard_mode true --es dashboard_tiles '[{\"label\":\"Main app\",\"url\":\"https://myapp.eu\"},{\"label\":\"Reports\",\"url\":\"https://reports.myapp.eu\"}]'"
The same two keys work inside --es config as dashboard_mode and dashboard_tiles.
Additional Settings
Every key below is a straight passthrough: the value you pass is stored as-is.
Navigation and exit
| Parameter | Description |
|---|---|
--es return_mode "tap_anywhere" |
How to reach settings: tap_anywhere (tap the screen return_tap_count times, the default), button (fixed button) or corner_sequence (tap the top-left corner twice, then the bottom-right corner twice, within 3 seconds; WebView and media player only, App mode counts taps instead). Any other value leaves no way in |
--es return_button_position "top-left" |
Fixed-button corner: top-left, top-right, bottom-left, bottom-right |
--ei return_tap_count 5 |
Number of taps to open settings |
--ei return_tap_timeout 1500 |
Time window, in milliseconds, to complete all the taps, counted from the first one (default 1500). The Settings screen accepts 500 to 5000; over ADB any value works. Raise it before you drive the gesture from a script, see Scripting the settings gesture |
--ez volume_up_5tap_enabled true |
Five presses of Volume Up opens settings |
--ez webview_back_button_enabled true |
Show an in-page back button in WebView mode |
--es back_button_timer_delay "10" |
Countdown in seconds when back_button_mode is timer |
--ez overlay_button_visible true |
Show the floating return button in External App mode |
--es overlay_button_position "bottom-right" |
Corner for that button |
--ei pin_max_attempts 5 |
Wrong-PIN attempts before lockout |
--es screen_orientation "landscape" |
FreeKiosk's orientation: auto (follow the device), portrait, landscape, reverse_portrait or reverse_landscape. Not applied to an external app |
--es keyboard_mode "default" |
On-screen keyboard: default, force_numeric, smart or none (no on-screen keyboard; a scanner still types into the fields). Some third-party keyboards (SwiftKey on a Huawei MediaPad M5 Lite, reported in #148) still show their suggestion bar and capitalize the first character of every scan: install a blank input method ("Null Keyboard") and make it the default, keeping your usual keyboard enabled to type the PIN |
Lockdown
| Parameter | Description |
|---|---|
--ez allow_power_button true |
Allow the power menu in lock task |
--ez allow_notifications false |
Allow the notification shade in lock task |
--ez allow_system_info false |
Allow the status bar system info in lock task |
--ez block_factory_reset false |
Apply the DISALLOW_FACTORY_RESET restriction |
--ez allow_hardware_screenshot true |
Allow the Power + Volume Down screenshot while Lock Mode is on (Device Owner only, off by default, applies the next time Lock Mode starts) |
--ez allow_usb_debug_dialog true |
Let the "Allow USB debugging?" prompt appear while Lock Mode is on (Device Owner only, off by default, applies the next time Lock Mode starts; see the troubleshooting entry) |
--ez keep_screen_on true |
Keep the display awake |
--ez auto_wake_on_screen_off true |
Wake the screen again by itself when something turns it off (Settings > Display > Auto Wake on Screen Off); off by default |
--ez pause_page_screen_off true |
Pause the page's own activity (timers, image fetching) while the screen is really off; off by default. A screen-off command, a lock, the power button or a schedule counts, a dimmed screensaver does not |
WebView behavior
| Parameter | Description |
|---|---|
--ez auto_reload true |
Reload the page after a loading error |
--ez hide_error_url true |
Leave the URL out of the loading error screen |
--ez always_load_from_network true |
Fetch every image, script and style sheet from the network on each load, so an updated site never shows old files. Uses more data, and a page cannot show from cache while the network is down |
--ez pdf_viewer_enabled true |
Open PDFs in the bundled viewer. This is also what allows file:// URLs: without it the WebView refuses to load a local file, whatever the label says (see the FAQ) |
--ez disable_overscroll true |
Remove the elastic stretch at the top and bottom of the page. Off by default (Android's standard behaviour) |
--ez pull_to_refresh true |
Drag down from the top of the page to reload it, as in a browser. Off by default |
--ez session_reset_button_enabled true |
Show a small button, bottom-left, that clears cookies, cache and web storage after a confirmation, then returns to the start URL. Meant for shared tablets. Off by default |
--es webview_zoom_level "100" |
Page zoom, 50 to 200 |
--es webview_zoom_mode "standard" |
standard (CSS zoom) or fit (reflow) |
--ez disable_user_zoom false |
Block pinch and double-tap zoom |
--ez inactivity_return_enabled false |
Return to the start URL after inactivity |
--es inactivity_return_delay "60" |
That delay, in seconds |
Multiple URLs
| Parameter | Description |
|---|---|
--ez url_rotation_enabled true |
Cycle through a list of URLs |
--es url_rotation_list '["https://a","https://b"]' |
The list, as a JSON array |
--es url_rotation_interval "30" |
Seconds between changes, minimum 5 |
--ez url_rotation_pause_on_touch true |
Hold the rotation while someone touches the page or types |
--es url_rotation_resume_delay "60" |
Seconds without a touch before the rotation resumes, minimum 5 |
--ez url_planner_enabled true |
Schedule URLs by day and time |
--es url_planner_events '[...]' |
Planner events, as a JSON array |
URL Planner events
url_planner_events takes a JSON array. The planner only runs in Website mode with url_planner_enabled true; outside an event the tablet shows the normal URL. Requires 2.0.0-beta.2 or later: earlier builds ignore both keys without a warning.
adb shell "am start -n com.freekiosk/.MainActivity --es pin YOUR_PIN --ez url_planner_enabled true --es url_planner_events '[{\"id\":\"advert-1\",\"type\":\"oneTime\",\"name\":\"Autumn advert\",\"url\":\"https://example.com/advert.html\",\"enabled\":true,\"priority\":1,\"startDate\":\"2026-10-12\",\"endDate\":\"2026-10-25\",\"allDay\":true}]'"
| Field | Description |
|---|---|
id |
Unique string per event |
type |
oneTime (dated) or recurring (weekly) |
name, url, enabled |
Label, URL to show, on/off |
priority |
1 is highest, used when events overlap; a oneTime event wins over a recurring one of equal priority |
startDate, endDate |
oneTime only, YYYY-MM-DD, local time. The end date is included |
allDay |
oneTime only. true, or give startTime and endTime instead |
days |
recurring only, 0 (Sunday) to 6 (Saturday) |
startTime, endTime |
HH:MM, 24 h, local time. An end before the start runs overnight. For oneTime, a daily window on each day of the range |
Windows PowerShell: it strips the double quotes inside the JSON, and FreeKiosk then receives
[{id:advert-1,...}], which is not valid. Put the command in a.shfile,adb pushit to/data/local/tmpand run it withadb shell sh /data/local/tmp/file.sh, or usecmd.exe/Git Bash.
URL filtering
| Parameter | Description |
|---|---|
--ez url_filter_enabled true |
Restrict which URLs may load |
--es url_filter_mode "blacklist" |
blacklist or whitelist |
--es url_filter_list '[]' |
Patterns, as a JSON array |
--ez url_filter_show_feedback true |
Tell the user when a URL is blocked |
Screen and brightness
| Parameter | Description |
|---|---|
--ez brightness_management_enabled true |
Let FreeKiosk manage brightness |
--es default_brightness "0.5" |
Brightness from 0 to 1 |
--ez auto_brightness_enabled false |
Follow the ambient light sensor |
--ez screen_scheduler_enabled false |
Turn the screen on and off on a schedule |
--es screen_scheduler_rules '[]' |
Schedule rules, as a JSON array |
--ez screen_scheduler_wake_on_touch true |
Touch wakes the screen outside scheduled hours |
--es screensaver_delay "300000" |
Inactivity before the screensaver, in milliseconds (300000 = 5 minutes; 300 would be 0.3 s) |
--es screensaver_brightness "0" |
Brightness while the screensaver is showing |
Screen scheduler rule format
screen_scheduler_rules takes a JSON array of rules. Each rule:
| Field | Type | Meaning |
|---|---|---|
id |
string | Any unique identifier |
name |
string | Shown in the app's rule list |
enabled |
boolean | A disabled rule is kept but ignored |
days |
number[] | 0 = Sunday, 1 = Monday … 6 = Saturday |
sleepTime |
"HH:MM" |
24-hour time the screen turns off |
wakeTime |
"HH:MM" |
24-hour time the screen turns on |
Times are in the tablet's own time zone.
When sleepTime is later than wakeTime, the window runs overnight and days names
the evening it starts. So [1,2,3,4,5] with sleepTime "17:00" and wakeTime "07:00"
turns the screen off every weekday evening and back on the next morning, and leaves it on
all weekend: Saturday is not listed, so no window starts on Saturday evening, and the one
that started on Friday ends on Saturday at 07:00. List 0 and 6 as well for every night.
When sleepTime is earlier than wakeTime, the window sits within the day (a lunch
break, say) on the listed days. Equal times, or a time that is not HH:MM, and the rule is
ignored.
adb shell "am start -n com.freekiosk/.MainActivity --es pin 1234 --ez screen_scheduler_enabled true --es screen_scheduler_rules '[{\"id\":\"office\",\"name\":\"Office hours\",\"enabled\":true,\"days\":[1,2,3,4,5],\"sleepTime\":\"17:00\",\"wakeTime\":\"07:00\"}]'"
This is the format src/types/screenScheduler.ts implements, and the one the app's own rule
editor writes, so a rule built on a tablet and read back from the cloud is a valid example.
Status bar
| Parameter | Description |
|---|---|
--ez status_bar_enabled true |
Show FreeKiosk's own status bar |
--ez status_bar_show_battery true |
Battery indicator |
--ez status_bar_show_wifi true |
Wi-Fi indicator |
--ez status_bar_show_time true |
Clock |
--es status_bar_theme "dark" |
Status bar theme: dark or light |
Kiosk Mode Options
| Parameter | Type | Default | Description |
|---|---|---|---|
--ez kiosk_enabled true |
Boolean | true |
Enable/disable kiosk mode |
--ez auto_start true |
Boolean | - | Auto-launch the locked app after config |
--es auto_launch "true" |
String | - | Auto-launch on boot (alternative to auto_start) |
--es auto_relaunch "true" |
String | - | Auto-relaunch if app crashes/exits. auto_relaunch_app is accepted as a synonym |
--es test_mode "false" |
String | "true" |
"false" = production (sets back_button_mode to immediate). "true" = testing (sets back_button_mode to test). Shortcut for back_button_mode |
--es back_button_mode "immediate" |
String | "test" |
Behavior when returning to FreeKiosk via Android back button: "test" (stay on FreeKiosk, back button allowed), "timer" (countdown then relaunch app), "immediate" (instantly relaunch app). If test_mode is also set, back_button_mode takes priority |
--es status_bar "true" |
String | - | Show custom status bar |
Password Options
| Parameter | Type | Default | Description |
|---|---|---|---|
--es pin_mode "numeric" |
String | numeric |
PIN input mode: numeric (4-6 digits) or alphanumeric (letters, numbers, special chars) |
REST API Options
| Parameter | Type | Description |
|---|---|---|
--es rest_api_enabled "true" |
String | Enable REST API server |
--es rest_api_port "8080" |
String | API server port |
--es rest_api_key "secret" |
String | API authentication key |
MQTT Options
| Parameter | Type | Description |
|---|---|---|
--es mqtt_enabled "true" |
String | Enable MQTT client |
--es mqtt_broker_url "host" |
String | MQTT broker hostname or IP |
--es mqtt_port "1883" |
String | MQTT broker port |
--es mqtt_username "user" |
String | MQTT authentication username |
--es mqtt_password "pass" |
String | MQTT authentication password (stored securely in Keychain) |
--es mqtt_client_id "id" |
String | MQTT client ID (auto-generated if empty) |
--es mqtt_base_topic "freekiosk" |
String | Base MQTT topic prefix |
--es mqtt_discovery_prefix "homeassistant" |
String | Home Assistant MQTT discovery prefix |
--es mqtt_status_interval "30" |
String | Status publish interval in seconds |
--es mqtt_allow_control "true" |
String | Allow remote control via MQTT |
--es mqtt_device_name "name" |
String | Friendly device name for HA discovery |
Media Player Options
| Parameter | Type | Description |
|---|---|---|
--ez media_player_cache true |
Boolean | Play the Media Player from files kept on the device (offline cache). Without it, the default is on for a TV and off everywhere else. The playlist itself is not set over ADB: use Settings or the cloud |
--ez media_player_unattended true |
Boolean | Unattended playback of the Media Player: no error text on screen, and an item that does not load or freezes for 30 seconds is skipped. Without it, the default is on for a TV and off everywhere else. |
--ei media_player_cache_limit_mb 2048 |
Integer | Largest the offline cache may grow, in megabytes (default 2048). A file that would pass it is not downloaded and plays from its URL. A per-device value: it is not part of the cloud config |
Screensaver Options
| Parameter | Type | Description |
|---|---|---|
--es screensaver_enabled "true" |
String | Enable screensaver on inactivity |
Cloud Enrollment
| Parameter | Type | Description |
|---|---|---|
--es cloud_token "TOKEN" |
String | One-time enrollment token from the FreeKiosk Cloud Add device page. The tablet enrolls itself once the app is running |
--es cloud_url "https://..." |
String | Cloud address. Optional: it defaults to https://cloud.freekiosk.app, so only a self-hosted cloud needs it |
adb shell am start -n com.freekiosk/.MainActivity --es pin "1234" --es cloud_token "TOKEN"
Enrolling resets all local settings. The Settings screen warns about it before a manual enrollment; the ADB
route does not ask. The tablet is then configured from the cloud (a profile, or the settings you push), so set what
you need from the cloud, or send the ADB settings after the enrollment: a change made on the tablet is synced up to
the cloud. Settings sent in the same command as cloud_token are lost too (checked on a tablet: a URL and the REST API
settings sent with the token were gone once it had enrolled).
The token is never written to logcat. The enrollment runs the next time the app starts, and only on a tablet that is not enrolled yet: sent to a tablet that is already enrolled, the token is queued and then ignored (unenroll it first from Settings, Advanced, Cloud). If the tablet cannot reach the cloud yet, it retries every 30 seconds; a token that was refused (expired, already used, device limit reached) is reported on the welcome screen.
Scripting the settings gesture
Opening the settings takes return_tap_count taps (5 by default) on the same spot, all
completed within return_tap_timeout (1500 ms by default). The window starts at the first
tap, it is not a delay between two taps. A script that taps with adb shell input tap has to
fit every call into that window. On an emulator over USB a call took about 0.12 s, so the
default is enough there; over wireless adb or from a slow host, a call can take a second or
more (the reporter in #250 measured about
one second), and the counter resets before the fifth tap. Raise the window first, then tap:
adb shell am start -n com.freekiosk/.MainActivity --es pin "1234" --ei return_tap_timeout 15000
for i in 1 2 3 4 5; do adb shell input tap 540 960; done
Taps must land within 80 px of the first one, so use the same coordinates for all of them.
The Settings screen only accepts 500 to 5000 and clamps to that range when it saves, so a
larger value set over ADB lasts until someone saves the settings by hand. Set it back to 1500
afterwards if the tablet will be used by the public. Requires 2.0.0-beta.2 or later: from
1.2.19 to 2.0.0-beta.1 every return_* key was dropped in silence, which is why editing the
stored settings by hand looked like the only way.
Waiting for Configuration Completion
The ADB command returns immediately, but FreeKiosk needs time to save settings and restart. Use broadcast receivers to wait for completion:
TypeScript/JavaScript Example
private async setupKioskModeUsingFreeKiosk(packageName: string): Promise<void> {
console.log(`Setting up kiosk mode for ${packageName}...`);
// Start listening for EXTERNAL_APP_LAUNCHED broadcast
const appLaunchMonitor = this.execAsync(
`adb -s ${this.adbTarget} logcat -c && adb -s ${this.adbTarget} logcat -s "FreeKiosk-ADB" | grep -m 1 "EXTERNAL_APP_LAUNCHED: ${packageName}"`
);
// Send configuration command with auto_start
const kioskCmd = `adb -s ${this.adbTarget} shell am start -n com.freekiosk/.MainActivity --es lock_package "${packageName}" --es pin "${PIN}" --ez auto_start true`;
await this.execAsync(kioskCmd);
// Wait for external app to be launched and visible (timeout after 30s)
console.log("Waiting for app to launch...");
await Promise.race([
appLaunchMonitor,
new Promise((_, reject) =>
setTimeout(() => reject(new Error('App launch timeout after 30s')), 30000)
)
]);
console.log(`✅ ${packageName} is now running and ready!`);
// Start sending video/content here
}
Bash Script Example
#!/bin/bash
PACKAGE="com.example.app"
PIN="1234"
# Monitor logcat for completion marker in background
adb logcat -c
adb logcat -s "FreeKiosk-ADB" | grep -m 1 "SETTINGS_LOADED" &
LOGCAT_PID=$!
# Send configuration
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "$PACKAGE" \
--es pin "$PIN" \
--ez auto_start true
# Wait for completion (with 30s timeout)
timeout 30 wait $LOGCAT_PID
echo "Configuration complete!"
Broadcast Events
FreeKiosk emits these broadcasts during ADB configuration:
| Broadcast Action | When | Description |
|---|---|---|
com.freekiosk.ADB_CONFIG_SAVED |
Immediately after config saved | Database write complete, restart imminent |
com.freekiosk.ADB_CONFIG_RESTARTING |
Just before restart | Process kill in 500ms |
com.freekiosk.SETTINGS_LOADED |
After restart complete | App restarted and settings loaded successfully |
com.freekiosk.EXTERNAL_APP_LAUNCHED |
After external app launch (auto_start=true) | External app is launched and visible (includes package_name extra) |
For WebView mode: Wait for SETTINGS_LOADED
For External App mode with auto_start: Wait for EXTERNAL_APP_LAUNCHED to know when the app is ready to receive content
Waiting for External App Launch
#!/bin/bash
PACKAGE="com.example.app"
PIN="1234"
# Monitor for external app launch
adb logcat -c
adb logcat -s "FreeKiosk-ADB" | grep -m 1 "EXTERNAL_APP_LAUNCHED: $PACKAGE" &
LOGCAT_PID=$!
# Configure and auto-launch
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "$PACKAGE" \
--es pin "$PIN" \
--ez auto_start true
# Wait for app to be visible (with 30s timeout)
timeout 30 wait $LOGCAT_PID
echo "✅ $PACKAGE is now running and ready!"
# Start sending video/content here
Examples
1. Cloud Gaming Kiosk
Lock device to a game streaming app with auto-relaunch (production mode):
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "com.valvesoftware.steamlink" \
--es pin "1234" \
--es auto_relaunch "true" \
--es test_mode "false" \
--ez auto_start true
Note
test_mode "false" sets back_button_mode to immediate, meaning the Android back button will instantly relaunch the app. Omit it or set to "true" during testing to allow the back button to return to FreeKiosk without auto-relaunch.
🏨 2. Hotel Room Tablet
Display hotel dashboard with REST API for Home Assistant:
adb shell am start -n com.freekiosk/.MainActivity \
--es url "https://hotel.local/dashboard" \
--es pin "5678" \
--es rest_api_enabled "true" \
--es rest_api_port "8080" \
--es rest_api_key "hotel_secret_key" \
--es screensaver_enabled "true"
🍽️ 3. Restaurant Menu Display
Simple URL kiosk:
adb shell am start -n com.freekiosk/.MainActivity \
--es url "https://menu.restaurant.com" \
--es pin "0000" \
--es status_bar "false"
4. Multi-App Kiosk
Configure a home screen grid with multiple apps:
adb shell "am start -n com.freekiosk/.MainActivity \
--es external_app_mode multi \
--es managed_apps '[{\"packageName\":\"com.spotify.music\"},{\"packageName\":\"com.netflix.mediaclient\"},{\"packageName\":\"com.youtube\",\"launchOnBoot\":true,\"keepAlive\":true}]' \
--es pin 1234 \
--es test_mode false"
Tip: Display names are auto-resolved from the system. You can override them:
--es managed_apps '[{\"packageName\":\"com.app\",\"displayName\":\"My Custom Name\"}]'
5. Full JSON Configuration
For complex setups, use a JSON config. Note that shell escaping can be tricky - using individual parameters is often easier:
# JSON goes in single quotes inside the double-quoted command (see "Quoting JSON values")
adb shell "am start -n com.freekiosk/.MainActivity \
--es pin 1234 \
--es config '{\"lock_package\":\"com.app\",\"auto_relaunch\":\"true\"}'"
# Or use individual parameters (recommended for shell scripts)
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "com.app" \
--es auto_relaunch "true" \
--es status_bar "true" \
--es rest_api_enabled "true" \
--es rest_api_port "8080" \
--es pin "1234"
6. Modify Existing Configuration
Change the locked app on an already-configured device:
# Must use the existing PIN
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "com.newapp.package" \
--es pin "1234"
JSON Configuration Format
When using --es config '{...}', the following keys are supported:
{
"url": "https://example.com",
"lock_package": "com.example.app",
"display_mode": "external_app",
"external_app_mode": "multi",
"managed_apps": [
{"packageName": "com.app1", "showOnHomeScreen": true},
{"packageName": "com.app2", "launchOnBoot": true, "keepAlive": true}
],
"kiosk_enabled": "true",
"auto_launch": "true",
"auto_relaunch": "true",
"screensaver_enabled": "true",
"screensaver_delay": "300000",
"screensaver_brightness": "10",
"status_bar_enabled": "true",
"status_bar_show_battery": "true",
"status_bar_show_wifi": "true",
"status_bar_show_time": "true",
"rest_api_enabled": "true",
"rest_api_port": "8080",
"rest_api_key": "your_api_key",
"allow_power_button": "false",
"back_button_mode": "immediate",
"test_mode": "false",
"default_brightness": "75",
"brightness_management_enabled": "true",
"mqtt_enabled": "true",
"mqtt_broker_url": "broker.local",
"mqtt_port": "1883",
"mqtt_username": "user",
"mqtt_password": "password",
"mqtt_client_id": "tablet1",
"mqtt_base_topic": "freekiosk",
"mqtt_discovery_prefix": "homeassistant",
"mqtt_status_interval": "30",
"mqtt_allow_control": "true",
"mqtt_device_name": "Kitchen Tablet"
}
Complete Provisioning Script
Here's a complete bash script for provisioning a new device:
#!/bin/bash
# provision_kiosk.sh - Provision a FreeKiosk device
PACKAGE="com.cloudgaming.app"
PIN="1234"
API_KEY="my_secret_key"
echo "Setting Device Owner..."
adb shell dpm set-device-owner com.freekiosk/.DeviceAdminReceiver
echo "Waiting for device..."
sleep 2
echo "Granting Usage Stats permission (required for foreground monitoring)..."
adb shell appops set com.freekiosk android:get_usage_stats allow
echo "Granting WRITE_SECURE_SETTINGS (required for auto-enabling accessibility service)..."
adb shell pm grant com.freekiosk android.permission.WRITE_SECURE_SETTINGS
echo "Configuring FreeKiosk..."
adb shell am start -n com.freekiosk/.MainActivity \
--es lock_package "$PACKAGE" \
--es pin "$PIN" \
--es auto_relaunch "true" \
--es test_mode "false" \
--es rest_api_enabled "true" \
--es rest_api_port "8080" \
--es rest_api_key "$API_KEY" \
--ez auto_start true
echo "✅ Device provisioned!"
echo " Locked to: $PACKAGE"
echo " REST API: http://<device-ip>:8080"
💻 PowerShell Script (Windows)
# provision_kiosk.ps1 - Provision a FreeKiosk device (Windows)
$Package = "com.cloudgaming.app"
$Pin = "1234"
$ApiKey = "my_secret_key"
Write-Host "Setting Device Owner..."
adb shell dpm set-device-owner com.freekiosk/.DeviceAdminReceiver
Start-Sleep -Seconds 2
Write-Host "Granting Usage Stats permission..."
adb shell appops set com.freekiosk android:get_usage_stats allow
Write-Host "Granting WRITE_SECURE_SETTINGS..."
adb shell pm grant com.freekiosk android.permission.WRITE_SECURE_SETTINGS
Write-Host "Configuring FreeKiosk..."
# Note: JSON escaping in PowerShell is complex, use individual parameters
adb shell am start -n com.freekiosk/.MainActivity `
--es lock_package $Package `
--es auto_relaunch "true" `
--es test_mode "false" `
--es rest_api_enabled "true" `
--es rest_api_port "8080" `
--es rest_api_key $ApiKey `
--es pin $Pin `
--ez auto_start true
Write-Host "✅ Device provisioned!"
Troubleshooting
Error: "Can't set package ... as device owner"
java.lang.RuntimeException: Can't set package ComponentInfo{com.freekiosk/com.freekiosk.DeviceAdminReceiver} as device owner.
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:177)
dpm reports every provisioning failure with this same message, so it never tells
you which precondition failed. Run the diagnostic script instead — it checks each
one separately and names the blocker:
# Windows
.\scripts\set-device-owner.ps1
The preconditions it checks, and how to clear each:
| Blocker | Fix |
|---|---|
| FreeKiosk not installed | adb install app-release.apk |
| A device owner is already set | Factory reset. -Remove / dpm remove-active-admin only works if the APK was built android:testOnly="true" |
| Secondary users exist | adb shell pm remove-user <id> |
| Any account is on the device | Remove every account under Settings → Accounts, then retry |
android.software.device_admin missing |
See below — the ROM has no device policy support |
Warning
adb shell dpm set-active-admin prints Success: even when it did nothing —
the tool never checks the return value. Confirm with
adb shell dumpsys device_policy, which lists the admin only if it really
was registered.
ROM does not declare android.software.device_admin
Many cheap Android TV boxes (MXQ, X96, H96 and similar) ship AOSP TV builds with the device admin feature stripped out. Check with:
adb shell pm list features | grep device_admin
If that prints nothing, DevicePolicyManagerService is running with
mHasFeature = false: setDeviceOwner() returns false unconditionally and
setActiveAdmin() is a no-op. No change to FreeKiosk can work around this —
the feature has to be declared in the system image.
On a userdebug or eng build that grants adb root (check with
adb shell getprop ro.build.type), the script can declare it for you:
.\scripts\set-device-owner.ps1 -Fix # writes to /system, then REBOOTS the device
Equivalent manual steps:
adb root && adb remount
adb shell 'cat > /system/etc/permissions/android.software.device_admin.xml <<EOF
<permissions>
<feature name="android.software.device_admin" />
</permissions>
EOF'
adb shell chmod 644 /system/etc/permissions/android.software.device_admin.xml
adb shell restorecon /system/etc/permissions/android.software.device_admin.xml
adb reboot # the feature list is only parsed at boot
adb shell dpm set-device-owner com.freekiosk/.DeviceAdminReceiver
Notes:
- The change survives reboots, but not a factory reset or an OTA that
rewrites
/system. Reapply it after either. - On a
userbuild withoutadb root,/systemcannot be modified. Such a box cannot be provisioned as Device Owner without reflashing it, so run FreeKiosk in its non-Device-Owner mode instead (grant "Display over other apps" and "Usage Access" by hand — see the sections below). android.software.managed_usersis usually missing on the same ROMs. Device Owner and lock task do not need it; work profiles and secondary users do.
FreeKiosk does not start after a reboot
First confirm it is really the boot path that is broken, not the app:
adb logcat -d | grep -E 'Start proc .*freekiosk|E/BootReceiver'
BootReceiver logs an error about WRITE_SECURE_SETTINGS on every BOOT_COMPLETED
run (harmless in itself). If that line is absent after a reboot, the receiver never
received BOOT_COMPLETED — the ROM dropped the broadcast, and no FreeKiosk setting
can fix it. Verify the receiver itself still works by delivering an equivalent
broadcast by hand:
adb root
adb shell am broadcast -a android.intent.action.QUICKBOOT_POWERON -n com.freekiosk/.BootReceiver
# FreeKiosk should appear ~4 s later
Note
am broadcast -a android.intent.action.BOOT_COMPLETED is silently dropped even as
root — it is a protected broadcast. It prints Broadcast completed: result=0 and
starts nothing, which looks like a FreeKiosk bug but is not. Use
QUICKBOOT_POWERON, which BootReceiver also handles.
Two ROM behaviours have been observed to break boot launch, both on Android TV boxes (Droidlogic/MXQ, Android 9):
BOOT_COMPLETEDis never delivered to third-party manifest receivers, so "Launch on Boot" never fires.- The Home intent is resolved while user 0 is still locked.
MainActivityis notdirectBootAware, so it is filtered out of that query and the OEM launcher wins Home — the Device Owner default-launcher policy is registered correctly but is never consulted. Android does not re-resolve Home after unlock, so the OEM launcher keeps the screen for the rest of the session.pm disable-useron the OEM launcher does not help: the ROM re-enables it at boot.
Confirm (2) with:
adb shell pm resolve-activity -a android.intent.action.MAIN -c android.intent.category.HOME
If that returns com.freekiosk.MainActivity while the OEM launcher is nonetheless on
screen after a reboot, the Home intent was resolved before FreeKiosk was eligible.
Workaround (needs a userdebug/eng ROM that grants adb root):
.\scripts\install-boot-autostart.ps1 # installs, reboots, verifies
It installs /system/bin/freekiosk-autostart.sh and an init .rc that runs it on
sys.boot_completed=1; the script waits for user 0 to unlock, then starts
MainActivity, retrying up to three times. Verified over three consecutive reboots on
the MXQ box. Undo with .\scripts\install-boot-autostart.ps1 -Uninstall and a reboot.
Like the device_admin patch above, this lives in /system and does not survive a
factory reset or an OTA that rewrites /system.
Error: "PIN required for first setup"
Cause: Device has no PIN configured, but none was provided.
Solution: Add --es pin "XXXX" to your command.
Error: "PIN required" / "Invalid PIN"
Cause: Device already configured, wrong or missing PIN.
Solution: Use the existing PIN configured on the device.
Error: "Package not found"
Cause: The lock_package app is not installed on the device.
Solution: Install the target app first:
adb install myapp.apk
External app doesn't stay on top / disappears
Cause: FreeKiosk requires "Display over other apps" (SYSTEM_ALERT_WINDOW) permission to keep external apps locked.
Solution:
Option 1: Set Device Owner (recommended for kiosks)
adb shell dpm set-device-owner com.freekiosk/.DeviceAdminReceiver
With Device Owner, FreeKiosk can automatically grant itself all required permissions including "appear on top" and "Usage Access".
Option 2: Manual permission (without Device Owner)
- Go to Settings → Apps → FreeKiosk → Display over other apps
- Enable the permission manually
EXTERNAL_APP_LAUNCHED not appearing in logcat
Cause: Without Device Owner, the "Usage Access" (PACKAGE_USAGE_STATS) permission must be granted manually for FreeKiosk to verify that the external app is in the foreground.
Solution: Grant the permission via ADB:
adb shell appops set com.freekiosk android:get_usage_stats allow
Without this permission, the broadcast will still be emitted but with (NOT verified) instead of (verified in foreground). The logcat tag is FreeKiosk-ADB:
adb logcat -s "FreeKiosk-ADB"
Note
Device Owner can only be set when no user accounts are active on the device (Settings → Accounts). Remove all accounts first, then run the command. You can sign back in afterwards. If account removal alone doesn't work, a factory reset is a reliable fallback. Once set, all permissions are managed automatically.
♿ Accessibility Service: "Permission denial: WRITE_SECURE_SETTINGS"
Cause: The WRITE_SECURE_SETTINGS permission is required to programmatically enable the Accessibility Service. Being a Device Owner alone does not grant this permission automatically.
Solution: Grant the permission via ADB (one-time):
adb shell pm grant com.freekiosk android.permission.WRITE_SECURE_SETTINGS
After granting, tap "Enable Automatically (Device Owner)" in Settings → Advanced → Accessibility Service. The permission persists across reboots.
Alternatively, you can enable the Accessibility Service manually: Settings → Accessibility → Installed Services → FreeKiosk.
❓ Nothing happens
Cause: ADB debugging might be disabled or device not authorized.
Solution:
- Enable USB Debugging in Developer Options
- Accept the "Allow USB debugging" prompt on device
- Verify with
adb devices
🔒 The "Allow USB debugging" prompt does not appear in Lock Mode
Symptom: a computer that was never authorized shows as unauthorized in adb devices, and the prompt never shows on the tablet while Lock Mode is on.
Cause: the prompt is a screen of the system interface (SystemUI), and Lock Mode only lets whitelisted apps come to the front. Checked on an Android 15 emulator: with the setting off, the system refuses it (Attempted Lock Task Mode violation); with it on, a SystemUI screen opens over Lock Mode.
Solutions:
- Authorize the computer before turning Lock Mode on. The authorization is remembered.
- For a new computer later, turn Lock Mode off in the settings (5 taps, PIN), plug the computer in, tap Allow, then turn Lock Mode back on.
- Or switch on Settings > Security > Allow the USB Debugging Prompt In Lock Mode (
--ez allow_usb_debug_dialog true). Device Owner only, off by default, and it takes effect the next time Lock Mode starts. While it is on, anyone who can plug a computer into the tablet can see the prompt and tap Allow, which gives that computer ADB access, and the other screens of the system interface are no longer blocked either. Turn it off when you are done.
The real prompt could not be triggered on the emulator (it does not enforce ADB authorization), and only stock Android (com.android.systemui) was checked: on a manufacturer's Android the prompt may belong to another package.
🔄 How to reset and re-provision
# Option 1: Factory reset (loses all data)
adb shell am broadcast -a android.intent.action.MASTER_CLEAR
# Option 2: Remove Device Owner from the app (needs the PIN): Settings > Advanced > Remove Device Owner.
# `adb shell dpm remove-active-admin` is refused on a release build (see the table above).
# Then clear the FreeKiosk data:
adb shell pm clear com.freekiosk
Security Considerations
| Risk | Mitigation |
|---|---|
| ADB Access = Full Control | Anyone with ADB access to an unlocked device can potentially reconfigure it. Disable USB debugging in production. |
| PIN Storage | The ADB PIN is saved to Android Keystore via react-native-keychain with PBKDF2 hashing (same secure storage as the UI PIN). The native side also keeps a SHA-256 hash for ADB re-authentication. |
| Network ADB | If using adb tcpip, ensure proper network security as anyone on the network could potentially access ADB. |
| Configuration Storage | ADB configuration is first saved to SharedPreferences as a "pending config", then applied to AsyncStorage by React Native on the next startup. This two-step bridge ensures reliable persistence across process restarts (~500ms). |
Recommendations:
- Use strong PINs (6+ digits)
- Disable USB debugging after setup in production
- Use Device Owner mode for full kiosk lockdown
- Consider physical security of USB port
See Also
- REST API Documentation - Remote control via HTTP
- Installation Guide - Manual setup instructions