Re-layout product makefiles by partitions.

BUG: 148693683
Test: build GSI image.
Change-Id: If02f34f83bbfbf8b3054fc552a7312f9daeea3ad
diff --git a/products/atv_base.mk b/products/atv_base.mk
index cd15f37..fc9d227 100644
--- a/products/atv_base.mk
+++ b/products/atv_base.mk
@@ -14,130 +14,8 @@
 # limitations under the License.
 #
 
-PRODUCT_IS_ATV := true
+$(call inherit-product, device/google/atv/products/atv_system.mk)
+$(call inherit-product, device/google/atv/products/atv_system_ext.mk)
+$(call inherit-product, device/google/atv/products/atv_product.mk)
+$(call inherit-product, device/google/atv/products/atv_vendor.mk)
 
-PRODUCT_PACKAGES := \
-    TvProvider \
-    TvSettings \
-    SettingsIntelligence \
-    tv_input.default
-
-ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
-PRODUCT_PACKAGES += Traceur
-endif
-
-PRODUCT_COPY_FILES := \
-    device/google/atv/permissions/tv_core_hardware.xml:system/etc/permissions/tv_core_hardware.xml
-
-DEVICE_PACKAGE_OVERLAYS := \
-    device/google/atv/overlay
-
-# From build/target/product/core_base.mk
-PRODUCT_PACKAGES += \
-    UserDictionaryProvider \
-    libkeystore \
-
-# From build/target/product/core.mk
-PRODUCT_PACKAGES += \
-    BasicDreams \
-    CalendarProvider \
-    CaptivePortalLogin \
-    CertInstaller \
-    ExternalStorageProvider \
-    FusedLocation \
-    InputDevices \
-    KeyChain \
-    PacProcessor \
-    PrintSpooler \
-    ProxyHandler \
-    SharedStorageBackup \
-    VpnDialogs \
-    com.android.media.tv.remoteprovider \
-    PackageInstaller
-
-# From build/target/product/generic_no_telephony.mk
-PRODUCT_PACKAGES += \
-    Bluetooth \
-    SystemUI \
-    librs_jni \
-    audio.primary.default \
-    clatd \
-    clatd.conf \
-    local_time.default \
-    screenrecord
-
-# Media tuner jni
-PRODUCT_PACKAGES += libmedia_tv_tuner
-
-# PRODUCT_SUPPORTS_CAMERA: Whether the product supports cameras at all
-# (built-in or external USB camera). When 'false', we drop cameraserver, which
-# saves ~3 MiB of RAM. When 'true', additional settings are required for
-# external webcams to work, see "External USB Cameras" documentation.
-#
-# Defaults to true to mimic legacy behaviour.
-PRODUCT_SUPPORTS_CAMERA ?= true
-ifeq ($(PRODUCT_SUPPORTS_CAMERA),true)
-    PRODUCT_PACKAGES += cameraserver
-else
-    # When cameraserver is not included, we need to configure Camera API to not
-    # connect to it.
-    PRODUCT_PROPERTY_OVERRIDES += config.disable_cameraservice=true
-endif
-
-PRODUCT_COPY_FILES += \
-    frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
-
-# Enable frame-exact AV sync
-PRODUCT_PROPERTY_OVERRIDES += \
-    persist.sys.media.avsync=true
-
-
-# SDK builds needs to build layoutlib-legacy that depends on debug info
-ifneq ($(PRODUCT_IS_ATV_SDK),true)
-    # Strip the local variable table and the local variable type table to reduce
-    # the size of the system image. This has no bearing on stack traces, but will
-    # leave less information available via JDWP.
-    # From //build/make/target/product/go_defaults_common.mk
-    PRODUCT_MINIMIZE_JAVA_DEBUG_INFO := true
-
-    # Do not generate libartd.
-    # From //build/make/target/product/go_defaults_common.mk
-    PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD := false
-endif
-
-
-# Do not include the Live Channels app if USE_OEM_TV_APP flag is set.
-# The feature com.google.android.tv.installed is used to tell whether a device
-# has the pre-installed Live Channels app. This is necessary for the Play Store
-# to identify the compatible devices that can install later updates of the app.
-ifneq ($(USE_OEM_TV_APP),true)
-    ifneq ($(PRODUCT_IS_ATV_SDK),true)
-        PRODUCT_PACKAGES += TV
-    else
-        PRODUCT_PACKAGES += LiveTv
-    endif # if PRODUCT_IS_ATV_SDK
-
-    PRODUCT_COPY_FILES += \
-        device/google/atv/permissions/com.google.android.tv.installed.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/com.google.android.tv.installed.xml
-endif
-
-# To enable access to /dev/dvb*
-BOARD_SEPOLICY_DIRS += device/google/atv/sepolicy
-
-
-# Copy .kl file for generic voice remotes
-PRODUCT_COPY_FILES += \
-    device/google/atv/Generic.kl:system/usr/keylayout/Generic.kl
-
-$(call inherit-product-if-exists, frameworks/base/data/sounds/AudioTv.mk)
-$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
-$(call inherit-product-if-exists, external/google-fonts/dancing-script/fonts.mk)
-$(call inherit-product-if-exists, external/google-fonts/carrois-gothic-sc/fonts.mk)
-$(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
-$(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
-$(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
-$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
-$(call inherit-product-if-exists, external/hyphenation-patterns/patterns.mk)
-$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
-$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/product/core_minimal.mk)
diff --git a/products/atv_product.mk b/products/atv_product.mk
new file mode 100644
index 0000000..7e61f51
--- /dev/null
+++ b/products/atv_product.mk
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This makefile contains the product partition contents for
+# a generic TV device.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_product.mk)
+
+PRODUCT_PACKAGES += \
+    SettingsIntelligence \
+    SystemUI \
+    TvSettings
+
+# Do not include the Live Channels app if USE_OEM_TV_APP flag is set.
+# The feature com.google.android.tv.installed is used to tell whether a device
+# has the pre-installed Live Channels app. This is necessary for the Play Store
+# to identify the compatible devices that can install later updates of the app.
+ifneq ($(USE_OEM_TV_APP),true)
+    ifneq ($(PRODUCT_IS_ATV_SDK),true)
+        PRODUCT_PACKAGES += TV
+    else
+        PRODUCT_PACKAGES += LiveTv
+    endif # if PRODUCT_IS_ATV_SDK
+
+    PRODUCT_COPY_FILES += \
+        device/google/atv/permissions/com.google.android.tv.installed.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/com.google.android.tv.installed.xml
+endif
diff --git a/products/atv_system.mk b/products/atv_system.mk
new file mode 100644
index 0000000..237e493
--- /dev/null
+++ b/products/atv_system.mk
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This makefile contains the system partition contents for
+# a generic TV device.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_system.mk)
+
+$(call inherit-product-if-exists, frameworks/base/data/sounds/AudioTv.mk)
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/dancing-script/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/carrois-gothic-sc/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
+$(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/hyphenation-patterns/patterns.mk)
+$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
+$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
+
+PRODUCT_IS_ATV := true
+
+PRODUCT_PACKAGES += \
+    TvProvider
+
+# Media tuner jni
+PRODUCT_PACKAGES += \
+    libmedia_tv_tuner
+
+# From build/target/product/core.mk
+PRODUCT_PACKAGES += \
+    BasicDreams \
+    Bluetooth \
+    CalendarProvider \
+    CaptivePortalLogin \
+    CertInstaller \
+    clatd \
+    clatd.conf \
+    ExternalStorageProvider \
+    FusedLocation \
+    InputDevices \
+    KeyChain \
+    librs_jni \
+    PacProcessor \
+    PrintSpooler \
+    ProxyHandler \
+    SharedStorageBackup \
+    screenrecord \
+    UserDictionaryProvider \
+    VpnDialogs \
+    com.android.media.tv.remoteprovider
+
+# Traceur for debug only
+PRODUCT_PACKAGES_DEBUG += \
+    Traceur
+
+# PRODUCT_SUPPORTS_CAMERA: Whether the product supports cameras at all
+# (built-in or external USB camera). When 'false', we drop cameraserver, which
+# saves ~3 MiB of RAM. When 'true', additional settings are required for
+# external webcams to work, see "External USB Cameras" documentation.
+#
+# Defaults to true to mimic legacy behaviour.
+PRODUCT_SUPPORTS_CAMERA ?= true
+ifeq ($(PRODUCT_SUPPORTS_CAMERA),true)
+    PRODUCT_PACKAGES += cameraserver
+else
+    # When cameraserver is not included, we need to configure Camera API to not
+    # connect to it.
+    PRODUCT_PROPERTY_OVERRIDES += config.disable_cameraservice=true
+endif
+
+# SDK builds needs to build layoutlib-legacy that depends on debug info
+ifneq ($(PRODUCT_IS_ATV_SDK),true)
+    # Strip the local variable table and the local variable type table to reduce
+    # the size of the system image. This has no bearing on stack traces, but will
+    # leave less information available via JDWP.
+    # From //build/make/target/product/go_defaults_common.mk
+    PRODUCT_MINIMIZE_JAVA_DEBUG_INFO := true
+
+    # Do not generate libartd.
+    # From //build/make/target/product/go_defaults_common.mk
+    PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD := false
+endif
+
+DEVICE_PACKAGE_OVERLAYS += \
+    device/google/atv/overlay
+
+# Enable frame-exact AV sync
+PRODUCT_PROPERTY_OVERRIDES += \
+    persist.sys.media.avsync=true
+
+# Copy .kl file for generic voice remotes
+PRODUCT_COPY_FILES += \
+    device/google/atv/Generic.kl:system/usr/keylayout/Generic.kl
+
+PRODUCT_COPY_FILES += \
+    device/google/atv/permissions/tv_core_hardware.xml:system/etc/permissions/tv_core_hardware.xml
+
+PRODUCT_COPY_FILES += \
+    frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
diff --git a/products/atv_system_ext.mk b/products/atv_system_ext.mk
new file mode 100644
index 0000000..c476a8c
--- /dev/null
+++ b/products/atv_system_ext.mk
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This makefile contains the system_ext partition contents for
+# a generic TV device.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_system_ext.mk)
diff --git a/products/atv_vendor.mk b/products/atv_vendor.mk
new file mode 100644
index 0000000..b2f2ca5
--- /dev/null
+++ b/products/atv_vendor.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This makefile contains the vendor partition contents for
+# a generic TV device.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/media_vendor.mk)
+
+PRODUCT_PACKAGES += \
+    tv_input.default
+
+PRODUCT_PACKAGES += \
+    audio.primary.default \
+    local_time.default
+
+# To enable access to /dev/dvb*
+BOARD_SEPOLICY_DIRS += device/google/atv/sepolicy