Merge commit 'LineageOS/cm-14.1' into N
diff --git a/core/Makefile b/core/Makefile
index 62c72a4..e221090 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1,5 +1,17 @@
 # Put some miscellaneous rules here
 
+# Build system colors
+
+ifneq ($(BUILD_WITH_COLORS),0)
+  CL_RED="\033[31m"
+  CL_GRN="\033[32m"
+  CL_YLW="\033[33m"
+  CL_BLU="\033[34m"
+  CL_MAG="\033[35m"
+  CL_CYN="\033[36m"
+  CL_RST="\033[0m"
+endif
+
 # HACK: clear LOCAL_PATH from including last build target before calling
 # intermedites-dir-for
 LOCAL_PATH := $(BUILD_SYSTEM)
@@ -121,7 +133,7 @@
 ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
 BUILD_KEYS := test-keys
 else
-BUILD_KEYS := dev-keys
+BUILD_KEYS := release-keys
 endif
 BUILD_VERSION_TAGS += $(BUILD_KEYS)
 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
@@ -232,7 +244,7 @@
 	$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
 			TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
 			TARGET_DEVICE="$(TARGET_VENDOR_DEVICE_NAME)" \
-			CM_DEVICE="$(TARGET_DEVICE)" \
+			AIM_DEVICE="$(TARGET_DEVICE)" \
 			PRODUCT_NAME="$(TARGET_VENDOR_PRODUCT_NAME)" \
 			PRODUCT_BRAND="$(PRODUCT_BRAND)" \
 			PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
@@ -587,6 +599,7 @@
 	$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
 	$(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
 	$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+			@echo -e ${CL_RED}"Succesfully made boot image: $@"${CL_RST}
 
 .PHONY: bootimage-nodeps
 bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
@@ -618,12 +631,14 @@
 	$(call pretty,"Target boot image: $@")
 	$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
 	$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+		@echo -e ${CL_RED}"Made boot image: $@"${CL_RST}
 
 .PHONY: bootimage-nodeps
 bootimage-nodeps: $(MKBOOTIMG)
 	@echo "make $@: ignoring dependencies"
 	$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
 	$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+		@echo -e ${CL_RED}"Made boot image: $@"${CL_RST}
 
   endif # PRODUCT_SUPPORTS_VBOOT
 endif # TARGET_BOOTIMAGE_USE_EXT2 / BOARD_CUSTOM_BOOTIMG_MK
@@ -731,7 +746,7 @@
 $(kernel_notice_file): \
 	    $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \
 	    | $(ACP)
-	@echo Copying: $@
+	@echo -e ${CL_RED}"Copying:"${CL_RST}" $@"
 	$(hide) mkdir -p $(dir $@)
 	$(hide) $(ACP) $< $@
 
@@ -1053,7 +1068,7 @@
 	java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
 
 define build-recoveryramdisk
-  @echo ----- Making recovery ramdisk ------
+   @echo -e ${CL_BLU}"----- Making recovery image ------"${CL_RST}
   $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
   $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
   @echo Copying baseline ramdisk...
@@ -1105,7 +1120,7 @@
   $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
     $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
     $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
-  @echo ----- Made recovery image: $(1) --------
+  @echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST}
 endef
 
 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
@@ -1315,20 +1330,22 @@
 $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
 	$(call build-systemimage-target,$@)
 
-ifndef I_WANT_A_QUAIL_STAR
-ifneq ($(WITHOUT_CHECK_API),true)
-$(BUILT_SYSTEMIMAGE): checkapi
-ifneq ($(TARGET_DISABLE_CMSDK),true)
-$(BUILT_SYSTEMIMAGE): checkapi-cm
-endif
-endif
-endif
+# Disable apicheck
+
+#ifndef I_WANT_A_QUAIL_STAR
+#ifneq ($(WITHOUT_CHECK_API),true)
+#$(BUILT_SYSTEMIMAGE): checkapi
+#ifneq ($(TARGET_DISABLE_CMSDK),true)
+#$(BUILT_SYSTEMIMAGE): checkapi-cm
+#endif
+#endif
+#endif
 
 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
 
 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
