Merge "Refactor hiddenapi rules to share common code"
diff --git a/core/definitions.mk b/core/definitions.mk
index b8ab84d..02fc77a 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -660,7 +660,8 @@
 ###########################################################
 
 define module-stubs-files
-$(foreach module,$(1),$(ALL_MODULES.$(module).STUBS))
+$(foreach module,$(1),$(if $(filter $(module),$(JAVA_SDK_LIBRARIES)),\
+$(call java-lib-files,$(module).stubs),$(ALL_MODULES.$(module).STUBS)))
 endef
 
 ###########################################################
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 355f414..f75e263 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -124,6 +124,8 @@
 $(call add_json_bool, Malloc_not_svelte,                 $(call invert_bool,$(filter true,$(MALLOC_SVELTE))))
 $(call add_json_str,  Override_rs_driver,                $(OVERRIDE_RS_DRIVER))
 
+$(call add_json_bool, Product_is_iot,                    $(filter true,$(PRODUCT_IOT)))
+
 $(call add_json_bool, Treble_linker_namespaces,          $(filter true,$(PRODUCT_TREBLE_LINKER_NAMESPACES)))
 $(call add_json_bool, Enforce_vintf_manifest,            $(filter true,$(PRODUCT_ENFORCE_VINTF_MANIFEST)))
 
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 812b7e4..0bc0c32 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -41,6 +41,7 @@
 TARGET_BOOTLOADER_BOARD_NAME := goldfish_$(TARGET_ARCH)
 
 TARGET_USES_64_BIT_BINDER := true
+TARGET_USES_MKE2FS := true
 
 # no hardware camera
 USE_CAMERA_STUB := true
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 4f6a10c..c861770 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -57,6 +57,7 @@
 
 
 TARGET_USES_64_BIT_BINDER := true
+TARGET_USES_MKE2FS := true
 
 # no hardware camera
 USE_CAMERA_STUB := true
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index f50a84c..64d942a 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -15,6 +15,7 @@
 #emulator now uses 64bit kernel to run 32bit x86 image
 #
 TARGET_USES_64_BIT_BINDER := true
+TARGET_USES_MKE2FS := true
 
 # The IA emulator (qemu) uses the Goldfish devices
 HAVE_HTC_AUDIO_DRIVER := true
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
index fa9f5ec..7a49f09 100755
--- a/target/board/generic_x86_64/BoardConfig.mk
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -17,6 +17,7 @@
 TARGET_2ND_ARCH_VARIANT := x86_64
 
 TARGET_USES_64_BIT_BINDER := true
+TARGET_USES_MKE2FS := true
 
 # The IA emulator (qemu) uses the Goldfish devices
 HAVE_HTC_AUDIO_DRIVER := true
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 4c0b932..480b395 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -60,6 +60,8 @@
     $(LOCAL_DIR)/full_x86.mk \
     $(LOCAL_DIR)/generic.mk \
     $(LOCAL_DIR)/generic_x86.mk \
+    $(LOCAL_DIR)/mainline_arm64.mk \
+    $(LOCAL_DIR)/mainline_system_arm64.mk \
     $(LOCAL_DIR)/sdk_arm64.mk \
     $(LOCAL_DIR)/sdk.mk \
     $(LOCAL_DIR)/sdk_phone_arm64.mk \
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 9db5d43..a94eeca 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -20,7 +20,6 @@
     95-configured \
     adb \
     adbd \
-    adbd.recovery \
     am \
     android.hidl.allocator@1.0-service \
     android.hidl.base-V1.0-java \
@@ -95,7 +94,6 @@
     ip-up-vpn \
     javax.obex \
     keystore \
-    ld.config.recovery.txt \
     ld.config.txt \
     ld.mc \
     libaaudio \
@@ -186,7 +184,6 @@
     libwifi-service \
     libwilhelm \
     linker \
-    linker.recovery \
     lmkd \
     locksettings \
     logcat \
@@ -215,7 +212,6 @@
     pppd \
     privapp-permissions-platform.xml \
     racoon \
-    recovery \
     resize2fs \
     run-as \
     schedtest \
