Remove ELF PRODUCT_COPY_FILES

We're banning ELF prebuilts in PRODUCT_COPY_FILES. Define prebuilt
modules for vendor prebuilts so we can run check_elf_file.py on them.
Use PRODUCT_PACKAGES to install ELF prebuilts.

Bug: 140560012
Test: Build pass. Built artifacts should not change.
Test: m SELINUX_IGNORE_NEVERALLOWS=true
Change-Id: Ia598bc241ba0c3d2a651662d4dd337a3023b149d
diff --git a/device.mk b/device.mk
index f9e5589..e203f7b 100644
--- a/device.mk
+++ b/device.mk
@@ -1,3 +1,5 @@
+PRODUCT_SOONG_NAMESPACES += device/linaro/poplar/proprietary
+
 # 1. bootimage
 # 1.1 kernel and dtb
 LOCAL_KERNEL := device/linaro/poplar-kernel/Image
@@ -83,13 +85,13 @@
     android.hardware.graphics.composer@2.1-impl \
     android.hardware.graphics.composer@2.1-service
 ## copy packages
-PRODUCT_COPY_FILES += \
-    $(LOCAL_PATH)/proprietary/hisilicon/libGLES_mali.so:$(TARGET_COPY_OUT_VENDOR)/lib/egl/libGLES_mali.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/hwcomposer.poplar.so:$(TARGET_COPY_OUT_VENDOR)/lib/hw/hwcomposer.poplar.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhi_gfx2d.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhi_gfx2d.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/overlay.poplar.so:$(TARGET_COPY_OUT_VENDOR)/lib/hw/overlay.poplar.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/gralloc.poplar.so:$(TARGET_COPY_OUT_VENDOR)/lib/hw/gralloc.poplar.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libion_ext.so:$(TARGET_COPY_OUT_VENDOR)/lib/libion_ext.so
+PRODUCT_PACKAGES += \
+    libGLES_mali \
+    hwcomposer.poplar \
+    libhi_gfx2d \
+    overlay.poplar \
+    gralloc.poplar \
+    libion_ext
 
 # Property required by HiSilicon gralloc
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -105,17 +107,17 @@
 
 # start HAL media.codec >>>>>>>>
 ## copy packages
-PRODUCT_COPY_FILES += \
-    $(LOCAL_PATH)/proprietary/hisilicon/libstagefrighthw.so:$(TARGET_COPY_OUT_VENDOR)/lib/libstagefrighthw.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhi_common.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhi_common.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhi_msp.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhi_msp.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhi_vfmw.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhi_vfmw.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libOMX_Core.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX_Core.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libOMX.hisi.video.decoder.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX.hisi.video.decoder.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhiavplayer.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhiavplayer.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhiavplayer_adp.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhiavplayer_adp.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/libhiavplayerservice.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhiavplayerservice.so \
-    $(LOCAL_PATH)/proprietary/hisilicon/hiavplayer:$(TARGET_COPY_OUT_VENDOR)/bin/hiavplayer
+PRODUCT_PACKAGES += \
+    libstagefrighthw \
+    libhi_common \
+    libhi_msp \
+    libhi_vfmw \
+    libOMX_Core \
+    libOMX.hisi.video.decoder \
+    libhiavplayer \
+    libhiavplayer_adp \
+    libhiavplayerservice \
+    hiavplayer
 ## service init.rc scripts
 PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/vendor/hiavplayer.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hiavplayer.rc
@@ -137,8 +139,8 @@
     android.hardware.bluetooth@1.0-service.rc \
     android.hardware.bluetooth@1.0-impl
 ## copy packages
-PRODUCT_COPY_FILES += \
-    $(LOCAL_PATH)/proprietary/bt-wifi/libbt-vendor.so:$(TARGET_COPY_OUT_VENDOR)/lib/libbt-vendor.so
+PRODUCT_PACKAGES += \
+    libbt-vendor
 ## config files
 PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/bluetooth/rtkbt.conf:$(TARGET_COPY_OUT_VENDOR)/etc/bluetooth/rtkbt.conf
