This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncFileReader( | |
file: File, | |
override val coroutineContext: CoroutineContext = Dispatchers.IO | |
) : CoroutineScope, Closeable { | |
private val fileChannel = file.inputStream().buffered() | |
private val bufferChannel: Channel<ByteBuffer> = Channel(capacity = 2) | |
private var job: Job? = null | |
fun start() { | |
job = launch { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2021 Anton Malinskiy | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.malinskiy.adam | |
import com.malinskiy.adam.transport.withDefaultBuffer | |
import io.ktor.util.cio.* | |
import io.ktor.utils.io.* | |
import kotlinx.coroutines.runBlocking | |
import org.junit.AfterClass | |
import org.junit.BeforeClass | |
import org.junit.Test | |
import java.io.File |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use raw text message to receive status from am instrument command. | |
* | |
* @deprecated Use {@link #PROTO_STD} for API level 26 and above. | |
*/ | |
@Deprecated | |
RAW_TEXT("-r", 0, InstrumentationResultParser::new), | |
/** | |
* Use instrumentationData protobuf status reporter to receive status from am instrument | |
* command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String readLogcat(long startTimeMs) { | |
try { | |
... | |
// Start the process | |
final Process process = new ProcessBuilder() | |
.command("logcat", "-d", "-v threadtime,uid", "-T", timestamp) | |
.start(); | |
// Nothing to write. Don't let the command accidentally block. | |
process.getOutputStream().close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ByteArrayOutputStream mPendingData = new ByteArrayOutputStream(); | |
public void addOutput(byte[] data, int offset, int length) { | |
mPendingData.write(data, offset, length); | |
try { | |
InstrumentationData.Session session = | |
InstrumentationData.Session.parseFrom(mPendingData.toByteArray()); | |
mPendingData.reset(); | |
updateState(session); | |
} | |
catch (InvalidProtocolBufferException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.malinskiy.marathon.execution.queue | |
import kotlinx.coroutines.async | |
import kotlinx.coroutines.cancelAndJoin | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.actor | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.newFixedThreadPoolContext | |
import kotlinx.coroutines.runBlocking | |
import org.junit.jupiter.api.Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
require "pp" | |
require 'fileutils' | |
require "gruff" | |
require 'rmagick' | |
def read_cal(file) | |
data_segment = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use coroutineScope | |
runBlocking { | |
//Verify the ADB server is running | |
StartAdbInteractor().execute() | |
//Create AndroidDebugBridgeServer instance | |
val adb = AndroidDebugBridgeServerFactory().apply { | |
coroutineContext = Dispatchers.IO | |
}.build() | |
//Execute requests using suspendable execute() methods. First list available devices | |
val devices = adb.execute(request = ListDevicesRequest()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val output = adb.execute(ShellCommandRequest("echo hello"), "emulator-5554") | |
println(output) // hello |
NewerOlder