use of com.android.ddmlib.IShellOutputReceiver in project GT by Tencent.
the class AdbHProfDumpListener method onSuccess.
@Override
public void onSuccess(String remoteFilePath, Client client) {
synchronized (sLock) {
APTConsoleFactory.getInstance().APTPrint("onSuccess(String remoteFilePath, Client client)");
try {
APTConsoleFactory.getInstance().APTPrint("remoteFilePath=" + remoteFilePath);
String pkgName = client.getClientData().getClientDescription();
if (pkgName == null) {
pkgName = "null";
}
String filePath = getHprofFilePath(pkgName);
client.getDevice().pullFile(remoteFilePath, filePath);
client.getDevice().executeShellCommand("rm " + remoteFilePath, new IShellOutputReceiver() {
public void addOutput(byte[] data, int offset, int length) {
APTConsoleFactory.getInstance().APTPrint("addOutput");
}
public void flush() {
APTConsoleFactory.getInstance().APTPrint("flush");
}
public boolean isCancelled() {
APTConsoleFactory.getInstance().APTPrint("isCancelled");
return false;
}
});
} catch (Exception e) {
e.printStackTrace();
APTConsoleFactory.getInstance().APTPrint(e.getMessage());
}
sLock.notify();
}
}
use of com.android.ddmlib.IShellOutputReceiver in project android by JetBrains.
the class MultiUserUtilsTest method createMockDevice.
@NotNull
private static IDevice createMockDevice(@NotNull String pmListUsersOutput, @NotNull String amCurrentUserOutput) throws Exception {
IDevice device = mock(IDevice.class);
when(device.getVersion()).thenReturn(new AndroidVersion(23, null));
doAnswer(invocation -> {
String cmd = (String) invocation.getArguments()[0];
String answer = null;
if (cmd.equals("pm list users")) {
answer = pmListUsersOutput;
} else if (cmd.equals("am get-current-user")) {
answer = amCurrentUserOutput;
} else {
fail("Mock device does not support shell command: " + cmd);
}
byte[] bytes = answer.getBytes(Charsets.UTF_8);
IShellOutputReceiver receiver = (IShellOutputReceiver) invocation.getArguments()[1];
receiver.addOutput(bytes, 0, bytes.length);
receiver.flush();
return null;
}).when(device).executeShellCommand(anyString(), anyObject());
return device;
}
Aggregations