本文整理汇总了Java中eu.chainfire.libsuperuser.Shell.run方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.run方法的具体用法?Java Shell.run怎么用?Java Shell.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.chainfire.libsuperuser.Shell
的用法示例。
在下文中一共展示了Shell.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
public boolean execute() {
MyLog.entry();
logs = Shell.run("su", commands, null, true);
boolean result;
if (logs == null) {
result = false;
} else {
for (final String line : logs) {
MyLog.debug(" - " + line);
}
result = true;
}
MyLog.exit();
return result;
}
示例2: runCommand
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
/**
* Run a given command with the classpath from a given context
* @param su should it be run with su?
* @param uid the uid to run under
* @param codePath path to dex file
* @param command command string {@see #getCommandLineForMainClass}
* @return command output
*/
public static List<String> runCommand(boolean su, int uid, String codePath, String command) {
String shell = "sh";
if (su) {
if (!Shell.SU.available()) {
throw new RuntimeException("su not available!");
}
shell = "su";
}
if (uid > 0) {
command = String.format("%d %s", uid, command);
}
return Shell.run(shell, new String[]{command}, new String[]{String.format("CLASSPATH=%s", codePath)}, true);
}
示例3: runSuCommand
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
public static void runSuCommand(String[] cmds, String selinuxContext) {
if (!TextUtils.isEmpty(selinuxContext) && isSELinuxEnforced()) {
String shell = Shell.SU.shell(0, selinuxContext);
Shell.run(shell, cmds, null, false, false);
} else {
Shell.run("su", cmds, null, false, false);
}
}
示例4: runSuCommand
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
public static void runSuCommand(String[] cmds, String selinuxContext) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
|| TextUtils.isEmpty(selinuxContext)) {
Shell.SU.run(cmds);
} else {
String shell = Shell.SU.shell(0, selinuxContext);
Shell.run(shell, cmds, null, false);
}
}
示例5: runSuCommand
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
public static void runSuCommand(String[] cmds, String selinuxContext) {
if (!TextUtils.isEmpty(selinuxContext) && isSELinuxEnforced()) {
String shell = Shell.SU.shell(0, selinuxContext);
Shell.run(shell, cmds, null, false, true);
} else {
Shell.SU.run(cmds);
}
}
示例6: doInBackground
import eu.chainfire.libsuperuser.Shell; //导入方法依赖的package包/类
@Override
protected String doInBackground(String... cmdArgs) {
checkFilesystem();
String command[] = mCommandList.toArray(new String[mCommandList.size()]);
String shell = enableSU ? "su" : "sh";
List<String> res = Shell.run(shell, command, null, true);
for (String queryRes : res)
publishProgress(queryRes);
publishProgress(COMMAND_EXECUTED);
return null;
}