From c484f16bcb013242f22962adac69c671298a44f2 Mon Sep 17 00:00:00 2001 From: Deokgyu Yang Date: Wed, 22 Sep 2021 21:54:56 +0900 Subject: [PATCH] gts3l-common: lpm: Enable the power-off mode charging using Samsung LPM Signed-off-by: Deokgyu Yang Change-Id: I834d67453b2057e88d3e1cd1b1a4c6fac0c85f72 --- extract-files.sh | 3 ++ gts3l.mk | 4 ++ proprietary-files.txt | 25 +++++++++-- rootdir/etc/init.qcom.power.rc | 82 +++++++++++++++++++++------------- rootdir/etc/init.qcom.usb.rc | 2 +- rootdir/etc/init.samsung.rc | 58 +++--------------------- sepolicy/charger.te | 25 +++++++++++ sepolicy/file.te | 1 + sepolicy/file_contexts | 2 + 9 files changed, 114 insertions(+), 88 deletions(-) create mode 100644 sepolicy/charger.te diff --git a/extract-files.sh b/extract-files.sh index 673e1f1..72f3a49 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -66,6 +66,9 @@ function blob_fixup() { vendor/lib/libmmcamera2_sensor_modules.so) sed -i "s|/system/etc/firmware|/vendor/firmware\x0\x0\x0\x0|g" "${2}" ;; + lib64/libpixelflinger.so) + "${PATCHELF}" --replace-needed "libcutils.so" "libcutils-v29.so" "${2}" + ;; esac } diff --git a/gts3l.mk b/gts3l.mk index ce486d9..e918e3a 100755 --- a/gts3l.mk +++ b/gts3l.mk @@ -140,6 +140,10 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/camera/N05QL_s5k5e3yx_chromatix.xml:$(TARGET_COPY_OUT_VENDOR)/firmware/N05QL_s5k5e3yx_chromatix.xml \ $(LOCAL_PATH)/camera/W13QS_imx258_chromatix.xml:$(TARGET_COPY_OUT_VENDOR)/firmware/W13QS_imx258_chromatix.xml +# Charger +PRODUCT_PACKAGES += \ + libsuspend + # Connectivity Engine support (CNE) PRODUCT_PACKAGES += \ libcnefeatureconfig diff --git a/proprietary-files.txt b/proprietary-files.txt index 411fa56..3d5eb63 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -818,8 +818,6 @@ lib64/libsavsvc.so lib64/libsnaace.so lib64/libsnamrnb.so lib64/libsnamrwb.so -lib64/libsxqk.so -lib64/libsxqk_skia.so lib/libsomx263dsw.so lib/libsomx264dsw.so lib/libsomxaacd.so @@ -848,7 +846,6 @@ lib/libsavsvc.so lib/libsnaace.so lib/libsnamrnb.so lib/libsnamrwb.so -lib/libsxqk.so # Peripheral Manager vendor/bin/pm-proxy @@ -888,6 +885,28 @@ vendor/lib64/libqti-perfd.so vendor/lib64/libqti-util.so vendor/lib64/libqti-utils.so +# Power-off charging +bin/lpm +lib64/libmaet.so +lib64/libpixelflinger.so +lib64/libsxqk_skia.so +lib64/libsxqk.so +media/battery_error.spi +media/battery_low.spi +media/battery_temperature_error.spi +media/battery_temperature_limit.spi +media/battery_water_usb.spi +media/charging_New_Fast.spi +media/charging_New_Normal.spi +media/dock_error_usb.spi +media/incomplete_connect.spi +media/lcd_density.txt +media/percentage.spi +media/safety_timer_usb.spi +media/slow_charging_usb.spi +media/temperature_limit_usb.spi +media/water_protection_usb.spi + # QMI vendor/bin/irsc_util vendor/bin/rmt_storage diff --git a/rootdir/etc/init.qcom.power.rc b/rootdir/etc/init.qcom.power.rc index 12e95bf..8de25f4 100644 --- a/rootdir/etc/init.qcom.power.rc +++ b/rootdir/etc/init.qcom.power.rc @@ -26,22 +26,12 @@ # on init - # Disable UFS powersaving - write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 0 - write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 0 - write /sys/devices/soc/${ro.boot.bootdevice}/${ro.boot.bootdevice}:ufs_variant/pm_qos_enable 0 write /sys/module/lpm_levels/parameters/sleep_disabled "Y" # Drop write bit from cpu_max_freq so that libqti-perfd can't set it chmod 0444 /sys/module/msm_performance/parameters/cpu_max_freq on boot - # Update foreground and background cpusets - write /dev/cpuset/foreground/cpus 0-3 - write /dev/cpuset/background/cpus 0-3 - write /dev/cpuset/system-background/cpus 0-3 - write /dev/cpuset/top-app/cpus 0-3 - # Add a cpuset for the camera daemon # we want all cores for camera mkdir /dev/cpuset/camera-daemon @@ -56,10 +46,50 @@ on boot on charger wait /dev/block/platform/soc/${ro.boot.bootdevice} - # Enable UFS powersaving - write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 1 - write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 1 - write /sys/devices/soc/${ro.boot.bootdevice}/${ro.boot.bootdevice}:ufs_variant/pm_qos_enable 1 + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice + + wait /dev/block/bootdevice/by-name/efs + mount ext4 /dev/block/bootdevice/by-name/efs /efs nosuid nodev noatime noauto_da_alloc,discard,data=ordered,errors=panic + mkdir /efs/Battery 0775 radio system + chown radio system /efs/Battery + chmod 0775 /efs/Battery + chmod 0664 /sys/class/power_supply/battery/batt_temp_table + chown system radio /sys/class/power_supply/battery/batt_temp_table + chmod 0664 /sys/class/power_supply/battery/batt_capacity_max + chown system radio /sys/class/power_supply/battery/batt_capacity_max + chmod 0664 /efs/Battery/batt_capacity_max + chown radio system /efs/Battery/batt_capacity_max + chmod 0664 /sys/class/power_supply/battery/battery_cycle + chown system radio /sys/class/power_supply/battery/battery_cycle + chmod 0664 /sys/class/power_supply/battery/batt_after_manufactured + chown system radio /sys/class/power_supply/battery/batt_after_manufactured + chown system radio /sys/class/power_supply/battery/cisd_fullcaprep_max + chmod 0660 /sys/class/power_supply/battery/cisd_fullcaprep_max + chown system radio /sys/class/power_supply/battery/cisd_data + chmod 0660 /sys/class/power_supply/battery/cisd_data + chown system system /efs/FactoryApp/cisd_data + chmod 0660 /efs/FactoryApp/cisd_data + chown system system /efs/FactoryApp/cisd_wc_data + chmod 0660 /efs/FactoryApp/cisd_wc_data + chown system system /efs/FactoryApp/asoc + chmod 0660 /efs/FactoryApp/asoc + chown system system /efs/FactoryApp/batt_after_manufactured + chmod 0640 /efs/FactoryApp/batt_after_manufactured + chown system system /efs/FactoryApp/batt_discharge_level + chmod 0640 /efs/FactoryApp/batt_discharge_level + chown system radio /sys/class/power_supply/battery/cisd_data_json + chmod 0660 /sys/class/power_supply/battery/cisd_data_json + copy /system/vendor/firmware/battery_data.dat /efs/Battery/battery_data.dat + chmod 0400 /efs/Battery/battery_data.dat + write /sys/class/power_supply/battery/batt_update_data "/efs/Battery/battery_data.dat" + chown radio system /efs + chmod 0771 /efs + chown radio system /efs/usb_hw_param + chmod 771 /efs/usb_hw_param + chown system system /efs/usb_hw_param/usb_hw_param.log + chmod 0660 /efs/usb_hw_param/usb_hw_param.log + mkdir /efs/lpm 0775 system system + write /sys/module/lpm_levels/parameters/sleep_disabled "N" write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "userspace" @@ -70,9 +100,12 @@ on charger write /sys/devices/system/cpu/cpu2/online 0 write /sys/devices/system/cpu/cpu3/online 0 write /sys/module/msm_thermal/parameters/enabled "N" - start vendor.hvdcp_opti + + class_start sec-charger start thermal-engine + setprop sys.usb.configfs 1 + on enable-low-power # Disable thermal hotplug to switch governor write /sys/module/msm_thermal/core_control/enabled 0 @@ -157,11 +190,6 @@ on enable-low-power write /sys/class/devfreq/soc:qcom,memlat-cpu2/polling_interval 10 write /sys/class/devfreq/soc:qcom,mincpubw/governor "cpufreq" - # Enable UFS powersaving - write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 1 - write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 1 - write /sys/devices/soc/${ro.boot.bootdevice}/${ro.boot.bootdevice}:ufs_variant/pm_qos_enable 1 - # Enable all LPMs (this will enable C4, D4, D3, E4 and M3 LPMs) write /sys/module/lpm_levels/parameters/sleep_disabled "N" @@ -174,9 +202,6 @@ on property:sys.boot_completed=1 # Set I/O squeduler setprop sys.io.scheduler "bfq" - # Start I/O prefetcher service - start iop - # Update cpusets now that boot is complete and we want better load balancing write /dev/cpuset/top-app/cpus 0-3 write /dev/cpuset/foreground/cpus 0-2 @@ -186,10 +211,10 @@ on property:sys.boot_completed=1 on property:init.svc.recovery=running trigger enable-low-power -service vendor.charger /system/bin/chargeonlymode - class charger +service charger /system/bin/lpm + class sec-charger user system - group system graphics input + group system radio graphics input capabilities SYS_BOOT seclabel u:r:charger:s0 @@ -198,8 +223,3 @@ service energy-awareness /vendor/bin/energy-awareness user root group system oneshot - -service vendor.hvdcp_opti /vendor/bin/hvdcp_opti - class main - user root - group system wakelock diff --git a/rootdir/etc/init.qcom.usb.rc b/rootdir/etc/init.qcom.usb.rc index df72208..caa6c90 100644 --- a/rootdir/etc/init.qcom.usb.rc +++ b/rootdir/etc/init.qcom.usb.rc @@ -33,7 +33,7 @@ on init chown system radio /sys/class/usb_notify/usb_control/disable chmod 0660 /sys/class/usb_notify/usb_control/disable -on charger +on charger && property:ro.debuggable=1 mkdir /dev/usb-ffs 0770 shell shell mkdir /dev/usb-ffs/adb 0770 shell shell mount configfs none /config diff --git a/rootdir/etc/init.samsung.rc b/rootdir/etc/init.samsung.rc index 918e787..f0738a2 100644 --- a/rootdir/etc/init.samsung.rc +++ b/rootdir/etc/init.samsung.rc @@ -66,7 +66,7 @@ on init mkdir /mnt/user/0 0755 root root mkdir /mnt/expand 0771 system system mkdir /mnt/appfuse 0711 root root - + # Add qseecomd default property setprop vendor.sys.qseecomd.enable stopped @@ -294,7 +294,7 @@ on boot chown system system /sys/kernel/ipv4/tcp_rmem_def chown system system /sys/kernel/ipv4/tcp_rmem_max chown root radio /proc/cmdline - + # Permissions for Power chown radio system /sys/power/cpufreq_max_limit chown radio system /sys/power/cpufreq_min_limit @@ -305,7 +305,7 @@ on boot chown radio system /sys/devices/system/cpu/kernel_max chmod 664 /sys/devices/system/cpu/kernel_max - + # Permissions for booster chown radio system /sys/class/kgsl/kgsl-3d0/max_pwrlevel chmod 664 /sys/class/kgsl/kgsl-3d0/max_pwrlevel @@ -329,7 +329,7 @@ on boot chmod 664 /sys/class/devfreq/soc:qcom,cpubw/available_frequencies chmod 664 /sys/class/devfreq/soc:qcom,cpubw/min_freq chmod 664 /sys/class/devfreq/soc:qcom,cpubw/max_freq - + # Permissions for input_booster chown system radio /sys/class/input_booster/level chown system radio /sys/class/input_booster/head @@ -343,7 +343,7 @@ on boot chmod 0664 /sys/class/input_booster/touchkey/level chmod 0664 /sys/class/input_booster/touchkey/freq chmod 0664 /sys/class/input_booster/touchkey/time - + # Permissions for Camera chown cameraserver cameraserver /sys/kernel/mm/vmscan/mem_boost_mode chown system system /sys/class/camera/rear/rear_camfw @@ -875,51 +875,3 @@ on boot chmod 444 /sys/class/sec/sdinfo/data chown system system /sys/block/mmcblk0/diskios chmod 660 /sys/block/mmcblk0/diskios - -on charger - wait /dev/block/platform/soc/${ro.boot.bootdevice} - symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice - mount ext4 /dev/block/bootdevice/by-name/system /system wait ro - wait /dev/block/bootdevice/by-name/efs - mount ext4 /dev/block/bootdevice/by-name/efs /efs nosuid nodev noatime noauto_da_alloc,discard,data=ordered,errors=panic - mkdir /efs/Battery 0775 radio system - chown radio system /efs/Battery - chmod 0775 /efs/Battery - chmod 0664 /sys/class/power_supply/battery/batt_temp_table - chown system radio /sys/class/power_supply/battery/batt_temp_table - chmod 0664 /sys/class/power_supply/battery/batt_capacity_max - chown system radio /sys/class/power_supply/battery/batt_capacity_max - chmod 0664 /efs/Battery/batt_capacity_max - chown radio system /efs/Battery/batt_capacity_max - chmod 0664 /sys/class/power_supply/battery/battery_cycle - chown system radio /sys/class/power_supply/battery/battery_cycle - chmod 0664 /sys/class/power_supply/battery/batt_after_manufactured - chown system radio /sys/class/power_supply/battery/batt_after_manufactured - chown system radio /sys/class/power_supply/battery/cisd_fullcaprep_max - chmod 0660 /sys/class/power_supply/battery/cisd_fullcaprep_max - chown system radio /sys/class/power_supply/battery/cisd_data - chmod 0660 /sys/class/power_supply/battery/cisd_data - chown system system /efs/FactoryApp/cisd_data - chmod 0660 /efs/FactoryApp/cisd_data - chown system system /efs/FactoryApp/cisd_wc_data - chmod 0660 /efs/FactoryApp/cisd_wc_data - chown system system /efs/FactoryApp/asoc - chmod 0660 /efs/FactoryApp/asoc - chown system system /efs/FactoryApp/batt_after_manufactured - chmod 0640 /efs/FactoryApp/batt_after_manufactured - chown system system /efs/FactoryApp/batt_discharge_level - chmod 0640 /efs/FactoryApp/batt_discharge_level - chown system radio /sys/class/power_supply/battery/cisd_data_json - chmod 0660 /sys/class/power_supply/battery/cisd_data_json - copy /system/vendor/firmware/battery_data.dat /efs/Battery/battery_data.dat - chmod 0400 /efs/Battery/battery_data.dat - write /sys/class/power_supply/battery/batt_update_data "/efs/Battery/battery_data.dat" - chown radio system /efs - chmod 0771 /efs - chown radio system /efs/usb_hw_param - chmod 771 /efs/usb_hw_param - chown system system /efs/usb_hw_param/usb_hw_param.log - chmod 0660 /efs/usb_hw_param/usb_hw_param.log - mkdir /efs/lpm 0775 system system - class_start sec-charger - diff --git a/sepolicy/charger.te b/sepolicy/charger.te new file mode 100644 index 0000000..954588b --- /dev/null +++ b/sepolicy/charger.te @@ -0,0 +1,25 @@ +binder_use(charger) + +allow charger ashmem_device:chr_file execute; +allow charger input_device:chr_file write; + +allow charger sysfs_graphics:dir search; +allow charger sysfs_graphics:file rw_file_perms; + +allow charger sysfs_usb_supply:dir search; +allow charger sysfs_usb_supply:file rw_file_perms; + +allow charger sysfs_batteryinfo:file rw_file_perms; +allow charger sysfs_rtc:file r_file_perms; +allow charger sysfs_sec_keypad:file r_file_perms; + +allow charger app_efs_file:dir search; +allow charger app_efs_file:file rw_file_perms; +allow charger battery_efs_file:dir rw_dir_perms; +allow charger battery_efs_file:file create_file_perms; +allow charger efs_file:dir rw_dir_perms; +allow charger efs_file:file create_file_perms; +allow charger sec_efs_file:dir rw_dir_perms; +allow charger sec_efs_file:file create_file_perms; + +set_prop(charger, powerctl_prop) \ No newline at end of file diff --git a/sepolicy/file.te b/sepolicy/file.te index 9fb81ef..5361867 100644 --- a/sepolicy/file.te +++ b/sepolicy/file.te @@ -51,6 +51,7 @@ type sysfs_camera_writable, fs_type, sysfs_type; type sysfs_fpc, fs_type, sysfs_type; type sysfs_lcd_writable, fs_type, sysfs_type; type sysfs_mdnie_writable, fs_type, sysfs_type; +type sysfs_sec_keypad, fs_type, sysfs_type; type sysfs_sec_switch, fs_type, sysfs_type; type sysfs_tsp, fs_type, sysfs_type; type sysfs_wifi, fs_type, sysfs_type; diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index 5cd7ae4..d837b93 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -17,6 +17,7 @@ # Binaries /(vendor|system/vendor)/bin/hw/macloader u:object_r:macloader_exec:s0 /(vendor|system/vendor)/bin/secril_config_svc u:object_r:secril_config_svc_exec:s0 +/system/bin/lpm u:object_r:charger_exec:s0 /system/bin/set-audio-rotation u:object_r:set-audio-rotation_exec:s0 # Data files @@ -197,5 +198,6 @@ /sys/devices/virtual/fingerprint/fingerprint(/.*)? u:object_r:sysfs_fpc:s0 /sys/devices/virtual/lcd/panel(/.*)? u:object_r:sysfs_lcd_writable:s0 /sys/devices/virtual/mdnie(/.*)? -- u:object_r:sysfs_mdnie_writable:s0 +/sys/devices/virtual/sec/sec_keypad(/.*)? u:object_r:sysfs_sec_keypad:s0 /sys/devices/virtual/sec/switch(/.*)? u:object_r:sysfs_sec_switch:s0 /sys/devices/virtual/sec/tsp(/.*)? u:object_r:sysfs_tsp:s0