Skip to main content

Decode, parse, manipulate, and validate MediaTek thermal.conf files

Project description

mtk-thermal-parser

Decode, parse, manipulate, validate, and diff MediaTek thermal configuration files (thermal.conf).

The codec uses a position-dependent Caesar cipher on the printable ASCII range 32-122. The document pipeline preserves all syntactic elements — section order, key order, comments, blank lines, original whitespace, and unknown directives — enabling lossless round-trips.

Tested Scope

The codec and lossless document pipeline have been validated against nine thermal policy files from a MediaTek MT6789 device (Android T), with byte-identical decode/encode round trips for every file.

Tested against the currently available reference implementation and policy set. Other MediaTek generations or vendor variants may use different formats.

Installation

pip install mtk-thermal-parser

Requires Python 3.9+. No external runtime dependencies.

CLI Usage

# Decode an encoded thermal.conf to plaintext
mtk-thermal decode thermal.conf -o decoded.conf

# Encode a plaintext file to encoded format
mtk-thermal encode decoded.conf -o thermal.conf

# Inspect configuration structure and typed values
mtk-thermal inspect thermal.conf

# Validate configuration (syntax, structure, semantics)
mtk-thermal validate thermal.conf

# Get a value
mtk-thermal get thermal.conf charger-cooler mode

# Set a value and write modified output
mtk-thermal set thermal.conf charger-cooler mode disabled -o modified.conf

# Diff two configurations
mtk-thermal diff original.conf modified.conf

# Reformat (canonicalize serialization)
mtk-thermal format thermal.conf -o canonical.conf

Device Commands (requires ADB and a connected Android device)

# Inspect thermal service status
mtk-thermal device status

# List available policies
mtk-thermal device list

# Show current / permanent policy
mtk-thermal device current

# Apply a policy by index (0=normal, 1=coolers-off, 2=performance)
mtk-thermal device apply 0

# Apply a custom policy by name
mtk-thermal device apply my-policy

# Push a local config to the device
mtk-thermal device push my-policy.conf

# Pull a policy from the device
mtk-thermal device pull thermal.conf -o backup.conf

# Clear a data-override policy
mtk-thermal device clear thermal.conf

Python API

from mtk_thermal_parser import ThermalCodec, Parser, SemanticModel

# Decode
decoded = ThermalCodec.decode(encoded_bytes)

# Lossless parse
doc = Parser.parse(decoded.decode('ascii'))

# Typed inspection
model = SemanticModel(doc)
for section in model:
    print(f"[{section.name}]")
    for key in section.keys:
        typed = section.typed(key)
        print(f"  {key}: {typed}")

# Round-trip: decode -> parse -> serialize -> encode
serialized = doc.serialize()
re_encoded = ThermalCodec.encode(serialized.encode('ascii'))
assert re_encoded == original_encoded_bytes

Key Features

  • Lossless parsing — preserves section order, key order, comments, blank lines, whitespace, unknown directives
  • Exact round-trip — decode → parse → serialize → encode reproduces the original bytes
  • Auto-detection — distinguishes encoded vs plaintext input automatically
  • Typed valuesTemperatureValue (m°C), CurrentValue (mA), EnabledValue, IntListValue, StringListValue
  • Validation — syntax, structure (duplicate keys), semantics (list types, parallel array lengths)
  • Semantic diff — per-key and per-list-element comparison
  • Optional device integration — ADB-based policy management

Safety Considerations

Structural validation confirms that a file is syntactically correct; it is not a thermal-safety certification.

Some vendor policies disable cooling, raise temperature thresholds to extreme values, or disable hardware protection. Always verify the behavior of a policy on your specific hardware before making persistent changes. Use the device debug_only mechanism where available to test policies without side effects.

Known Limitations

  • Characters {|}~ (0x7B-0x7E) are outside the 91-character encoding range and cannot round-trip. These characters do not appear in known MediaTek thermal configurations.
  • Tested against MT6789 (Android T) policies. Other MediaTek SoCs or Android versions may use different formats or encoding variants.
  • Device integration requires ADB and root access for some operations.
  • The thermal_intf IPC protocol is internal; no direct socket access by userspace callers has been confirmed.

License

MPL-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtk_thermal_parser-0.1.0.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mtk_thermal_parser-0.1.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file mtk_thermal_parser-0.1.0.tar.gz.

File metadata

  • Download URL: mtk_thermal_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mtk_thermal_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9c6dcad11fb9d853755053e356d930f9b4afb29992fa15cfa3ca0cb69daf3ed
MD5 a73f3eb4430fb5a1f9c0be1a3b70358e
BLAKE2b-256 39fe4ac7f5d3d46c1822c783bebda9062ebf1e862eab3b5b28aad100fb381622

See more details on using hashes here.

Provenance

The following attestation bundles were made for mtk_thermal_parser-0.1.0.tar.gz:

Publisher: release.yml on ReCoreShift/mtk-thermal-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mtk_thermal_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mtk_thermal_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dedfff984809fcf3187500a26345d8fe8c27e39d7a9fbc17d642fbdcf87e385
MD5 fcddf27ec7bd8cf96dfa2c29da15324a
BLAKE2b-256 80094173eaa4cdc936f64e1a629268ba9bc1d3d8b1c93535bd3718cbf221ebab

See more details on using hashes here.

Provenance

The following attestation bundles were made for mtk_thermal_parser-0.1.0-py3-none-any.whl:

Publisher: release.yml on ReCoreShift/mtk-thermal-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page