Skip to content
Aurelio Bernal edited this page Nov 30, 2026 · 5 revisions

API overview

ClusterTune's external API (version 1) lists and applies profiles, reads what is applied and why, changes the saved CPU/GPU settings, reads the device's capabilities, and manages per-app assignments. It adds no service, timer or polling loop to ClusterTune, shows no toast, and does not open the app.

  • Provider authority: com.aure.clustertune.api, URI content://com.aure.clustertune.api
  • JSON frequencies: CPU in integer kHz, GPU in integer Hz. The short settings syntax uses MHz by default.
  • Every name and value is defined in the contract library.

Ways in

Entry point Who uses it Details
ContentResolver.call(uri, method, arg, extras) Android apps Java library
clustertune command line ADB from a computer Command line
adb shell content call … ADB, firmware with Android's content command Raw ADB commands
adb shell am broadcast … ShellApiReceiver … ADB, every firmware (the command line uses it) Raw ADB commands
Locale/Tasker action plugin Tasker, MacroDroid, Automate Tasker plugin

All of them run the same code: method names, arguments, validation, errors and replies are identical. Calls from every entry point are serialized together.

Access

There is no Android permission to request. ClusterTune identifies each caller and asks the user once, like Magisk or KernelSU ask about root:

  • ClusterTune itself and root (UID 0) are always allowed; root could change the clocks directly anyway.
  • Apps (identified by their Binder UID) and ADB (as "ADB shell") are asked the first time: "Allow App to control ClusterTune?". The call that raised the question waits for the answer (60 seconds; 45 seconds through am broadcast) and then runs or fails with access_denied. Other calls from the same caller while the question is open, and a call whose question went unanswered, fail with access_pending without running.
  • Automation apps are asked when they first add a ClusterTune plugin action (see Tasker plugin).
  • Android does not let a background app open a dialog, so unless ClusterTune is on screen the question arrives as a high-importance notification; tapping it opens the dialog.

Every decision is listed under Settings → App access, where it can be switched or removed (asked again next time); ADB is always listed first, so it can be allowed before its first command. Decisions are checked on every call and recorded in History. Several apps sharing one UID are allowed if any of them is allowed. Package names, claimed UIDs, URI grants and extras cannot grant access.

The provider's other entry points (query, insert, files, batches, MIME types…) expose nothing: callers that are not allowed get a SecurityException without being asked, allowed ones UnsupportedOperationException.

Methods

Methods are named resource.verb. A resource name alone runs its read method.

Resource Methods Shortcut
state: what is applied right now and why state.get state
tuning: the saved CPU/GPU settings ClusterTune applies and restores tuning.get, tuning.set tuning
profile: saved profiles profile.list, profile.apply profile
app: per-app assignments app.list, app.set, app.clear app
device: CPU policies, frequency steps, governors, GPU device.get device
api: version and discovery api.info api

One rule connects every entry point: the command line uses the method name with a space, and its remaining words are the argument:

clustertune profile apply medium      =  method "profile.apply", arg "medium"
clustertune tuning                    =  method "tuning" (shortcut for "tuning.get"), no arg

See API methods for every method's argument, reply and examples.

Tuning, state and profiles

  • tuning is what ClusterTune keeps applied: the "normal" settings it restores after an app assignment, the sleep profile or Auto Tune ends. Applying a profile or changing values (profile.apply, tuning.set) changes the saved tuning and applies it.
  • state is what is actually applied now, which can differ from tuning while an app assignment, the sleep profile or Auto Tune is active. It also says who applied it.
  • A profile is a named set of values; applying it copies it into the tuning. tuning.get names the profile when the tuning still matches it.

Replies

Every call returns the same fields: a Bundle from ContentResolver.call, or one JSON object from am broadcast and the command line's --json.

Field Type Meaning
api_version Int 1
ok Boolean Whether the call succeeded
code String ok or an error code
message String Explanation on failure, for people; do not parse it
data String (JSON object) The result; on failure {} or failure details

Clients should ignore reply fields they do not know; new ones may be added within version 1.

Extras

Extra Type Meaning
api_version Int Optional; only 1 is accepted
if_revision String Optional, for profile.apply and tuning.set: apply only if the saved tuning still has this revision (see Conditional writes)

Unknown extras, other versions, or if_revision on other methods fail with invalid_argument or unsupported_version. Read methods take no argument.

Request objects

Instead of separate method, argument and extras, a whole request can be sent as one JSON object through the method request, with the object as its argument:

{"method": "tuning.set", "arg": "cpu6.max=2.4GHz gpu.max=600", "if_revision": "7e5f24cdc5c80ef4"}
Field Meaning
method Required. Any method or shortcut, for example profile.apply or tuning
arg The argument as a string. For tuning.set and app.set it may also be a JSON object (the JSON settings or assignment)
if_revision Optional, as the extra
api_version Optional, as the extra

The request runs exactly as if its fields were passed separately, and the reply is that method's reply. Unknown fields, a nested request, or if_revision passed as a separate extra fail with invalid_argument. It works in every entry point:

echo '{"method":"profile.apply","arg":"medium"}' | adb shell sh /sdcard/Android/data/com.aure.clustertune/files/clustertune --request -
adb shell 'am broadcast -n com.aure.clustertune/.api.ShellApiReceiver --es method request --es arg '\''{"method":"tuning"}'\'''
contentResolver.call(uri, "request", """{"method":"tuning.set","arg":{"cpu":[{"id":6,"max_khz":2246400}]}}""", null)

