I have a oneplus2 and I need to know the difference between charging_enabled
vs battery_charging_enabled
files present in /sys/class/power_supply/battery
I am using an app called Battery Charge Limit that is currently using battery_charging_enabled
file to toggle charging when the preset limit is reached but even though I can see my phone is discharging (the app stop phone's charging even though the cable is plugged in), the discharging current is unusually very small as compared to "normal" discharging (without the app). Why is this happening? From where is it getting the extra power (if not from the battery) to keep up with the activities done on the phone.
I was wondering if the full charge condition (the ability of the phone to run directly on plugged power source instead of battery after it charges to 100%) was being applied at 90% (which I have set as the max charge limit in the app).
Also I checked the status of charging_enabled
while the app was activated and it was 1, which means that it was not affected by the app (which is obvious as the control file used by the app is different).
Edit: I just changed the control file of the app from battery_charging_enabled
to charging_enabled
and now the battery drain seems normal.
Can anyone explain the difference between these control files ?
Edit: Adding device codes snippets from the file /android/lineage/kernel/oneplus/msm8994/drivers/power/qpnp-smbcharger.c
. Hope it helps.
case POWER_SUPPLY_PROP_BATTERY_CHARGING_ENABLED:
smbchg_battchg_en(chip, val->intval,
REASON_BATTCHG_USER, &unused);
pr_err("chg_en form userspace battery charging enable: %d\n",val->intval);
break;
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
smbchg_usb_en(chip, val->intval, REASON_USER);
smbchg_dc_en(chip, val->intval, REASON_USER);
chip->chg_enabled = val->intval;
pr_err("chg_en form userspace charging enable: %d\n",chip->chg_enabled);
schedule_work(&chip->usb_set_online_work);
break;
------------------------------------------------------------------------
case POWER_SUPPLY_PROP_BATTERY_CHARGING_ENABLED:
val->intval = smcghg_is_battchg_en(chip, REASON_BATTCHG_USER);
break;
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
val->intval = chip->chg_enabled;