{% include 'LICENSE.jinja2' %}

{% if device_info.device_uses_updatable_apex %}
# Enable updating of APEXes
$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk)

{% endif %}
{% if device_info.device_is_ab %}
# A/B
{% if device_info.device_uses_virtual_ab %}
$(call inherit-product, $(SRC_TARGET_DIR)/product/virtual_ab_ota.mk)

{% endif %}
PRODUCT_PACKAGES += \
    android.hardware.boot@1.2-impl \
    android.hardware.boot@1.2-impl.recovery \
    android.hardware.boot@1.2-service

PRODUCT_PACKAGES += \
    update_engine \
    update_engine_sideload \
    update_verifier

{% if partitions.system.fstab_entry and partitions.system.fstab_entry.is_slotselect() %}
AB_OTA_POSTINSTALL_CONFIG += \
    RUN_POSTINSTALL_system=true \
    POSTINSTALL_PATH_system=system/bin/otapreopt_script \
    FILESYSTEM_TYPE_system={{ partitions.system.fstab_entry.fs_type }} \
    POSTINSTALL_OPTIONAL_system=true

{% endif %}
{% if partitions.vendor.fstab_entry and partitions.vendor.fstab_entry.is_slotselect() %}
AB_OTA_POSTINSTALL_CONFIG += \
    RUN_POSTINSTALL_vendor=true \
    POSTINSTALL_PATH_vendor=bin/checkpoint_gc \
    FILESYSTEM_TYPE_vendor={{ partitions.vendor.fstab_entry.fs_type }} \
    POSTINSTALL_OPTIONAL_vendor=true

{% endif %}
PRODUCT_PACKAGES += \
    checkpoint_gc \
    otapreopt_script

{% endif %}
{% if device_info.board_api_level
      or device_info.board_shipping_api_level
      or device_info.first_api_level %}
# API levels
{% if device_info.board_shipping_api_level %}
BOARD_SHIPPING_API_LEVEL := {{ device_info.board_shipping_api_level }}
{% endif %}
{% if device_info.board_api_level %}
BOARD_API_LEVEL := {{ device_info.board_api_level }}
{% endif %}
{% if device_info.first_api_level %}
PRODUCT_SHIPPING_API_LEVEL := {{ device_info.first_api_level }}
{% endif %}

{% endif %}
{% if device_info.device_uses_dynamic_partitions %}
# fastbootd
PRODUCT_PACKAGES += \
    android.hardware.fastboot@1.1-impl-mock \
    fastbootd

{% endif %}
# Health
PRODUCT_PACKAGES += \
    android.hardware.health@2.1-impl \
{% if not device_info.device_is_ab %}
    android.hardware.health@2.1-impl.recovery \
{% endif %}
    android.hardware.health@2.1-service

# Overlays
PRODUCT_ENFORCE_RRO_TARGETS := *

{% if device_info.device_uses_dynamic_partitions %}
# Partitions
PRODUCT_USE_DYNAMIC_PARTITIONS := true

{% endif %}
{% if device_info.product_characteristics %}
# Product characteristics
PRODUCT_CHARACTERISTICS := {{ device_info.product_characteristics }}

{% endif %}
# Rootdir
PRODUCT_PACKAGES += \{{ '\n' }}
{%- for file in rootdir_bin_files %}
    {{ file.name }} \
{% endfor %}

PRODUCT_PACKAGES += \
    {{ fstab.fstab.name }} \{{ '\n' }}
{%- for file in rootdir_etc_files %}
    {{ file.name }} \
{% endfor %}
{%- for file in rootdir_recovery_etc_files %}
    {{ file.name }} \
{% endfor %}

{% if device_info.device_uses_dynamic_partitions %}
PRODUCT_COPY_FILES += \
{% if device_info.device_uses_virtual_ab %}
    $(LOCAL_PATH)/rootdir/etc/{{ fstab.fstab.name }}:$(TARGET_VENDOR_RAMDISK_OUT)/first_stage_ramdisk/{{ fstab.fstab.name }}
{% else %}
    $(LOCAL_PATH)/rootdir/etc/{{ fstab.fstab.name }}:$(TARGET_COPY_OUT_RAMDISK)/{{ fstab.fstab.name }}
{% endif %}

{% endif %}
# Soong namespaces
PRODUCT_SOONG_NAMESPACES += \
    $(LOCAL_PATH)

# Inherit the proprietary files
$(call inherit-product, vendor/{{ device_info.manufacturer }}/{{ device_info.codename }}/{{ device_info.codename }}-vendor.mk)

