What does 'adb shell start/stop' do?

2020-02-23 06:07发布

问题:

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).

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

回答1:

Run this on your device

grep ^service /init*rc


回答2:

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.



回答3:

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;'


标签: android adb