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


Java NormalShell类代码示例

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


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

示例1: getRunningProcesses

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
@WorkerThread public static List<Process> getRunningProcesses() {
    final List<Process> processes = new ArrayList<>();

    final NormalShell normalShell = ShellManager.get().getNormalShell();
    if (normalShell != null) {
        final Command command = new Command("toolbox ps -p -P -x -c") {
            @Override public void onCommandOutput(int id, String line) {
                super.onCommandOutput(id, line);
                try {
                    processes.add(new Process(line));
                } catch (Exception ignored) { }
            }
        };
        normalShell.add(command);
        command.waitFor();
    }
    return processes;
}
 
开发者ID:amartinz,项目名称:HardwareLibrary,代码行数:19,代码来源:ProcessManager.java

示例2: getInstalledPackagesShell

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
@DebugLog @NonNull private List<PackageInfo> getInstalledPackagesShell(PackageManager pm) {
    final List<PackageInfo> pkgInfos = new ArrayList<>();
    final List<String> cmdResultList = NormalShell.fireAndBlockList("pm list packages");
    if (cmdResultList != null && !cmdResultList.isEmpty()) {
        for (final String cmdResult : cmdResultList) {
            if (TextUtils.isEmpty(cmdResult)) {
                continue;
            }
            final String pkgName = cmdResult.substring(cmdResult.indexOf(":") + 1);
            try {
                final PackageInfo pkgInfo = pm.getPackageInfo(pkgName, 0);
                pkgInfos.add(pkgInfo);
            } catch (Exception ignored) { }
        }
    }
    return pkgInfos;
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:18,代码来源:BaseAppListFragment.java

示例3: getRunningApps

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
@WorkerThread public static List<Process> getRunningApps() {
    final List<Process> processes = new ArrayList<>();

    final NormalShell normalShell = ShellManager.get().getNormalShell();
    if (normalShell != null) {
        final int myPid = android.os.Process.myPid();
        final Command command = new Command("toolbox ps -p -P -x -c") {
            @Override public void onCommandOutput(int id, String line) {
                super.onCommandOutput(id, line);
                Process process;
                try {
                    process = new Process(line);
                } catch (Exception ignored) {
                    return;
                }
                if (process.user.matches(APP_ID_PATTERN)) {
                    if (process.ppid == myPid || process.name.equals("toolbox")) {
                        // skip the processes we created to get the running apps.
                        return;
                    }
                    processes.add(process);
                }
            }
        };
        normalShell.add(command);
        command.waitFor();
    }

    return processes;
}
 
开发者ID:amartinz,项目名称:HardwareLibrary,代码行数:31,代码来源:ProcessManager.java

示例4: getProp

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
@Nullable private static String getProp(String property, String defaultValue) {
    final String result = NormalShell.fireAndBlockString(getPropCommand(property));
    if (TextUtils.isEmpty(result)) {
        return defaultValue;
    }
    return result.trim();
}
 
开发者ID:amartinz,项目名称:HardwareLibrary,代码行数:8,代码来源:KnoxInformation.java

示例5: getUidFromPidPerStat

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
public static int getUidFromPidPerStat(int pid) {
    final String path = String.format("/proc/%s", pid);
    final String cmd = String.format("stat -c %%u %s", path);
    final String result = NormalShell.fireAndBlockString(cmd);

    if (!TextUtils.isEmpty(result)) {
        try {
            return Integer.parseInt(result.trim());
        } catch (NumberFormatException ignored) { }
    }
    return INVALID;
}
 
开发者ID:amartinz,项目名称:ExecutionLibrary,代码行数:13,代码来源:ProcessHelper.java

示例6: readFileViaShell

import at.amartinz.execution.NormalShell; //导入依赖的package包/类
public static String readFileViaShell(final String filePath, final boolean useSu) {
    final Command command = new Command(String.format("cat %s;", filePath));
    return useSu ? RootShell.fireAndBlockString(command) : NormalShell.fireAndBlock(command);
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:5,代码来源:Utils.java


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