tree: 602211ac287cd2571b4b381e18d2799eb3f38a2d [search]
  1. ApiContractModels.kt
  2. README.md
  3. schema.md
  4. settings_api.json
src/com/android/settings/validation/README.md

Settings Platform API Tracking & Gating

This is an automated build-time gating pipeline designed to protect the static contract boundaries of the Settings Platform framework.


🔍 What is this pipeline?

The Settings Platform framework relies on Kotlin DSL configurations (PreferencesApiScreen) to expose settings data access interfaces consumed by automated clients and AI agents.

Without static gating, developers could land changes that accidentally alter settings keys, mutate primitive data types (e.g., turning a boolean switch into an integer range), or drop security permissions completely unreviewed. This creates a high risk of silent runtime crashes, semantic regressions, and security bypasses for downstream services.

This pipeline extracts the static layout of all settings platform stubs into a single-source-of-truth contract file in the package directory: 👉 packages/apps/Settings/src/com/android/settings/validation/settings_api.json


🚨 Why did the presubmit test fail?

If you are reading this guide, it is likely because the presubmit validation test SettingsApiGeneratorTest failed in your CL.

This failure occurs because you have modified, added, or removed a Settings Platform API screen or preference definition. Since your code edits altered the active API stubs, the generated stubs no longer match the committed settings_api.json file, triggering a presubmit diff mismatch assertion.


🛠️ How to Fix the Failure (Regeneration)

To resolve the failure and unblock your presubmit, you simply need to regenerate settings_api.json in your local workspace to match the latest state of your code, and then amend your commit:

  1. Initialize your build environment and target:

    . build/make/rbesetup.sh
    lunch rango-trunk_staging-userdebug
    

    (Or lunch your device's specific target)

  2. Run the automated regeneration script:

    ./packages/apps/Settings/generate_settings_api_json.sh
    

    This script will compile Settings, execute the Robolectric extraction test, capture the dynamic JSON payload, and automatically overwrite your local settings_api.json file.

  3. Verify the Git diff and amend your commit:

    git diff src/com/android/settings/validation/settings_api.json
    git add src/com/android/settings/validation/settings_api.json
    git commit --amend --no-edit
    

🛡️ Code Ownership & Approvals

Because settings_api.json is a critical contract file, changes to it are gated by per-file path ownership rules in the packages/apps/Settings/OWNERS file.

Amending your commit with the updated settings_api.json file will automatically route your CL to the designated Settings Platform API Maintainers for explicit review and approval.