Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runner/android_test_orchestrator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**Bug Fixes**

* Remove use of guava. Fixes https://github.com/android/android-test/issues/2422

**New Features**

**Breaking Changes**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package androidx.test.orchestrator;

import static androidx.test.internal.util.Checks.checkState;
import static androidx.test.orchestrator.OrchestratorConstants.AJUR_CLASS_ARGUMENT;
import static androidx.test.orchestrator.OrchestratorConstants.AJUR_COVERAGE;
import static androidx.test.orchestrator.OrchestratorConstants.AJUR_COVERAGE_FILE;
Expand All @@ -24,7 +25,6 @@
import static androidx.test.orchestrator.OrchestratorConstants.ISOLATED_ARGUMENT;
import static androidx.test.orchestrator.OrchestratorConstants.ORCHESTRATOR_DEBUG_ARGUMENT;
import static androidx.test.orchestrator.OrchestratorConstants.TARGET_INSTRUMENTATION_ARGUMENT;
import static com.google.common.base.Preconditions.checkState;

import android.Manifest.permission;
import android.app.Activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ android_library(
"//runner/android_junit_runner",
"//services/shellexecutor:exec_client",
"@maven//:androidx_core_core",
"@maven//:com_google_guava_guava",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

package androidx.test.orchestrator;

import static androidx.test.internal.util.Checks.checkNotNull;
import static androidx.test.internal.util.Checks.checkState;

import android.os.Bundle;
import androidx.test.orchestrator.callback.OrchestratorCallback;
import androidx.test.orchestrator.listeners.OrchestrationListenerManager;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/** Encapsulates all the logic for receiving callbacks from the app under test. */
class CallbackLogic extends OrchestratorCallback.Stub {
private static final String TAG = "CallbackLogic";
private static final Splitter CLASS_METHOD_SPLITTER = Splitter.on('#');

private final List<String> listOfTests = new ArrayList<>();
private final Object testLock = new Object();
Expand All @@ -38,7 +39,7 @@ class CallbackLogic extends OrchestratorCallback.Stub {
@Override
public void addTest(String test) {
synchronized (testLock) {
List<String> classAndMethod = CLASS_METHOD_SPLITTER.splitToList(test);
List<String> classAndMethod = Arrays.asList(test.split("#"));
if (classAndMethod.size() > 1
&& (classAndMethod.get(1).isEmpty() || classAndMethod.get(1).equals("null"))) {
listOfTests.add(classAndMethod.get(0));
Expand All @@ -51,8 +52,7 @@ public void addTest(String test) {
@Override
public void sendTestNotification(Bundle bundle) {
synchronized (testLock) {
Preconditions.checkNotNull(
listenerManager, "Unable to process test notification. No ListenerManager");
checkNotNull(listenerManager, "Unable to process test notification. No ListenerManager");
listenerManager.handleNotification(bundle);
}
}
Expand All @@ -65,8 +65,8 @@ List<String> provideCollectedTests() {

void setListenerManager(OrchestrationListenerManager mListenerManager) {
synchronized (testLock) {
Preconditions.checkState(null == this.listenerManager, "Listener manager assigned twice.");
this.listenerManager = Preconditions.checkNotNull(mListenerManager, "Listener manager null");
checkState(null == this.listenerManager, "Listener manager assigned twice.");
this.listenerManager = checkNotNull(mListenerManager, "Listener manager null");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import static androidx.test.orchestrator.OrchestratorConstants.TARGET_INSTRUMENTATION_ARGUMENT;

import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.test.services.shellexecutor.ClientNotConnected;
import androidx.test.services.shellexecutor.ShellExecutorFactory;
import com.google.common.io.ByteStreams;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -135,7 +136,7 @@ public void run() {
InputStream inputStream =
runShellCommand(buildShellParams(getTargetInstrumentationArguments()));
try {
ByteStreams.copy(inputStream, outputStream);
transferInputToOutputStream(inputStream, outputStream);
} finally {
if (inputStream != null) {
inputStream.close();
Expand All @@ -157,6 +158,19 @@ public void run() {
listener.runFinished();
}

private static void transferInputToOutputStream(InputStream is, OutputStream os)
throws IOException {
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
is.transferTo(os);
} else {
byte[] buf = new byte[8192];
int bytesRead = -1;
while ((bytesRead = is.read(buf)) >= 0) {
os.write(buf, 0, bytesRead);
}
}
}

private String getTargetInstrumentation() {
return arguments.getString(TARGET_INSTRUMENTATION_ARGUMENT);
}
Expand Down
1 change: 0 additions & 1 deletion runner/android_test_orchestrator/stubapp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ android_binary(
"//runner/android_junit_runner",
"//runner/android_test_orchestrator",
"@maven//:androidx_multidex_multidex",
"@maven//:com_google_guava_guava",
"@maven//:junit_junit",
],
)
Expand Down
Loading