-	@echo "Install system fs image: $@"
+	@echo -e ${CL_CYN}"Install system fs image: $@"${CL_RST}
 	$(copy-file-to-target)
 	$(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
 
@@ -1790,13 +1807,13 @@
 $(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP)
 	@echo "Package OTA tools: $@"
 	$(hide) rm -rf $@ $(zip_root)
-	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity $(zip_root)/external/vboot_reference/tests/devkeys $(zip_root)/vendor/cm/build/tools
+	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity $(zip_root)/external/vboot_reference/tests/devkeys $(zip_root)/vendor/aim/build/tools
 	$(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
 	$(hide) $(ACP) $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar $(zip_root)/framework/
 	$(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/
 	$(hide) $(ACP) -p -r external/vboot_reference/tests/devkeys/* $(zip_root)/external/vboot_reference/tests/devkeys
 	$(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
-	$(hide) $(ACP) -p vendor/cm/build/tools/getb64key.py $(zip_root)/vendor/cm/build/tools/
+	$(hide) $(ACP) -p vendor/aim/build/tools/getb64key.py $(zip_root)/vendor/aim/build/tools/
 	$(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
 	$(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *)
 	$(hide) zip -qryX $(abspath $@) build/target/product/security/
@@ -2136,17 +2153,23 @@
 	$(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
 endif
 ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
-	$(hide) vendor/cm/build/tools/getb64key.py $(PRODUCT_DEFAULT_DEV_CERTIFICATE).x509.pem > $(zip_root)/META/releasekey.txt
+	$(hide) vendor/aim/build/tools/getb64key.py $(PRODUCT_DEFAULT_DEV_CERTIFICATE).x509.pem > $(zip_root)/META/releasekey.txt
 else
-	$(hide) vendor/cm/build/tools/getb64key.py $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem > $(zip_root)/META/releasekey.txt
+	$(hide) vendor/aim/build/tools/getb64key.py $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem > $(zip_root)/META/releasekey.txt
 endif
 	$(hide) echo "ota_override_device=$(OTA_SCRIPT_OVERRIDE_DEVICE)" >> $(zip_root)/META/misc_info.txt
 	$(hide) echo "ota_override_prop=$(OTA_SCRIPT_OVERRIDE_PROP)" >> $(zip_root)/META/misc_info.txt
 	@# Zip everything up, preserving symlinks and placing META/ files first to
 	@# help early validation of the .zip file while uploading it.
+ifneq ($(BLOCK_BASED_OTA),false)
+	$(hide) (cd $(zip_root) && \
+	        zip -0qryX ../$(notdir $@) ./META && \
+	        zip -0qryXu ../$(notdir $@) .)
+else
 	$(hide) (cd $(zip_root) && \
 	        zip -qryX ../$(notdir $@) ./META && \
 	        zip -qryXu ../$(notdir $@) .)
+endif
 	@# Run fs_config on all the system, vendor, boot ramdisk,
 	@# and recovery ramdisk files in the zip, and save the output
 	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
@@ -2195,7 +2218,7 @@
 ifeq ($(WITH_GMS),true)
     $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
 else
-ifneq ($(CM_BUILD),)
+ifneq ($(AIM_BUILD),)
     $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := true
 else
     $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
@@ -2219,6 +2242,11 @@
     $(INTERNAL_OTA_PACKAGE_TARGET): block_based := --block
 endif
 
+# Assume non-release recoveries skip signature check
+ifneq ($(TARGET_BUILD_VARIANT),user)
+    extra_ota_args := --no_signing
+endif
+
 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE)
 	@echo "$(OTA_FROM_TARGET_SCRIPT)" > $(PRODUCT_OUT)/ota_script_path
 	@echo "Package OTA: $@"
@@ -2227,19 +2255,37 @@
 	   $(block_based) \
 	   -p $(HOST_OUT) \
 	   -k $(KEY_CERT_PAIR) \
+	   $(extra_ota_args) \
 	   --backup=$(backuptool) \
 	   $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
 	   $(BUILT_TARGET_FILES_PACKAGE) $@
 
-CM_TARGET_PACKAGE := $(PRODUCT_OUT)/lineage-$(LINEAGE_VERSION).zip
+AIM_TARGET_PACKAGE := $(PRODUCT_OUT)/AIM-$(AIM_VERSION).zip
 
-.PHONY: otapackage bacon
+.PHONY: otapackage aim bacon
 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
+aim: bacon
 bacon: otapackage
-	$(hide) ln -f $(INTERNAL_OTA_PACKAGE_TARGET) $(CM_TARGET_PACKAGE)
-	$(hide) $(MD5SUM) $(CM_TARGET_PACKAGE) | sed "s|$(PRODUCT_OUT)/||" > $(CM_TARGET_PACKAGE).md5sum
-	@echo "Package Complete: $(CM_TARGET_PACKAGE)" >&2
-
+	$(hide) ln -f $(INTERNAL_OTA_PACKAGE_TARGET) $(AIM_TARGET_PACKAGE)
+	$(hide) $(MD5SUM) $(AIM_TARGET_PACKAGE) > $(AIM_TARGET_PACKAGE).md5sum
+	#@echo "Compilation Successful: $(AIM_TARGET_PACKAGE)"
+	@echo -e ${CL_RST} "" ${CL_RST}
+	@echo -e ${CL_RST} "       d8888 8888888 888b     d888     8888888b.   .d88888b.  888b     d888 "
+	@echo -e ${CL_RST} "      d88888   888   8888b   d8888     888   Y88b d88P' 'Y88b 8888b   d8888 "
+	@echo -e ${CL_RST} "     d88P888   888   88888b.d88888     888    888 888     888 88888b.d88888 "
+	@echo -e ${CL_RST} "    d88P 888   888   888Y88888P888     888   d88P 888     888 888Y88888P888 "
+	@echo -e ${CL_RST} "   d88P  888   888   888 Y888P 888     8888888P   888     888 888 Y888P 888 "
+	@echo -e ${CL_RST} "  d88P   888   888   888  Y8P  888     888 T88b   888     888 888  Y8P  888 "
+	@echo -e ${CL_RST} " d8888888888   888   888   '   888     888  T88b  Y88b. .d88P 888   '   888 "
+	@echo -e ${CL_RST} "d88P     888 8888888 888       888     888   T88b  'Y88888P'  888       888 "
+	@echo -e ${CL_RST} "                                                                            "
+	@echo -e ${CL_RST} "" ${CL_RST}
+	@echo -e ${CL_BLD}${CL_RED}"             	  Build completed! Now Flash the Rom and ENJOY!!  " ${CL_RED}
+	@echo -e ${CL_BLD}${CL_BLU}" ============================================================================================================" ${CL_BLU}
+	@echo -e ${CL_BLD}${CL_RED}"       AIM ROM is based on Android 7.1.2 developed by AnandRamachandran and shadowreaper1 	 " ${CL_RED}
+	@echo -e ${CL_BLD}${CL_BLU}" =====================================-Package complete-=====================================================" ${CL_BLU}
+	@echo -e ${CL_BLD}${CL_GRN}" zip: $(AIM_TARGET_PACKAGE)" ${CL_GRN}
+	@echo -e ${C L_BLD}${CL_RED}" ============================================================================================================" ${CL_RED}
 endif    # build_ota_package
 # -----------------------------------------------------------------
 # The factory package
@@ -2583,3 +2629,4 @@
 ifneq ($(sdk_repo_goal),)
 include $(TOPDIR)development/build/tools/sdk_repo.mk
 endif
+
diff --git a/core/binary.mk b/core/binary.mk
index 069a3dd..8d2d58b 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -298,49 +298,6 @@
   my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 
-####################################################
-## Add FDO flags if FDO is turned on and supported
-## Please note that we will do option filtering during FDO build.
-## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
-##################################################################
-my_fdo_build :=
-ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
-  ifeq ($(BUILD_FDO_INSTRUMENT),true)
-    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
-    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
-    my_fdo_build := true
-  else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
-    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
-    my_fdo_build := true
-  endif
-  # Disable ccache (or other compiler wrapper) except gomacc, unless
-  # it can handle -fprofile-use properly.
-
-  # ccache supports -fprofile-use as of version 3.2. Parse the version output
-  # of each wrapper to determine if it's ccache 3.2 or newer.
-  is_cc_ccache := $(shell if [ "`$(my_cc_wrapper) -V 2>/dev/null | head -1 | cut -d' ' -f1`" = ccache ]; then echo true; fi)
-  ifeq ($(is_cc_ccache),true)
-    cc_ccache_version := $(shell $(my_cc_wrapper) -V | head -1 | grep -o '[[:digit:]]\+\.[[:digit:]]\+')
-    vmajor := $(shell echo $(cc_ccache_version) | cut -d'.' -f1)
-    vminor := $(shell echo $(cc_ccache_version) | cut -d'.' -f2)
-    cc_ccache_ge_3_2 = $(shell if [ $(vmajor) -gt 3 -o $(vmajor) -eq 3 -a $(vminor) -ge 2 ]; then echo true; fi)
-  endif
-  is_cxx_ccache := $(shell if [ "`$(my_cxx_wrapper) -V 2>/dev/null | head -1 | cut -d' ' -f1`" = ccache ]; then echo true; fi)
-  ifeq ($(is_cxx_ccache),true)
-    cxx_ccache_version := $(shell $(my_cxx_wrapper) -V | head -1 | grep -o '[[:digit:]]\+\.[[:digit:]]\+')
-    vmajor := $(shell echo $(cxx_ccache_version) | cut -d'.' -f1)
-    vminor := $(shell echo $(cxx_ccache_version) | cut -d'.' -f2)
-    cxx_ccache_ge_3_2 = $(shell if [ $(vmajor) -gt 3 -o $(vmajor) -eq 3 -a $(vminor) -ge 2 ]; then echo true; fi)
-  endif
-
-  ifneq ($(cc_ccache_ge_3_2),true)
-    my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper))
-  endif
-  ifneq ($(cxx_ccache_ge_3_2),true)
-    my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper))
-  endif
-endif
-
 ###########################################################
 ## Explicitly declare assembly-only __ASSEMBLY__ macro for
 ## assembly source
@@ -368,11 +325,27 @@
 my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
     ifeq ($(my_sdclang),true)
+        SDCLANG_PRECONFIGURED_FLAGS := -Wno-vectorizer-no-neon
+
+        ifeq ($(LOCAL_SDCLANG_LTO), true)
+        ifneq ($(LOCAL_MODULE_CLASS), STATIC_LIBRARIES)
+
+            ifeq ($(strip $(LOCAL_SDCLANG_LTO_LDFLAGS)),)
+                LOCAL_SDCLANG_LTO_LDFLAGS := $(SDCLANG_COMMON_FLAGS)
+            endif
+
+            SDCLANG_PRECONFIGURED_FLAGS += -fuse-ld=qcld -flto
+            my_target_global_ldflags += -fuse-ld=qcld -flto $(LOCAL_SDCLANG_LTO_LDFLAGS)
+        endif
+        endif
+        my_target_global_cflags += $(SDCLANG_COMMON_FLAGS) $(SDCLANG_PRECONFIGURED_FLAGS)
+        SDCLANG_PRECONFIGURED_FLAGS :=
+
         ifeq ($(strip $(my_cc)),)
-            my_cc := $(my_cc_wrapper) $(SDCLANG_PATH)/clang $(SDLLVM_AE_FLAG) -Wno-vectorizer-no-neon
+            my_cc := $(SDCLANG_PATH)/clang
         endif
         ifeq ($(strip $(my_cxx)),)
-            my_cxx := $(my_cxx_wrapper) $(SDCLANG_PATH)/clang++ $(SDLLVM_AE_FLAG) -Wno-vectorizer-no-neon
+            my_cxx := $(SDCLANG_PATH)/clang++
         endif
     endif
 else
diff --git a/core/clang/arm.mk b/core/clang/arm.mk
index 4053bb2..4b73ae6 100644
--- a/core/clang/arm.mk
+++ b/core/clang/arm.mk
@@ -4,10 +4,10 @@
 
 CLANG_CONFIG_arm_EXTRA_CFLAGS :=
 
-ifneq (,$(filter krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ifneq (,$(filter kryo krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
   # Android's clang support's krait as a CPU whereas GCC doesn't. Specify
   # -mcpu here rather than the more normal core/combo/arch/arm/armv7-a-neon.mk.
-  CLANG_CONFIG_arm_EXTRA_CFLAGS += -mcpu=krait -mfpu=neon-vfpv4
+  CLANG_CONFIG_arm_EXTRA_CFLAGS += -mcpu=krait
 endif
 
 CLANG_CONFIG_arm_EXTRA_CPPFLAGS :=
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 09eddce..be6b928 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -159,7 +159,8 @@
 LOCAL_CLANG:=
 LOCAL_SDCLANG:=
 LOCAL_SDCLANG_LTO:=
-LOCAL_SDCLANG_EXTRA_FLAGS_32:=
+LOCAL_SDCLANG_LTO_LDFLAGS:=
+LOCAL_SDCLANG_LTO_UNSAFE_FILTER:=
 LOCAL_JAR_EXCLUDE_FILES:=
 LOCAL_JAR_PACKAGES:=
 LOCAL_JAR_EXCLUDE_PACKAGES:=
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index 6a1d861..08018d8 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -114,7 +114,6 @@
 			-Wl,--fatal-warnings \
 			-Wl,-maarch64linux \
 			-Wl,--hash-style=gnu \
-			-Wl,--fix-cortex-a53-843419 \
 			-fuse-ld=gold \
 			-Wl,--icf=safe \
 			-Wl,--no-undefined-version \
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index 8dee4ea..ac3e1fe 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -8,46 +8,36 @@
 
 local_arch_has_lpae := false
 
-ifneq (,$(filter cortex-a15 denver krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ifneq (,$(filter cortex-a15 kryo krait denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
 	# TODO: krait is not a cortex-a15, we set the variant to cortex-a15 so that
 	#       hardware divide operations are generated. This should be removed and a
 	#       krait CPU variant added to GCC. For clang we specify -mcpu for krait in
 	#       core/clang/arm.mk.
-	arch_variant_cflags := -mcpu=cortex-a15 -mfpu=neon-vfpv4
+	arch_variant_cflags := -mcpu=cortex-a15
 
 	local_arch_has_lpae := true
 	arch_variant_ldflags := \
 		-Wl,--no-fix-cortex-a8
 else
-ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a9)
-	arch_variant_cflags := -mcpu=cortex-a9 -mfpu=neon
-else
-ifneq (,$(filter cortex-a8 scorpion,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-	arch_variant_cflags := -mcpu=cortex-a8 -mfpu=neon
+ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a8)
+	arch_variant_cflags := -mcpu=cortex-a8
 	arch_variant_ldflags := \
 		-Wl,--fix-cortex-a8
 else
 ifneq (,$(filter cortex-a7 cortex-a53 cortex-a53.a57,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-	arch_variant_cflags := -mcpu=cortex-a7 -mfpu=neon-vfpv4
+	arch_variant_cflags := -mcpu=cortex-a7
 
 	local_arch_has_lpae := true
 	arch_variant_ldflags := \
 		-Wl,--no-fix-cortex-a8
 else
-ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a5)
-	arch_variant_cflags := -mcpu=cortex-a7 -mfpu=neon-vfpv4
-	arch_variant_ldflags := \
-		-Wl,--no-fix-cortex-a8
-else
-	arch_variant_cflags := -march=armv7-a -mfpu=neon
+	arch_variant_cflags := -march=armv7-a
 	# Generic ARM might be a Cortex A8 -- better safe than sorry
 	arch_variant_ldflags := \
 		-Wl,--fix-cortex-a8
 endif
 endif
 endif
-endif
-endif
 
 ifeq (true,$(local_arch_has_lpae))
 	# Fake an ARM compiler flag as these processors support LPAE which GCC/clang
@@ -61,3 +51,13 @@
 
 arch_variant_cflags += \
     -mfloat-abi=softfp
+
+ifneq (,$(filter cortex-a7 cortex-a15 krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+	arch_variant_cflags += -mfpu=neon-vfpv4
+else
+ifneq (,$(filter cortex-a53 cortex-a53.a57 kryo denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+        arch_variant_cflags += -mfpu=neon-fp-armv8
+else
+	arch_variant_cflags += -mfpu=neon
+endif
+endif
diff --git a/core/combo/arch/arm64/armv8-a.mk b/core/combo/arch/arm64/armv8-a.mk
index 5e27e5a..54727ed 100644
--- a/core/combo/arch/arm64/armv8-a.mk
+++ b/core/combo/arch/arm64/armv8-a.mk
@@ -3,3 +3,15 @@
 else
 	arch_variant_cflags :=
 endif
+
+ifneq (,$(filter cortex-a53 default,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+	arch_variant_cflags  += -mfix-cortex-a53-835769
+	arch_variant_ldflags := -Wl,--fix-cortex-a53-843419
+	arch_variant_ldflags += -Wl,--fix-cortex-a53-835769
+else
+	arch_variant_cflags  += -mno-fix-cortex-a53-835769
+	arch_variant_ldflags := -Wl,--no-fix-cortex-a53-843419
+	arch_variant_ldflags += -Wl,--no-fix-cortex-a53-835769
+	RS_DISABLE_A53_WORKAROUND := true
+endif
+
diff --git a/core/combo/fdo.mk b/core/combo/fdo.mk
index 8fb8fd3..03649c0 100644
--- a/core/combo/fdo.mk
+++ b/core/combo/fdo.mk
@@ -17,17 +17,3 @@
 # Setup FDO related flags.
 
 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=
-
-# Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
-# The profile will be generated on /sdcard/fdo_profile on the device.
-$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
-$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_LDFLAGS := -lgcov -lgcc
-
-# Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
-ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
-  $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
-endif
-
-$(combo_2nd_arch_prefix)TARGET_FDO_OPTIMIZE_CFLAGS := \
-    -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) \
-    -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
diff --git a/core/config.mk b/core/config.mk
index 5ca6a9a..0807b18 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -190,7 +190,7 @@
 $(call project-set-path-variant,recovery,RECOVERY_VARIANT,bootable/recovery)
 
 -include vendor/extra/BoardConfigExtra.mk
--include vendor/cm/config/BoardConfigCM.mk
+-include vendor/aim/config/BoardConfigCM.mk
 
 # The build system exposes several variables for where to find the kernel
 # headers:
@@ -659,10 +659,10 @@
 endif
 
 # Rules for QCOM targets
-include vendor/cm/build/core/qcom_target.mk
+include vendor/aim/build/core/qcom_target.mk
 
 # Rules for MTK targets
-include vendor/cm/build/core/mtk_target.mk
+include vendor/aim/build/core/mtk_target.mk
 
 # ###############################################################
 # Set up final options.
@@ -916,10 +916,10 @@
     PRODUCT_COPY_FILES := $(filter-out $(TARGET_COPY_FILES_OVERRIDES), $(PRODUCT_COPY_FILES))
 endif
 
-ifneq ($(CM_BUILD),)
+ifneq ($(AIM_BUILD),)
 ## We need to be sure the global selinux policies are included
 ## last, to avoid accidental resetting by device configs
-$(eval include vendor/cm/sepolicy/sepolicy.mk)
+$(eval include vendor/aim/sepolicy/sepolicy.mk)
 
 # Include any vendor specific config.mk file
 -include $(TOPDIR)vendor/*/build/core/config.mk
@@ -930,3 +930,4 @@
 endif
 
 include $(BUILD_SYSTEM)/dumpvar.mk
+
diff --git a/core/definitions.mk b/core/definitions.mk
index bca474e..6a10ad3 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2427,7 +2427,7 @@
 
 # $(1): the package file.
 define add-dex-to-package-arg
-$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
+$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -0qjX $(1)
 endef
 
 # Add java resources added by the current module.
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 1150350..db728ee 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -3,10 +3,27 @@
 #
 ####################################
 
+# Filter out duplicates
+define uniq__dx
+  $(eval seen :=)
+  $(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))
+  ${seen}
+endef
+
+PRODUCT_BOOT_JARS := $(call uniq__dx,$(subst $(space), ,$(strip $(PRODUCT_BOOT_JARS))))
+PRODUCT_BOOT_JARS_NOPREOPT := $(call uniq__dx,$(subst $(space), ,$(strip $(PRODUCT_BOOT_JARS_NOPREOPT))))
+
+# Filter out non-preopt boot jars out of preoptable boot jars
+# this is to prevent further duplicates, as well, as strictly
+# enforcing the non-preopt rule here: non-preop boot jars are
+# not allowed to stay in normal boot jars so remove them here
+PRODUCT_BOOT_JARS := $(filter-out $(PRODUCT_BOOT_JARS_NOPREOPT),$(PRODUCT_BOOT_JARS))
+
 # list of boot classpath jars for dexpreopt
 DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
 DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
-PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
+DEXPREOPT_BOOT_JARS_CLASSPATH := $(PRODUCT_BOOT_JARS) $(PRODUCT_BOOT_JARS_NOPREOPT)
+PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_CLASSPATH),/system/framework/$(m).jar))
 
 PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar))
 
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 92cb3a2..65dbb6e 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -1,9 +1,8 @@
-
 # List of variables we want to print in the build banner.
 print_build_config_vars := \
   PLATFORM_VERSION_CODENAME \
   PLATFORM_VERSION \
