本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}