Repository navigation
API
ClusterTune's external API (version 1) lets other apps, scripts and automations apply profiles, change the CPU/GPU settings, read what is applied and why, look up the device's frequency steps, and manage per-app settings. It adds no background service, timer or polling to ClusterTune, shows no toast, and does not open the app.
At a glance:
- One provider,
content://com.aure.clustertune.api, reached withContentResolver.call(uri, method, arg, extras). - Methods are named
resource.verb(profile.apply); a resource alone (profile) runs its read method. - Arguments are short strings (
medium,cpu6.max=2.4GHz gpu.max=600); replies carry JSON. - No permission to request: the user allows each caller once, like a root manager.
- All names and values are constants in the contract library.
| Entry point | For | Details |
|---|---|---|
ContentResolver.call(…) |
Android apps | Java library |
clustertune command line |
Computers over ADB | Command line |
adb shell content call … |
ADB on firmware with Android's content command |
Raw ADB commands |
adb shell am broadcast … |
ADB on any firmware (the command line uses it) | Raw ADB commands |
| Locale/Tasker action plugin | Tasker, MacroDroid, Automate | Tasker plugin |
They all run the same code, so method names, arguments, validation, errors and replies are identical. Requests from all of them are applied one at a time.
| Resource | What it is |
|---|---|
| tuning | The CPU/GPU settings ClusterTune keeps applied: limits, minimums and governors per CPU policy, plus the GPU limit and governor. Applying a profile or changing values updates the tuning, and ClusterTune restores it whenever an app assignment, the sleep profile or Auto Tune ends. |
| state | What is actually applied right now, and who applied it. It differs from the tuning while an app assignment, the sleep profile or Auto Tune is active. |
| profile | A named set of values (bundled, your own, or Stock). Applying one copies it into the tuning. |
| app | Per-app assignments: a profile, custom values or an Auto Tune target that ClusterTune applies while that app is visible. |
| device | The hardware's CPU policies, supported frequency steps, governors and GPU. |
CPU policies are groups of cores that share frequency controls. They are identified by an ID such as 0 or 6; read the IDs from device.get rather than assuming them.
| Resource | Methods | Shortcut |
|---|---|---|
state |
state.get |
state |
tuning |
tuning.get, tuning.set
|
tuning |
profile |
profile.list, profile.apply
|
profile |
app |
app.list, app.set, app.clear
|
app |
device |
device.get |
device |
api |
api.info |
api |
The shortcut is the resource name alone, standing for its read method. The command line uses the same names with a space, and its remaining words become the argument:
clustertune profile apply medium → method "profile.apply", arg "medium"
clustertune tuning → method "tuning" (= "tuning.get"), no arg
Every method's argument, reply and examples: API methods.
A request is a method, an optional argument string and optional extras:
| Extra | Type | Meaning |
|---|---|---|
api_version |
Int | Optional; only 1 is accepted. Pass it to fail clearly against a future, incompatible API |
if_revision |
String | Optional, for profile.apply and tuning.set: apply only if the saved tuning still has this revision (Conditional writes) |
Read methods take no argument. Arguments are limited to 32,768 characters. Unknown extras, another api_version, or if_revision on a method that doesn't take it fail with invalid_argument or unsupported_version before anything runs.
Every call returns the same fields: as a Bundle from ContentResolver.call, or as 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 | On failure, an explanation for people; don't parse it |
data |
String (JSON object) | The result; on failure {} or details listed below |
For example, a failed profile.apply underclock on an Odin 3:
{
"api_version": 1,
"ok": false,
"code": "ambiguous_profile",
"message": "\"underclock\" matches several profiles: Small Underclock, Medium Underclock, Large Underclock. Use more of the name or the ID.",
"data": {"matches": [
{"id": "bundled_cq8725s_small", "name": "Small Underclock"},
{"id": "bundled_cq8725s_medium", "name": "Medium Underclock"},
{"id": "bundled_cq8725s_large", "name": "Large Underclock"}
]}
}New reply fields may appear within version 1; ignore the ones you don't know.
| Code | Meaning | What to do |
|---|---|---|
access_denied |
The user denied this caller | Ask the user to allow it under Settings → App access in ClusterTune |
access_pending |
The user hasn't answered the access question yet, or it expired | Ask the user to answer ClusterTune's notification or dialog, then retry |
invalid_argument |
Bad argument or extra; nothing ran | Fix the request; message says what is wrong |
unknown_method |
No such method |
message lists the valid ones |
unsupported_version |
api_version other than 1 |
— |
profile_not_found |
No profile matches the name or ID |
message lists the profile names |
ambiguous_profile |
A name matches several profiles; data.matches lists them as {id, name}
|
Use more of the name, or the ID |
unsupported |
Not possible on this device or right now, for example GPU settings without GPU tuning, or an Auto Tune assignment while Auto Tune is off | — |
unavailable |
ClusterTune can't reach its privileged host; data has reason, execution_method and host_error
|
See the reasons below |
conflict |
if_revision no longer matches; nothing was written. data.revision is the current one |
Re-read tuning.get and decide again |
apply_failed |
Writing the hardware failed, and the host rolled back | Retry, or check ClusterTune's History |
superseded |
A newer request replaced this one, possibly after the hardware was written | Read state.get and tuning.get
|
persistence_failed |
The hardware was written, but the tuning could not be saved | Read tuning.get before retrying |
operation_failed |
Anything else |
message explains |
response_too_large |
A reply exceeded 262,144 characters | — |
unavailable reasons:
-
no_execution_method: neither PServer nor root works; set up ClusterTune first. -
host_unavailable: a method was found, but the privileged host couldn't be started or queried;host_errorsays why when known. Retrying after a few seconds often works. -
no_cpu_policies: the host found no tunable CPU policies.
Invalid requests never reach the hardware. Failed writes use the host's own rollback and verification. Work after a successful write (History, the Quick Settings tile) never turns that success into a failure.
tuning.set and app.set take settings like these:
cpu6.max=2.4GHz gpu.max=600 cpu.gov=schedutil cpu0.min=stock
Each setting is TARGET.FIELD=VALUE; separate them with spaces or commas (commas save quoting through adb shell).
| Part | Values |
|---|---|
| Target |
cpuN for one CPU policy (IDs from device.get), cpu for every policy, gpu
|
| Field |
max, min (CPU only), gov (or governor) |
| Frequency | A number in MHz, or with a unit: 2.4GHz, 2400, 2400MHz, 2400000kHz and 2400000000Hz are the same |
| Reset |
stock for a frequency (the Stock maximum, or the automatic Stock minimum); default for a governor |
A cpuN setting overrides cpu for that policy, in any order. Each setting may appear once.
Frequencies snap to a supported step: maximums down and minimums up, so a ceiling you set is never exceeded and a floor never undercut. Values beyond the supported range use the nearest end of it. Every moved value is reported in the reply's adjusted list:
"adjusted": [{"setting": "gpu.max", "requested": "600", "applied_hz": 525000000}](applied_khz for CPU settings.)
| You write | On an Odin 3 this sets |
|---|---|
cpu6.max=2.4GHz |
CPU 6 maximum 2246.4 MHz (snapped down from 2400) |
cpu0.min=1GHz |
CPU 0 minimum 1152 MHz (snapped up from 1000) |
cpu.gov=schedutil cpu0.gov=default |
schedutil on every policy except CPU 0, which returns to its default governor |
gpu.max=stock |
The GPU's Stock maximum |
Both methods also accept JSON, where values are exact: supported steps in kHz (CPU) or Hz (GPU), with null for stock/default. The short form is translated into this and validated the same way.
{
"cpu": [{"id": 6, "max_khz": 2438400, "min_khz": null, "governor": "schedutil"}],
"gpu": {"max_hz": 525000000, "governor": null}
}Rules: at least one setting, at most 64 CPU entries, no duplicate or unknown policies or fields, minimum not above maximum, governors from device.get.
profile.apply and app.set accept a profile's 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). If several profiles match, the call fails with ambiguous_profile and lists them; nothing is guessed.
Names are handy when typing. Apps should store IDs, since users can rename profiles.
tuning.get returns a revision that identifies the saved tuning. Pass it as if_revision to profile.apply or tuning.set, and ClusterTune checks it under the same lock that serializes every apply: if anything changed the tuning in the meantime, the call fails with conflict (with the current revision in data) instead of writing.
This also makes retries safe. If a reply was lost and the first call did go through, the retry fails with conflict instead of applying twice.
tuning.set is always conditional on the tuning it was built from, even without if_revision, so it never silently overwrites a concurrent change.
There is no Android permission to request. ClusterTune identifies every caller and asks the user once, the way Magisk or KernelSU ask about root.
- ClusterTune itself and root are always allowed (root could change the clocks directly anyway).
-
Apps (identified by their Binder UID, not by anything they claim) and ADB (as "ADB shell") are asked the first time they call: Allow … to control ClusterTune?
- The call that raised the question waits for the answer, up to 60 seconds (45 through
am broadcast), then runs or fails withaccess_denied. - Other calls from the same caller in the meantime, and a call whose question went unanswered, fail with
access_pendingwithout running. - Android doesn't let a background app open a dialog, so unless ClusterTune is on screen the question arrives as a notification; tapping it opens the dialog.
- The call that raised the question waits for the answer, up to 60 seconds (45 through
- Automation apps are asked when they first add a ClusterTune plugin action (see Tasker plugin).
The user sees every decision under Settings → App access and can switch it or remove it (the caller is asked again next time). ADB is always listed first, so it can be allowed before its first command. Decisions are checked on every call. Apps that share a UID are allowed if any of them is.
The provider's other entry points (query, insert, files, batches, MIME types…) expose nothing: callers that aren't allowed get a SecurityException without being asked, and allowed ones get UnsupportedOperationException.
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 | Fires 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 changes made by the firmware itself 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. See Watching for changes for code.
The command line is the comfortable way to use ADB. The raw forms below suit scripts that already handle JSON or Bundles.
Android's content command (missing on some firmware, such as the AYN Odin 3):
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:7e5f24cdc5c80ef4It prints Result: Bundle[{…}].
The broadcast entry point, which every firmware has:
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' --es if_revision 7e5f24cdc5c80ef4It prints Broadcast completed: result=-1, data="{…}", where data is the reply object and result is 1 on an API failure. Only senders holding android.permission.DUMP (ADB, root and the system) can reach this receiver, and since Android doesn't say which of them sent a broadcast, every broadcast call uses the ADB shell access decision.
Neither command's exit status reflects API failures; check ok (the command line's exit status does).
- Method names, argument formats, reply keys and error codes never change within API version 1.
- New methods, reply fields and error codes may be added; treat unknown codes as failures.
- Send
api_version: 1if you'd rather fail clearly than talk to a future incompatible version.
External API
Project