-  LINEAGE_VERSION \
+  AIM_VERSION \
   TARGET_PRODUCT \
   TARGET_BUILD_VARIANT \
   TARGET_BUILD_TYPE \
@@ -33,6 +32,10 @@
 print_build_config_vars += \
   WITH_SU
 endif
+ifeq ($(WITH_MAGISK),true)
+print_build_config_vars += \
+  WITH_MAGISK
+endif
 ifeq ($(WITH_GMS),true)
 print_build_config_vars += \
   WITH_GMS
@@ -103,7 +106,7 @@
 
 ifneq ($(filter report_config,$(DUMP_MANY_VARS)),)
 # Construct the shell commands that print the config banner.
-report_config_sh := echo '============================================';
+report_config_sh := echo "=============== Lets Ami-fy ================";
 report_config_sh += $(foreach v,$(print_build_config_vars),echo '$v=$($(v))';)
 report_config_sh += echo '============================================';
 endif
@@ -130,7 +133,7 @@
 endif # CALLED_FROM_SETUP
 
 ifneq ($(PRINT_BUILD_CONFIG),)
-$(info ============================================)
+$(info =============Lets Ami-fy ===================)
 $(foreach v, $(print_build_config_vars),\
   $(info $v=$($(v))))
 $(info ============================================)
