Commit 879b8a61 authored by Vaibhav Raheja's avatar Vaibhav Raheja Committed by Chromium LUCI CQ

arcvm: Not booting in the case of NEED_POWERWASH.

Currently, ARCVM is not booting in the case of
AdbSideloadResponseCode::NEED_POWERWASH. AdbSideloadResponseCode can
return 3 possible values:
1. SUCCESS - Here, the sideloading flag should be setup
accordingly.
2. FAILED - Because of an unsuccessful response, here we stop
the upgradation of ARC and log an error.
3. NEED_POWERWASH - Currently, this is implemented
incorrectly - replicating the above FAILED case.
NEED_POWERWASH occurs when bootlockbox has an undefined
NVSpace - http://shortn/_3dSlMMlZBc.

The scope of this CL is to upgrade the ARC in NEED_POWERWASH
scenario while ensuring that is_enabled_sideloading flag is
set to 0, without going into the implementation details of
Powerwash.

BUG=b:175420640

TEST=Tested with following:
1. Put the device to be in Need_Powerwash case.
2. android-sh on the device post-login.

Unit Test:
testing/xvfb.py ./out/Debug/components_unittests
--gtest_filter="ArcVmClientAdapterTest.*"

Change-Id: Ic2864fbb065672db595b774e744f1a2423385f87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587566
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837936}
parent b13ae184
......@@ -686,10 +686,7 @@ void FakeSessionManagerClient::EnableAdbSideload(
void FakeSessionManagerClient::QueryAdbSideload(
QueryAdbSideloadCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback),
force_query_adb_sideload_failure_
? AdbSideloadResponseCode::FAILED
: AdbSideloadResponseCode::SUCCESS,
FROM_HERE, base::BindOnce(std::move(callback), adb_sideload_response_,
adb_sideload_enabled_));
}
......
......@@ -258,8 +258,8 @@ class COMPONENT_EXPORT(SESSION_MANAGER) FakeSessionManagerClient
adb_sideload_enabled_ = adb_sideload_enabled;
}
void set_force_query_adb_sideload_failure(bool force_failure) {
force_query_adb_sideload_failure_ = force_failure;
void set_adb_sideload_response(AdbSideloadResponseCode response) {
adb_sideload_response_ = response;
}
bool session_stopped() const { return session_stopped_; }
......@@ -303,9 +303,9 @@ class COMPONENT_EXPORT(SESSION_MANAGER) FakeSessionManagerClient
// This simulates a policy load error in session manager.
bool force_retrieve_policy_load_error_ = false;
// If set to true, QueryAdbSideload() always replies with a failed
// response, irrespective of the value of adb_sideload_enabled_.
bool force_query_adb_sideload_failure_ = false;
// The response that will be returned when QueryAdbSideload() is called.
AdbSideloadResponseCode adb_sideload_response_ =
AdbSideloadResponseCode::SUCCESS;
int clear_forced_re_enrollment_vpd_call_count_ = 0;
// Callback which is run after calling |StartDeviceWipe| or
......
......@@ -690,13 +690,19 @@ class ArcVmClientAdapter : public ArcClientAdapter,
VLOG(1) << "IsAdbSideloadAllowed, response_code="
<< static_cast<int>(response_code) << ", enabled=" << enabled;
if (response_code !=
chromeos::SessionManagerClient::AdbSideloadResponseCode::SUCCESS) {
LOG(ERROR) << "Unsuccessful response from QueryAdbSideload";
std::move(callback).Run(false);
return;
switch (response_code) {
case chromeos::SessionManagerClient::AdbSideloadResponseCode::FAILED:
LOG(ERROR) << "Failed response from QueryAdbSideload";
std::move(callback).Run(false);
return;
case chromeos::SessionManagerClient::AdbSideloadResponseCode::
NEED_POWERWASH:
params.is_adb_sideloading_enabled = false;
break;
case chromeos::SessionManagerClient::AdbSideloadResponseCode::SUCCESS:
params.is_adb_sideloading_enabled = enabled;
break;
}
params.is_adb_sideloading_enabled = enabled;
ConfigureUpstartJobs(
std::move(jobs),
......
......@@ -835,14 +835,14 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_NoUserId) {
EXPECT_TRUE(arc_instance_stopped_called());
}
// Tests that an "invalid Adb Sideload response" case is handled properly.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_NoValidAdbResponse) {
// Tests that a "Failed Adb Sideload response" case is handled properly.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_FailedAdbResponse) {
SetValidUserInfo();
StartMiniArc();
// Ask the Fake Session Manager to return a failed Adb Sideload response.
chromeos::FakeSessionManagerClient::Get()
->set_force_query_adb_sideload_failure(true);
chromeos::FakeSessionManagerClient::Get()->set_adb_sideload_response(
chromeos::FakeSessionManagerClient::AdbSideloadResponseCode::FAILED);
UpgradeArc(false);
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
EXPECT_FALSE(arc_instance_stopped_called());
......@@ -855,6 +855,24 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_NoValidAdbResponse) {
EXPECT_TRUE(arc_instance_stopped_called());
}
// Tests that a "Need_Powerwash Adb Sideload response" case is handled properly.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_NeedPowerwashAdbResponse) {
SetValidUserInfo();
StartMiniArc();
// Ask the Fake Session Manager to return a Need_Powerwash Adb Sideload
// response.
chromeos::FakeSessionManagerClient::Get()->set_adb_sideload_response(
chromeos::FakeSessionManagerClient::AdbSideloadResponseCode::
NEED_POWERWASH);
UpgradeArc(true);
EXPECT_TRUE(GetTestConciergeClient()->start_arc_vm_called());
EXPECT_FALSE(arc_instance_stopped_called());
EXPECT_TRUE(
base::Contains(GetTestConciergeClient()->start_arc_vm_request().params(),
"androidboot.enable_adb_sideloading=0"));
}
// Tests that adb sideloading is disabled by default.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_AdbSideloadingPropertyDefault) {
SetValidUserInfo();
......
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