rk3399 android 9.0 root 权限及测试应用
功能:rk3399 9.0 上root權限,第三方APP可以調用su指令。
1.修改system/extras/su/su.cpp 文件
diff --git a/su/su.cpp b/su/su.cpp
index f3e4ff0..00a41a4 100644
--- a/su/su.cpp
+++ b/su/su.cpp
@@ -80,8 +80,8 @@ void extract_uidgids(const char* uidgids, uid_t* uid, gid_t* gid, gid_t* gids, i
?}
?
?int main(int argc, char** argv) {
- ? ?uid_t current_uid = getuid();
- ? ?if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed");
+ ? ?//uid_t current_uid = getuid();
+ ? ?//if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed");
2.修改system/core/libcutils/libcutils/fs_config.cpp文件
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 62e91cf..5f5a405 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -173,7 +173,7 @@ static const struct fs_path_config android_files[] = {
? ? ?// the following two files are INTENTIONALLY set-uid, but they
? ? ?// are NOT included on user builds.
? ? ?{ 06755, AID_ROOT, ? ? ?AID_ROOT, ? ? ?0, "system/xbin/procmem" },
- ? ?{ 04755, AID_ROOT, ? ? ?AID_SHELL, ? ? 0, "system/xbin/su" },
+ ? ?{ 06755, AID_ROOT, ? ? ?AID_SHELL, ? ? 0, "system/xbin/su" },
3.在device/rockchip/common/BoardConfig.mk中設置
BOARD_SELINUX_ENFORCING := false
4.APP調用su方法
1):創建類 ShellUtil.java
public class ShellUtil {public static void execShell(String[] cmds) {Process p = null;try {p = Runtime.getRuntime().exec("su");} catch (IOException e) {e.printStackTrace();}DataOutputStream os = new DataOutputStream(p.getOutputStream());for (String tmpCmd : cmds) {try {os.writeBytes(tmpCmd+"\n");os.flush();try {p.waitFor();} catch (InterruptedException e) {e.printStackTrace();}} catch (IOException e) {e.printStackTrace();}try {os.close();} catch (IOException e) {e.printStackTrace();}}} }2):調用代碼
String[] cmds={"reboot"}; new Thread(new Runnable() {@Overridepublic void run() {ShellUtil.execShell(cmds);} }).start();歡迎關注,有問題可以交流
總結
以上是生活随笔為你收集整理的rk3399 android 9.0 root 权限及测试应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 条件运算符 c语言,C语言 —— 条件运
- 下一篇: linux代码之atomic