if[$1 !="device/amazon/thor"]&&[$1 !="device/samsung/i9100"]&&[$1 !="device/lge/h850"]&&[$1 !="device/lge/mako"];then#Some devices won't compile, or have too small of a /system partition
sed -i 's|XTRA_SERVER_QUERY=1|XTRA_SERVER_QUERY=0|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's|#XTRA_SERVER|XTRA_SERVER|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
#XTRA: Enable HTTPS
sed -i 's|http://xtra|https://xtra|' overlay/frameworks/base/core/res/res/values-*/*.xml gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
#XTRA: Use format version 3 if possible
if grep -sq "XTRA_VERSION_CHECK" gps.conf gps/gps.conf configs/gps.conf;then#Using hardware/qcom/gps OR precompiled blob OR device specific implementation
sed -i 's|XTRA_VERSION_CHECK=0|XTRA_VERSION_CHECK=1|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's|xtra2.bin|xtra3grc.bin|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
declare -a optionsYes=("CONFIG_ARM64_SW_TTBR0_PAN""CONFIG_BUG""CONFIG_BUG_ON_DATA_CORRUPTION""CONFIG_CC_STACKPROTECTOR""CONFIG_CC_STACKPROTECTOR_STRONG""CONFIG_CPU_SW_DOMAIN_PAN""CONFIG_DEBUG_CREDENTIALS""CONFIG_DEBUG_KERNEL""CONFIG_DEBUG_LIST""CONFIG_DEBUG_NOTIFIERS""CONFIG_DEBUG_RODATA""CONFIG_DEBUG_WX""CONFIG_FORTIFY_SOURCE""CONFIG_GCC_PLUGIN_LATENT_ENTROPY""CONFIG_GCC_PLUGIN_RANDSTRUCT""CONFIG_GCC_PLUGINS""CONFIG_GCC_PLUGIN_STRUCTLEAK""CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL""CONFIG_HARDENED_USERCOPY""CONFIG_IO_STRICT_DEVMEM""CONFIG_KAISER""CONFIG_LEGACY_VSYSCALL_NONE""CONFIG_PAGE_POISONING""CONFIG_PAGE_POISONING_NO_SANITY""CONFIG_PAGE_POISONING_ZERO""CONFIG_PAGE_TABLE_ISOLATION""CONFIG_PANIC_ON_OOPS""CONFIG_RANDOMIZE_BASE""CONFIG_REFCOUNT_FULL""CONFIG_RETPOLINE""CONFIG_SCHED_STACK_END_CHECK""CONFIG_SECCOMP""CONFIG_SECCOMP_FILTER""CONFIG_SECURITY""CONFIG_SECURITY_PERF_EVENTS_RESTRICT""CONFIG_SECURITY_YAMA""CONFIG_SECURITY_YAMA_STACKED""CONFIG_SLAB_FREELIST_RANDOM""CONFIG_SLAB_HARDENED""CONFIG_SLUB_DEBUG""CONFIG_STRICT_DEVMEM""CONFIG_STRICT_KERNEL_RWX""CONFIG_STRICT_MEMORY_RWX""CONFIG_SYN_COOKIES""CONFIG_UNMAP_KERNEL_AT_EL0""CONFIG_VMAP_STACK")
for option in "${optionsYes[@]}"
do
sed -i 's/# '$option' is not set/'$option'=y/'$defconfigPath&>/dev/null || true;
#Some defconfigs are very minimal/not-autogenerated, so lets add the rest. Obviously most won't have any affect as they aren't supported.
if[[$defconfigPath== *"lineage"* ]];then
if ! grep -q $option"=y"$defconfigPath;then
echo$option"=y"| tee -a $defconfigPath > /dev/null;
fi;
fi;
done
#Disable supported options
#TODO: Disable earjack/uart debugger
declare -a optionsNo=("CONFIG_ACPI_CUSTOM_METHOD""CONFIG_BINFMT_MISC""CONFIG_COMPAT_BRK""CONFIG_COMPAT_VDSO""CONFIG_CP_ACCESS64""CONFIG_DEVKMEM""CONFIG_DEVMEM""CONFIG_DEVPORT""CONFIG_HIBERNATION""CONFIG_INET_DIAG""CONFIG_KEXEC""CONFIG_LEGACY_PTYS""CONFIG_MSM_BUSPM_DEV""CONFIG_OABI_COMPAT""CONFIG_PROC_KCORE""CONFIG_PROC_VMCORE""CONFIG_SECURITY_SELINUX_DISABLE""CONFIG_SLAB_MERGE_DEFAULT")
for option in "${optionsNo[@]}"
do
sed -i 's/'$option'=y/# '$option' is not set/'$defconfigPath&>/dev/null || true;
done
#Extras
sed -i 's/CONFIG_DEFAULT_MMAP_MIN_ADDR=4096/CONFIG_DEFAULT_MMAP_MIN_ADDR=32768/'$defconfigPath&>/dev/null || true;
sed -i 's/CONFIG_LSM_MMAP_MIN_ADDR=4096/CONFIG_DEFAULT_MMAP_MIN_ADDR=32768/'$defconfigPath&>/dev/null || true;