aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2019-12-24 17:17:59 +0800
committerHsin-Yi Chen <hsinyichen@google.com>2020-02-20 09:19:54 +0000
commitf6885840bead4dacf506d46e9772f0045a667d4c (patch)
tree5cb39bf582a5858f314e3c766ccbaff1ebff4889
parent25f795c6e30b0bceb312e34de9c2fd697cf3723f (diff)
downloadacloud-f6885840bead4dacf506d46e9772f0045a667d4c.tar.gz
Disable adb_connector for local cuttlefish with --no-autoconnect
Bug: 133211308 Test: acloud-dev create --no-autoconnect --local-image --local-instance Change-Id: I7be7f5a854d516fc675f33f8c39e6ab1770673a8
-rw-r--r--create/avd_spec.py10
-rw-r--r--create/avd_spec_test.py4
-rw-r--r--create/local_image_local_instance.py13
-rw-r--r--create/local_image_local_instance_test.py10
4 files changed, 26 insertions, 11 deletions
diff --git a/create/avd_spec.py b/create/avd_spec.py
index 76340fdb..b34ad033 100644
--- a/create/avd_spec.py
+++ b/create/avd_spec.py
@@ -90,7 +90,7 @@ def EscapeAnsi(line):
# pylint: disable=too-many-public-methods
-class AVDSpec(object):
+class AVDSpec:
"""Class to store data on the type of AVD to create."""
def __init__(self, args):
@@ -675,6 +675,14 @@ class AVDSpec(object):
return self._autoconnect is not False
@property
+ def connect_adb(self):
+ """Auto-connect to adb.
+
+ Return: Boolean, whether autoconnect is enabled.
+ """
+ return self._autoconnect is not False
+
+ @property
def connect_vnc(self):
"""Launch vnc.
diff --git a/create/avd_spec_test.py b/create/avd_spec_test.py
index 2fef629e..22c1db5d 100644
--- a/create/avd_spec_test.py
+++ b/create/avd_spec_test.py
@@ -370,24 +370,28 @@ class AvdSpecTest(driver_test_lib.BaseDriverTest):
self.args.autoconnect = False
self.AvdSpec._ProcessMiscArgs(self.args)
self.assertEqual(self.AvdSpec.autoconnect, False)
+ self.assertEqual(self.AvdSpec.connect_adb, False)
self.assertEqual(self.AvdSpec.connect_vnc, False)
self.assertEqual(self.AvdSpec.connect_webrtc, False)
self.args.autoconnect = constants.INS_KEY_VNC
self.AvdSpec._ProcessMiscArgs(self.args)
self.assertEqual(self.AvdSpec.autoconnect, True)
+ self.assertEqual(self.AvdSpec.connect_adb, True)
self.assertEqual(self.AvdSpec.connect_vnc, True)
self.assertEqual(self.AvdSpec.connect_webrtc, False)
self.args.autoconnect = constants.INS_KEY_ADB
self.AvdSpec._ProcessMiscArgs(self.args)
self.assertEqual(self.AvdSpec.autoconnect, True)
+ self.assertEqual(self.AvdSpec.connect_adb, True)
self.assertEqual(self.AvdSpec.connect_vnc, False)
self.assertEqual(self.AvdSpec.connect_webrtc, False)
self.args.autoconnect = constants.INS_KEY_WEBRTC
self.AvdSpec._ProcessMiscArgs(self.args)
self.assertEqual(self.AvdSpec.autoconnect, True)
+ self.assertEqual(self.AvdSpec.connect_adb, True)
self.assertEqual(self.AvdSpec.connect_vnc, False)
self.assertEqual(self.AvdSpec.connect_webrtc, True)
diff --git a/create/local_image_local_instance.py b/create/local_image_local_instance.py
index 43bb1684..0ee5ee8d 100644
--- a/create/local_image_local_instance.py
+++ b/create/local_image_local_instance.py
@@ -54,8 +54,8 @@ from acloud.public import report
logger = logging.getLogger(__name__)
_CMD_LAUNCH_CVD_ARGS = (" -daemon -cpus %s -x_res %s -y_res %s -dpi %s "
- "-memory_mb %s -system_image_dir %s "
- "-instance_dir %s")
+ "-memory_mb %s -run_adb_connector=%s "
+ "-system_image_dir %s -instance_dir %s")
_CMD_LAUNCH_CVD_DISK_ARGS = (" -blank_data_image_mb %s "
"-data_policy always_create")
_CONFIRM_RELAUNCH = ("\nCuttlefish AVD[id:%d] is already running. \n"
@@ -98,6 +98,7 @@ class LocalImageLocalInstance(base_avd_create.BaseAVDCreate):
constants.CMD_LAUNCH_CVD)
cmd = self.PrepareLaunchCVDCmd(launch_cvd_path,
avd_spec.hw_property,
+ avd_spec.connect_adb,
local_image_path,
avd_spec.local_instance_id)
@@ -170,8 +171,8 @@ class LocalImageLocalInstance(base_avd_create.BaseAVDCreate):
self._FindCvdHostBinaries(avd_spec.local_tool_dirs))
@staticmethod
- def PrepareLaunchCVDCmd(launch_cvd_path, hw_property, system_image_dir,
- local_instance_id):
+ def PrepareLaunchCVDCmd(launch_cvd_path, hw_property, connect_adb,
+ system_image_dir, local_instance_id):
"""Prepare launch_cvd command.
Create the launch_cvd commands with all the required args and add
@@ -181,6 +182,7 @@ class LocalImageLocalInstance(base_avd_create.BaseAVDCreate):
launch_cvd_path: String of launch_cvd path.
hw_property: dict object of hw property.
system_image_dir: String of local images path.
+ connect_adb: Boolean flag that enables adb_connector.
local_instance_id: Integer of instance id.
Returns:
@@ -189,7 +191,8 @@ class LocalImageLocalInstance(base_avd_create.BaseAVDCreate):
instance_dir = instance.GetLocalInstanceRuntimeDir(local_instance_id)
launch_cvd_w_args = launch_cvd_path + _CMD_LAUNCH_CVD_ARGS % (
hw_property["cpu"], hw_property["x_res"], hw_property["y_res"],
- hw_property["dpi"], hw_property["memory"], system_image_dir,
+ hw_property["dpi"], hw_property["memory"],
+ ("true" if connect_adb else "false"), system_image_dir,
instance_dir)
if constants.HW_ALIAS_DISK in hw_property:
launch_cvd_w_args = (launch_cvd_w_args + _CMD_LAUNCH_CVD_DISK_ARGS %
diff --git a/create/local_image_local_instance_test.py b/create/local_image_local_instance_test.py
index e5204709..d1a0acca 100644
--- a/create/local_image_local_instance_test.py
+++ b/create/local_image_local_instance_test.py
@@ -35,12 +35,12 @@ class LocalImageLocalInstanceTest(driver_test_lib.BaseDriverTest):
LAUNCH_CVD_CMD_WITH_DISK = """sg group1 <<EOF
sg group2
-launch_cvd -daemon -cpus fake -x_res fake -y_res fake -dpi fake -memory_mb fake -system_image_dir fake_image_dir -instance_dir fake_cvd_dir -blank_data_image_mb fake -data_policy always_create
+launch_cvd -daemon -cpus fake -x_res fake -y_res fake -dpi fake -memory_mb fake -run_adb_connector=true -system_image_dir fake_image_dir -instance_dir fake_cvd_dir -blank_data_image_mb fake -data_policy always_create
EOF"""
LAUNCH_CVD_CMD_NO_DISK = """sg group1 <<EOF
sg group2
-launch_cvd -daemon -cpus fake -x_res fake -y_res fake -dpi fake -memory_mb fake -system_image_dir fake_image_dir -instance_dir fake_cvd_dir
+launch_cvd -daemon -cpus fake -x_res fake -y_res fake -dpi fake -memory_mb fake -run_adb_connector=true -system_image_dir fake_image_dir -instance_dir fake_cvd_dir
EOF"""
_EXPECTED_DEVICES_IN_REPORT = [
@@ -77,7 +77,7 @@ EOF"""
"""Test the report returned by _CreateAVD."""
mock_utils.IsSupportedPlatform.return_value = True
mock_get_image.return_value = ("/image/path", "/host/bin/path")
- mock_avd_spec = mock.Mock(autoconnect=False, unlock_screen=False)
+ mock_avd_spec = mock.Mock(connect_adb=False, unlock_screen=False)
self.Patch(instance, "GetLocalInstanceName",
return_value="local-instance-1")
local_ins = mock.MagicMock(
@@ -145,7 +145,7 @@ EOF"""
constants.LIST_CF_USER_GROUPS = ["group1", "group2"]
launch_cmd = self.local_image_local_instance.PrepareLaunchCVDCmd(
- constants.CMD_LAUNCH_CVD, hw_property, "fake_image_dir",
+ constants.CMD_LAUNCH_CVD, hw_property, True, "fake_image_dir",
"fake_cvd_dir")
self.assertEqual(launch_cmd, self.LAUNCH_CVD_CMD_WITH_DISK)
@@ -153,7 +153,7 @@ EOF"""
hw_property = {"cpu": "fake", "x_res": "fake", "y_res": "fake",
"dpi":"fake", "memory": "fake"}
launch_cmd = self.local_image_local_instance.PrepareLaunchCVDCmd(
- constants.CMD_LAUNCH_CVD, hw_property, "fake_image_dir",
+ constants.CMD_LAUNCH_CVD, hw_property, True, "fake_image_dir",
"fake_cvd_dir")
self.assertEqual(launch_cmd, self.LAUNCH_CVD_CMD_NO_DISK)