当前位置: 首页>>代码示例>>Java>>正文


Java Shell.add方法代码示例

本文整理汇总了Java中com.stericson.RootShell.execution.Shell.add方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.add方法的具体用法?Java Shell.add怎么用?Java Shell.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.stericson.RootShell.execution.Shell的用法示例。


在下文中一共展示了Shell.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enableUMS

import com.stericson.RootShell.execution.Shell; //导入方法依赖的package包/类
boolean enableUMS(Context context) {
    try {
        String enableCommand = data.getString(Constants.setPermissionCmds, "")+"\n"+data.getString(Constants.enableUMScmds, "");
        if(enableCommand.isEmpty()) {
            Toast.makeText(context, context.getString(R.string.toast_open_app_once), Toast.LENGTH_SHORT).show();
            return false;
        }
        Shell rootShell = RootTools.getShell(true);
        Command cmd = new Command(0, "setenforce 0\n"+enableCommand);
        rootShell.add(cmd);
        //if(!rootShell.isExecuting) rootShell.close();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(context, context.getString(R.string.error_ums), Toast.LENGTH_SHORT).show();
        openApp(context);
        return false;
    }
    Toast.makeText(context, context.getString(R.string.toast_ums_enabled), Toast.LENGTH_SHORT).show();
    isUMSdisabled = false;
    showNotification(context);
    return true;
}
 
开发者ID:GokulNC,项目名称:USB_Mass_Storage_Enabler,代码行数:23,代码来源:UsbBroadcastReceiver.java

示例2: disableUMS

import com.stericson.RootShell.execution.Shell; //导入方法依赖的package包/类
boolean disableUMS(Context context, boolean removeNotif) {
    try {
        String disableCommand = data.getString(Constants.disableUMScmds, "");
        if(disableCommand.isEmpty()) {
            Toast.makeText(context, context.getString(R.string.toast_open_app_once), Toast.LENGTH_SHORT).show();
            return false;
        }
        Shell rootShell = RootTools.getShell(true);
        Command cmd = new Command(0, disableCommand);
        rootShell.add(cmd);
        //if(!rootShell.isExecuting) rootShell.close();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(context, context.getString(R.string.error_ums_disable), Toast.LENGTH_SHORT).show();
        return false;
    }
    Toast.makeText(context, context.getString(R.string.toast_ums_disabled), Toast.LENGTH_SHORT).show();
    isUMSdisabled = true;
    if(removeNotif) removeNotification(context);
    else showNotification(context);
    //TODO: if(MainActivity.isAppOpen) MainActivity.updateUSBconfig(); //When toggled from notif
    return true;
}
 
开发者ID:GokulNC,项目名称:USB_Mass_Storage_Enabler,代码行数:24,代码来源:UsbBroadcastReceiver.java

示例3: runAndWait

import com.stericson.RootShell.execution.Shell; //导入方法依赖的package包/类
public static ExecutionResult runAndWait(String cmd, Shell shell, boolean exceptionOnFailure) throws IOException
{
	Logger.debug("Run&Wait: " + cmd);

	CommandCapture cc = new CommandCapture(0, cmd);
	shell.add(cc);

	if (!waitForCommand(cc))
	{
		throw new IOException(String.format("Error waiting for command to finish executing {%s}", cmd));
	}

	if (exceptionOnFailure && cc.getExitCode() != 0)
	{
		throw new IOException(String.format("Unsuccessful exit code (%d) when executing command {%s}", cc.getExitCode(), cmd));
	}

	return new ExecutionResult(cc.toString(), cc.getExitCode());
}
 
开发者ID:JohnNPhillips,项目名称:HistoryCleanerPro,代码行数:20,代码来源:RootHelper.java

示例4: getMounts

import com.stericson.RootShell.execution.Shell; //导入方法依赖的package包/类
/**
 * This will return an ArrayList of the class Mount. The class mount contains the following
 * property's: device mountPoint type flags
 * <p/>
 * These will provide you with any information you need to work with the mount points.
 *
 * @return <code>ArrayList<Mount></code> an ArrayList of the class Mount.
 * @throws Exception if we cannot return the mount points.
 */
public ArrayList<Mount> getMounts() throws Exception {

    InternalVariables.mounts = new ArrayList<>();

    if (null == InternalVariables.mounts || InternalVariables.mounts.isEmpty()) {
        Shell shell = RootTools.getShell(true);

        Command cmd = new Command(Constants.GET_MOUNTS,
                false,
                "cat /proc/mounts") {

            @Override
            public void commandOutput(int id, String line) {
                if (id == Constants.GET_MOUNTS) {
                    RootTools.log(line);

                    String[] fields = line.split(" ");
                    InternalVariables.mounts.add(new Mount(new File(fields[0]), // device
                            new File(fields[1]), // mountPoint
                            fields[2], // fstype
                            fields[3] // flags
                    ));
                }

                super.commandOutput(id, line);
            }
        };
        shell.add(cmd);
        this.commandWait(shell, cmd);
    }

    return InternalVariables.mounts;
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:43,代码来源:RootToolsInternalMethods.java

示例5: runShellCommand

import com.stericson.RootShell.execution.Shell; //导入方法依赖的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);
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:14,代码来源:RootTools.java


注:本文中的com.stericson.RootShell.execution.Shell.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。