Errors

Code Meaning data
access_denied The user denied this app or ADB
access_pending The user has not answered yet, or the question expired
unknown_method No such method; the message lists them
invalid_argument Bad argument or extra; nothing was changed
unsupported_version api_version other than 1
profile_not_found No profile matches; the message lists the names
ambiguous_profile Several profiles match a name matches: [{id, name}]
unsupported Not supported on this device or in this state (for example GPU tuning without a GPU, or an Auto Tune assignment while Auto Tune is off)
unavailable The privileged host cannot be used reason, execution_method, host_error
conflict if_revision no longer matches; nothing was written revision: the current one
apply_failed Writing to the hardware failed; the host rolled back
superseded A newer request replaced this one, possibly after the hardware was written
persistence_failed The hardware was written, but the saved tuning could not be stored
operation_failed Any other failure
response_too_large A read reply exceeded 262,144 characters

unavailable reasons: no_execution_method (neither PServer nor root works), host_unavailable (a method was found, but the privileged host could not be started or queried; host_error says why when known) and no_cpu_policies. Read state.get and tuning.get after superseded or persistence_failed. Validation errors never reach the hardware; failed writes use the host's existing rollback and verification. Work after a successful write (History, the Quick Settings tile) never turns that success into a failure.

Short settings syntax

tuning.set and app.set accept settings like:

cpu6.max=2.4GHz gpu.max=600 cpu.gov=schedutil cpu0.min=stock
  • Settings are TARGET.FIELD=VALUE, separated by spaces or commas (commas avoid quoting through adb shell).
  • Targets: cpuN (a policy ID from device.get), cpu (every policy; a cpuN setting overrides it) and gpu.
  • Fields: max, min (CPU only) and gov (also governor).
  • Frequencies are MHz unless they carry a unit: 2.4GHz, 2400, 2400MHz, 2400000kHz and 2400000000Hz are the same.
  • stock selects the Stock maximum, or the Stock (automatic) minimum; default releases a governor override.
  • Frequencies snap to a supported step: maximums down, minimums up, so a requested ceiling is never exceeded and a requested floor never undercut. Values beyond the range use the last step. Every moved value is reported in the reply's adjusted list, for example {"setting": "gpu.max", "requested": "600", "applied_hz": 525000000} (applied_khz for CPU).

The short form is translated into the JSON form below and validated the same way. JSON values are exact: they must be supported steps, in kHz or Hz, and null stands for stock/default:

{
  "cpu": [{"id": 6, "max_khz": 2438400, "min_khz": null, "governor": "schedutil"}],
  "gpu": {"max_hz": 525000000, "governor": null}
}

JSON rules: at least one setting; at most 64 CPU entries; no duplicate or unknown policies or fields; minimum not above maximum; governors must be listed by device.get. Arguments are limited to 32,768 characters.

Profile names

profile.apply and app.set accept a profile ID, its exact name ignoring case (medium underclock), or a unique start of the name or of one of its words (medium, large u, stock). Several matches fail with ambiguous_profile and list them; nothing is guessed. Apps should store profile IDs, because users can rename profiles.

Conditional writes

tuning.get returns a revision of the saved tuning. Pass it as if_revision to profile.apply or tuning.set, and ClusterTune compares it under the lock that serializes every apply: if anything changed the saved tuning since, the call fails with conflict (and the current revision in data) instead of writing. This makes a retry after a lost reply safe: if the first call succeeded, the retry fails with conflict rather than applying twice.

tuning.set is always conditional on the saved tuning it was built from, even without if_revision, so concurrent changes are never silently overwritten.

Change notifications

Instead of polling, register a ContentObserver on content://com.aure.clustertune.api with notifyForDescendants = true. Notifications carry no data: re-read with the matching method.

URI Signalled when Re-read with
…/state Any successful apply (manual, API, app assignment, sleep, boot), or Auto Tune starting, stopping or changing target. Individual Auto Tune steps and firmware changes are not signalled. state.get
…/tuning The saved tuning changes tuning.get
…/profile A profile is created, edited, deleted or reordered profile.list
…/app An app assignment changes, or the Auto Tune setting is switched app.list

Observing needs no approval; the signals only say that something changed.

Raw ADB commands

The command line is the convenient way. The raw forms are useful in scripts that already parse JSON:

# Android's content command
adb shell content call --uri content://com.aure.clustertune.api --method profile.apply --arg medium
adb shell content call --uri content://com.aure.clustertune.api --method tuning.set --arg 'cpu6.max=2.4GHz,gpu.max=600' --extra if_revision:s:7e5f24cdc5c80ef4

# Broadcast entry point (works where content is missing, for example on the AYN Odin 3)
adb shell am broadcast -n com.aure.clustertune/.api.ShellApiReceiver --es method state
adb shell am broadcast -n com.aure.clustertune/.api.ShellApiReceiver --es method tuning.set --es arg 'cpu6.max=2.4GHz,gpu.max=600'

content prints Result: Bundle[…]. am broadcast prints Broadcast completed: result=-1, data="{…}" (result=1 on an API failure), where data is the reply object. Neither command's exit status reflects API failures; check ok. The broadcast receiver only accepts senders holding android.permission.DUMP (ADB, root, the system); Android does not say which of them sent it, so every broadcast call uses the ADB shell decision.

Clone this wiki locally