• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Shell类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getInode

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * This method will return the inode number of a file. This method is dependent on having a version of
 * ls that supports the -i parameter.
 *
 * @param file path to the file that you wish to return the inode number
 * @return String The inode number for this file or "" if the inode number could not be found.
 */
public String getInode(String file) {
    try {
        CommandCapture command = new CommandCapture(Constants.GI, false, "/data/local/ls -i " + file) {

            @Override
            public void output(int id, String line) {
                if (id == Constants.GI) {
                    if (!line.trim().equals("") && Character.isDigit((char) line.trim().substring(0, 1).toCharArray()[0])) {
                        InternalVariables.inode = line.trim().split(" ")[0];
                    }
                }
            }
        };
        Shell.startRootShell().add(command);
        commandWait(Shell.startRootShell(), command);

        return InternalVariables.inode;
    } catch (Exception ignore) {
        return "";
    }
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:29,代码来源:RootToolsInternalMethods.java


示例2: getShell

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * The shell is set by BrowserPagerActivity and is released when BrowserPagerActivity
 * is destroyed.
 * Returns current global shell. If current shell is non-root, but root shell is requested,
 * it will ask for root shell every #REASK_FOR_ROOT_SHELL_THRESHOLD calls.
 *
 * @return shell shared Shell instance
 */
@Nullable
private Shell getShell() {
    synchronized (mShellLock) {
        final boolean suEnabled = Settings.getInstance().isSuEnabled();
        if (suEnabled && mShell != null && !mIsRootShell) {
            if (mSkipReaskForRootShellCount >= REASK_FOR_ROOT_SHELL_THRESHOLD) {
                mSkipReaskForRootShellCount = 0;
                final Pair<Boolean, Shell> result = ShellFactory.getRootShell();
                applyResult(result);
            } else {
                mSkipReaskForRootShellCount++;
            }
        }
        if (!suEnabled && mShell != null && mIsRootShell) {
            openNewShell();
            mSkipReaskForRootShellCount = REASK_FOR_ROOT_SHELL_THRESHOLD;
        }
        if (mShell == null || !Shell.isAnyShellOpen()) {
            openNewShell();
            mSkipReaskForRootShellCount = REASK_FOR_ROOT_SHELL_THRESHOLD;
        }
        return mShell;
    }
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:33,代码来源:ShellHolder.java


示例3: runTest

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
@Override
protected void runTest() throws Throwable {
    super.runTest();

    // init what application inits
    final Context context = getInstrumentation().getContext();
    final Settings settings = Settings.getInstance(context);
    com.docd.purefm.Environment.init((Application) context.getApplicationContext());
    PFMTextUtils.init(context);
    final Shell shell = ShellHolder.getShell();
    assertNotNull(shell);

    // override settings to force our test busybox
    if (!com.docd.purefm.Environment.hasBusybox()) {
        throw new RuntimeException("install busybox on a device before running this test");
    }
    settings.setUseCommandLine(true, false);

    testAgainstJavaIoFile(shell, settings);
    testFileReading(shell, settings);
    testFileDeletion(shell, settings);
    testFileCreation(shell, settings);
    testMkdir(shell, settings);
    testMkdirs(shell, settings);
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:26,代码来源:CommandLineFileTest.java


示例4: getInode

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * This method will return the inode number of a file. This method is dependent on having a version of
 * ls that supports the -i parameter.
 *
 * @param file path to the file that you wish to return the inode number
 * @return String The inode number for this file or "" if the inode number could not be found.
 */
public String getInode(String file) {
    try {
        CommandCapture command = new CommandCapture(Constants.GI, false, "/data/local/ls -i " + file) {

            @Override
            public void output(int id, String line) {
                if (id == Constants.GI) {
                    if (!line.trim().equals("") && Character.isDigit((char) line.trim().substring(0, 1).toCharArray()[0])) {
                        InternalVariables.inode = line.trim().split(" ")[0];
                    }
                }
            }
        };
        Shell.startRootShell().add(command);
        commandWait(command);

        return InternalVariables.inode;
    } catch (Exception ignore) {
        return "";
    }
}
 
开发者ID:cernekee,项目名称:ics-openconnect,代码行数:29,代码来源:RootToolsInternalMethods.java


示例5: initBamboo

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
private void initBamboo() {
    try {
        Shell shell = RootTools.getShell(true);
        shell.useCWD(this);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                + " init") {
        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Fusion,项目名称:BambooGarden,代码行数:18,代码来源:Garden.java


示例6: createNewBamboo

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
private void createNewBamboo(final BambooInfo bamboo) {
    try {
        Shell shell = RootTools.getShell(true);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                + " create "
                + bamboo.getName()) {
        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Fusion,项目名称:BambooGarden,代码行数:18,代码来源:Garden.java


示例7: updateBambooColor

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
protected void updateBambooColor(BambooInfo bamboo, int color) {
    try {
        Shell shell = RootTools.getShell(true);
        JavaCommandCapture cmd = new JavaCommandCapture(
                43,
                false,
                Garden.this,
                "com.voilaweb.mobile.bamboogarden.RootHelper"
                        + " color "
                        + bamboo.getName()
                        + " " + color) {

            @Override
            public void commandCompleted(int id, int exitCode) {
                super.commandCompleted(id, exitCode);
                refreshBambooGarden();
            }

        };
        shell.add(cmd);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Fusion,项目名称:BambooGarden,代码行数:26,代码来源:Garden.java


示例8: deleteBamboo

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
private void deleteBamboo(final BambooInfo bamboo) {
    if(bamboo != null) {
        try {
            Shell shell = RootTools.getShell(true);
            JavaCommandCapture cmd = new JavaCommandCapture(
                    43,
                    false,
                    Garden.this,
                    "com.voilaweb.mobile.bamboogarden.RootHelper"
                            + " delete "
                            + bamboo.getName()) {

                @Override
                public void commandCompleted(int id, int exitCode) {
                    super.commandCompleted(id, exitCode);
                    refreshBambooGarden();
                }

            };
            shell.add(cmd);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:Fusion,项目名称:BambooGarden,代码行数:27,代码来源:Garden.java


示例9: BlockDeviceObserver

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * Creates a new block device observer.
 * Does not start observing until {@link #startWatching()} is called.
 * @param rootShell The shell to execute mount commands in.
 * @param listener A listener to receive block device events.
 *                 Calls are received on the main thread.
 */
public BlockDeviceObserver(Shell rootShell, PartitionListener listener) {
    super("/dev/block/", FileObserver.CREATE | FileObserver.DELETE);
    mVolumes = new HashMap<String, Volume>();
    mListener = listener;
    mHandler = new Handler(Looper.getMainLooper());
    mRootShell = rootShell;
    detectDevices();
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:16,代码来源:BlockDeviceObserver.java


示例10: unmount

import com.stericson.RootTools.execution.Shell; //导入依赖的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);
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:16,代码来源:Mount.java


示例11: Automounter

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * Creates a new automounter.
 * Must be registered to a {@link com.morlunk.mountie.fs.BlockDeviceObserver} in order to automount.
 * @param rootShell A root shell to execute mount commands in.
 * @param dirName The name of the directory to mount in on external storage.
 * @param mountListener A listener for newly automounted devices.
 * @param unmountListener A listener for unmounted automounted devices.
 */
public Automounter(Shell rootShell, String dirName, MountListener mountListener, UnmountListener unmountListener) {
    mRootShell = rootShell;
    mEmulatedDirectory = new File(Environment.getExternalStorageDirectory(), dirName);
    mMountDirectory = new File(DATA_DIR, dirName);
    mMountListener = mountListener;
    mUnmountListener = unmountListener;
    mMounts = new HashSet<Mount>();
    cleanDirectory(); // Treat directory like a tmpfs and delete+unmount contents.
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:18,代码来源:Automounter.java


示例12: closeShell

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * This will close either the root shell or the standard shell depending on what you specify.
 *
 * @param root a <code>boolean</code> to specify whether to close the root shell or the standard shell.
 * @throws IOException
 */
public static void closeShell(boolean root) throws IOException {
    if (root)
        Shell.closeRootShell();
    else
        Shell.closeShell();
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:13,代码来源:RootTools.java


示例13: getBusyBoxApplets

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * This will return an List of Strings. Each string represents an applet available from BusyBox.
 * <p/>
 *
 * @param path Path to the busybox binary that you want the list of applets from.
 * @return <code>null</code> If we cannot return the list of applets.
 */
public List<String> getBusyBoxApplets(String path) throws Exception {

    if (path != null && !path.endsWith("/") && !path.equals("")) {
        path += "/";
    } else if (path == null) {
        //Don't know what the user wants to do...what am I pshycic?
        throw new Exception("Path is null, please specifiy a path");
    }

    final List<String> results = new ArrayList<String>();

    CommandCapture command = new CommandCapture(Constants.BBA, false, path + "busybox --list") {

        @Override
        public void output(int id, String line) {
            if (id == Constants.BBA) {
                if (!line.trim().equals("") && !line.trim().contains("not found")) {
                    results.add(line);
                }
            }
        }
    };

    //try without root first...
    Shell.startShell().add(command);
    commandWait(Shell.startShell(), command);

    if(results.size() <= 0) {
        //try with root...
        Shell.startRootShell().add(command);
        commandWait(Shell.startRootShell(), command);
    }
    
    return results;
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:43,代码来源:RootToolsInternalMethods.java


示例14: isAccessGiven

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * @return <code>true</code> if your app has been given root access.
 * @throws TimeoutException if this operation times out. (cannot determine if access is given)
 */
public boolean isAccessGiven() {
    try {
        RootTools.log("Checking for Root access");
        InternalVariables.accessGiven = false;

        CommandCapture command = new CommandCapture(Constants.IAG, false, "id") {
            @Override
            public void output(int id, String line) {
                if (id == Constants.IAG) {
                    Set<String> ID = new HashSet<String>(Arrays.asList(line.split(" ")));
                    for (String userid : ID) {
                        RootTools.log(userid);

                        if (userid.toLowerCase().contains("uid=0")) {
                            InternalVariables.accessGiven = true;
                            RootTools.log("Access Given");
                            break;
                        }
                    }
                    if (!InternalVariables.accessGiven) {
                        RootTools.log("Access Denied?");
                    }
                }
            }
        };
        Shell.startRootShell().add(command);
        commandWait(Shell.startRootShell(), command);

        return InternalVariables.accessGiven;

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:acomminos,项目名称:Mountie,代码行数:40,代码来源:RootToolsInternalMethods.java


示例15: runCommand

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
private static CommandResult runCommand(String command) throws IOException, CommandException
{
    final WaitCommand cmd = new WaitCommand(command);
    final Shell shell = Shell.getOpenShell();
    if (shell == null) throw new NullPointerException("Must start a shell before adding a command.");
    shell.add(cmd);
    final CommandResult result = cmd.waitForFinish();

    CommandNotFoundException.throwIfNotFound(result);
    if (result.terminated) throw new CommandException(result);

    return result;
}
 
开发者ID:Takhion,项目名称:android-tetheringfixer,代码行数:14,代码来源:Fixer.java


示例16: setSettingForce

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
public void setSettingForce(String path, String value) throws Exception {
	Shell shell = RootTools.getShell(true);
	
	CommandCapture command = new CommandCapture(0, "chmod 777 " + path);
	shell.add(command);
	commandWait(command);

	try {
		CommandCapture command2 = new CommandCapture(0, "echo " + value + " > " + path);
		shell.add(command2);
		commandWait(command2);
	} catch (Exception e) {
	}
}
 
开发者ID:shaun2029,项目名称:Multi-Core-Control,代码行数:15,代码来源:SysfsInterface.java


示例17: setFilePermissions

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
protected int setFilePermissions(Shell shell, String permissions, String file) throws Exception{
	if (shell == null) shell = RootTools.getShell(true);

	CommandCapture command = new CommandCapture(0, "chmod " + permissions + " " + file);
	shell.add(command);
	commandWait(command);
	
	return command.getExitCode();
}
 
开发者ID:shaun2029,项目名称:Multi-Core-Control,代码行数:10,代码来源:SysfsInterface.java


示例18: getRootShell

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
@Nullable
static Pair<Boolean, Shell> getRootShell() {
    try {
        return new Pair<>(true, RootTools.getShell(true));
    } catch (IOException | RootDeniedException | TimeoutException e) {
        return null;
    }
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:9,代码来源:ShellFactory.java


示例19: execute

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
public boolean execute(@NonNull final Command command) {
    final Shell shell = getShell();
    if (shell == null) {
        Log.w("ShellHolder", "No shell. Execution aborted.");
        return false;
    }
    try {
        shell.add(command);
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:15,代码来源:ShellHolder.java


示例20: openNewShell

import com.stericson.RootTools.execution.Shell; //导入依赖的package包/类
/**
 * Opens new shell. This method is called from {@link #getShell()} and is already synchronized
 * with {@link #mShellLock}
 */
private void openNewShell() {
    try {
        final Pair<Boolean, Shell> result = ShellFactory.getShell();
        applyResult(result);
    } catch (IOException e) {
        Log.w("getShell() error:", e);
    }
}
 
开发者ID:Doctoror,项目名称:Pure-File-Manager,代码行数:13,代码来源:ShellHolder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IBk类代码示例发布时间:2022-05-21
下一篇:
Java Consul类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap