Sometimes you want to do something after startup, such as creating directories on sdcard and modifying/Data Access Permissions, which can be put in init. how can I do this in RC? recently, due to the need of my work, I have made some research in this area for your reference.
The following example shows how to implement a function: After the Android system is started, modify the/data access permission to 770.
4 steps in total: 1. Decompress ramdisk. IMG 2. Use the C language to complete the functions required. 3. Modify init. RC and start the executable program in C language. 4. Create ramdisk. IMG.
1. Unzip ramdisk. IMG:
Manually decompress and modify ramdisk. IMG of Android:
Copy ramdisk.imgto another directory, change its name to ramdisk.img.gz, and run the command
Gunzip ramdisk.img.gz
Create a folder named ramdisk.
Cpio-I-f ../ramdisk. img
Now you can see and operate the content in ramdisk.
This step can be referred to: http://blog.csdn.net/liushaogeng/archive/2010/10/14/5941259.aspx
2. Complete a C program chpermission. C to modify permissions. The Code is as follows:
# Include <stdlib. h>
Int main ()
{
System ("chmod 700/Data ");
Return 0;
}
Then compile this program, but need to compile the android executable program, can refer to my blog: http://blog.csdn.net/liushaogeng/archive/2010/09/01/5855925.aspx, using the blog introduced in the two methods can be.After compilation, push the executable file to the/data directory of the simulator:# ADB push chpermission/Data
3. Modify the init. RC file in the ramdisk directory to start the chpermission program and add the following code:
# Add by me on 2010-10-18
Service chpermission/data/chpermission
Oneshot
It is used to start chpermission and complete the corresponding function-modify data permissions.
Init. RC syntax can refer to blog: http://blog.csdn.net/liushaogeng/archive/2010/10/18/5949244.aspx
4. Create ramdisk. IMG,
After modifying init. RC, you can use the following command to repackage it into an image:
Cpio-I-t-f ../ramdisk. img> List
Cpio-o-h NEWC-o lk. IMG <list
The LK. IMG generated in the current directory is our new image.
Refer to blog: http://blog.csdn.net/liushaogeng/archive/2010/10/14/5941259.aspx
Copy ramdisk. IMG to the directory pointed to by the SDK.
All OK. Restart your simulator and check whether the data permission is 770.