Commit e146ff46 authored by Sherry Hu's avatar Sherry Hu Committed by Chromium LUCI CQ

Move starting/stop arcvm-adbd upstart job to ArcAdbdMonitorBridge.

Chrome uses ArcAdbdMonitorBridge to control arcvm-adbd.
Android notify Chrome over Mojo to make sure arcvm-adbd job start/stop
when guest's adbd startup/shutdown.

The change is paired with https://crrev.com/c/2600256 and https://crrev.com/c/2600476

TEST=Toggle ADB debugging on Android developer setting, start/stop
arcvm-adbd job successfully.
TEST=component_unittests --gtest_filter="ArcVmClientAdapterTest.*"
TEST=unit_tests --gtest_filter="ArcAdbdMonitorBridgeTest.*"

Change-Id: Ib3742fba4854dc20e71ebe09d7a145ea45047101
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600436
Commit-Queue: Sherry Hu <shuanghu@chromium.org>
Reviewed-by: default avatarLong Cheng <lgcheng@google.com>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844852}
parent 1f0c266b
......@@ -26,10 +26,6 @@ namespace arc {
namespace {
// TODO(shuanghu): Remove this flag after Android code check in. This flag is
// for disabling adb-over-usb feature temporarily.
constexpr const bool g_disable_adb_over_usb = true;
// The "_2d" in job names below corresponds to "-". Upstart escapes characters
// that aren't valid in D-Bus object paths with underscore followed by its
// ascii code in hex. So "arc_2dcreate_2ddata" becomes "arc-create-data".
......@@ -86,7 +82,6 @@ bool IsAdbOverUsbEnabled() {
bool is_host_on_vm =
chromeos::system::StatisticsProvider::GetInstance()->IsRunningOnVm();
bool is_adb_over_usb_enabled =
g_disable_adb_over_usb &&
ShouldStartAdbd(is_dev_mode, is_host_on_vm, has_adbd_json, udc_disabled);
return g_enable_adb_over_usb_for_testing || is_adb_over_usb_enabled;
}
......
......@@ -96,7 +96,6 @@ constexpr base::TimeDelta kConnectSleepDurationInitial =
base::Optional<base::TimeDelta> g_connect_timeout_limit_for_testing;
base::Optional<base::TimeDelta> g_connect_sleep_duration_initial_for_testing;
base::Optional<int> g_boot_notification_server_fd;
bool g_enable_adb_over_usb_for_testing = false;
chromeos::ConciergeClient* GetConciergeClient() {
return chromeos::DBusThreadManager::Get()->GetConciergeClient();
......@@ -414,16 +413,6 @@ bool SendUpgradePropsToArcVmBootNotificationServer(
return true;
}
// Returns true if the daemon for adb-over-usb should be started on the device.
bool ShouldStartAdbd(bool is_dev_mode,
bool is_host_on_vm,
bool has_adbd_json,
bool is_adb_over_usb_disabled) {
// Do the same check as ArcSetup::MaybeStartAdbdProxy().
return is_dev_mode && !is_host_on_vm && has_adbd_json &&
!is_adb_over_usb_disabled;
}
} // namespace
class ArcVmClientAdapter : public ArcClientAdapter,
......@@ -614,20 +603,6 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnIsDevMode(chromeos::VoidDBusMethodCallback callback,
bool is_dev_mode) {
is_dev_mode_ = is_dev_mode;
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce([]() {
std::string output;
return base::GetAppOutput({"crossystem", "dev_enable_udc?0"},
&output);
}),
base::BindOnce(&ArcVmClientAdapter::OnIsAdbOverUsbDisabled,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void OnIsAdbOverUsbDisabled(chromeos::VoidDBusMethodCallback callback,
bool is_adb_over_usb_disabled) {
is_adb_over_usb_disabled_ = is_adb_over_usb_disabled;
std::deque<JobDesc> jobs{
// Note: the first Upstart job is a task, and the callback for the start
// request won't be called until the task finishes. When the callback is
......@@ -725,8 +700,6 @@ class ArcVmClientAdapter : public ArcClientAdapter,
if (file_system_status_rewriter_for_testing_)
file_system_status_rewriter_for_testing_.Run(&file_system_status);
file_system_status_has_adbd_json_ = file_system_status.has_adbd_json();
VLOG(2) << "Retrieving demo session apps path";
DCHECK(demo_mode_delegate_);
demo_mode_delegate_->EnsureOfflineResourcesLoaded(base::BindOnce(
......@@ -904,15 +877,6 @@ class ArcVmClientAdapter : public ArcClientAdapter,
VLOG(1) << "Starting arcvm-post-vm-start-services.";
std::vector<std::string> environment;
bool should_start_adbd = ShouldStartAdbd(*is_dev_mode_, is_host_on_vm_,
file_system_status_has_adbd_json_,
*is_adb_over_usb_disabled_) ||
g_enable_adb_over_usb_for_testing;
if (should_start_adbd) {
environment.push_back("SERIALNUMBER=" + serial_number_);
environment.push_back(
base::StringPrintf("ARCVM_CID=%" PRId64, current_cid_));
}
std::deque<JobDesc> jobs{JobDesc{kArcVmPostVmStartServicesJobName,
UpstartOperation::JOB_START,
std::move(environment)}};
......@@ -967,9 +931,6 @@ class ArcVmClientAdapter : public ArcClientAdapter,
base::Optional<bool> is_dev_mode_;
// True when the *host* is running on a VM.
const bool is_host_on_vm_;
// True when adb-over-usb is disabled.
base::Optional<bool> is_adb_over_usb_disabled_;
// A cryptohome ID of the primary profile.
cryptohome::Identification cryptohome_id_;
// A hash of the primary profile user ID.
......@@ -981,7 +942,6 @@ class ArcVmClientAdapter : public ArcClientAdapter,
bool should_notify_observers_ = false;
int64_t current_cid_ = kInvalidCid;
bool file_system_status_has_adbd_json_ = false;
FileSystemStatusRewriter file_system_status_rewriter_for_testing_;
// The delegate is owned by ArcSessionRunner.
......@@ -1024,10 +984,6 @@ void SetArcVmBootNotificationServerFdForTesting(base::Optional<int> fd) {
g_boot_notification_server_fd = fd;
}
void EnableAdbOverUsbForTesting() {
g_enable_adb_over_usb_for_testing = true;
}
std::vector<std::string> GenerateUpgradePropsForTesting(
const UpgradeParams& upgrade_params,
const std::string& serial_number,
......
......@@ -41,9 +41,6 @@ void SetArcVmBootNotificationServerAddressForTesting(
// Sets the an FD ConnectToArcVmBootNotificationServer() returns for testing.
void SetArcVmBootNotificationServerFdForTesting(base::Optional<int> fd);
// Enable adb-over-usb and let the adapter start the support daemon for testing.
void EnableAdbOverUsbForTesting();
// Generates a list of props from |upgrade_params|, each of which takes the form
// "prefix.prop_name=value"
std::vector<std::string> GenerateUpgradePropsForTesting(
......
......@@ -909,7 +909,6 @@ TEST_F(ArcVmClientAdapterTest,
TEST_F(ArcVmClientAdapterTest,
UpgradeArc_StartArcVmPostVmStartServicesFailure) {
SetValidUserInfo();
EnableAdbOverUsbForTesting();
StartMiniArc();
// Inject failure to FakeUpstartClient.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment