当前位置:   article > 正文

Android start stop命令

android start stop

我们经常使用stop start命令来重启framework,我们来看下其代码

是在system/core/toolbox下面,原理很简单就是利用ctl属性来控制进程。

start.c

  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <cutils/properties.h>
  5. int start_main(int argc, char *argv[])
  6. {
  7. if(argc > 1) {
  8. property_set("ctl.start", argv[1]);
  9. } else {
  10. /* defaults to starting the common services stopped by stop.c */
  11. property_set("ctl.start", "netd");
  12. property_set("ctl.start", "surfaceflinger");
  13. property_set("ctl.start", "zygote");
  14. property_set("ctl.start", "zygote_secondary");
  15. }
  16. return 0;
  17. }

stop.c

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <cutils/properties.h>
  4. int stop_main(int argc, char *argv[])
  5. {
  6. if(argc > 1) {
  7. property_set("ctl.stop", argv[1]);
  8. } else{
  9. /* defaults to stopping the common services */
  10. property_set("ctl.stop", "zygote_secondary");
  11. property_set("ctl.stop", "zygote");
  12. property_set("ctl.stop", "surfaceflinger");
  13. property_set("ctl.stop", "netd");
  14. }
  15. return 0;
  16. }
所以从上面代码看,start stop还可以启动和停止init中的service,类似我们设置ctl.start clt.stop


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/945140
推荐阅读
相关标签
  

闽ICP备14008679号