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/property_service.cpp b/init/property_service.cpp
index 95ef35c..99d3c83 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -64,6 +64,7 @@
 
 using namespace std::literals;
 
+using android::base::GetIntProperty;
 using android::base::ReadFileToString;
 using android::base::Split;
 using android::base::StartsWith;
@@ -541,9 +542,11 @@
     size_t flen = 0;
 
     const char* context = kInitContext.c_str();
-    for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
-        if (StartsWith(filename, path_prefix)) {
-            context = secontext;
+    if (GetIntProperty("ro.vndk.version", 28) >= 28) {
+        for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
+            if (StartsWith(filename, path_prefix)) {
+                context = secontext;
+            }
         }
     }