Android Framework 通过脚本动态修改应用私有文件执行权限

24 篇文章 4 订阅
3 篇文章 0 订阅

你只活一次 要悦己

在这里插入图片描述

脚本配置

  • Android_source/device/sprd/***/test/test_chmod.rc
	service test_chmod /vendor/bin/test_chmod.sh
	    user root
	    disabled
	    oneshot
	
	on property:sys.test_chmod=true
	    start test_chmod
  • Android_source/device/sprd/***/test/test_chmod.sh
	#!/system/bin/sh
	
	chmod -R 0777 /storage/emulated/0/Android/data/com.***.***/
  • Android_source/device/sprd///BoardConfig.mk
# add chmod config
PRODUCT_COPY_FILES += device/sprd/***/test/test_chmod.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/test_chmod.rc
PRODUCT_COPY_FILES += device/sprd/***/test/test_chmod.sh:$(TARGET_COPY_OUT_VENDOR)/bin/test_chmod.sh

SE策略

  • Android_source/vendor/***/sepolicy/file_contexts
	# add chmod config
	/vendor/bin/test_chmod.sh   u:object_r:test_exec:s0
  • Android_source/vendor/***/sepolicy/test.te
	# audioserver - audio services daemon
	
	type test, domain;
	tyep test_exec, exec_type, file_type, vendor_file_type;
	
	init_daemon_domain(test)
  • Android_source/vendor/***/sepolicy/init.te
	allow init test:process sigkill;
	allow init test:process { getpgid sigkill signal setpgid };

代码调用

	SystemProperties.set("sys.test_chmod","true");
	//执行权限顺序,根据实际情况添加延迟
	//SystemClock.sleep(2000);
  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值