@@ -231,7 +227,6 @@
     SettingsProvider \
     sgdisk \
     Shell \
-    shell_and_utilities_recovery \
     shell_and_utilities_system \
     sm \
     storaged \
@@ -285,6 +280,8 @@
     logpersist.start \
     micro_bench \
     perfprofd \
+    procrank \
+    showmap \
     sqlite3 \
     strace
 
diff --git a/target/product/base_vendor.mk b/target/product/base_vendor.mk
index 4596cb6..678b60a 100644
--- a/target/product/base_vendor.mk
+++ b/target/product/base_vendor.mk
@@ -14,6 +14,14 @@
 # limitations under the License.
 #
 
+# Base modules and settings for recovery.
+PRODUCT_PACKAGES += \
+    adbd.recovery \
+    ld.config.recovery.txt \
+    linker.recovery \
+    recovery \
+    shell_and_utilities_recovery \
+
 # Base modules and settings for the vendor partition.
 PRODUCT_PACKAGES += \
     android.hardware.cas@1.0-service \
diff --git a/target/product/mainline_arm64.mk b/target/product/mainline_arm64.mk
new file mode 100644
index 0000000..bcebe61
--- /dev/null
+++ b/target/product/mainline_arm64.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2018 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.
+#
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/base_vendor.mk)
+
+PRODUCT_NAME := mainline_arm64
+PRODUCT_DEVICE := generic_arm64
+PRODUCT_BRAND := generic
+PRODUCT_SHIPPING_API_LEVEL := 28
+
+PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS := true
+PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST := system/etc/seccomp_policy/mediacodec.policy
diff --git a/target/product/mainline_system.mk b/target/product/mainline_system.mk
new file mode 100644
index 0000000..96365b5
--- /dev/null
+++ b/target/product/mainline_system.mk
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2018 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.
+#
+
+# TODO(hansson): change inheritance to core_minimal, then generic_no_telephony
+$(call inherit-product, $(SRC_TARGET_DIR)/product/base_system.mk)
+
+PRODUCT_NAME := mainline_system
+PRODUCT_BRAND := generic
+PRODUCT_SHIPPING_API_LEVEL := 28
+
+_selinux_policy_whitelist := \
+  vendor/etc/selinux/vndservice_contexts \
+  vendor/etc/selinux/plat_pub_versioned.cil \
+  vendor/etc/selinux/plat_sepolicy_vers.txt \
+  vendor/etc/selinux/precompiled_sepolicy \
+  vendor/etc/selinux/precompiled_sepolicy.plat_and_mapping.sha256 \
+  vendor/etc/selinux/vendor_file_contexts \
+  vendor/etc/selinux/vendor_hwservice_contexts \
+  vendor/etc/selinux/vendor_mac_permissions.xml \
+  vendor/etc/selinux/vendor_property_contexts \
+  vendor/etc/selinux/vendor_seapp_contexts \
+  vendor/etc/selinux/vendor_sepolicy.cil \
+
+_base_mk_whitelist := \
+  $(_selinux_policy_whitelist) \
+  recovery/root/etc/mke2fs.conf \
+  root/init \
+  root/init.environ.rc \
+  root/init.rc \
+  root/init.usb.configfs.rc \
+  root/init.usb.rc \
+  root/init.zygote32.rc \
+  root/sbin/charger \
+  root/ueventd.rc \
+  vendor/lib/mediadrm/libdrmclearkeyplugin.so \
+  vendor/lib64/mediadrm/libdrmclearkeyplugin.so \
+
+_my_whitelist := $(_base_mk_whitelist)
+
+$(call require-artifacts-in-path, $(TARGET_COPY_OUT_SYSTEM), $(_my_whitelist))
diff --git a/target/product/mainline_system_arm64.mk b/target/product/mainline_system_arm64.mk
new file mode 100644
index 0000000..b080f43
--- /dev/null
+++ b/target/product/mainline_system_arm64.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2018 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.
+#
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk)
+
+PRODUCT_NAME := mainline_system_arm64
+PRODUCT_DEVICE := generic_arm64
+PRODUCT_BRAND := generic
+PRODUCT_SHIPPING_API_LEVEL := 28