diff --git a/core/executable.mk b/core/executable.mk
index 5a33db7..de54c77 100644
--- a/core/executable.mk
+++ b/core/executable.mk
@@ -42,10 +42,6 @@
 
 my_skip_non_preferred_arch :=
 
-ifeq ($(LOCAL_SDCLANG), true)
-include $(SDCLANG_FLAG_DEFS)
-endif
-
 # check if preferred arch is supported
 include $(BUILD_SYSTEM)/module_arch_supported.mk
 ifeq ($(my_module_arch_supported),true)
@@ -84,7 +80,7 @@
 
 my_module_arch_supported :=
 
-ifeq ($(LOCAL_SDCLANG), true)
+ifeq ($(SDCLANG), true)
 ifeq ($(LOCAL_SDCLANG_LTO), true)
 include $(SDCLANG_LTO_DEFS)
 endif
diff --git a/core/main.mk b/core/main.mk
index 7df4dcb..c972bd2 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -209,10 +209,42 @@
 $(info $(space))
 $(info Please follow the machine setup instructions at)
 $(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
+$(info $(space))
+$(info Continue at your own peril!)
 $(info ************************************************************)
-$(error stop)
 endif
 
+# Check for the current JDK.
+#
+# For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS.
+requires_openjdk := false
+ifeq ($(BUILD_OS),linux)
+requires_openjdk := true
+endif
+
+
+# Check for the current jdk
+ifeq ($(requires_openjdk), true)
+# The user asked for openjdk, so check that the host
+# java version is really openjdk and not some other JDK.
+ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
+$(info ************************************************************)
+$(info You asked for an OpenJDK based build but your version is)
+$(info $(java_version_str).)
+$(info ************************************************************)
+endif # java version is not OpenJdk
+else # if requires_openjdk
+ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
+$(info ************************************************************)
+$(info You are attempting to build with an unsupported JDK.)
+$(info $(space))
+$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
+$(info Please follow the machine setup instructions at)
+$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
+$(info ************************************************************)
+endif # java version is not Sun Oracle JDK
+endif # if requires_openjdk
+
 KNOWN_INCOMPATIBLE_JAVAC_VERSIONS := google
 incompat_javac := $(foreach v,$(KNOWN_INCOMPATIBLE_JAVAC_VERSIONS),$(findstring $(v),$(javac_version_str)))
 ifneq ($(incompat_javac),)
@@ -236,7 +268,6 @@
 $(info Please follow the machine setup instructions at)
 $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
 $(info ************************************************************)
-$(error stop)
 endif
 
 endif # if JAVA_NOT_REQUIRED
@@ -380,7 +411,7 @@
 
 else # !user_variant
   # Turn on checkjni for non-user builds.
-  ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
+  #ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
   # Set device insecure for non-user builds.
   ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
   # Allow mock locations by default for non user builds
diff --git a/core/pdk_config.mk b/core/pdk_config.mk
index c0aaacd..b87163f 100644
--- a/core/pdk_config.mk
+++ b/core/pdk_config.mk
@@ -87,7 +87,7 @@
 # That's desired by us: we want only absent files from the platform zip package.
 # Copy with the last-modified time preserved, never follow symbolic links.
 $(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
-	@mkdir -p $(dir $@)
+	$(hide) mkdir -p $(dir $@)
 	$(hide) rm -rf $@
 	$(hide) cp -fpPR $< $@
 
diff --git a/core/product_config.mk b/core/product_config.mk
index 7b440b1..cc75260 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -179,12 +179,12 @@
 include $(BUILD_SYSTEM)/product.mk
 include $(BUILD_SYSTEM)/device.mk
 
-# A CM build needs only the CM product makefiles.
-ifneq ($(CM_BUILD),)
-  all_product_configs := $(shell find device -path "*/$(CM_BUILD)/lineage.mk")
+# An AIM build needs only AIMROM product makefiles.
+ifneq ($(AIM_BUILD),)
+  all_product_configs := $(shell find device -path "*/$(AIM_BUILD)/aim.mk")
   ifeq ($(all_product_configs),)
-    # Fall back to cm.mk
-    all_product_configs := $(shell find device -path "*/$(CM_BUILD)/cm.mk")
+    # Fall back to lineage.mk
+    all_product_configs := $(shell find device -path "*/$(CM_BUILD)/lineage.mk")
   endif
 else
   ifneq ($(strip $(TARGET_BUILD_APPS)),)
@@ -196,9 +196,9 @@
     # files in the tree.
     all_product_configs := $(get-all-product-makefiles)
   endif # TARGET_BUILD_APPS
-endif # CM_BUILD
+endif # AIM_BUILD
 
-ifeq ($(CM_BUILD),)
+ifeq ($(AIM_BUILD),)
 # Find the product config makefile for the current product.
 # all_product_configs consists items like:
 # <product_name>:<path_to_the_product_makefile>
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 26c455d..232fc56 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -20,11 +20,6 @@
 endif
 endif # my_module_multilib == both
 
-
-ifeq ($(LOCAL_SDCLANG), true)
-include $(SDCLANG_FLAG_DEFS)
-endif
-
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 include $(BUILD_SYSTEM)/module_arch_supported.mk
 
@@ -52,7 +47,7 @@
 
 endif # TARGET_2ND_ARCH
 
-ifeq ($(LOCAL_SDCLANG), true)
+ifeq ($(SDCLANG), true)
 ifeq ($(LOCAL_SDCLANG_LTO), true)
 include $(SDCLANG_LTO_DEFS)
 endif
diff --git a/core/static_library.mk b/core/static_library.mk
index 61a63d0..28c518c 100644
--- a/core/static_library.mk
+++ b/core/static_library.mk
@@ -6,10 +6,6 @@
 my_module_multilib := both
 endif
 
-ifeq ($(LOCAL_SDCLANG), true)
-include $(SDCLANG_FLAG_DEFS)
-endif
-
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 include $(BUILD_SYSTEM)/module_arch_supported.mk
 
@@ -37,7 +33,7 @@
 
 endif # TARGET_2ND_ARCH
 
-ifeq ($(LOCAL_SDCLANG), true)
+ifeq ($(SDCLANG), true)
 ifeq ($(LOCAL_SDCLANG_LTO), true)
 include $(SDCLANG_LTO_DEFS)
 endif
diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk
index e3761ae..3dbd845 100644
--- a/core/tasks/vendor_module_check.mk
+++ b/core/tasks/vendor_module_check.mk
@@ -98,7 +98,7 @@
 $(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info)
 $(_vendor_module_owner_info_txt):
 	@echo "Write vendor module owner info $@"
-	@mkdir -p $(dir $@) && rm -f $@
+	$(hide) mkdir -p $(dir $@) && rm -f $@
 ifdef _vendor_module_owner_info
 	@for w in $(PRIVATE_INFO); \
 	  do \
diff --git a/envsetup.sh b/envsetup.sh
index 814bcf5..e9609f7 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -35,7 +35,7 @@
 Look at the source to view more functions. The complete list is:
 EOF
     T=$(gettop)
-    for i in `cat $T/build/envsetup.sh $T/vendor/cm/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
+    for i in `cat $T/build/envsetup.sh $T/vendor/aim/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
       echo "$i"
     done | column
 }
@@ -45,8 +45,8 @@
 {
     T=$(gettop)
     # Grep out the variable names from the script.
-    cached_vars=`cat $T/build/envsetup.sh $T/vendor/cm/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
-    cached_abs_vars=`cat $T/build/envsetup.sh $T/vendor/cm/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
+    cached_vars=`cat $T/build/envsetup.sh $T/vendor/aim/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
+    cached_abs_vars=`cat $T/build/envsetup.sh $T/vendor/aim/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
     # Call the build system to dump the "<val>=<value>" pairs as a shell script.
     build_dicts_script=`\cd $T; export CALLED_FROM_SETUP=true; export BUILD_SYSTEM=build/core; \
                         command make --no-print-directory -f build/core/config.mk \
@@ -132,17 +132,17 @@
         return
     fi
 
-    if (echo -n $1 | grep -q -e "^lineage_") ; then
+    if (echo -n $1 | grep -q -e "^aim_") ; then
+        AIM_BUILD=$(echo -n $1 | sed -e 's/^aim_//g')
+        export BUILD_NUMBER=$( (date +%s%N ; echo $AIM_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10 )
+    elif (echo -n $1 | grep -q -e "^lineage_") ; then
+        # Fall back to lineage_<product>
         CM_BUILD=$(echo -n $1 | sed -e 's/^lineage_//g')
         export BUILD_NUMBER=$( (date +%s%N ; echo $CM_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10 )
-    elif (echo -n $1 | grep -q -e "^cm_") ; then
-        # Fall back to cm_<product>
-        CM_BUILD=$(echo -n $1 | sed -e 's/^cm_//g')
-        export BUILD_NUMBER=$( (date +%s%N ; echo $CM_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10 )
     else
-        CM_BUILD=
+        AIM_BUILD=
     fi
-    export CM_BUILD
+    export AIM_BUILD
 
         TARGET_PRODUCT=$1 \
         TARGET_BUILD_VARIANT= \
@@ -547,9 +547,26 @@
 {
     local uname=$(uname)
     echo
-    echo "You're building on" $uname
-    echo
-    if [ "z${CM_DEVICES_ONLY}" != "z" ]; then
+	echo ""
+	tput setaf 1;
+	tput bold;
+	echo "       d8888 8888888 888b     d888     8888888b.   .d88888b.  888b     d888 "
+	echo "      d88888   888   8888b   d8888     888   Y88b d88P' 'Y88b 8888b   d8888 "
+	echo "     d88P888   888   88888b.d88888     888    888 888     888 88888b.d88888 "
+	echo "    d88P 888   888   888Y88888P888     888   d88P 888     888 888Y88888P888 "
+	echo "   d88P  888   888   888 Y888P 888     8888888P   888     888 888 Y888P 888 "
+	echo "  d88P   888   888   888  Y8P  888     888 T88b   888     888 888  Y8P  888 "
+	echo " d8888888888   888   888   '   888     888  T88b  Y88b. .d88P 888   '   888 "
+	echo "d88P     888 8888888 888       888     888   T88b  'Y88888P'  888       888 "
+	tput sgr0;
+	echo ""
+	echo "                      Welcome to the device menu                      "
+	echo ""
+	tput bold;
+	echo "     Type lunch to display all officially supported device list     "
+	tput sgr0;
+	echo ""
+    if [ "z${AIM_DEVICES_ONLY}" != "z" ]; then
        echo "Breakfast menu... pick a combo:"
     else
        echo "Lunch menu... pick a combo:"
@@ -563,7 +580,7 @@
         i=$(($i+1))
     done | column
 
-    if [ "z${CM_DEVICES_ONLY}" != "z" ]; then
+    if [ "z${AIM_DEVICES_ONLY}" != "z" ]; then
        echo "... and don't forget the bacon!"
     fi
 
@@ -579,7 +596,10 @@
         answer=$1
     else
         print_lunch_menu
-        echo -n "Which would you like? [aosp_arm-eng] "
+        tput setaf 2;
+        tput bold;
+        echo -n "Go ahead and pick a number or enter lunch combo(aim_device-userdebug)... "
+        tput sgr0;
         read answer
     fi
 
@@ -601,8 +621,9 @@
 
     if [ -z "$selection" ]
     then
-        echo
-        echo "Invalid lunch combo: $answer"
+        echo""
+        echo "Dude are you blind? Drunk? smoke weed?..input correct combo"
+	echo""
         return 1
     fi
 
@@ -622,16 +643,16 @@
     check_product $product
     if [ $? -ne 0 ]
     then
-        # if we can't find a product, try to grab it off the CM github
+        # if we can't find a product, try to grab it off the AIM github page
         T=$(gettop)
         cd $T > /dev/null
-        vendor/cm/build/tools/roomservice.py $product
+        vendor/aim/build/tools/roomservice.py $product
         cd - > /dev/null
         check_product $product
     else
         T=$(gettop)
         cd $T > /dev/null
-        vendor/cm/build/tools/roomservice.py $product true
+        vendor/aim/build/tools/roomservice.py $product true
         cd - > /dev/null
     fi
     TARGET_PRODUCT=$product \
@@ -1637,6 +1658,7 @@
     fi
     echo " ####${color_reset}"
     echo
+    prebuilts/sdk/tools/jack-admin stop-server 2>&1 >/dev/null
     return $ret
 }
 
@@ -1707,7 +1729,7 @@
 
 # Add completions
 check_bash_version && {
-    dirs="sdk/bash_completion vendor/cm/bash_completion"
+    dirs="sdk/bash_completion vendor/aim/bash_completion"
     for dir in $dirs; do
     if [ -d ${dir} ]; then
         for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
@@ -1720,4 +1742,5 @@
 
 export ANDROID_BUILD_TOP=$(gettop)
 
-. $ANDROID_BUILD_TOP/vendor/cm/build/envsetup.sh
+. $ANDROID_BUILD_TOP/vendor/aim/build/envsetup.sh&& . vendor/aim/extra/aimlog.sh && . vendor/aim/extra/root.sh && . vendor/aim/extra/tree_converter.sh
+
diff --git a/target/product/base.mk b/target/product/base.mk
index dcd48e7..a12f939 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -108,6 +108,7 @@
     mtpd \
     ndc \
     netd \
+    om \
     ping \
     ping6 \
     platform.xml \
diff --git a/target/product/core.mk b/target/product/core.mk
index 28558c5..61d7c0f 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -33,7 +33,6 @@
     DeskClock \
     DocumentsUI \
     DownloadProviderUi \
-    Email \
     ExactCalculator \
     Exchange2 \
     ExternalStorageProvider \
@@ -44,13 +43,11 @@
     Launcher2 \
     ManagedProvisioning \
     MtpDocumentsProvider \
-    PicoTts \
     PacProcessor \
     libpac \
     PrintSpooler \
     PrintRecommendationService \
     ProxyHandler \
-    QuickSearchBox \
     Settings \
     SharedStorageBackup \
     StorageManager \
@@ -58,5 +55,6 @@
     TeleService \
     VpnDialogs \
     MmsService
-
+    #Email
+    #PicoTts 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_base.mk)
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
index b98f0be..9afba6f 100644
--- a/target/product/full_base.mk
+++ b/target/product/full_base.mk
@@ -30,7 +30,7 @@
 $(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)
 
 # Get the TTS language packs
-$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk)
+#$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk)
 
 ifeq ($(TARGET_LOCALES),)
 # Get a list of languages.
diff --git a/target/product/sdk_base.mk b/target/product/sdk_base.mk
index fa257ae..6c35d76 100644
--- a/target/product/sdk_base.mk
+++ b/target/product/sdk_base.mk
@@ -93,12 +93,12 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
 
 # include available languages for TTS in the system image
--include external/svox/pico/lang/PicoLangDeDeInSystem.mk
--include external/svox/pico/lang/PicoLangEnGBInSystem.mk
--include external/svox/pico/lang/PicoLangEnUsInSystem.mk
--include external/svox/pico/lang/PicoLangEsEsInSystem.mk
--include external/svox/pico/lang/PicoLangFrFrInSystem.mk
--include external/svox/pico/lang/PicoLangItItInSystem.mk
+#include external/svox/pico/lang/PicoLangDeDeInSystem.mk
+#include external/svox/pico/lang/PicoLangEnGBInSystem.mk
+#include external/svox/pico/lang/PicoLangEnUsInSystem.mk
+#include external/svox/pico/lang/PicoLangEsEsInSystem.mk
+#include external/svox/pico/lang/PicoLangFrFrInSystem.mk
+#include external/svox/pico/lang/PicoLangItItInSystem.mk
 
 # locale. en_US is both first and in alphabetical order to
 # ensure this is the default locale.
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index 039c344..eb6cfb8 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -63,6 +63,6 @@
 fi
 echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
 
-echo "ro.cm.device=$CM_DEVICE"
+echo "ro.aim.device=$AIM_DEVICE"
 
 echo "# end build properties"
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index ade2ef5..4d63b9d 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -697,16 +697,11 @@
       for xf in self.transfers:
         if xf.style == "zero":
           tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
-          print("%10d %10d (%6.2f%%) %7s %s" % (
-              tgt_size, tgt_size, 100.0, xf.style, xf.tgt_name))
 
         elif xf.style == "new":
           for piece in self.tgt.ReadRangeSet(xf.tgt_ranges):
             new_f.write(piece)
           tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
-          print("%10d %10d (%6.2f%%) %7s %s" % (
-              tgt_size, tgt_size, 100.0, xf.style,
-              xf.tgt_name))
 
         elif xf.style == "diff":
           src = self.src.ReadRangeSet(xf.src_ranges)
@@ -734,12 +729,6 @@
             # These are identical; we don't need to generate a patch,
             # just issue copy commands on the device.
             xf.style = "move"
-            if xf.src_ranges != xf.tgt_ranges:
-              print("%10d %10d (%6.2f%%) %7s %s %s (from %s)" % (
-                  tgt_size, tgt_size, 100.0, xf.style,
-                  xf.tgt_name if xf.tgt_name == xf.src_name else (
-                      xf.tgt_name + " (from " + xf.src_name + ")"),
-                  str(xf.tgt_ranges), str(xf.src_ranges)))
           else:
             # For files in zip format (eg, APKs, JARs, etc.) we would
             # like to use imgdiff -z if possible (because it usually
@@ -787,11 +776,6 @@
           size = len(patch)
           with lock:
             patches[patchnum] = (patch, xf)
-            print("%10d %10d (%6.2f%%) %7s %s %s %s" % (
-                size, tgt_size, size * 100.0 / tgt_size, xf.style,
-                xf.tgt_name if xf.tgt_name == xf.src_name else (
-                    xf.tgt_name + " (from " + xf.src_name + ")"),
-                str(xf.tgt_ranges), str(xf.src_ranges)))
 
       threads = [threading.Thread(target=diff_worker)
                  for _ in range(self.threads)]
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 8c26e60..4906939 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -170,6 +170,11 @@
     # Exit code 124 == abort. run_program returns raw, so left-shift 8bit
     self.script.append('run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can\'t install this package on top of incompatible data. Please try another package or run a factory reset");')
 
+  def FlashMagisk(self):
+    self.script.append('package_extract_dir("magisk", "/tmp/magisk");')
+    self.script.append('run_program("/sbin/busybox", "unzip", "/tmp/magisk/magisk.zip", "META-INF/com/google/android/*", "-d", "/tmp/magisk");')
+    self.script.append('run_program("/sbin/sh", "/tmp/magisk/META-INF/com/google/android/update-binary", "dummy", "1", "/tmp/magisk/magisk.zip");')
+
   def ShowProgress(self, frac, dur):
     """Update the progress bar, advancing it over 'frac' over the next
     'dur' seconds.  'dur' may be zero to advance it via SetProgress
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index a9a8dd0..24f7235 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -800,6 +800,15 @@
   script.ShowProgress(0.05, 5)
   script.WriteRawImage("/boot", "boot.img")
 
+  if block_based:
+    if os.environ.get('WITH_MAGISK' == 'true'):
+      script.Print(" ")
+      script.Print("Flashing Magisk...")
+      script.Print(" ")
+      common.ZipWriteStr(output_zip, "magisk/magisk.zip",
+                   ""+input_zip.read("SYSTEM/addon.d/magisk.zip"))
+    script.FlashMagisk()
+    script.Print(" ")
   script.ShowProgress(0.2, 10)
   device_specific.FullOTA_InstallEnd()
 
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 8efbd52..3f83965 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -494,7 +494,7 @@
 
   # Save the base64 key representation in the update for key-change
   # validations
-  p = common.Run(["python", "vendor/cm/build/tools/getb64key.py",
+  p = common.Run(["python", "vendor/aim/build/tools/getb64key.py",
                  mapped_keys[0]], stdout=subprocess.PIPE)
   data, _ = p.communicate()
   if p.returncode == 0:
diff --git a/tools/warn.py b/tools/warn.py
index 8097123..1e6a8c7 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -34,10 +34,10 @@
     return 'grey'
 
 warnpatterns = [
-    { 'category':'make',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'make: overriding commands/ignoring old commands',
-        'patterns':[r".*: warning: overriding commands for target .+",
-                    r".*: warning: ignoring old commands for target .+"] },
+#    { 'category':'make',    'severity':severity.MEDIUM,   'members':[], 'option':'',
+#        'description':'make: overriding commands/ignoring old commands',
+#        'patterns':[r".*: warning: overriding commands for target .+",
+#                    r".*: warning: ignoring old commands for target .+"] },
     { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], 'option':'-Wimplicit-function-declaration',
         'description':'Implicit function declaration',
         'patterns':[r".*: warning: implicit declaration of function .+"] },