zoukankan      html  css  js  c++  java
  • 软件申请获取root权限

     

    申请root的工具类

    //获取root权限
            RootManager manager=new RootManager();
            manager.upgradeRootPermission(getPackageCodePath());
    public class RootManager {
    
        /**
         * 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
         * 
         * @return 应用程序是/否获取Root权限
         */
        public boolean upgradeRootPermission(String pkgCodePath) {
            Process process = null;
            DataOutputStream os = null;
            try {
                String cmd="chmod 777 " + pkgCodePath;
                process = Runtime.getRuntime().exec("su"); //切换到root帐号
                os = new DataOutputStream(process.getOutputStream());
                os.writeBytes(cmd + "
    ");
                os.writeBytes("exit
    ");
                os.flush();
                process.waitFor();
            } catch (Exception e) {
                return false;
            } finally {
                try {
                    if (os != null) {
                        os.close();
                    }
                    process.destroy();
                } catch (Exception e) {
                }
            }
            return true;
        }
    
    }
  • 相关阅读:
    REP开发技巧
    css grid栅格布局
    flex学习, 尝试布局一个计算器
    sublime text html插件emmet
    flex布局
    SQL Server为字段添加默认值
    windows和linux文件输
    python eric6 IDE
    git撤销修改
    pyQt5
  • 原文地址:https://www.cnblogs.com/yejiurui/p/3256512.html
Copyright © 2011-2022 走看看