35

Question

What do adb shell start and adb shell stop actually do?

Description

I think they call /system/bin/start and /system/bin/stop. But these two executables don't give any clue about what they do. When tested on a real device, I found the zygote process is started and stopped. So these two commands seem to control the Android runtime (which corresponds to the yellow and blue parts in the figure below).

Android Architecture

But what exact processes/services are started/stopped with these two commands?

Community
  • 1
  • 1
Cyker
  • 9,946
  • 8
  • 65
  • 93

4 Answers4

19

Basically, all your Android services are restarted; those that are created and registered in SystemServer.java. This is called within the "Context of Zygote". So yes, Zygote is stopped.

All your services registered with ServiceManager in Android will get removed within ServiceManager. To restart them, do adb shell start.

Also note that SystemServer is started by Zygote, so init.rc tells that if Zygote is stopped, then even SystemServer must be stopped. Even SurfaceFlinger dies, since it's started from SystemServer but natively.

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
human.js
  • 1,342
  • 13
  • 15
2

Run this on your device

grep ^service /init*rc
Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • Until quite recently, most official android releases did not include `grep` – Chris Stratton Jun 06 '13 at 19:49
  • 1
    Use `adb pull` to copy all those files onto your workstation and then run grep from there. – Edward Falk Dec 19 '13 at 00:48
  • 1
    @ChrisStratton: compile/download `busybox` and run `busybox grep`. – pevik Oct 02 '15 at 12:05
  • @pevik - you might notice my comment said "until recently" and was written in 2013. Most Android devices in use today have a built in grep. Busybox is an option for those that don't, but it can be a pain to install for convenient use on secured devices. Examining the init files on a development machine is probably going to be more informative anyway, but now that it is there I do use the built in grep if I have a strong idea of what I am looking for. – Chris Stratton Oct 03 '15 at 16:17
  • 6
    How does this address the question?? – Don Hatch Dec 27 '17 at 22:11
  • 1
    @DonHatch after you do the grep command you will get list of available services. start/stop would allow you to start/stop these services – Ramast Jun 13 '20 at 16:29
2

I have been wondering what "stop" does on Android too. Learned from someone that "stop" stops AP being rendered by SurfaceFlinger.

Had a try with the command like below. Execute the command, wait for a few seconds and then execute "stop" on Android. The command keeps printing increased number and creating .txt files. So maybe it only stops the Android part while the Linux part remains active. Just FYI.

busybox sh -c 'i=0;while [ $i -ne 100 ]; do echo $i >> count.txt; sleep 1; i=$(($i + 1)); echo $i; touch "$i.txt"; done;'
Di Liu
  • 111
  • 5
1

adb shell "start --help"

usage: start [SERVICE...]

Starts the given system service, or netd/surfaceflinger/zygotes.

adb shell "stop --help"

usage: stop [SERVICE...]

Stops the given system service, or netd/surfaceflinger/zygotes.

Kevin Ding
  • 568
  • 5
  • 9