# Vanta product layer. Reached through vendor/extra/product.mk, which
# vendor/lineage/config/common.mk inherits FIRST ("Allow vendor/extra to
# override any property by setting it first"). Nothing in vendor/lineage is
# patched; where Lineage installs a user-visible file of its own, Vanta either
# feeds it through the hook Lineage provides (boot animation), overrides the
# module under a different install path (setup wizard, updater), or — where the
# path is the point — rewrites the source Lineage's own module installs
# (fonts_customization.xml, tools/fonts.sh; recovery art, tools/recovery.sh).

VANTA_VERSION := 0.1
VANTA_WITH_BRIDGE ?= false
VANTA_WITH_HALO ?= false
# Set from devices/<device>.env by the build scripts (b5q: true).
VANTA_FOLDABLE ?= false
VANTA_DEVICE ?= unknown
# Google apps (MindTheGapps, vendor/gapps from the device manifest). Set by devices/*.env.
VANTA_GAPPS ?= false

PRODUCT_SOONG_NAMESPACES += vendor/vanta

# Lineage installs its boot animation to /product/media, which bootanimation
# reads before /system/media, so a PRODUCT_COPY_FILES to system would silently
# lose. Its genrule takes a prebuilt instead of rendering its own when this
# soong config var is set.
$(call soong_config_set,lineage_bootanimation,prebuilt_file,vendor/vanta/prebuilt/bootanimation.zip)

# Shows up in ro.lineage.version, which Settings and recovery print:
# 24.0-<date>-UNOFFICIAL-Vanta0.1-<device>.
TARGET_UNOFFICIAL_BUILD_ID := Vanta$(VANTA_VERSION)

PRODUCT_PACKAGES += \
    VantaFrameworkOverlay \
    VantaSettingsProviderOverlay \
    VantaSetup

# Overlays (resources generated from design/tokens.json by tools/gen_overlays.py).
PRODUCT_PACKAGES += \
    VantaRailOnly \
    VantaSystemUIOverlay \
    VantaSettingsOverlay \
    VantaLauncher3Overlay \
    VantaAuroraDefaultOverlay \
    VantaBrandPlatformOverlay \
    VantaBrandPartsOverlay

# IBM Plex Sans: the files and the overlay the theme JSON enables. The named
# family rides in Lineage's own fonts_customization.xml (tools/fonts.sh).
PRODUCT_PACKAGES += \
    IBMPlexSans-VF.ttf \
    IBMPlexSans-Italic-VF.ttf \
    FontIBMPlexSansOverlay

# Apps. Their privapp / default-permissions / preferred-apps prebuilt_etc
# modules come in through each app's `required:`.
PRODUCT_PACKAGES += \
    VantaHub \
    VantaHome \
    VantaVoice \
    VantaEdge \
    VantaGuard \
    VantaArena \
    VantaAurora \
    VantaWelcome

$(call inherit-product, vendor/vanta/tones/tones.mk)

PRODUCT_PACKAGES += VantaRolesOverlay

# Google services: Play Store, Play services, Services Framework, sync adapters,
# Restore. Google's SetupWizard is overridden by VantaWelcome, which signs in to
# Google itself and turns Play Protect's install checks off.
ifeq ($(VANTA_GAPPS),true)
ifeq ($(wildcard vendor/gapps/arm64/arm64-vendor.mk),)
$(error VANTA_GAPPS=true but vendor/gapps is not synced (the device manifest carries MindTheGapps))
endif
$(call inherit-product, vendor/gapps/arm64/arm64-vendor.mk)
endif

# Optional prebuilts: tools/stage.sh stages the APK and declares its module
# only when the matching flag is on, so both sides must agree.
ifeq ($(VANTA_WITH_BRIDGE),true)
ifeq ($(wildcard vendor/vanta/prebuilt/s10-bridge.apk),)
$(error VANTA_WITH_BRIDGE=true but vendor/vanta/prebuilt/s10-bridge.apk is not staged (run tools/stage.sh with the same flag))
endif
PRODUCT_PACKAGES += S10Bridge
endif

ifeq ($(VANTA_WITH_HALO),true)
ifeq ($(wildcard vendor/vanta/prebuilt/ZodroidHalo.apk),)
$(error VANTA_WITH_HALO=true but vendor/vanta/prebuilt/ZodroidHalo.apk is not staged (run tools/stage.sh with the same flag))
endif
PRODUCT_PACKAGES += ZodroidHalo
endif

PRODUCT_PRODUCT_PROPERTIES += \
    ro.vanta.version=$(VANTA_VERSION) \
    ro.vanta.bridge=$(VANTA_WITH_BRIDGE) \
    ro.vanta.halo=$(VANTA_WITH_HALO) \
    ro.vanta.foldable=$(VANTA_FOLDABLE) \
    ro.vanta.device=$(VANTA_DEVICE) \
    ro.vanta.gapps=$(VANTA_GAPPS)
