Skip to content

Instantly share code, notes, and snippets.

@Bert-Proesmans
Created December 30, 2022 16:10
Show Gist options
  • Save Bert-Proesmans/770e7f1a54ac15c0a0581756d29f8883 to your computer and use it in GitHub Desktop.
Save Bert-Proesmans/770e7f1a54ac15c0a0581756d29f8883 to your computer and use it in GitHub Desktop.
configVerCode=202206010
capacity=(5 60 55 60 false false)
temperature=(40 45 90 55)
cooldownRatio=(50 10)
cooldownCurrent=
cooldownCustom=()
resetBattStats=(true false false)
chargingSwitch=(battery/charge_control_limit 0 battery/charge_control_limit_max --)
applyOnBoot=()
applyOnPlug=(true)
maxChargingCurrent=()
maxChargingVoltage=(3900 battery/voltage_max::3900000::4450000)
language=
runCmdOnPause=''
ampFactor=
voltFactor=
loopCmd=''
prioritizeBattIdleMode=false
currentWorkaround=false
battStatusWorkaround=true
schedule=''
battStatusOverride=''
rebootResume=false
: one-line script sample; echo nothing >/dev/null
# WARNINGS
# Do not edit this in Windows Notepad, ever!
# It replaces LF (Linux/Unix) with CRLF (Windows) line endings.
# As you may have guessed, what is null by default, can be null.
# "language=" is interpreted as "language=en".
# Nullifying values that should not be null causes unexpected behavior.
# However, doing so with "--set var=" restores the default value of "var".
# In other words, for regular users, "--set" is safer than modifying the config file directly.
# Do not feel like you must configure everything!
# Do not change what you don't understand.
# NOTES
# The daemon does not have to be restarted after making changes to this file - unless one of the changes is charging_switch.
# A change to current_workaround (cw) only takes effect after an acc [re]initialization (install, upgrade or "accd --init") or system reboot.
# If those 2 variables are updated with "acc --set" (not acca --set), accd is restarted automatically (--init is implied, as needed).
# The only nullable variables are those which are null by default (var=, var="" and var=()).
# BASICS
# capacity=(shutdown_capacity cooldown_capacity resume_capacity pause_capacity capacity_sync capacity_mask)
# temperature=(cooldown_temp max_temp max_temp_pause shutdown_temp)
# cooldownRatio=(cooldown_charge cooldown_pause)
# cooldownCustom=cooldown_custom=(file raw_value charge_seconds pause_seconds)
# cooldownCurrent=cooldown_current=[milliamps]
# resetBattStats=(reset_batt_stats_on_pause reset_batt_stats_on_unplug reset_batt_stats_on_plug)
# chargingSwitch=charging_switch=(ctrl_file1 on off ctrl_file2 on off --)
# chargingSwitch=charging_switch=(milliamps)
# chargingSwitch=charging_switch=(3700-4300 millivolts)
# applyOnBoot=apply_on_boot=(ctrl_file1::value[::default] ctrl_file2::value[::default] ... --exit)
# applyOnPlug=apply_on_plug=(ctrl_file1::value[::default] ctrl_file2::value[::default] ...)
# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default ctrl_file2::value::default ...)
# maxChargingVoltage=max_charging_voltage=([value] ctrl_file1::value::default ctrl_file2::value::default ...) --exit)
# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default1 ctrl_file2::value::default2 ...)
# maxChargingVoltage=max_charging_voltage=([value] ctrl_file1::value::default1 ctrl_file2::value::default2 ...) --exit)
# language=lang=language_code
# runCmdOnPause=run_cmd_on_pause='command...'
# ampFactor=amp_factor=[multiplier]
# voltFactor=volt_factor=[multiplier]
# loopCmd=loop_cmd='command...'
# prioritizeBattIdleMode=prioritize_batt_idle_mode=boolean
# currentWorkaround=current_workaround=boolean
# battStatusWorkaround=batt_status_workaround=boolean
# schedule=sched='HHMM command...
# HHMM command...
# ...'
# battStatusOverride=batt_status_override=Idle|Discharging|'code to PRINT value for _status'
# rebootResume=reboot_resume=boolean
# ALIASES/SHORTCUTS
# cc cooldown_capacity
# rc resume_capacity
# pc pause_capacity
# cs capacity_sync
# cm capacity_mask
# sc shutdown_capacity
# ct cooldown_temp
# cch cooldown_charge
# cp cooldown_pause
# mt max_temp
# mtp max_temp_pause
# st shutdown_temp
# ccu cooldown_custom
# cdc cooldown_current
# rbsp reset_batt_stats_on_pause
# rbsu reset_batt_stats_on_unplug
# rbspl reset_batt_stats_on_plug
# s charging_switch
# ab apply_on_boot
# ap apply_on_plug
# mcc max_charging_current
# mcv max_charging_voltage
# l lang
# rcp run_cmd_on_pause
# af amp_factor
# vf volt_factor
# lc loop_cmd
# pbim prioritize_batt_idle_mode
# cw current_workaround
# bsw batt_status_workaround
# sd sched
# bso batt_status_override
# rr reboot_resume
# FINE, BUT WHAT DOES EACH OF THESE VARIABLES ACTUALLY MEAN?
# configVerCode #
# This is checked during updates to determine whether config should be patched. Do NOT modify.
# shutdown_capacity (sc) #
# When the battery is discharging and its capacity/voltage_now_millivolts <= sc and phone has been running for 15 minutes or more, acc daemon turns the phone off to reduce the discharge rate and protect the battery from potential damage induced by voltage below the operating range.
# sc=-1 disables it.
# cooldown_capacity (cc) #
# Capacity/voltage_now_millivolts at which the cooldown cycle starts.
# Cooldown reduces battery stress induced by prolonged exposure to high temperature and high charging voltage.
# It does so through periodically pausing charging for a few seconds (more details below).
# resume_capacity (rc) #
# Capacity or voltage_now_millivolts at which charging should resume.
# pause_capacity (pc) #
# Capacity or voltage_now_millivolts at which charging should pause.
# capacity_sync (cs) #
# Some devices, notably from the Pixel lineup, have a capacity discrepancy issue between Android and the kernel.
# capacity_sync forces Android to report the actual battery capacity supplied by the kernel.
# The discrepancy is usually detected and corrected automatically by accd.
# This setting overrides the automatic behavior.
# Besides, it also prevents Android from getting capacity readings below 2%, since some systems shutdown before battery level actually drops to 0%.
# capacity_mask (cm) #
# Implies capacity_sync.
# This forces Android to report "capacity = capacity * (100 / pause_capacity)", effectively masking capacity limits (more like capacity_sync on steroids).
# It also prevents Android from getting capacity readings below 2%, since some systems shutdown before battery level actually drops to 0%.
# cooldown_temp (ct) #
# Temperature (°C) at which the cooldown cycle starts.
# Cooldown reduces the battery degradation rate by lowering the device's temperature.
# Refer back to cooldown_capacity for more details.
# max_temp (mt) #
# mtp or max_temp_pause #
# These two work together and are NOT tied to the cooldown cycle.
# On max_temp (°C), charging is paused for max_temp_pause (seconds).
# Unlike the cooldown cycle, which aims at reducing BOTH high temperature and high voltage induced stress - this is ONLY meant specifically for reducing high temperature induced stress.
# Even though both are separate features, this complements the cooldown cycle when environmental temperatures are off the charts.
# shutdown_temp (st) #
# Shutdown the system if battery temperature >= this value.
# cooldown_charge (cch) #
# cooldown_pause (cp) #
# These two dictate the cooldown cycle intervals (seconds).
# When not set, the cycle is disabled.
# Suggested values are cch=50 and cp=10.
# If charging gets a bit slower than desired, try cch=50 and cp=5.
# Note that cooldown_capacity and cooldown_temp can be disabled individually by assigning them values that would never be reached under normal circumstances.
# cooldown_custom (ccu) #
# When cooldown_capacity and/or cooldown_temp don't suit your needs, this comes to the rescue.
# It takes precedence over the regular cooldown settings.
# cooldown_current (cdc) #
# Instead of pausing charging periodically during the cooldown phase, limit the max charging current (e.g., to 500 mA)
# reset_batt_stats_on_pause (rbsp) #
# Reset battery stats after pausing charging.
# reset_batt_stats_on_unplug (rbsu) #
# Reset battery stats if the charger has been unplugged for a few seconds.
# reset_batt_stats_on_plug (rbspl) #
# Reset battery stats if the charger has been plugged for a few seconds.
# charging_switch (s) #
# If unset, acc cycles through its database and sets the first working switch/group that disables charging.
# If the set switch/group doesn't work, acc unsets chargingSwitch and repeats the above.
# If all switches fail to disable charging, chargingSwitch is unset and acc/d exit with error code 7.
# This automated process can be disabled by appending " --" to "charging_switch=...".
# e.g., acc -s s="battery/charge_enabled 1 0 --"
# acc -ss always appends " --".
# charging_switch=milliamps (e.g., 0-250) enables current-based charging control.
# If charging switch is set to 3700-4300 (millivolts), acc stops charging by limiting voltage.
# For details, refer to the readme's tips section.
# Unlike the original variant, this kind of switch is never unset automatically.
# Thus, in this case, appending " --" to it leads to invalid syntax.
# A daemon restart is required after changing this (automated by "acc --set").
# apply_on_boot (ab) #
# Settings to apply on boot or daemon start/restart.
# The --exit flag (refer back to applyOnBoot=...) tells the daemon to stop after applying settings.
# If the --exit flag is not included, default values are restored when the daemon stops.
# apply_on_plug (ap) #
# Settings to apply on plug
# This exists because some /sys files (e.g., current_max) are reset on charger re-plug.
# Default values are restored on unplug and when the daemon stops.
# max_charging_current (mcc) #
# max_charging_voltage (mcv) #
# Only the current/voltage value is to be supplied.
# Control files are automatically selected.
# lang (l) #
# acc language, managed with "acc --set --lang" (acc -sl).
# When null, English (en) is assumed.
# run_cmd_on_pause (rcp) #
# Run commands* after pausing charging.
# * Usually a script ("sh some_file" or ". some_file")
# amp_factor (af) #
# volt_factor (vf) #
# Unit multiplier for conversion (e.g., 1V = 1000000 Microvolts)
# ACC can automatically determine the units, but the mechanism is not 100% foolproof.
# e.g., if the input current is too low, the unit is miscalculated.
# This issue is rare, though.
# Leave these properties alone if everything is running fine.
# loop_cmd (lc) #
# This is meant for extending accd's functionality.
# It is periodically executed by the is_charging function -- which is called regularly, within the main accd loop.
# The boolean isCharging is available.
# Refer back to COMMAND EXAMPLES.
# prioritize_batt_idle_mode (pbim) #
# If enabled charging switches that support battery idle mode take precedence.
# It is only used when charging_switch is not set.
# This is disabled by default due to issues on Samsung (store_mode) and other devices.
# current_workaround (cw) #
# Only use current control files whose paths match "batt" (default: false).
# This is necessary only if the current limit affects both input and charging current values.
# Try this if low current values don't work.
# "accd --init" is required after changing this (automated by "acc --set").
# batt_status_workaround (bsw) #
# With this enabled, in addition to just reading POWER_SUPPLY_STATUS, if the battery is "Charging" and current is within -11 and 95 mA (inclusive), battery status is considered "Idle". Status is considered "Discharging", if current drops significantly, after calling the disable_charging function.
# By not relying solely on the information provided by POWER_SUPPLY_STATUS, this approach boosts compatibility quite dramatically. So much so, that on certain devices (e.g., Nokia 2.2), acc only works when this is enabled.
# On the other hand, the user may observe charging control inconsistencies on devices that report wrong current values or major current fluctuations.
# Oftentimes, charging control issues are related to the power adapter.
# sched (sd) #
# Command/script schedules, in the following format:
#
# sched="HHMM command...
# HHMM command...
# ..."
#
# e.g., 3900 mV at 22:00, and 4100 mV at 6:00, daily:
# sched="2200 acc -s mcv=3900
# 0600 acc -s mcv=4100"
#
# 12 hour format is not supported.
# Each schedule must be on its own line.
# Each line is daemonized.
# This is not limited to acc commands. It can run anything.
#
# Commands:
# -s|--set [sd|sched]="[+-]schedule to add or pattern to delete"
# e.g.,
# acc -s sd=-2050 (delete schedules that match 2050)
# acc -s sd="+2200 acc -s mcv=3900 mcc=500; acc -n "Switched to \"sleep\" profile" (append schedule)
# Note: "acc -s sd=" behaves just like similar commands (restores default value; for schedules, it's null)
# batt_status_override (bso) #
# Overrides the battery status determined by the not_charging function.
# It can be Idle, Discharging (both case sensitive), or logic to PRINT the desired value for the _status variable.
# When set to Idle or Discharging, _status will be set to that value if the enforced* charging switch state is off.
# It only works in conjunction with an enforced charging switch (set manually, has a trailing " --").
#
# Usage scenario: the switch "main/cool_mode 0 1" supports idle mode. However, sometimes it does not respond soon enough (e.g., due to fast charging). The user can then enforce it with acc -ss and set batt_status_override=Idle. This means, when main/cool_mode is on (0), _status will be determined by the not_charging function (as usual), but when it's off (1), _status will be Idle, bypassing the not_charging function.
#
# If the user were to write their own logic, it would've be something as follows:
# batt_status_override='[ $(cat main/cool_mode) -eq 1 ] && printf Idle'
# reboot_resume (rr) #
# Reboot (when capacity <= resume_capacity) to re-enable charging.
# A warning notification is posted 60 seconds prior, for the user to block the action, if they so please.
# one-line scripts #
# Every line that begins with ": " is interpreted as a one-line script.
# This feature can be useful for many things, including setting up persistent config profiles (source a file that overrides the main config).
# All script lines are executed whenever the config is loaded/sourced.
# This happens regularly while the daemon is running, and at least once per command run.
# Warning: all files used in one-line scripts must reside somewhere in /data/adb/, just like acc's own data files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment