Do not start/stop logcat invocation for TcpDevice

TcpDevice lifecycle starts later so no device is available
at early stage. These device will handle the logcat start
and stop themselves based on when they are up.

Test: unit tests, run google-gce-cts-launcher
Bug: 34571399
Change-Id: I6164c7a0f508d2ee18eaca0ce9c24324451d164d
diff --git a/src/com/android/tradefed/device/NativeDevice.java b/src/com/android/tradefed/device/NativeDevice.java
index 793dc1b..1b723b7 100644
--- a/src/com/android/tradefed/device/NativeDevice.java
+++ b/src/com/android/tradefed/device/NativeDevice.java
@@ -294,7 +294,7 @@
      *
      * @param delay the delay in ms
      */
-    void setLogStartDelay(int delay) {
+    protected void setLogStartDelay(int delay) {
         mLogStartDelay = delay;
     }
 
diff --git a/src/com/android/tradefed/invoker/TestInvocation.java b/src/com/android/tradefed/invoker/TestInvocation.java
index 5885cd4..d19ec46 100644
--- a/src/com/android/tradefed/invoker/TestInvocation.java
+++ b/src/com/android/tradefed/invoker/TestInvocation.java
@@ -843,7 +843,8 @@
     private void reportLogs(ITestDevice device, ITestInvocationListener listener, Stage stage) {
         InputStreamSource logcatSource = null;
         InputStreamSource emulatorOutput = null;
-        if (device != null) {
+        // only get logcat if we have an actual device available to avoid empty logs.
+        if (device != null && !(device.getIDevice() instanceof StubDevice)) {
             logcatSource = device.getLogcat();
             device.clearLogcat();
             if (device.getIDevice() != null && device.getIDevice().isEmulator()) {
@@ -1002,7 +1003,9 @@
                         config.getDeviceConfigByName(deviceName).getDeviceOptions());
                 if (config.getDeviceConfigByName(deviceName).getDeviceOptions()
                         .isLogcatCaptureEnabled()) {
-                    context.getDevice(deviceName).startLogcat();
+                    if (!(context.getDevice(deviceName).getIDevice() instanceof StubDevice)) {
+                        context.getDevice(deviceName).startLogcat();
+                    }
                 }
             }
 
@@ -1079,7 +1082,9 @@
         } finally {
             // ensure we always deregister the logger
             for (String deviceName : context.getDeviceConfigNames()) {
-                context.getDevice(deviceName).stopLogcat();
+                if (!(context.getDevice(deviceName).getIDevice() instanceof StubDevice)) {
+                    context.getDevice(deviceName).stopLogcat();
+                }
             }
             getLogRegistry().unregisterLogger();
             config.getLogOutput().closeLog();