Recovery: move TWRP makevars to BoardConfigSoong 2/2

Change-Id: I288c1e259033270ad7a278805ad969c007fae561
diff --git a/Android.mk b/Android.mk
index cc6c5ad..a9da18b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -362,7 +362,7 @@
     LOCAL_CFLAGS += -DTW_USE_SERIALNO_PROPERTY_FOR_DEVICE_ID
 endif
 ifneq ($(TW_BRIGHTNESS_PATH),)
-	LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=$(TW_BRIGHTNESS_PATH)
+	LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=\"$(TW_BRIGHTNESS_PATH)\"
 endif
 ifneq ($(TW_SECONDARY_BRIGHTNESS_PATH),)
 	LOCAL_CFLAGS += -DTW_SECONDARY_BRIGHTNESS_PATH=$(TW_SECONDARY_BRIGHTNESS_PATH)
diff --git a/gui/Android.bp b/gui/Android.bp
index 2c4a33e..db982c7 100644
--- a/gui/Android.bp
+++ b/gui/Android.bp
@@ -20,7 +20,7 @@
 
 cc_library_static {
     name: "libguitwrp",
-    defaults: ["libguitwrp_defaults"],
+    defaults: ["libguitwrp_defaults", "twrp_defaults"],
     cflags: [
         "-fno-strict-aliasing", 
         "-Wno-implicit-fallthrough",
diff --git a/gui/libguitwrp_defaults.go b/gui/libguitwrp_defaults.go
index 472836e..b1e114e 100644
--- a/gui/libguitwrp_defaults.go
+++ b/gui/libguitwrp_defaults.go
@@ -273,72 +273,10 @@
 func globalFlags(ctx android.BaseContext) []string {
 	var cflags []string
 
-	if getMakeVars(ctx, "TW_DELAY_TOUCH_INIT_MS") != "" {
-		cflags = append(cflags, "-DTW_DELAY_TOUCH_INIT_MS="+getMakeVars(ctx, "TW_DELAY_TOUCH_INIT_MS"))
-	}
-
-	if getMakeVars(ctx, "TW_EVENT_LOGGING") == "true" {
-		cflags = append(cflags, "-D_EVENT_LOGGING")
-	}
-
-	if getMakeVars(ctx, "TW_USE_KEY_CODE_TOUCH_SYNC") != "" {
-		cflags = append(cflags, "DTW_USE_KEY_CODE_TOUCH_SYNC="+getMakeVars(ctx, "TW_USE_KEY_CODE_TOUCH_SYNC"))
-	}
-
-	if getMakeVars(ctx, "TW_SCREEN_BLANK_ON_BOOT") != "" {
-		cflags = append(cflags, "-DTW_SCREEN_BLANK_ON_BOOT")
-	}
-
-	if getMakeVars(ctx, "TW_OZIP_DECRYPT_KEY") != "" {
-		cflags = append(cflags, "-DTW_OZIP_DECRYPT_KEY=\""+getMakeVars(ctx, "TW_OZIP_DECRYPT_KEY")+"\"")
-	} else {
-		cflags = append(cflags, "-DTW_OZIP_DECRYPT_KEY=0")
-	}
-
-	if getMakeVars(ctx, "TW_NO_SCREEN_BLANK") != "" {
-		cflags = append(cflags, "-DTW_NO_SCREEN_BLANK")
-	}
-
-	if getMakeVars(ctx, "TW_NO_SCREEN_TIMEOUT") != "" {
-		cflags = append(cflags, "-DTW_NO_SCREEN_TIMEOUT")
-	}
-
-	if getMakeVars(ctx, "TW_OEM_BUILD") != "" {
-		cflags = append(cflags, "-DTW_OEM_BUILD")
-	}
-
-	if getMakeVars(ctx, "TW_X_OFFSET") != "" {
-		cflags = append(cflags, "-DTW_X_OFFSET="+getMakeVars(ctx, "TW_X_OFFSET"))
-	}
-
-	if getMakeVars(ctx, "TW_Y_OFFSET") != "" {
-		cflags = append(cflags, "-DTW_Y_OFFSET="+getMakeVars(ctx, "TW_Y_OFFSET"))
-	}
-
-	if getMakeVars(ctx, "TW_W_OFFSET") != "" {
-		cflags = append(cflags, "-DTW_W_OFFSET="+getMakeVars(ctx, "TW_W_OFFSET"))
-	}
-
-	if getMakeVars(ctx, "TW_H_OFFSET") != "" {
-		cflags = append(cflags, "-DTW_H_OFFSET="+getMakeVars(ctx, "TW_H_OFFSET"))
-	}
-
-        if getMakeVars(ctx, "TW_FRAMERATE") != "" {
-                cflags = append(cflags, "-DTW_FRAMERATE="+getMakeVars(ctx, "TW_FRAMERATE"))
-        }
-
-	if getMakeVars(ctx, "TW_ROUND_SCREEN") == "true" {
-		cflags = append(cflags, "-DTW_ROUND_SCREEN")
-	}
-
-	if getMakeVars(ctx, "TW_EXCLUDE_NANO") == "true" {
-		cflags = append(cflags, "-DTW_EXCLUDE_NANO")
-	}
 
 	if getMakeVars(ctx, "AB_OTA_UPDATER") == "true" {
 		cflags = append(cflags, "-DAB_OTA_UPDATER=1")
 	}
-
 	return cflags
 }
 
diff --git a/minuitwrp/Android.bp b/minuitwrp/Android.bp
index 7a56103..137e7fa 100644
--- a/minuitwrp/Android.bp
+++ b/minuitwrp/Android.bp
@@ -19,7 +19,7 @@
 
 cc_library_shared {
     name: "libminuitwrp",
-    defaults: ["libminuitwrp_defaults"],
+    defaults: ["libminuitwrp_defaults", "twrp_defaults"],
     cflags: [
         "-DTWRES=\"/twres/\""
     ],
diff --git a/minuitwrp/libminuitwrp_defaults.go b/minuitwrp/libminuitwrp_defaults.go
index a060b0a..8c738c5 100644
--- a/minuitwrp/libminuitwrp_defaults.go
+++ b/minuitwrp/libminuitwrp_defaults.go
@@ -11,68 +11,12 @@
 func globalFlags(ctx android.BaseContext) []string {
 	var cflags []string
 
-	if getMakeVars(ctx, "TW_SUPPORT_INPUT_1_2_HAPTICS") == "true" {
-		cflags = append(cflags, "-DUSE_QTI_HAPTICS")
-	}
-
-	if getMakeVars(ctx, "TW_SUPPORT_INPUT_AIDL_HAPTICS") == "true" {
-		cflags = append(cflags, "-DUSE_QTI_AIDL_HAPTICS")
-	}
-
-	if getMakeVars(ctx, "TW_SUPPORT_INPUT_AIDL_HAPTICS_FQNAME") != "" {
-		cflags = append(cflags, "-DUSE_QTI_AIDL_HAPTICS_FQNAME="+getMakeVars(ctx, "TW_SUPPORT_INPUT_AIDL_HAPTICS_FQNAME"))
-	}
-
-	if getMakeVars(ctx, "TW_SUPPORT_INPUT_AIDL_HAPTICS_FIX_OFF") == "true" {
-		cflags = append(cflags, "-DUSE_QTI_AIDL_HAPTICS_FIX_OFF")
-	}
-
-	if getMakeVars(ctx, "TW_USE_SAMSUNG_HAPTICS") == "true" {
-                cflags = append(cflags, "-DUSE_SAMSUNG_HAPTICS")
-        }
-
-	if getMakeVars(ctx, "TW_TARGET_USES_QCOM_BSP") == "true" {
-		cflags = append(cflags, "-DMSM_BSP")
-	}
-
-	if getMakeVars(ctx, "TW_NEW_ION_HEAP") == "true" {
-		cflags = append(cflags, "-DNEW_ION_HEAP")
-	}
-
 	matches, err := filepath.Glob("external/libdrm/Android.*")
 	_ = matches
 	if err == nil {
 		cflags = append(cflags, "-DHAS_DRM")
 	}
 
-	if getMakeVars(ctx, "TW_INCLUDE_JPEG") != "" {
-		cflags = append(cflags, "-DTW_INCLUDE_JPEG")
-	}
-
-	if getMakeVars(ctx, "RECOVERY_TOUCHSCREEN_SWAP_XY") == "true" {
-		cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_SWAP_XY")
-	}
-
-	if getMakeVars(ctx, "RECOVERY_TOUCHSCREEN_FLIP_X") == "true" {
-		cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_X")
-	}
-
-	if getMakeVars(ctx, "RECOVERY_TOUCHSCREEN_FLIP_Y") == "true" {
-		cflags = append(cflags, "-DRECOVERY_TOUCHSCREEN_FLIP_Y")
-	}
-
-	if getMakeVars(ctx, "RECOVERY_GRAPHICS_FORCE_USE_LINELENGTH") == "true" {
-		cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_USE_LINELENGTH")
-	}
-
-	if getMakeVars(ctx, "RECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER") == "true" {
-		cflags = append(cflags, "-DRECOVERY_GRAPHICS_FORCE_SINGLE_BUFFER")
-	}
-
-	if getMakeVars(ctx, "TWRP_EVENT_LOGGING") == "true" {
-		cflags = append(cflags, "-D_EVENT_LOGGING")
-	}
-
 	var pixelFormat = strings.Replace(getMakeVars(ctx, "TARGET_RECOVERY_FORCE_PIXEL_FORMAT"), "\"", "", -1)
 
 	switch pixelFormat {
@@ -117,20 +61,6 @@
 		break
 	}
 
-	if getMakeVars(ctx, "TARGET_RECOVERY_OVERSCAN_PERCENT") != "" {
-		cflags = append(cflags, "-DOVERSCAN_PERCENT="+getMakeVars(ctx, "TARGET_RECOVERY_OVERSCAN_PERCENT"))
-	} else {
-		cflags = append(cflags, "-DOVERSCAN_PERCENT=0")
-	}
-
-	if getMakeVars(ctx, "TW_SCREEN_BLANK_ON_BOOT") == "true" {
-		cflags = append(cflags, "-DTW_SCREEN_BLANK_ON_BOOT")
-	}
-
-	if getMakeVars(ctx, "TW_FBIOPAN") == "true" {
-		cflags = append(cflags, "-DTW_FBIOPAN")
-	}
-
 	var tw_rotation = getMakeVars(ctx, "TW_ROTATION")
 	switch tw_rotation {
 	case "0":
@@ -148,31 +78,6 @@
 			cflags = append(cflags, "-DTW_ROTATION=0")
 		}
 	}
-
-	if getMakeVars(ctx, "TW_IGNORE_MAJOR_AXIS_0") == "true" {
-		cflags = append(cflags, "-DTW_IGNORE_MAJOR_AXIS_0")
-	}
-
-	if getMakeVars(ctx, "TW_IGNORE_MT_POSITION_0") == "true" {
-		cflags = append(cflags, "-DTW_IGNORE_MT_POSITION_0")
-	}
-
-	if getMakeVars(ctx, "TW_IGNORE_ABS_MT_TRACKING_ID") == "true" {
-		cflags = append(cflags, "-DTW_IGNORE_ABS_MT_TRACKING_ID")
-	}
-
-	if getMakeVars(ctx, "TW_INPUT_BLACKLIST") != "" {
-		cflags = append(cflags, "-DTW_INPUT_BLACKLIST="+getMakeVars(ctx, "TW_INPUT_BLACKLIST"))
-	}
-
-	if getMakeVars(ctx, "TW_WHITELIST_INPUT") != "" {
-		cflags = append(cflags, "-DWHITELIST_INPUT="+getMakeVars(ctx, "TW_WHITELIST_INPUT"))
-	}
-
-	if getMakeVars(ctx, "TW_HAPTICS_TSPDRV") == "true" {
-		cflags = append(cflags, "-DTW_HAPTICS_TSPDRV")
-	}
-
 	return cflags
 }
 
diff --git a/soong/makevars.go b/soong/makevars.go
index f453ed0..acb138f 100644
--- a/soong/makevars.go
+++ b/soong/makevars.go
@@ -5,7 +5,7 @@
 )
 
 func getMakeVars(ctx android.BaseContext, mVar string) string {
-	makeVars := ctx.Config().VendorConfig("makeVarsPlugin")
+	makeVars := ctx.Config().VendorConfig("twrpVarsPlugin")
 	var makeVar = ""
 	if makeVars.IsSet(mVar) {
 		makeVar = makeVars.String(mVar)