OSDN Git Service

vndservicemanager: load vendor service_contexts.
authorMartijn Coenen <maco@google.com>
Fri, 31 Mar 2017 23:12:12 +0000 (16:12 -0700)
committerMartijn Coenen <maco@google.com>
Mon, 3 Apr 2017 21:33:12 +0000 (14:33 -0700)
Also, don't crash when /dev/vndbinder is not
accessible.

Bug: 36052864
Test: loads vendor service contexts
Test: doesn't crash without /dev/vndbinder, works with it
Change-Id: Ida9dd94791206e14246348a8b8e66be09ed8fca7

cmds/servicemanager/Android.bp
cmds/servicemanager/service_manager.c

index 5431233..68d39db 100644 (file)
@@ -43,6 +43,9 @@ cc_binary {
         "service_manager.c",
         "binder.c",
     ],
+    cflags: [
+        "-DVENDORSERVICEMANAGER=1",
+    ],
     shared_libs: ["libcutils", "libselinux"],
     init_rc: ["vndservicemanager.rc"],
 }
index 5d44e87..45bb1d0 100644 (file)
 
 #include "binder.h"
 
-#if 0
-#define ALOGI(x...) fprintf(stderr, "svcmgr: " x)
-#define ALOGE(x...) fprintf(stderr, "svcmgr: " x)
+#ifdef VENDORSERVICEMANAGER
+#define LOG_TAG "VendorServiceManager"
 #else
 #define LOG_TAG "ServiceManager"
-#include <log/log.h>
 #endif
+#include <log/log.h>
 
 struct audit_data {
     pid_t pid;
@@ -374,7 +373,14 @@ int main(int argc, char** argv)
 
     bs = binder_open(driver, 128*1024);
     if (!bs) {
+#ifdef VENDORSERVICEMANAGER
+        ALOGW("failed to open binder driver %s\n", driver);
+        while (true) {
+            sleep(UINT_MAX);
+        }
+#else
         ALOGE("failed to open binder driver %s\n", driver);
+#endif
         return -1;
     }
 
@@ -388,7 +394,11 @@ int main(int argc, char** argv)
     cb.func_log = selinux_log_callback;
     selinux_set_callback(SELINUX_CB_LOG, cb);
 
+#ifdef VENDORSERVICEMANAGER
+    sehandle = selinux_android_vendor_service_context_handle();
+#else
     sehandle = selinux_android_service_context_handle();
+#endif
     selinux_status_open(true);
 
     if (sehandle == NULL) {