Development environment-Android modify init.rc

Because of some special logic, I hope not to open services such as boot animation when starting.

I mentioned the replacement of boot animation before, just change bootanimation.zip in the "/system/media" directory.

Some of the more detailed content, such as desc.txt and other configurations, will be mentioned in other blogs.

Android production boot animation

 

The main research this time is how to completely turn off the boot animation and boot ringtone.

 

The logic of the boot animation has also been studied before.

When the system starts, it will automatically execute the rc script in Ramdisk. There is a file /root/init.rc in it, which is the main system service javascript:; when we open this script, we will find that there are many sentences beginning with service. It is the system service. Its function is to start the binary files and sh scripts under system/bin when booting up to start the required system services. After executing the script, system services will be started in the script sequence

After the system service is started, the media service is generally started first, followed by the startup and shutdown animation and ringtone service, because the power-on animation and ringtone are dependent on the media service, if you add and delete the code here, you can turn on or off the animation And the purpose of the ringtone.

At this time, some friends may ask again. Isn't it enough to turn off the animation and ringtones to enter the system/media and delete the files directly? It doesn't need to be so troublesome.
Then there is another place involved. If you delete the animation and ringtones directly, when the system starts the service, if the animation and ringtone files are not found under system/media, it will load the default switch animation, the default switch The animation is an ANDROID, located in system/framework/framework-res.apk. Unzip the framework file. Under the assets folder, there is an images file and two png pictures, which are the default switch animations of Android. Therefore, it is impossible to completely close the animation and ringtones by directly deleting the animation and ringtone files. We can only completely turn it on and off by modifying system services.

 

In /root/init.rc, the following script is the corresponding service to start the boot animation. As long as this script is deleted, the boot animation can be turned off.

service bootanim /system/bin/bootanimation          
    class core                                                         
    user root         
    group graphics audio
    disabled                                           
    oneshot 

You can see init.rc in the root directory of Android, but you can't modify it. If you change it, it will be in vain. It will be restored after restarting, ramdisk...

init.rc is a file in rootfs. Android will link rootfs (initramfs) to linux kernel image to generate boot.img for normal startup and recovery.img in recovery mode.
Android bootloader must change boot.img every time it reboots Loaded into the ram, one part is the real linux kernel image (zImage), and the other part is the initramfs (including init, init.rc, etc.).
After that, when the Linux kernel is initialized, the initramfs will be mounted as rootfs to /.
This way , You use adb shell or serial port to modify the init.rc on /, because the next restart will reload, your modifications will naturally disappear.

Here, the generated boot.img is integrated into kernel.img.
 

 

 

PS:

There is another episode here, because the init.rc file of Android is in a public directory. Modifying this file may cause the init.rc in all projects to be modified.

Therefore, you need to modify the device.mk file, and replace the following code with the init.rc file in the specified directory.

PRODUCT_COPY_FILES += \
    device/hisilicon/bigfish/etc/init.rc:root/init.rc \

Change to the following:

 PRODUCT_COPY_FILES += \
   device/kedacom/${TARGET_PRODUCT}/etc/init.rc:root/init.rc \

 

The above is how to turn off the bootanimation service in the startup service,

You can also refer to this section for opening and closing other services.

 

Guess you like

Origin blog.csdn.net/Ivan804638781/article/details/100076102