本文整理汇总了Java中com.facebook.stetho.dumpapp.DumperContext类的典型用法代码示例。如果您正苦于以下问题:Java DumperContext类的具体用法?Java DumperContext怎么用?Java DumperContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DumperContext类属于com.facebook.stetho.dumpapp包,在下文中一共展示了DumperContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
/**
* Entry point for the Stetho dumpapp script.
*
* {@link #initialize} must have been called in the app before running dumpapp.
*/
@Override
public void dump(DumperContext dumpContext) throws DumpException {
ensureInitialized();
List<String> args = dumpContext.getArgsAsList();
PrintStream writer = dumpContext.getStdout();
String cmd = args.isEmpty() ? null : args.get(0);
List<String> rest = args.isEmpty() ? new ArrayList<String>() : args.subList(1, args.size());
if (cmd != null && cmd.equals("memcache")) {
memcache(writer, rest);
} else if (cmd != null && cmd.equals("diskcache")) {
diskcache(mMainFileCache, "Main", writer, rest);
diskcache(mSmallFileCache, "Small", writer, rest);
} else {
usage(writer);
if (TextUtils.isEmpty(cmd)) {
throw new DumpUsageException("Missing command");
} else {
throw new DumpUsageException("Unknown command: " + cmd);
}
}
}
示例2: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(argsIter, null);
if ("throw".equals(command)) {
doUncaughtException(argsIter);
} else if ("kill".equals(command)) {
doKill(dumpContext, argsIter);
} else if ("exit".equals(command)) {
doSystemExit(argsIter);
} else {
doUsage(dumpContext.getStdout());
if (command != null) {
throw new DumpUsageException("Unsupported command: " + command);
}
}
}
示例3: doKill
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
private void doKill(DumperContext dumpContext, Iterator<String> argsIter) throws DumpException {
String signal = ArgsHelper.nextOptionalArg(argsIter, OPTION_KILL_DEFAULT);
try {
Process kill = new ProcessBuilder()
.command("/system/bin/kill", "-" + signal, String.valueOf(android.os.Process.myPid()))
.redirectErrorStream(true)
.start();
// Handle kill command output gracefully in the event that the signal delivered didn't
// actually take out our process...
try {
InputStream in = kill.getInputStream();
Util.copy(in, dumpContext.getStdout(), new byte[1024]);
} finally {
kill.destroy();
}
} catch (IOException e) {
throw new DumpException("Failed to invoke kill: " + e);
}
}
示例4: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
final PrintStream output = dumpContext.getStdout();
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String outputPath = argsIter.hasNext() ? argsIter.next() : null;
if (outputPath == null) {
usage(output);
} else {
if ("-".equals(outputPath)) {
handlePipeOutput(output);
} else {
File outputFile = new File(outputPath);
if (!outputFile.isAbsolute()) {
outputFile = mContext.getFileStreamPath(outputPath);
}
writeHprof(outputFile);
output.println("Wrote to " + outputFile);
}
}
}
示例5: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
Iterator<String> args = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(args, "");
if ("ls".equals(command)) {
doLs(dumpContext.getStdout());
} else if ("tree".equals(command)) {
doTree(dumpContext.getStdout());
} else if ("download".equals(command)) {
doDownload(dumpContext.getStdout(), args);
} else {
doUsage(dumpContext.getStdout());
if (!"".equals(command)) {
throw new DumpUsageException("Unknown command: " + command);
}
}
}
示例6: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
PrintStream writer = dumpContext.getStdout();
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(argsIter, null);
if (CMD_LIST.equalsIgnoreCase(command)) {
doList(writer);
} else if (CMD_DELETE.equalsIgnoreCase(command)) {
doRemove(writer, argsIter);
} else if (CMD_CLEAR.equalsIgnoreCase(command)) {
doClear(writer);
} else if (CMD_REFRESH.equalsIgnoreCase(command)) {
doRefresh(writer);
} else {
usage(writer);
if (command != null) {
throw new DumpUsageException("Unknown command: " + command);
}
}
}
示例7: dumpTypeMap
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
private void dumpTypeMap(DumperContext dumperContext, InfoDumper dumper) throws DumpException {
PrintStream writer = dumperContext.getStdout();
if (mIsAll) {
writer.println("[" + dumper.getTitle() + "]");
}
LinkedHashMap<String, String> dumps = dumper.getDumpMap(mContext);
if (dumps == null) {
writer.println(dumper.getErrorMessage());
if (mIsAll) {
writer.println("");
}
return;
}
for (Map.Entry<String, String> e : dumps.entrySet()) {
writer.println(e.getKey() + ": " + e.getValue());
}
if (mIsAll) {
writer.println("");
}
}
示例8: dumpTypeList
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
private void dumpTypeList(DumperContext dumperContext, InfoDumper dumper) throws DumpException {
PrintStream writer = dumperContext.getStdout();
if (mIsAll) {
writer.println("[" + dumper.getTitle() + "]");
}
List<String> dumps = dumper.getDumpList(mContext);
if (dumps == null) {
writer.println(dumper.getErrorMessage());
if (mIsAll) {
writer.println("");
}
return;
}
for (String dump : dumps) {
writer.println(dump);
}
if (mIsAll) {
writer.println("");
}
}
示例9: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
PrintStream writer = dumpContext.getStdout();
Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(argsIter, null);
if (CMD_LIST.equalsIgnoreCase(command)) {
doList(writer);
} else if (CMD_DELETE.equalsIgnoreCase(command)) {
doRemove(writer, argsIter);
} else if (CMD_CLEAR.equalsIgnoreCase(command)) {
doClear(writer);
} else if (CMD_REFRESH.equalsIgnoreCase(command)) {
doRefresh(writer);
} else {
usage(writer);
if (command != null) {
throw new DumpUsageException("Unknown command: " + command);
}
}
}
示例10: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
Iterator<String> args = dumpContext.getArgsAsList().iterator();
String command = ArgsHelper.nextOptionalArg(args, "");
if ("download".equals(command)) {
doDownload(dumpContext.getStdout(), args);
} else {
doUsage(dumpContext.getStdout());
if (!"".equals(command)) {
throw new DumpUsageException("Unknown command: " + command);
}
}
}
示例11: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
final PrintStream writer = dumpContext.getStdout();
List<String> args = dumpContext.getArgsAsList();
String commandName = args.isEmpty() ? "" : args.remove(0);
switch (commandName) {
case "alarms":
displayAlarms(writer);
break;
case "appInfo":
displayAppInfo(writer);
break;
case "bootReceiver":
displayBootReceiverState(writer);
break;
case "currentSession":
displayCurrentSessionData(writer);
break;
case "endpoint":
changeEndpoint(writer, args);
break;
case "notif":
displayNotificationReminder();
break;
default:
doUsage(writer);
break;
}
}
示例12: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpUsageException {
PrintStream writer = dumpContext.getStdout();
List<String> args = dumpContext.getArgsAsList();
String commandName = args.isEmpty() ? "" : args.remove(0);
if (commandName.equals("print")) {
doPrint(writer, args);
} else if (commandName.equals("write")) {
doWrite(args);
} else {
doUsage(writer);
}
}
示例13: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
PrintStream writer = dumpContext.getStdout();
Iterator<String> args = dumpContext.getArgsAsList().iterator();
String helloToWhom = ArgsHelper.nextOptionalArg(args, null);
if (helloToWhom != null) {
doHello(dumpContext.getStdin(), writer, helloToWhom);
} else {
doUsage(writer);
}
}
示例14: usage
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
private void usage(DumperContext dumperContext) {
PrintStream writer = dumperContext.getStdout();
final String cmdName = "dumpapp " + NAME;
final String usagePrefix = "Usage: " + cmdName + " ";
writer.println(usagePrefix + "<command>");
writer.print(usagePrefix + CMD_BUILD_CONFIG);
writer.println();
writer.print(usagePrefix + CMD_ID);
writer.println();
writer.print(usagePrefix + CMD_DPI);
writer.println();
writer.print(usagePrefix + CMD_MEMORY);
writer.println();
writer.print(usagePrefix + CMD_PERMISSION);
writer.println();
writer.print(usagePrefix + CMD_LAST_UPDATE);
writer.println();
writer.print(usagePrefix + CMD_APPLICATION_INFO);
writer.println();
writer.print(usagePrefix + CMD_OS_BUILD);
writer.println();
writer.print(usagePrefix + CMD_NETWORK);
writer.println();
writer.print(usagePrefix + CMD_ERROR);
writer.println();
writer.print(usagePrefix + CMD_TEL);
writer.println();
writer.print(usagePrefix + CMD_ALL);
writer.println();
}
示例15: dump
import com.facebook.stetho.dumpapp.DumperContext; //导入依赖的package包/类
@Override
public void dump(DumperContext dumpContext) throws DumpException {
PrintStream writer = dumpContext.getStdout();
Iterator<String> args = dumpContext.getArgsAsList().iterator();
String helloToWhom = ArgsHelper.nextOptionalArg(args, null);
if (helloToWhom != null) {
doHello(dumpContext.getStdin(), writer, helloToWhom);
} else {
doUsage(writer);
}
}