Override vendor's usb_audio_policy_configuration

Android 8.1 added the support for new type of USB Audio devices
(USB_HEADSET, instead of old USB_DEVICE)
Some older USB devices got converted to this USB_HEADSET while still
using the old protocol.
There is no driver change needed, but the audio policy needs to be
changed.
Since vendors are simply using AOSP usb_audio_policy_configuration
Override it by ourself.
diff --git a/base.mk b/base.mk
index 96980b3..c1415aa 100644
--- a/base.mk
+++ b/base.mk
@@ -33,6 +33,9 @@
 	device/phh/treble/ld.config.26.txt:system/etc/ld.config.26.txt \
 	device/phh/treble/ld.config.27.txt:system/etc/ld.config.27.txt \
 
+#USB Audio
+PRODUCT_COPY_FILES += \
+	frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:system/etc/usb_audio_policy_configuration.xml
 
 # NFC:
 #   Provide default libnfc-nci.conf file for devices that does not have one in
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 10bc0ce..f80dc3a 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -1,2 +1,3 @@
 /system/bin/phh-su                   u:object_r:phhsu_exec:s0
 /system/bin/vndk-detect			u:object_r:vndk_detect_exec:s0
+/system/etc/usb_audio_policy_configuration.xml	u:object_r:vendor_configs_file:s0
diff --git a/sepolicy/vndk_detect.te b/sepolicy/vndk_detect.te
index 01dec96..b530a35 100644
--- a/sepolicy/vndk_detect.te
+++ b/sepolicy/vndk_detect.te
@@ -11,6 +11,10 @@
 allow vndk_detect system_file:file rx_file_perms;
 
 #mount -o bind /system/bin/adbd /sbin/adbd
-allow vndk_detect adbd_exec:file { getattr };
+allow vndk_detect adbd_exec:file { getattr read };
 allow vndk_detect rootfs:file { mounton getattr };
 allow vndk_detect self:capability { sys_admin };
+
+#mount -o bind /system/etc/usb_audio_policy_configuration.xml /vendor/etc/usb_audio_policy_configuration.xml
+allow init vendor_configs_file:file { getattr mounton };
+
diff --git a/vndk.rc b/vndk.rc
index f9dce09..064f0ae 100644
--- a/vndk.rc
+++ b/vndk.rc
@@ -1,3 +1,4 @@
 on post-fs
 	exec - root -- /system/bin/vndk-detect
+	mount none /system/etc/usb_audio_policy_configuration.xml /vendor/etc/usb_audio_policy_configuration.xml bind
 	export LD_CONFIG_FILE /system/etc/ld.config.${persist.sys.vndk}.txt