本文整理汇总了Java中com.android.ddmlib.log.LogReceiver.parseNewData方法的典型用法代码示例。如果您正苦于以下问题:Java LogReceiver.parseNewData方法的具体用法?Java LogReceiver.parseNewData怎么用?Java LogReceiver.parseNewData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.ddmlib.log.LogReceiver
的用法示例。
在下文中一共展示了LogReceiver.parseNewData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runLocalEventLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs an event log service out of a local file.
* @param fileName the full file name of the local file containing the event log.
* @param logReceiver the receiver that will handle the log
* @throws IOException
*/
@WorkerThread
private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
throws IOException {
byte[] buffer = new byte[256];
FileInputStream fis = new FileInputStream(fileName);
try {
int count;
while ((count = fis.read(buffer)) != -1) {
logReceiver.parseNewData(buffer, 0, count);
}
} finally {
fis.close();
}
}
示例2: runLocalEventLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs an event log service out of a local file.
* @param fileName the full file name of the local file containing the event log.
* @param logReceiver the receiver that will handle the log
* @throws IOException
*/
@WorkerThread
private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
throws IOException {
byte[] buffer = new byte[256];
FileInputStream fis = new FileInputStream(fileName);
int count;
while ((count = fis.read(buffer)) != -1) {
logReceiver.parseNewData(buffer, 0, count);
}
}
示例3: runLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs a log service on the {@link com.android.ddmlib.Device}, and provides its output to the {@link LogReceiver}.
* <p/>This call is blocking until {@link LogReceiver#isCancelled()} returns true.
*
* @param adbSockAddr the socket address to connect to adb
* @param device the Device on which to run the service
* @param logName the name of the log file to output
* @param rcvr the {@link LogReceiver} to receive the log output
* @throws TimeoutException in case of timeout on the connection.
* @throws AdbCommandRejectedException if adb rejects the command
* @throws IOException in case of I/O error on the connection.
*/
static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName, LogReceiver rcvr)
throws TimeoutException, AdbCommandRejectedException, IOException {
SocketChannel adbChan = null;
try {
adbChan = SocketChannel.open(adbSockAddr);
adbChan.configureBlocking(false);
// if the device is not -1, then we first tell adb we're looking to talk
// to a specific device
setDevice(adbChan, device);
byte[] request = formAdbRequest("log:" + logName);
write(adbChan, request);
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
if (!resp.okay) {
throw new AdbCommandRejectedException(resp.message);
}
byte[] data = new byte[16384];
ByteBuffer buf = ByteBuffer.wrap(data);
while (true) {
int count;
if (rcvr != null && rcvr.isCancelled()) {
break;
}
count = adbChan.read(buf);
if (count < 0) {
break;
} else if (count == 0) {
try {
Thread.sleep(WAIT_TIME * 5);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
// Throw a timeout exception in place of interrupted exception to avoid API changes.
throw new TimeoutException(
"runLogService interrupted with immediate timeout via interruption.");
}
} else {
if (rcvr != null) {
rcvr.parseNewData(buf.array(), buf.arrayOffset(), buf.position());
}
buf.rewind();
}
}
} finally {
if (adbChan != null) {
//noinspection ThrowFromFinallyBlock
adbChan.close();
}
}
}
示例4: runLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs a log service on the {@link Device}, and provides its output to the {@link LogReceiver}.
* <p/>This call is blocking until {@link LogReceiver#isCancelled()} returns true.
* @param adbSockAddr the socket address to connect to adb
* @param device the Device on which to run the service
* @param logName the name of the log file to output
* @param rcvr the {@link LogReceiver} to receive the log output
* @throws TimeoutException in case of timeout on the connection.
* @throws AdbCommandRejectedException if adb rejects the command
* @throws IOException in case of I/O error on the connection.
*/
public static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName,
LogReceiver rcvr) throws TimeoutException, AdbCommandRejectedException, IOException {
SocketChannel adbChan = null;
try {
adbChan = SocketChannel.open(adbSockAddr);
adbChan.configureBlocking(false);
// if the device is not -1, then we first tell adb we're looking to talk
// to a specific device
setDevice(adbChan, device);
byte[] request = formAdbRequest("log:" + logName);
write(adbChan, request);
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
if (!resp.okay) {
throw new AdbCommandRejectedException(resp.message);
}
byte[] data = new byte[16384];
ByteBuffer buf = ByteBuffer.wrap(data);
while (true) {
int count;
if (rcvr != null && rcvr.isCancelled()) {
break;
}
count = adbChan.read(buf);
if (count < 0) {
break;
} else if (count == 0) {
try {
Thread.sleep(WAIT_TIME * 5);
} catch (InterruptedException ie) {
}
} else {
if (rcvr != null) {
rcvr.parseNewData(buf.array(), buf.arrayOffset(), buf.position());
}
buf.rewind();
}
}
} finally {
if (adbChan != null) {
adbChan.close();
}
}
}
示例5: runLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs a log service on the {@link Device}, and provides its output to the {@link LogReceiver}.
* <p/>This call is blocking until {@link LogReceiver#isCancelled()} returns true.
* @param adbSockAddr the socket address to connect to adb
* @param device the Device on which to run the service
* @param logName the name of the log file to output
* @param rcvr the {@link LogReceiver} to receive the log output
* @throws TimeoutException in case of timeout on the connection.
* @throws AdbCommandRejectedException if adb rejects the command
* @throws IOException in case of I/O error on the connection.
*/
public static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName,
LogReceiver rcvr) throws TimeoutException, AdbCommandRejectedException, IOException {
SocketChannel adbChan = null;
try {
adbChan = SocketChannel.open(adbSockAddr);
adbChan.configureBlocking(false);
// if the device is not -1, then we first tell adb we're looking to talk
// to a specific device
setDevice(adbChan, device);
byte[] request = formAdbRequest("log:" + logName);
write(adbChan, request);
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
if (resp.okay == false) {
throw new AdbCommandRejectedException(resp.message);
}
byte[] data = new byte[16384];
ByteBuffer buf = ByteBuffer.wrap(data);
while (true) {
int count;
if (rcvr != null && rcvr.isCancelled()) {
break;
}
count = adbChan.read(buf);
if (count < 0) {
break;
} else if (count == 0) {
try {
Thread.sleep(WAIT_TIME * 5);
} catch (InterruptedException ie) {
}
} else {
if (rcvr != null) {
rcvr.parseNewData(buf.array(), buf.arrayOffset(), buf.position());
}
buf.rewind();
}
}
} finally {
if (adbChan != null) {
adbChan.close();
}
}
}
示例6: runLogService
import com.android.ddmlib.log.LogReceiver; //导入方法依赖的package包/类
/**
* Runs a log service on the {@link Device}, and provides its output to the
* {@link LogReceiver}.
* <p/>
* This call is blocking until {@link LogReceiver#isCancelled()} returns
* true.
*
* @param adbSockAddr
* the socket address to connect to adb
* @param device
* the Device on which to run the service
* @param logName
* the name of the log file to output
* @param rcvr
* the {@link LogReceiver} to receive the log output
* @throws TimeoutException
* in case of timeout on the connection.
* @throws AdbCommandRejectedException
* if adb rejects the command
* @throws IOException
* in case of I/O error on the connection.
*/
public static void runLogService(InetSocketAddress adbSockAddr, Device device, String logName,
LogReceiver rcvr) throws TimeoutException, AdbCommandRejectedException, IOException {
SocketChannel adbChan = null;
try {
adbChan = SocketChannel.open(adbSockAddr);
adbChan.configureBlocking(false);
// if the device is not -1, then we first tell adb we're looking to
// talk
// to a specific device
setDevice(adbChan, device);
byte[] request = formAdbRequest("log:" + logName);
write(adbChan, request);
AdbResponse resp = readAdbResponse(adbChan, false /* readDiagString */);
if (resp.okay == false) {
throw new AdbCommandRejectedException(resp.message);
}
byte[] data = new byte[16384];
ByteBuffer buf = ByteBuffer.wrap(data);
while (true) {
int count;
if (rcvr != null && rcvr.isCancelled()) {
break;
}
count = adbChan.read(buf);
if (count < 0) {
break;
} else if (count == 0) {
try {
Thread.sleep(WAIT_TIME * 5);
} catch (InterruptedException ie) {}
} else {
if (rcvr != null) {
rcvr.parseNewData(buf.array(), buf.arrayOffset(), buf.position());
}
buf.rewind();
}
}
} finally {
if (adbChan != null) {
adbChan.close();
}
}
}