Adds new property for service name -> PID.

Bug: 138114550
Test: used in vts_ibase_test
Change-Id: Id21b81aa09b8597d17ad0a132ddd7749fe1182e9
diff --git a/init/service.cpp b/init/service.cpp
index 47f4db9..532b1d7 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -165,6 +165,15 @@
             property_set(boottime_property, std::to_string(start_ns));
         }
     }
+
+    // init.svc_debug_pid.* properties are only for tests, and should not be used
+    // on device for security checks.
+    std::string pid_property = "init.svc_debug_pid." + name_;
+    if (new_state == "running") {
+        property_set(pid_property, std::to_string(pid_));
+    } else if (new_state == "stopped") {
+        property_set(pid_property, "");
+    }
 }
 
 void Service::KillProcessGroup(int signal) {