当前位置:   article > 正文

Android start stop命令使用(十七)_android ctl.start

android ctl.start

1.Android start stop命令使用 

  1. 1.重启framwork
  2. # adb shell stop && adb shell start
  3. 2.源码位置:在system/core/toolbox/start.c下面,原理很简单就是利用ctl属性来控制进程。
  4. //start命令
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <cutils/properties.h>
  9. int start_main(int argc, char *argv[])
  10. {
  11. if(argc > 1) {
  12. property_set("ctl.start", argv[1]);
  13. } else {
  14. /* defaults to starting the common services stopped by stop.c */
  15. property_set("ctl.start", "netd");
  16. property_set("ctl.start", "surfaceflinger");
  17. property_set("ctl.start", "zygote");
  18. property_set("ctl.start", "zygote_secondary");
  19. }
  20. return 0;
  21. }
  22. //stop命令
  23. system/core/toolbox/stop.c
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <cutils/properties.h>
  27. int stop_main(int argc, char *argv[])
  28. {
  29. if(argc > 1) {
  30. property_set("ctl.stop", argv[1]);
  31. } else{
  32. /* defaults to stopping the common services */
  33. property_set("ctl.stop", "zygote_secondary");
  34. property_set("ctl.stop", "zygote");
  35. property_set("ctl.stop", "surfaceflinger");
  36. property_set("ctl.stop", "netd");
  37. }
  38. return 0;
  39. }
  40. 注意:start stop可以启动和停止init中的service,类似我们设置ctl.start clt.stop

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

闽ICP备14008679号