init.qti.usb.debug.rc: Add RC to execute init.qti.usb.debug.sh

The context vendor-qti-testscripts is only defined for userdebug build and
needed to be moved out of init.qcom.usb.rc to avoid any issues on
non-userdebug builds. init.qti.usb.debug.rc invokes the execution of
init.qti.usb.debug.sh with the condition of userdebug build in place.

Issue: FP3-A11#206
CRs-Fixed: 2887453
CRs-Fixed: 3116938
Change-Id: Ic04523e45d91eec6679fb2f1c70d85bb614f46d5
diff --git a/etc/Android.bp b/etc/Android.bp
index f5d3a05..25371a3 100644
--- a/etc/Android.bp
+++ b/etc/Android.bp
@@ -5,6 +5,13 @@
     sub_dir: "init/hw",
 }
 
+prebuilt_etc {
+ name: "init.qti.usb.debug.rc",
+ src: "init.qti.usb.debug.rc",
+ vendor: true,
+ sub_dir: "init",
+}
+
 sh_binary {
     name: "init.qcom.usb.sh",
     src: "init.qcom.usb.sh",
diff --git a/etc/init.qcom.usb.rc b/etc/init.qcom.usb.rc
index 3342bef..647fe94 100644
--- a/etc/init.qcom.usb.rc
+++ b/etc/init.qcom.usb.rc
@@ -43,9 +43,6 @@
     setprop sys.usb.config mass_storage
     setprop sys.usb.configfs 1
 
-on init
-    exec u:r:vendor-qti-testscripts:s0 -- /vendor/bin/sh /vendor/bin/init.qti.usb.debug.sh
-
 on boot
     mount configfs none /config
     mkdir /config/usb_gadget/g1 0770
diff --git a/etc/init.qti.usb.debug.rc b/etc/init.qti.usb.debug.rc
new file mode 100644
index 0000000..18d3b0b
--- /dev/null
+++ b/etc/init.qti.usb.debug.rc
@@ -0,0 +1,30 @@
+# Copyright (c) 2011-2016, 2018-2021 The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+on init
+    exec u:r:vendor-qti-testscripts:s0 -- /vendor/bin/sh /vendor/bin/init.qti.usb.debug.sh
diff --git a/vendor_product.mk b/vendor_product.mk
index 1dd23d0..e9f29b2 100644
--- a/vendor_product.mk
+++ b/vendor_product.mk
@@ -4,6 +4,7 @@
 # additional debugging on userdebug/eng builds
 ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
   PRODUCT_PACKAGES += init.qti.usb.debug.sh
+  PRODUCT_PACKAGES += init.qti.usb.debug.rc
 endif
 
 ifeq ($(TARGET_HAS_DIAG_ROUTER),true)