Loading toolbox/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ LOCAL_PATH:= $(call my-dir) common_cflags := \ -std=gnu99 \ -Werror -Wno-unused-parameter \ -I$(LOCAL_PATH)/upstream-netbsd/include/ \ -include bsd-compatibility.h \ Loading Loading @@ -63,10 +62,12 @@ OUR_TOOLS := \ ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) LOCAL_SRC_FILES := \ start_stop.cpp \ toolbox.c \ $(patsubst %,%.c,$(OUR_TOOLS)) \ LOCAL_CFLAGS += $(common_cflags) LOCAL_CONLYFLAGS += -std=gnu99 LOCAL_SHARED_LIBRARIES := \ libcutils \ Loading toolbox/start.c +1 −21 Original line number Diff line number Diff line #include <string.h> #include <stdio.h> #include <stdlib.h> #include <cutils/properties.h> int start_main(int argc, char *argv[]) { if(argc > 1) { property_set("ctl.start", argv[1]); } else { /* defaults to starting the common services stopped by stop.c */ property_set("ctl.start", "netd"); property_set("ctl.start", "surfaceflinger"); property_set("ctl.start", "zygote"); property_set("ctl.start", "zygote_secondary"); } return 0; } /* Needed by Android.mk. Actual code in start_stop.cpp. */ toolbox/start_stop.cpp 0 → 100644 +43 −0 Original line number Diff line number Diff line #include <error.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <cutils/properties.h> static const char* services[] = { "netd", "surfaceflinger", "zygote", "zygote_secondary", }; static int start_stop(bool start, int argc, char* argv[]) { if (getuid() != 0) error(1, 0, "must be root"); const char* property = start ? "ctl.start" : "ctl.stop"; if (argc > 2) { error(1, 0, "usage: %s [SERVICE]\n", argv[0]); } else if (argc == 2) { property_set(property, argv[1]); } else { if (start) { for (size_t i = 0; i < sizeof(services)/sizeof(services[0]); ++i) { property_set(property, services[i]); } } else { for (int i = sizeof(services)/sizeof(services[0]) - 1; i >= 0; --i) { property_set(property, services[i]); } } } return 0; } extern "C" int start_main(int argc, char* argv[]) { return start_stop(true, argc, argv); } extern "C" int stop_main(int argc, char* argv[]) { return start_stop(false, argc, argv); } toolbox/stop.c +1 −19 Original line number Diff line number Diff line #include <stdio.h> #include <string.h> #include <cutils/properties.h> int stop_main(int argc, char *argv[]) { if(argc > 1) { property_set("ctl.stop", argv[1]); } else{ /* defaults to stopping the common services */ property_set("ctl.stop", "zygote_secondary"); property_set("ctl.stop", "zygote"); property_set("ctl.stop", "surfaceflinger"); property_set("ctl.stop", "netd"); } return 0; } /* Needed by Android.mk. Actual code in start_stop.cpp. */ Loading
toolbox/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ LOCAL_PATH:= $(call my-dir) common_cflags := \ -std=gnu99 \ -Werror -Wno-unused-parameter \ -I$(LOCAL_PATH)/upstream-netbsd/include/ \ -include bsd-compatibility.h \ Loading Loading @@ -63,10 +62,12 @@ OUR_TOOLS := \ ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) LOCAL_SRC_FILES := \ start_stop.cpp \ toolbox.c \ $(patsubst %,%.c,$(OUR_TOOLS)) \ LOCAL_CFLAGS += $(common_cflags) LOCAL_CONLYFLAGS += -std=gnu99 LOCAL_SHARED_LIBRARIES := \ libcutils \ Loading
toolbox/start.c +1 −21 Original line number Diff line number Diff line #include <string.h> #include <stdio.h> #include <stdlib.h> #include <cutils/properties.h> int start_main(int argc, char *argv[]) { if(argc > 1) { property_set("ctl.start", argv[1]); } else { /* defaults to starting the common services stopped by stop.c */ property_set("ctl.start", "netd"); property_set("ctl.start", "surfaceflinger"); property_set("ctl.start", "zygote"); property_set("ctl.start", "zygote_secondary"); } return 0; } /* Needed by Android.mk. Actual code in start_stop.cpp. */
toolbox/start_stop.cpp 0 → 100644 +43 −0 Original line number Diff line number Diff line #include <error.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <cutils/properties.h> static const char* services[] = { "netd", "surfaceflinger", "zygote", "zygote_secondary", }; static int start_stop(bool start, int argc, char* argv[]) { if (getuid() != 0) error(1, 0, "must be root"); const char* property = start ? "ctl.start" : "ctl.stop"; if (argc > 2) { error(1, 0, "usage: %s [SERVICE]\n", argv[0]); } else if (argc == 2) { property_set(property, argv[1]); } else { if (start) { for (size_t i = 0; i < sizeof(services)/sizeof(services[0]); ++i) { property_set(property, services[i]); } } else { for (int i = sizeof(services)/sizeof(services[0]) - 1; i >= 0; --i) { property_set(property, services[i]); } } } return 0; } extern "C" int start_main(int argc, char* argv[]) { return start_stop(true, argc, argv); } extern "C" int stop_main(int argc, char* argv[]) { return start_stop(false, argc, argv); }
toolbox/stop.c +1 −19 Original line number Diff line number Diff line #include <stdio.h> #include <string.h> #include <cutils/properties.h> int stop_main(int argc, char *argv[]) { if(argc > 1) { property_set("ctl.stop", argv[1]); } else{ /* defaults to stopping the common services */ property_set("ctl.stop", "zygote_secondary"); property_set("ctl.stop", "zygote"); property_set("ctl.stop", "surfaceflinger"); property_set("ctl.stop", "netd"); } return 0; } /* Needed by Android.mk. Actual code in start_stop.cpp. */