From 5af16e1ddd3fd6c24d30878cd06468945b3e6194 Mon Sep 17 00:00:00 2001 From: Tad Date: Tue, 10 Jul 2018 21:27:55 -0400 Subject: [PATCH] Add build option to enable lowram/go on all devices --- .../LineageOS-14.1/android_build/lowram.mk | 37 +++++++++++++++++++ Scripts/LineageOS-14.1/Functions.sh | 12 +++++- Scripts/LineageOS-14.1/Patch.sh | 4 +- Scripts/LineageOS-15.1/Functions.sh | 12 +++++- Scripts/LineageOS-15.1/Patch.sh | 3 +- Scripts/init.sh | 1 + 6 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Patches/LineageOS-14.1/android_build/lowram.mk diff --git a/Patches/LineageOS-14.1/android_build/lowram.mk b/Patches/LineageOS-14.1/android_build/lowram.mk new file mode 100644 index 00000000..7c7dc9ed --- /dev/null +++ b/Patches/LineageOS-14.1/android_build/lowram.mk @@ -0,0 +1,37 @@ +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Sets Android Go recommended default values for propreties. + +# Set lowram options +PRODUCT_PROPERTY_OVERRIDES += \ + ro.config.low_ram=true \ + ro.lmk.critical_upgrade=true \ + ro.lmk.upgrade_pressure=40 \ + config.disable_atlas=true \ + persist.sys.use_16bpp_alpha=1 + +# Speed profile services and wifi-service to reduce RAM and storage. +PRODUCT_SYSTEM_SERVER_COMPILER_FILTER := speed-profile + +# Always preopt extracted APKs to prevent extracting out of the APK for gms +# modules. +PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK := true + +# Default heap sizes. Allow up to 256m for large heaps to make sure a single app +# doesn't take all of the RAM. +PRODUCT_PROPERTY_OVERRIDES += dalvik.vm.heapgrowthlimit=128m +PRODUCT_PROPERTY_OVERRIDES += dalvik.vm.heapsize=256m diff --git a/Scripts/LineageOS-14.1/Functions.sh b/Scripts/LineageOS-14.1/Functions.sh index 9d6ef999..8c3b466b 100644 --- a/Scripts/LineageOS-14.1/Functions.sh +++ b/Scripts/LineageOS-14.1/Functions.sh @@ -130,8 +130,18 @@ enableDexPreOptFull() { cd "$DOS_BUILD_BASE$1"; if [ -f BoardConfig.mk ]; then sed -i "s/WITH_DEXPREOPT_BOOT_IMG_ONLY := true/WITH_DEXPREOPT_BOOT_IMG_ONLY := false/" BoardConfig.mk; - echo "Enabled full dexpreopt"; + echo "Enabled full dexpreopt for $1"; fi; cd "$DOS_BUILD_BASE"; } export -f enableDexPreOptFull; + +enableLowRam() { + cd "$DOS_BUILD_BASE$1"; + if [ -f lineage.mk ]; then echo '$(call inherit-product, $(SRC_TARGET_DIR)/product/lowram.mk)' >> lineage.mk; fi; + if [ -f BoardConfig.mk ]; then echo 'MALLOC_SVELTE := true' >> BoardConfig.mk; fi; + if [ -f BoardConfigCommon.mk ]; then echo 'MALLOC_SVELTE := true' >> BoardConfigCommon.mk; fi; + echo "Enabled lowram for $1"; + cd "$DOS_BUILD_BASE"; +} +export -f enableLowRam; diff --git a/Scripts/LineageOS-14.1/Patch.sh b/Scripts/LineageOS-14.1/Patch.sh index 15ca065b..6f554342 100755 --- a/Scripts/LineageOS-14.1/Patch.sh +++ b/Scripts/LineageOS-14.1/Patch.sh @@ -68,6 +68,7 @@ patch -p1 < "$DOS_PATCHES/android_build/0001-Automated_Build_Signing.patch"; #Au sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence sed -i 's/ro.secure=0/ro.secure=1/' core/main.mk; #sed -i 's/ro.adb.secure=0/ro.adb.secure=1/' core/main.mk; +cp "$DOS_PATCHES/android_build/lowram.mk" target/product/lowram.mk; enterAndClear "device/qcom/sepolicy"; patch -p1 < "$DOS_PATCHES/android_device_qcom_sepolicy/0001-Camera_Fix.patch"; #Fix camera on user builds XXX: REMOVE THIS TRASH @@ -261,10 +262,11 @@ sed -i "s/TZ.BF.2.0-2.0.0134/TZ.BF.2.0-2.0.0134|TZ.BF.2.0-2.0.0137/" board-info. #Make changes to all devices cd "$DOS_BUILD_BASE"; +if [ "$DOS_LOWRAM_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableLowRam "$0"' {} \;; fi; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enhanceLocation "$0"' {} \; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableDexPreOpt "$0"' {} \; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableForcedEncryption "$0"' {} \; -#if [ "$STRONG_ENCRYPTION_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableStrongEncryption "$0"' {} \; fi; +#if [ "$STRONG_ENCRYPTION_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableStrongEncryption "$0"' {} \;; fi; find "kernel" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'hardenDefconfig "$0"' {} \; cd "$DOS_BUILD_BASE"; diff --git a/Scripts/LineageOS-15.1/Functions.sh b/Scripts/LineageOS-15.1/Functions.sh index f2e742c8..c025d85a 100644 --- a/Scripts/LineageOS-15.1/Functions.sh +++ b/Scripts/LineageOS-15.1/Functions.sh @@ -116,8 +116,18 @@ enableDexPreOptFull() { cd "$DOS_BUILD_BASE$1"; if [ -f BoardConfig.mk ]; then sed -i "s/WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY := true/WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY := false/" BoardConfig.mk; - echo "Enabled full dexpreopt"; + echo "Enabled full dexpreopt for $1"; fi; cd "$DOS_BUILD_BASE"; } export -f enableDexPreOptFull; + +enableLowRam() { + cd "$DOS_BUILD_BASE$1"; + if [ -f lineage.mk ]; then echo '$(call inherit-product, $(SRC_TARGET_DIR)/product/go_defaults.mk)' >> lineage.mk; fi; + if [ -f BoardConfig.mk ]; then echo 'MALLOC_SVELTE := true' >> BoardConfig.mk; fi; + if [ -f BoardConfigCommon.mk ]; then echo 'MALLOC_SVELTE := true' >> BoardConfigCommon.mk; fi; + echo "Enabled lowram for $1"; + cd "$DOS_BUILD_BASE"; +} +export -f enableLowRam; diff --git a/Scripts/LineageOS-15.1/Patch.sh b/Scripts/LineageOS-15.1/Patch.sh index 24fab97e..4affa698 100755 --- a/Scripts/LineageOS-15.1/Patch.sh +++ b/Scripts/LineageOS-15.1/Patch.sh @@ -242,10 +242,11 @@ sed -i "s/TZ.BF.2.0-2.0.0134/TZ.BF.2.0-2.0.0134|TZ.BF.2.0-2.0.0137/" board-info. #Make changes to all devices cd "$DOS_BUILD_BASE"; +if [ "$DOS_LOWRAM_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableLowRam "$0"' {} \;; fi; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enhanceLocation "$0"' {} \; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableDexPreOpt "$0"' {} \; find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableForcedEncryption "$0"' {} \; -#if [ "$STRONG_ENCRYPTION_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableStrongEncryption "$0"' {} \; fi; +#if [ "$STRONG_ENCRYPTION_ENABLED" = true ]; then find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enableStrongEncryption "$0"' {} \;; fi; find "kernel" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'hardenDefconfig "$0"' {} \; cd "$DOS_BUILD_BASE"; diff --git a/Scripts/init.sh b/Scripts/init.sh index fc470946..8934862f 100644 --- a/Scripts/init.sh +++ b/Scripts/init.sh @@ -37,6 +37,7 @@ export DOS_MICROG_INCLUDED="NLP"; #Determines inclusion of microG. Options: NONE export DOS_HOSTS_BLOCKING=true; #Switch to false to prevent inclusion of our HOSTS file export DOS_HOSTS_BLOCKING_LIST="https://divestos.xyz/hosts"; #Must be in the format "127.0.0.1 bad.domain.tld" export DOS_OVERCLOCKS_ENABLED=true; #Switch to false to disable overclocks +export DOS_LOWRAM_ENABLED=false; #Switch to true to enable lowram/Go configuration on all devices export DOS_STRONG_ENCRYPTION_ENABLED=false; #Switch to true to enable AES-256bit encryption XXX: THIS WILL **DESTROY** EXISTING INSTALLS! export DOS_NON_COMMERCIAL_USE_PATCHES=false; #Switch to false to prevent inclusion of non-commercial use patches