本文整理汇总了Java中com.stericson.RootTools.execution.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于com.stericson.RootTools.execution包,在下文中一共展示了Command类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanDirectory
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
public void cleanDirectory() {
for (final File file : mEmulatedDirectory.listFiles()) {
Command mountCommand = new CommandCapture(0, "umount " + mMountDirectory.getAbsolutePath() + "/" + file.getName()) {
@Override
public void commandCompleted(int id, int exitcode) {
super.commandCompleted(id, exitcode);
file.delete();
}
};
try {
mRootShell.add(mountCommand);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例2: commandWait
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
private void commandWait(Command cmd) {
int waitTill = 50;
int waitTillMultiplier = 2;
int waitTillLimit = 3200; //7 tries, 6350 msec
while (!cmd.isFinished() && waitTill<=waitTillLimit) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(waitTill);
waitTill *= waitTillMultiplier;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (!cmd.isFinished()){
LogUtils.e("Could not finish root command in " + (waitTill/waitTillMultiplier));
}
}
示例3: waitForCommand
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
private static boolean waitForCommand(Command cmd)
{
while (!cmd.isFinished())
{
synchronized (cmd)
{
try
{
if (!cmd.isFinished())
{
cmd.wait(2000);
}
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
if (!cmd.isExecuting() && !cmd.isFinished())
{
// Logger.errorST("Error: Command is not executing and is not finished!");
return false;
}
}
//Logger.debug("Command Finished!");
return true;
}
示例4: getMAC
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
public static String getMAC() {
final String[] result = {"deadbebe"};
Command command = new Command(0, "busybox ip addr show dev wlan0") {
@Override
public void output(int id, String line) {
if (line.contains("link/ether")) {
String[] split = line.trim().split(" ");
System.out.println("MAC - " + split[1]);
result[0] = split[1];
}
}
};
runCmd(command);
return result[0];
}
示例5: getHost
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
public static String getHost() {
final String[] result = {"deadbebe"};
Command command = new Command(0, "getprop net.hostname") {
@Override
public void output(int id, String line) {
result[0] = line;
}
};
runCmd(command);
return result[0];
}
示例6: unmount
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
public void unmount(Shell shell, final UnmountListener listener) throws IOException {
Command mountCommand = new CommandCapture(0, "umount " + getTarget()) {
@Override
public void commandCompleted(int id, int exitcode) {
super.commandCompleted(id, exitcode);
if (exitcode == 0) {
getDevice().removeMount(Mount.this);
listener.onUnmountSuccess(Mount.this);
} else {
listener.onUnmountError(Mount.this, null);
}
}
};
shell.add(mountCommand);
}
示例7: commandWait
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
private void commandWait(Command cmd) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(2000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例8: commandWait
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
private void commandWait(Command cmd) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(2000);
}
} catch (InterruptedException ex) {
Log.e(LOG_TAG, ex.toString());
}
}
}
示例9: commandWait
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
protected void commandWait(Command cmd) throws Exception {
while (!cmd.isFinished()) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(10);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例10: CommandNoOutput
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
public static void CommandNoOutput(String Command) throws RootDeniedException , IOException, TimeoutException, InterruptedException{
CommandCapture command = new CommandCapture(0, Command);
RootTools.getShell(true).add(command).wait();
}
示例11: runShellCommand
import com.stericson.RootTools.execution.Command; //导入依赖的package包/类
/**
* Executes a given command with root access or without depending on the value of the boolean passed.
* This will also start a root shell or a standard shell without you having to open it specifically.
* <p/>
* You will still need to close the shell after you are done using the shell.
*
* @param shell The shell to execute the command on, this can be a root shell or a standard shell.
* @param command The command to execute in the shell
* @throws IOException
*/
public static void runShellCommand(Shell shell, Command command) throws IOException {
shell.add(command);
}