feat: fleet/headless configuration profile support#559
Draft
djbclark wants to merge 2 commits into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.FleetProfileActivityThe activity is exported, headless (
Theme.NoDisplay), finishes immediately — no UI, no Toasts. Result is delivered four ways:startActivityForResultcallers getresult_success,result_applied_count,result_applied_keys[], etc.org.autojs.autojs6.action.FLEET_PROFILE_RESULTwith same extrasresult_path(default alongside profile or/sdcard/autojs6-fleet-result.json)/sdcard/autojs6-fleet-YYYY-MM-DD.logwith Unix-styleINFO/WARN/ERRORlinesProfile 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. Seedocs/FLEET_PROFILE.mdfor all aliases and supported value types.Files changed
FleetProfileApplier.kt(381 lines)FleetProfileActivity.kt(158 lines)AndroidManifest.xml(+20 lines)fleet_profile_default.json(31 lines)FLEET_PROFILE.md(170 lines)FleetProfileApplierTest.kt(202 lines)Design decisions
finish()immediately.SharedPreferencesparameter 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)
result_path/profile_pathresolved by canonical path resolution innormalizePath()andsafeFile()storage-root boundary check inFleetProfileActivity.clear_existingnow logs a warning when used, and has an explicit caveat comment.