Use preloads_copy script and policy from system/extras

This script and its related config was previously duplicated for
every device. Use a shared one instead.

Bug: 80508492
Test: make
Change-Id: I758caf9a732beaa14f95ea0139566facaca166f6
diff --git a/device-common.mk b/device-common.mk
index d0fac37..08146cc 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -450,7 +450,7 @@
 
 # Script that copies preloads directory from system_other to data partition
 PRODUCT_COPY_FILES += \
-    device/google/marlin/preloads_copy.sh:system/bin/preloads_copy.sh
+    system/extras/cppreopts/preloads_copy.sh:system/bin/preloads_copy.sh
 
 PRODUCT_PACKAGES_DEBUG += \
     update_engine_client
diff --git a/preloads_copy.sh b/preloads_copy.sh
deleted file mode 100644
index 7e5e8e4..0000000
--- a/preloads_copy.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/system/bin/sh
-#
-# Copyright (C) 2016 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 script copies preloaded content from system_b to data partition
-
-# create files with 644 (global read) permissions.
-umask 022
-
-if [ $# -eq 1 ]; then
-  # Where the system_b is mounted that contains the preloads dir
-  mountpoint=$1
-  dest_dir=/data/preloads
-  log -p i -t preloads_copy "Copying from $mountpoint/preloads"
-  # Parallelize by copying subfolders and files in the background
-  for file in $(find ${mountpoint}/preloads -mindepth 1 -maxdepth 1); do
-      cp -rn $file $dest_dir &
-  done
-  # Wait for jobs to finish
-  wait
-  log -p i -t preloads_copy "Copying complete"
-  exit 0
-else
-  log -p e -t preloads_copy "Usage: preloads_copy.sh <system_other-mount-point>"
-  exit 1
-fi
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index e627363..e5f1faf 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -79,7 +79,6 @@
 /firmware(/.*)?         u:object_r:firmware_file:s0
 
 # files in /system
-/system/bin/preloads_copy\.sh      u:object_r:preloads_copy_exec:s0
 /system/bin/move_widevine_data\.sh u:object_r:move-widevine-data-sh_exec:s0
 
 # files in /vendor
diff --git a/sepolicy/preloads_copy.te b/sepolicy/preloads_copy.te
deleted file mode 100644
index 7177839..0000000
--- a/sepolicy/preloads_copy.te
+++ /dev/null
@@ -1,14 +0,0 @@
-type preloads_copy, domain, coredomain;
-type preloads_copy_exec, system_file_type, exec_type, file_type;
-
-init_daemon_domain(preloads_copy)
-
-allow preloads_copy shell_exec:file rx_file_perms;
-allow preloads_copy toolbox_exec:file rx_file_perms;
-allow preloads_copy preloads_data_file:dir create_dir_perms;
-allow preloads_copy preloads_data_file:file create_file_perms;
-allow preloads_copy preloads_media_file:dir create_dir_perms;
-allow preloads_copy preloads_media_file:file create_file_perms;
-
-# Allow to copy from /postinstall
-allow preloads_copy system_file:dir r_dir_perms;