package com.aure.clustertune.api.contract; /** * Public contract of ClusterTune's external API, version {@value #VERSION}. * *

Copy this file into a client, or depend on the {@code api-contract} module. It contains only * constants: names and values never change within an API version. Methods, arguments and replies * are documented in the project wiki (https://github.com/AurelioB/ClusterTune/wiki). * *

Methods are named {@code resource.verb} ({@link Method}); a bare {@link Resource} name is * accepted for that resource's read method, for example {@code profile} for {@code profile.list}. * The {@code clustertune} command line uses the same names with a space: {@code clustertune profile apply medium}. * *

Entry points: *

*/ public final class ClusterTuneApi { private ClusterTuneApi() {} public static final int VERSION = 1; public static final String PACKAGE = "com.aure.clustertune"; public static final String AUTHORITY = "com.aure.clustertune.api"; public static final String URI = "content://" + AUTHORITY; /** CPU frequencies are integer kHz; GPU frequencies are integer Hz. */ public static final String CPU_FREQUENCY_UNIT = "kHz"; public static final String GPU_FREQUENCY_UNIT = "Hz"; /** The things the API acts on; also the bare method names accepted for each resource's read method. */ public static final class Resource { private Resource() {} /** What is applied right now and why (read only). */ public static final String STATE = "state"; /** The saved CPU/GPU settings ClusterTune applies and restores. */ public static final String TUNING = "tuning"; public static final String PROFILE = "profile"; /** Per-app assignments. */ public static final String APP = "app"; /** Hardware capabilities: CPU policies, frequency steps, governors, GPU. */ public static final String DEVICE = "device"; public static final String API = "api"; } /** Paths under {@link #URI} for {@code ContentObserver}s, one per changing resource; notifications carry no data. */ public static final String PATH_STATE = Resource.STATE; public static final String PATH_TUNING = Resource.TUNING; public static final String PATH_PROFILE = Resource.PROFILE; public static final String PATH_APP = Resource.APP; public static final String URI_STATE = URI + "/" + PATH_STATE; public static final String URI_TUNING = URI + "/" + PATH_TUNING; public static final String URI_PROFILE = URI + "/" + PATH_PROFILE; public static final String URI_APP = URI + "/" + PATH_APP; /** Provider {@code call} method names, {@code resource.verb}. */ public static final class Method { private Method() {} /** API version, methods, units, extras and notification URIs. Shortcut: {@code api}. */ public static final String API_INFO = "api.info"; /** Live limits and governors, the effective owner, Auto Tune and app detection. Shortcut: {@code state}. */ public static final String STATE_GET = "state.get"; /** The saved settings and their {@code revision}. Shortcut: {@code tuning}. */ public static final String TUNING_GET = "tuning.get"; /** {@code arg}: settings such as {@code cpu6.max=2.4GHz gpu.max=600} (MHz by default, snapped to supported steps) or a JSON settings object; changes part of the saved settings and applies them. */ public static final String TUNING_SET = "tuning.set"; /** Shortcut: {@code profile}. */ public static final String PROFILE_LIST = "profile.list"; /** {@code arg}: a profile ID, its name, or a unique start of a word in its name. Saves and applies it. */ public static final String PROFILE_APPLY = "profile.apply"; /** Shortcut: {@code app}. */ public static final String APP_LIST = "app.list"; /** {@code arg}: {@code PACKAGE PROFILE}, {@code PACKAGE SETTINGS...}, {@code PACKAGE autotune=FPS} or a JSON assignment object. */ public static final String APP_SET = "app.set"; /** {@code arg}: a package name. */ public static final String APP_CLEAR = "app.clear"; /** Policies, frequency steps, governors and GPU. Shortcut: {@code device}. */ public static final String DEVICE_GET = "device.get"; } /** Optional request extras for provider calls. */ public static final class Extra { private Extra() {} /** Integer; only {@link ClusterTuneApi#VERSION} is accepted. */ public static final String API_VERSION = "api_version"; /** String; the {@code revision} from {@code tuning.get}. Only for {@code profile.apply} and {@code tuning.set}. */ public static final String IF_REVISION = "if_revision"; } /** Keys of every provider reply {@code Bundle}. */ public static final class Result { private Result() {} public static final String API_VERSION = "api_version"; public static final String OK = "ok"; public static final String CODE = "code"; public static final String MESSAGE = "message"; /** A JSON object as a String. */ public static final String DATA = "data"; } /** Values of {@link Result#CODE}. Clients should treat unknown codes as failures. */ public static final class ErrorCode { private ErrorCode() {} public static final String OK = "ok"; public static final String UNKNOWN_METHOD = "unknown_method"; public static final String INVALID_ARGUMENT = "invalid_argument"; public static final String UNSUPPORTED_VERSION = "unsupported_version"; public static final String PROFILE_NOT_FOUND = "profile_not_found"; /** A profile name matched more than one profile; {@code data.matches} lists them. Use the ID or a longer name. */ public static final String AMBIGUOUS_PROFILE = "ambiguous_profile"; public static final String UNSUPPORTED = "unsupported"; public static final String UNAVAILABLE = "unavailable"; public static final String CONFLICT = "conflict"; public static final String APPLY_FAILED = "apply_failed"; public static final String SUPERSEDED = "superseded"; public static final String PERSISTENCE_FAILED = "persistence_failed"; public static final String OPERATION_FAILED = "operation_failed"; public static final String RESPONSE_TOO_LARGE = "response_too_large"; /** The user denied this app. Change it in ClusterTune's Settings, under App access. */ public static final String ACCESS_DENIED = "access_denied"; /** The user has not answered the access request yet (or dismissed it). Ask again after they approve. */ public static final String ACCESS_PENDING = "access_pending"; } /** ADB-only broadcast entry point; senders must hold android.permission.DUMP (ADB shell, root). */ public static final class Shell { private Shell() {} public static final String RECEIVER = PACKAGE + "/.api.ShellApiReceiver"; public static final String EXTRA_METHOD = "method"; public static final String EXTRA_ARG = "arg"; } }