init: Allow services to start before property triggers are up

Change-Id: I4f87657123bea88b7b5c537781868908d8d66b01
diff --git a/init/init.c b/init/init.c
index e2889b6..3471cf8 100755
--- a/init/init.c
+++ b/init/init.c
@@ -193,9 +193,11 @@
         char tmp[32];
         int fd, sz;
 
-        get_property_workspace(&fd, &sz);
-        sprintf(tmp, "%d,%d", dup(fd), sz);
-        add_environment("ANDROID_PROPERTY_WORKSPACE", tmp);
+        if (properties_inited()) {
+            get_property_workspace(&fd, &sz);
+            sprintf(tmp, "%d,%d", dup(fd), sz);
+            add_environment("ANDROID_PROPERTY_WORKSPACE", tmp);
+        }
 
         for (ei = svc->envvars; ei; ei = ei->next)
             add_environment(ei->name, ei->value);
@@ -281,7 +283,8 @@
     svc->pid = pid;
     svc->flags |= SVC_RUNNING;
 
-    notify_service_state(svc->name, "running");
+    if (properties_inited())
+        notify_service_state(svc->name, "running");
 }
 
 void service_stop(struct service *svc)
diff --git a/init/property_service.c b/init/property_service.c
index a5a7a70..e35cd38 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -49,6 +49,7 @@
 #define PERSISTENT_PROPERTY_DIR  "/data/property"
 
 static int persistent_properties_loaded = 0;
+static int property_area_inited = 0;
 
 static int property_set_fd = -1;
 
@@ -164,7 +165,7 @@
 
         /* plug into the lib property services */
     __system_property_area__ = pa;
-
+    property_area_inited = 1;
     return 0;
 }
 
@@ -497,6 +498,11 @@
     load_properties_from_file(PROP_PATH_RAMDISK_DEFAULT);
 }
 
+int properties_inited(void)
+{
+    return property_area_inited;
+}
+
 void start_property_service(void)
 {
     int fd;
diff --git a/init/property_service.h b/init/property_service.h
index 5bfa46c..045d20a 100644
--- a/init/property_service.h
+++ b/init/property_service.h
@@ -23,6 +23,7 @@
 void get_property_workspace(int *fd, int *sz);
 extern const char* property_get(const char *name);
 extern int property_set(const char *name, const char *value);
+extern int properties_inited();
 int get_property_set_fd(void);
 
 #endif	/* _INIT_PROPERTY_H */