本文整理匯總了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;
}