1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#define FOR_start
28#include "toys.h"
29
30static void start_stop(int start)
31{
32 char *property = start ? "ctl.start" : "ctl.stop";
33
34 char *services[] = {0,"netd","surfaceflinger","zygote","zygote_secondary",0},
35 **ss = toys.optargs;
36 int direction = 1;
37
38 if (getuid()) error_exit("must be root");
39
40 if (!*ss) {
41
42 ss = services+1;
43 if (!start) ss = services+ARRAY_LEN(services)-2, direction = -1;
44 }
45
46 for (; *ss; ss += direction)
47 if (__system_property_set(property, *ss))
48 error_exit("failed to set property '%s' to '%s'", property, *ss);
49}
50
51void start_main(void)
52{
53 start_stop(1);
54}
55
56void stop_main(void)
57{
58 start_stop(0);
59}
60