Skip to content

Instantly share code, notes, and snippets.

View Malinskiy's full-sized avatar

Anton Malinskiy Malinskiy

View GitHub Profile
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 {
* 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
* Unless required by applicable law or agreed to in writing, software
package com.malinskiy.adam
import com.malinskiy.adam.transport.withDefaultBuffer
import io.ktor.util.cio.*
import kotlinx.coroutines.runBlocking
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Test
* Use raw text message to receive status from am instrument command.
* @deprecated Use {@link #PROTO_STD} for API level 26 and above.
RAW_TEXT("-r", 0, InstrumentationResultParser::new),
* Use instrumentationData protobuf status reporter to receive status from am instrument
* command.
private static String readLogcat(long startTimeMs) {
try {
// Start the process
final Process process = new ProcessBuilder()
.command("logcat", "-d", "-v threadtime,uid", "-T", timestamp)
// Nothing to write. Don't let the command accidentally block.
private ByteArrayOutputStream mPendingData = new ByteArrayOutputStream();
public void addOutput(byte[] data, int offset, int length) {
mPendingData.write(data, offset, length);
try {
InstrumentationData.Session session =
catch (InvalidProtocolBufferException e) {
package com.malinskiy.marathon.execution.queue
import kotlinx.coroutines.async
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.newFixedThreadPoolContext
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
#!/usr/bin/env ruby -wKU
require "pp"
require 'fileutils'
require "gruff"
require 'rmagick'
def read_cal(file)
data_segment = false
//Use coroutineScope
runBlocking {
//Verify the ADB server is running
//Create AndroidDebugBridgeServer instance
val adb = AndroidDebugBridgeServerFactory().apply {
coroutineContext = Dispatchers.IO
//Execute requests using suspendable execute() methods. First list available devices
val devices = adb.execute(request = ListDevicesRequest())
val output = adb.execute(ShellCommandRequest("echo hello"), "emulator-5554")
println(output) // hello