diff --git a/proprietary/Android.bp b/proprietary/Android.bp
new file mode 100644
index 0000000..a90bdbc
--- /dev/null
+++ b/proprietary/Android.bp
@@ -0,0 +1,16 @@
+// 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.
+
+soong_namespace {
+}
diff --git a/proprietary/bt-wifi/Android.bp b/proprietary/bt-wifi/Android.bp
new file mode 100644
index 0000000..4b4e5dd
--- /dev/null
+++ b/proprietary/bt-wifi/Android.bp
@@ -0,0 +1,31 @@
+// 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.
+
+cc_prebuilt_library_shared {
+    name: "libbt-vendor",
+    srcs: ["libbt-vendor.so"],
+    shared_libs: [
+        "libcutils",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
diff --git a/proprietary/hisilicon/Android.bp b/proprietary/hisilicon/Android.bp
new file mode 100644
index 0000000..5fe5e8e
--- /dev/null
+++ b/proprietary/hisilicon/Android.bp
@@ -0,0 +1,349 @@
+// 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.
+
+cc_prebuilt_library_shared {
+    name: "gralloc.poplar",
+    srcs: ["gralloc.poplar.so"],
+    shared_libs: [
+        "libhardware",
+        "liblog",
+        "libcutils",
+        "libGLESv1_CM",
+        "libion",
+        "libion_ext",
+        "libsync",
+        "libutils",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    relative_install_path: "hw",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+    allow_undefined_symbols: true,
+}
+
+cc_prebuilt_binary {
+    name: "hiavplayer",
+    srcs: ["hiavplayer"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "liblog",
+        "libhiavplayerservice",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "hwcomposer.poplar",
+    srcs: ["hwcomposer.poplar.so"],
+    shared_libs: [
+        "liblog",
+        "libEGL",
+        "libhardware",
+        "libhi_gfx2d",
+        "libhi_msp",
+        "libutils",
+        "libcutils",
+        "libGLESv2",
+        "libui",
+        "android.hardware.graphics.allocator@2.0",
+        "libsync",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    relative_install_path: "hw",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libGLES_mali",
+    srcs: ["libGLES_mali.so"],
+    shared_libs: [
+        "android.hardware.graphics.common@1.0",
+        "liblog",
+        "libz",
+        "libc++",
+        "libm",
+        "libc",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    relative_install_path: "egl",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhiavplayer_adp",
+    srcs: ["libhiavplayer_adp.so"],
+    shared_libs: [
+        "libhiavplayer",
+        "libhiavplayerservice",
+        "libbinder",
+        "libutils",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhiavplayerservice",
+    srcs: ["libhiavplayerservice.so"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "liblog",
+        "libhiavplayer",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhiavplayer",
+    srcs: ["libhiavplayer.so"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "libhi_msp",
+        "libhi_common",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhi_common",
+    srcs: ["libhi_common.so"],
+    shared_libs: [
+        "libcutils",
+        "libutils",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhi_gfx2d",
+    srcs: ["libhi_gfx2d.so"],
+    shared_libs: [
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhi_msp",
+    srcs: ["libhi_msp.so"],
+    shared_libs: [
+        "libhi_common",
+        "libcutils",
+        "libutils",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libhi_vfmw",
+    srcs: ["libhi_vfmw.so"],
+    shared_libs: [
+        "libutils",
+        "liblog",
+        "libhi_common",
+        "libhi_msp",
+        "libcutils",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libion_ext",
+    srcs: ["libion_ext.so"],
+    shared_libs: [
+        "liblog",
+        "libion",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libOMX_Core",
+    srcs: ["libOMX_Core.so"],
+    shared_libs: [
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libOMX.hisi.video.decoder",
+    srcs: ["libOMX.hisi.video.decoder.so"],
+    shared_libs: [
+        "libutils",
+        "liblog",
+        "libhi_common",
+        "libhi_msp",
+        "libcutils",
+        "libhiavplayer_adp",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "libstagefrighthw",
+    srcs: ["libstagefrighthw.so"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "libcutils",
+        "libui",
+        "libdl",
+        "liblog",
+        "libc++",
+        "libc",
+        "libm",
+    ],
+    compile_multilib: "32",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}
+
+cc_prebuilt_library_shared {
+    name: "overlay.poplar",
+    srcs: ["overlay.poplar.so"],
+    shared_libs: [
+        "libEGL",
+        "liblog",
+        "libhardware",
+        "libutils",
+        "libcutils",
+        "libsync",
+        "libhidlbase",
+        "libhi_msp",
+        "libui",
+        "libc++",
+        "libc",
+        "libm",
+        "libdl",
+    ],
+    compile_multilib: "32",
+    relative_install_path: "hw",
+    vendor: true,
+    strip: {
+        none: true,
+    },
+}