Skip to content

feat: fleet/headless configuration profile support#559

Draft
djbclark wants to merge 2 commits into
SuperMonster003:masterfrom
djbclark:pr/fleet-profile
Draft

feat: fleet/headless configuration profile support#559
djbclark wants to merge 2 commits into
SuperMonster003:masterfrom
djbclark:pr/fleet-profile

Conversation

@djbclark

@djbclark djbclark commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Adds support for applying a JSON configuration profile without opening the app UI. Intended for fleet/headless deployments (MDM, provisioning tools, CI/CD) where the initial drawer toggles and settings would otherwise require fragile UI automation.

Apply a profile

adb shell am start -a org.autojs.autojs6.action.APPLY_FLEET_PROFILE \
    -e profile_path /sdcard/Download/autojs6-fleet.json \
    org.autojs.autojs.core.pref.fleet.FleetProfileActivity

The activity is exported, headless (Theme.NoDisplay), finishes immediately — no UI, no Toasts. Result is delivered four ways:

  1. Activity resultstartActivityForResult callers get result_success, result_applied_count, result_applied_keys[], etc.
  2. Broadcastorg.autojs.autojs6.action.FLEET_PROFILE_RESULT with same extras
  3. JSON result file — at result_path (default alongside profile or /sdcard/autojs6-fleet-result.json)
  4. Daily rotating log/sdcard/autojs6-fleet-YYYY-MM-DD.log with Unix-style INFO/WARN/ERROR lines

Profile format

Human-readable aliases for preference keys and ListPreference values:

{
  "foreground_service": true,
  "floating_menu_shown": false,
  "restart_strategy": "quick",
  "timed_task_backend": "alarm",
  "night_mode": "follow_system"
}

Raw key_$_... keys are also accepted. See docs/FLEET_PROFILE.md for all aliases and supported value types.

Files changed

File Purpose
FleetProfileApplier.kt (381 lines) Core logic — JSON parsing, key/value alias resolution, SharedPreferences writes
FleetProfileActivity.kt (158 lines) Exported headless Activity entry point
AndroidManifest.xml (+20 lines) Registers exported activity
fleet_profile_default.json (31 lines) Bundled reference profile for unattended deployments
FLEET_PROFILE.md (170 lines) User-facing documentation
FleetProfileApplierTest.kt (202 lines) 18 instrumented tests

Design decisions

  • Silent operation: No Toast, no UI, calls finish() immediately.
  • Alias tables: Human-readable key names and value names for readable profiles.
  • Defensive value passthrough: Logs a warning on unrecognized aliases, then passes through.
  • Test isolation: Accepts a SharedPreferences parameter for non-destructive tests.
  • clear_existing: Available but documented as destructive — wipes ALL preferences.

See also

Thank you for building and maintaining AutoJs6 — it is an essential tool for Android automation.

Security (addressed in review)

  • Path traversal via result_path/profile_path resolved by canonical path resolution in normalizePath() and safeFile() storage-root boundary check in FleetProfileActivity.
  • Exported activity with no caller permission — documented. The activity only writes AutoJs6's own SharedPreferences (not system settings). Profile files should come from trusted sources.
  • clear_existing now logs a warning when used, and has an explicit caveat comment.

djbclark added 2 commits July 14, 2026 00:16
FleetProfileApplier parses JSON profiles and writes preferences to
SharedPreferences, resolving human-readable key aliases (e.g.
'foreground_service') and value aliases (e.g. 'alarm' -> timed task
backend key) to internal preference keys.

FleetProfileActivity is an exported headless Activity (Theme.NoDisplay)
that applies a fleet profile via am start without any UI. Profiles can
be passed as a file path or content URI.

This is useful for MDM, fleet management, provisioning tools, and CI/CD
- anywhere you want to pre-configure AutoJs6 preferences without UI
automation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant