解压后的文件:
META-INF\com\google\android\updater-script的代码:
功能:安装程序并执行脚本\tmp\vipertweaks.sh
#RECOVERY交互性提示
ui_print("---------------------------------"); #在控制台显示的信息
ui_print("蝰蛇音效-ViPERFX");
ui_print("ViPERFX 2.5.0.5");
ui_print("For Android6.0");
ui_print("----By想飞的小伙(jsjson)");
ui_print("诈尸更新蝰蛇音效!");
ui_print("----2016.09.01 21:14 update");
ui_print("---------------------------------");
#执行程序
#挂载文件夹
run_program(
"/sbin/busybox",
"mount",
"/system"
);
#运行/sbin/busybox mount /system 挂载/system文件夹
ui_print("删除旧文件以及一些默认音效管理器,并替换成为蝰蛇...");
ui_print("Delete default sound Manager...");
#删除文件原有的音效管理器
delete_recursive(
"/system/app/AudioFX",
"/system/app/DSPManager",
"/system/app/Viper4Android",
"/system/app/MaxxAudioFX",
"/system/app/MusicFX",
"/system/app/MaxxAudio",
"/system/app/Material_V4A"
);
#删除的文件或文件夹,
删除文件
"/system/app/AudioFX",
"/system/app/DSPManager",
"/system/app/Viper4Android",
"/system/app/MaxxAudioFX",
"/system/app/MusicFX",
"/system/app/MaxxAudio",
"/system/app/Material_V4A"
delete_recursive(
"/system/priv-app/AudioFX",
"/system/priv-app/DSPManager",
"/system/priv-app/Viper4Android",
"/system/priv-app/MaxxAudioFX",
"/system/priv-app/MusicFX",
"/system/priv-app/MaxxAudio",
"/system/priv-app/Material_V4A"
);
#开始安装
ui_print("starting...");
ui_print("安装蝰蛇开始...");
ui_print("---------------------------------");
show_progress(1, 15); #下面的操作可能进行15秒钟完成,完成后进度前进1(100%)
package_extract_dir(
"system",
"/system"
);
#释放ROM包里system文件夹下所有文件和子文件夹至/system
show_progress(1, 15); #下面的操作可能进行15秒钟完成,完成后进度前进1(100%)
ui_print("安装中...");
#赋予权限
set_metadata_recursive(
"/system/priv-app",
"uid", 0, #ROOT用户
"gid", 0, #任何组
"dmode", 0755, #赋予755权限
"fmode", 0644, #赋予644权限
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
#递归地设置给定的目录dirname机器所有子目录,对应key的值
set_metadata_recursive(
"/system/su.d",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0755,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
set_metadata_recursive(
"/system/lib",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0644,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
set_metadata_recursive(
"/system/lib/soundfx",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0644,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
set_metadata_recursive(
"/system/vendor/pittpatt",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0644,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
set_metadata_recursive(
"/system/vendor/etc",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0644,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
set_metadata_recursive(
"/system/vendor/pittpatt",
"uid", 0,
"gid", 0,
"dmode", 0755,
"fmode", 0755,
"capabilities", 0x0,
"selabel",
"u:object_r:system_file:s0"
);
#解压tmp
package_extract_dir("tmp", "/tmp");
set_perm(
0,
0,
0777,
"/tmp/vipertweaks.sh"
);
#set_perm 0 2000 0550 SYSTEM:etc/init.goldfish.sh
(设置手机system中的etc/init.goldfish.sh的
用户为root,
用户组为shell,
所有者以及所属用户组成员可以进行读取和执行操作,其他用户无操作权限
ui_print("");
#运行vipertweaks.sh
run_program("/tmp/vipertweaks.sh", "vipertweak");
ui_print("");
ui_print("继续安装中...");
ui_print("");
run_program("/sbin/busybox", "umount", "/system");
ui_print("安装完成!");
ui_print("----------Enjoy!--------");
ui_print("只为单纯的蝰蛇音效!");
ui_print("享受极致音效吧!");
ui_print("Done!");
#!/sbin/sh
bp="/system/build.prop" #设置变量为系统下的/system/build.prop的字符串
busybox mount /system #挂在/system
busybox mount /data #挂在/data
if [ -f /system/build.prop.bak ]; #当/system/build.prop.bak文件存在并且是正规文件时返回真
then
rm -rf $bp #删除变量$bp
cp $bp.bak $bp #将/system/build.prop.bak的“.bak”去掉
else
cp $bp $bp.bak #若为假,则将/system/build.prop后的加上“.bak”
fi
#将misc文件中的字符串加入到build.prop中
echo " " >> $bp #向/system/build.prop后加空格
echo "# ViPER4Android Build.prop Tweaks" >> $bp #向/system/build.prop后加# ViPER4Android Build.prop Tweaks
echo " " >> $bp #向/system/build.prop后加空格
for mod in misc; #当变量mod中的值符合misc文件中的值时执行
do
for prop in `cat /tmp/$mod`;
do
export newprop=$(echo ${prop} | cut -d '=' -f1) #以'=' 为分隔符,取第一个字段
sed -i "/${newprop}/d" /system/build.prop
echo $prop >> /system/build.prop
done
done
#misc文件中的值
#lpa.decode=false
#lpa.releaselock=false
#lpa.use-stagefright=false
#tunnel.decode=false
\system\su.d\permissive.sh代码:
功能:设置Selinux成permissive,解决蝰蛇音效不能用的问题
su #获取ROOT
mount -o remount,rw /system #重新挂在/system为rw读写
mkdir -p /system/su.d #建立目录su.d,“-p”若所要建立目录的上层目录目system前尚未建立,则会一并建立上层目录
echo "#!/system/bin/sh" > /system/su.d/permissive.sh #直接清空原来的内容,填入新内容"#!/system/bin/sh"
echo "setenforce 0" > /system/su.d/permissive.sh #填入内容 setenforce 0
echo "0" > /sys/fs/selinux/enforce #执行 enforce 0
chmod 755 /system/su.d/permissive.sh #设置755权限