Merge "Enable zram swap" into main
diff --git a/device-common.mk b/device-common.mk
index 10f01eb..fb3de7e 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -86,6 +86,9 @@
device/linaro/dragonboard/fstab.common:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.$(TARGET_HARDWARE)
endif
+PRODUCT_VENDOR_PROPERTIES += \
+ persist.sys.zram_enabled=1
+
PRODUCT_COPY_FILES += \
$(TARGET_KERNEL_DIR)/Image.gz:kernel \
device/linaro/dragonboard/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.$(TARGET_HARDWARE).rc \
diff --git a/fstab.common b/fstab.common
index cde33c2..c618b7a 100644
--- a/fstab.common
+++ b/fstab.common
@@ -11,3 +11,4 @@
product /product erofs ro wait,logical,first_stage_mount,slotselect
system_dlkm /system_dlkm erofs ro wait,logical,first_stage_mount,slotselect
vendor_dlkm /vendor_dlkm erofs ro wait,logical,first_stage_mount,slotselect
+/dev/block/zram0 none swap defaults zramsize=75%
diff --git a/init.common.rc b/init.common.rc
index 51a42c6..42a582f 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -16,6 +16,9 @@
mount_all /vendor/etc/fstab.${ro.hardware} --late
on init
+ # ZRAM setup
+ write /sys/block/zram0/comp_algorithm lz4
+
# For legacy support
# See storage config details at http://source.android.com/tech/storage/
# since /storage is mounted on post-fs in init.rc
@@ -59,6 +62,15 @@
# little cores, not on bigs to be used only by init
write /dev/cpuset/system-background/cpus 0-3
+ trigger sys-boot-completed-set
+
+# We want one opportunity per boot to enable zram, so we
+# use a trigger we fire from the above stanza. If
+# persist.sys.zram_enabled becomes true after boot,
+# we don't want to run swapon_all at that time.
+on sys-boot-completed-set && property:persist.sys.zram_enabled=1
+ swapon_all
+
service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
-Dnl80211 -g@android:wpa_wlan0
interface aidl android.hardware.wifi.supplicant.ISupplicant/default
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 82370f6..660539c 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -5,6 +5,7 @@
/dev/block/platform/soc@0/1d84000\.ufshc/by-name/super u:object_r:super_block_device:s0
/dev/block/platform/soc@0/1d84000\.ufshc/by-name/userdata u:object_r:userdata_block_device:s0
/dev/block/platform/soc@0/1d84000\.ufshc/by-name/misc u:object_r:misc_block_device:s0
+/dev/block/zram0 u:object_r:swap_block_device:s0
/dev/dri u:object_r:dri_device:s0
/dev/dri/card0 u:object_r:graphics_device:s0