j7elte: ramdisk: Save/restore the batt_capacity_max value on boot to preserve battery...
authorDanny Wood <danwood76@gmail.com>
Fri, 14 Dec 2018 08:02:03 +0000 (08:02 +0000)
committerDario Trombello <dariotr@outlook.de>
Sun, 24 May 2020 19:06:36 +0000 (21:06 +0200)
Change-Id: I7f133cd5f79da93adc84fd84847a901f327c81ec

ramdisk/etc/init.target.rc

index f6127c06500a97fbd565b1c1ac775d1af9dc52fd..2c4d49a214a721dbd80b1ec423c22a8e61820d2c 100644 (file)
@@ -19,6 +19,9 @@ on fs
     # Permissions Camera
     chown system radio /sys/class/camera/flash/front_flash
 
+    # Restore the previous batt_capacity_max (if it exists)
+    copy /efs/Battery/prev_batt_capacity_max /sys/class/power_supply/battery/batt_capacity_max
+
 on property:sys.boot_completed=1
     write /proc/sys/vm/dirty_bytes 41943040
     write /proc/sys/vm/dirty_background_bytes 20971520
@@ -26,3 +29,8 @@ on property:sys.boot_completed=1
     # Set best cache size for internal and external storages
     write /sys/block/mmcblk0/bdi/read_ahead_kb 128
     write /sys/block/mmcblk1/bdi/read_ahead_kb 2048
+
+on shutdown
+    # Fix permissions then store the current batt_capacity_max value in the EFS partition
+    chmod 600 /sys/class/power_supply/battery/batt_capacity_max
+    copy /sys/class/power_supply/battery/batt_capacity_max /efs/Battery/prev_batt_capacity_max