当前位置:   article > 正文

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

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

你只活一次 要悦己

在这里插入图片描述

脚本配置

  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • Android_source/device/sprd/***/test/test_chmod.sh
	#!/system/bin/sh
	
	chmod -R 0777 /storage/emulated/0/Android/data/com.***.***/
  • 1
  • 2
  • 3
  • 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
  • 1
  • 2
  • 3

SE策略

  • Android_source/vendor/***/sepolicy/file_contexts
	# add chmod config
	/vendor/bin/test_chmod.sh   u:object_r:test_exec:s0
  • 1
  • 2
  • 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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Android_source/vendor/***/sepolicy/init.te
	allow init test:process sigkill;
	allow init test:process { getpgid sigkill signal setpgid };
  • 1
  • 2

代码调用

	SystemProperties.set("sys.test_chmod","true");
	//执行权限顺序,根据实际情况添加延迟
	//SystemClock.sleep(2000);
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/318961
推荐阅读
相关标签
  

闽ICP备14008679号