Android : change permission of system files

大憨熊 提交于 2019-12-02 15:20:36

问题


My phone is rooted and i wrote code in my app to change file permission of system file which is located at /sys/class/leds/lcd-backlight/brightness

Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("chmod 777 /sys/class/leds/lcd-backlight/brightness");

but this code can't change the file permission of the specified file and i won't got any kind of error or exception


回答1:


Download the RootTools.jar from this link https://github.com/Stericson/RootTools/releases

Put that .jar file into your project's 'libs' directory

import com.stericson.RootTools.*;

. .

Command cmd=new Command(0,"chmod 766 /sys/class/leds/lcd-backlight/brightness");
RootShell.getShell(true).add(cmd);



回答2:


That's not how you execute su-ed commands. Please refer to http://su.chainfire.eu/ for guidance.



来源:https://stackoverflow.com/questions/28293327/android-change-permission-of-system-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!