简体   繁体   English

在init.rc中禁用android服务

[英]Disabling android services in init.rc

I am working on a new hardware platform on which i need to flash Android OS.. For initial testing i need to stop all the Android services are there in android init.rc file. 我正在开发一个新的硬件平台,我需要在其上安装Android操作系统。对于初始测试,我需要停止Android init.rc文件中的所有Android服务。 I searched for the init.rc file in my code base ./bootable/diskinstaller/init.rc ./bootable/recovery/etc/init.rc ./system/core/rootdir/init.rc , I need to know about how to identify the android services in the init.rc ?.I am thinking of disabling the android dalvik VM. 我在我的代码库中搜索了init.rc文件./bootable/diskinstaller/init.rc ./bootable/recovery/etc/init.rc ./system/core/rootdir/init.rc ,我需要知道如何在init.rc中识别android服务?我正在考虑禁用android dalvik VM。 to stop all the android related services is it good to stop the dalvic VM or just disabling all the services one by one? 停止所有Android相关的服务是不是很好地停止dalvic VM或只是逐个禁用所有服务? Thanks! 谢谢!

Assuming that you have sucessfully booted, then you can shutdown the android framework with this command: 假设您已经成功启动,那么您可以使用以下命令关闭android框架:

setprop vold.decrypt trigger_shutdown_framework

This command was implemented as part of the encryption system in Honeycomb. 此命令是作为Honeycomb中加密系统的一部分实现的。 It will shutdown all but the core native sevices: 它将关闭除核心本机服务之外的所有服务:

  • init 在里面
  • adbd - so that you can still adb shell into the phone adbd - 这样你仍然可以将shell加入手机中
  • servicemanager - Which handles the native (not android) serivces servicemanager - 处理本机(非android)服务
  • ueventd ueventd

You can restart the android framework with the command: 您可以使用以下命令重新启动android框架:

setprop vold.decrypt trigger_restart_framework

Obviously you must be root to do this. 显然你必须是root才能做到这一点。

I searched a lot, and came to a particular solution to disable the Android services which might work, there is a init.rc file in Android source code 我搜索了很多,并找到了一个特定的解决方案来禁用可能有效的Android服务,Android源代码中有一个init.rc文件

./system/core/rootdir/init.rc

this init.rc file describes the system services, file system and other parameters that need to be set up. 此init.rc文件描述了需要设置的系统服务,文件系统和其他参数。 As init process is the first process which get executed after the kernel loaded,the init process looks for this init.rc script file and then parsed it and launch the system service processes. 由于init进程是在内核加载后执行的第一个进程,因此init进程会查找此init.rc脚本文件,然后对其进行解析并启动系统服务进程。

There is a service called Zygote (dalvic VM) used to initialise the SystemServer.java ,the first java component to run in the system,which contains declarations for all the Android services. 有一个名为Zygote(dalvic VM)的服务用于初始化SystemServer.java ,它是系统中运行的第一个java组件,它包含所有Android服务的声明。

service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server class main
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
onrestart restart media
onrestart restart netd

the android services are declared in run() method of SystemServer.java .The path for the file is android服务在SystemServer.java的 run()方法中声明。文件的路径是
/frameworks/base/services/java/com/android/server/SystemServer.java

If we comment out the zygote,the android services might not initialized.I haven't tested it due to some panic in kernel booting but hope it will be the solution.:) 如果我们注释掉zygote,android服务可能没有初始化。我没有测试它,因为内核启动时有些恐慌,但希望它会成为解决方案。:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM