Merge "Multilib support for odex"
diff --git a/core/config.mk b/core/config.mk
index 1c2db34..b91ff7f 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -524,6 +524,8 @@
   TARGET_DEFAULT_JAVA_LIBRARIES := core core-junit ext framework framework2
 endif
 
+TARGET_CPU_SMP ?= true
+
 # Flags for DEX2OAT
 DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
 DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT)
diff --git a/core/multilib.mk b/core/multilib.mk
index f630c94..a3ced65 100644
--- a/core/multilib.mk
+++ b/core/multilib.mk
@@ -1,4 +1,4 @@
-# Translate LOCAL_32_BIT_ONLY and LOCAL_NO_2ND_ARCH to LOCAL_MULTILIB,
+# Translate LOCAL_32_BIT_ONLY to LOCAL_MULTILIB,
 # and check LOCAL_MULTILIB is a valid value.  Returns module's multilib
 # setting in my_module_multilib, or empty if not set.
 
diff --git a/core/package.mk b/core/package.mk
index 0861a79..78b65db 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -1,6 +1,5 @@
 # We don't automatically set up rules to build packages for both
 # TARGET_ARCH and TARGET_2ND_ARCH.
-# By default, an package is built for TARGET_ARCH.
 # To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32".
 
 my_prefix := TARGET_
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index c280900..33f5dc6 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -14,26 +14,36 @@
 
 include $(BUILD_SYSTEM)/multilib.mk
 
-ifndef my_module_multilib
-# prebuilts default to building for either architecture,
-# the first if its supported, otherwise the second.
-my_module_multilib := both
-endif
+my_skip_non_preferred_arch :=
 
 # check if first arch is supported
 include $(BUILD_SYSTEM)/module_arch_supported.mk
 ifeq ($(my_module_arch_supported),true)
 # first arch is supported
 include $(BUILD_SYSTEM)/prebuilt_internal.mk
-else ifneq (,$($(my_prefix)2ND_ARCH))
+ifneq ($(my_module_multilib),both)
+my_skip_non_preferred_arch := true
+endif # $(my_module_multilib)
+endif # $(my_module_arch_supported)
+
+ifndef my_skip_non_preferred_arch
+ifneq (,$($(my_prefix)2ND_ARCH))
 # check if secondary arch is supported
 LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX)
 include $(BUILD_SYSTEM)/module_arch_supported.mk
 ifeq ($(my_module_arch_supported),true)
 # secondary arch is supported
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_MODULE_STEM :=
+LOCAL_BUILT_MODULE_STEM :=
+LOCAL_INSTALLED_MODULE_STEM :=
+LOCAL_INTERMEDIATE_TARGETS :=
 include $(BUILD_SYSTEM)/prebuilt_internal.mk
-endif
-endif # $(my_prefix)2ND_ARCH
+endif # $(my_module_arch_supported)
+endif # $($(my_prefix)2ND_ARCH)
+endif # $(my_skip_non_preferred_arch) not true
 
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 2445d0d..fcd3e55 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -19,13 +19,19 @@
 # Not much sense to check build prebuilts
 LOCAL_DONT_CHECK_MODULE := true
 
+my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
+
 ifdef LOCAL_PREBUILT_MODULE_FILE
   my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
 else
   ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
     my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
   else
-    my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
+    ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
+      my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
+    else
+      my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
+    endif
   endif
 endif
 
diff --git a/envsetup.sh b/envsetup.sh
index d026466..e4e2ece 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -186,7 +186,7 @@
             ;;
     esac
     if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
-        ANDROID_BUILD_PATHS=$ANDROID_EMULATOR_PREBUILTS:$ANDROID_BUILD_PATHS
+        ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ANDROID_EMULATOR_PREBUILTS
         export ANDROID_EMULATOR_PREBUILTS
     fi
 
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index c30cc75..6d58b1c 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -78,6 +78,7 @@
 BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
 BOARD_SEPOLICY_UNION += \
         adbd.te \
+        app.te \
         bootanim.te \
         device.te \
         domain.te \
@@ -88,4 +89,5 @@
         rild.te \
         shell.te \
         surfaceflinger.te \
-        system_server.te
+        system_server.te \
+        zygote.te
diff --git a/target/board/generic/sepolicy/app.te b/target/board/generic/sepolicy/app.te
new file mode 100644
index 0000000..fd33453
--- /dev/null
+++ b/target/board/generic/sepolicy/app.te
@@ -0,0 +1 @@
+allow appdomain qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/bootanim.te b/target/board/generic/sepolicy/bootanim.te
index d6506e1..a5a84f9 100644
--- a/target/board/generic/sepolicy/bootanim.te
+++ b/target/board/generic/sepolicy/bootanim.te
@@ -1,2 +1,3 @@
 allow bootanim self:process execmem;
 allow bootanim ashmem_device:chr_file execute;
+allow bootanim qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/surfaceflinger.te b/target/board/generic/sepolicy/surfaceflinger.te
index 4c35469..6712789 100644
--- a/target/board/generic/sepolicy/surfaceflinger.te
+++ b/target/board/generic/sepolicy/surfaceflinger.te
@@ -1,2 +1,3 @@
 allow surfaceflinger self:process execmem;
 allow surfaceflinger ashmem_device:chr_file execute;
+allow surfaceflinger qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/zygote.te b/target/board/generic/sepolicy/zygote.te
new file mode 100644
index 0000000..a5da574
--- /dev/null
+++ b/target/board/generic/sepolicy/zygote.te
@@ -0,0 +1 @@
+allow zygote qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 9d3bcc0..7f8f3dc 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -48,7 +48,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 576716800
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 681574400
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index faf8600..727d3db 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -44,7 +44,9 @@
 
 BOARD_SEPOLICY_DIRS += build/target/board/generic_x86/sepolicy
 BOARD_SEPOLICY_UNION += \
+        app.te \
         adbd.te \
+        bootanim.te \
         device.te \
         domain.te \
         file.te \
@@ -55,5 +57,6 @@
         qemud.te \
         rild.te \
         shell.te \
+        surfaceflinger.te \
         system_server.te \
         zygote.te
diff --git a/target/board/generic_x86/sepolicy/app.te b/target/board/generic_x86/sepolicy/app.te
new file mode 100644
index 0000000..fd33453
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/app.te
@@ -0,0 +1 @@
+allow appdomain qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/bootanim.te b/target/board/generic_x86/sepolicy/bootanim.te
new file mode 100644
index 0000000..762a573
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/bootanim.te
@@ -0,0 +1 @@
+allow bootanim qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/surfaceflinger.te b/target/board/generic_x86/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000..865405c
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/surfaceflinger.te
@@ -0,0 +1 @@
+allow surfaceflinger qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/zygote.te b/target/board/generic_x86/sepolicy/zygote.te
index 93993a4..d34c4a1 100644
--- a/target/board/generic_x86/sepolicy/zygote.te
+++ b/target/board/generic_x86/sepolicy/zygote.te
@@ -1,2 +1,3 @@
 allow zygote self:process execmem;
 allow zygote self:capability sys_nice;
+allow zygote qemu_device:chr_file rw_file_perms;