init: do not impose vendor_init restrictions on old vendor images

Do not restrict vendor_init restrictions on vendor images that were
built before P, as they will not have the correct permissions.

Bug: 77732028
Test: test new devices and see vendor_init still works
Change-Id: I636a07b54fbfb248e1d1a68a8f3c4d047fd5a9e9
diff --git a/init/subcontext.cpp b/init/subcontext.cpp
index c1846f7..9c0c0bb 100644
--- a/init/subcontext.cpp
+++ b/init/subcontext.cpp
@@ -30,6 +30,8 @@
 #include "util.h"
 
 #if defined(__ANDROID__)
+#include <android-base/properties.h>
+
 #include "property_service.h"
 #include "selinux.h"
 #else
@@ -37,6 +39,7 @@
 #endif
 
 using android::base::GetExecutablePath;
+using android::base::GetIntProperty;
 using android::base::Join;
 using android::base::Socketpair;
 using android::base::Split;
@@ -354,8 +357,10 @@
 static std::vector<Subcontext> subcontexts;
 
 std::vector<Subcontext>* InitializeSubcontexts() {
-    for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
-        subcontexts.emplace_back(path_prefix, secontext);
+    if (GetIntProperty("ro.vndk.version", 28) >= 28) {
+        for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
+            subcontexts.emplace_back(path_prefix, secontext);
+        }
     }
     return &subcontexts;
 }