blob: f0e49da9c29e58bd95e604a7fc35684c8a71810a [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "rmad/state_handler/provision_device_state_handler.h"
#include <base/logging.h>
namespace rmad {
ProvisionDeviceStateHandler::ProvisionDeviceStateHandler(
scoped_refptr<JsonStore> json_store)
: BaseStateHandler(json_store) {}
RmadErrorCode ProvisionDeviceStateHandler::InitializeState() {
if (!state_.has_provision_device()) {
state_.set_allocated_provision_device(new ProvisionDeviceState);
}
return RMAD_ERROR_OK;
}
BaseStateHandler::GetNextStateCaseReply
ProvisionDeviceStateHandler::GetNextStateCase(const RmadState& state) {
if (!state.has_provision_device()) {
LOG(ERROR) << "RmadState missing |provision| state.";
return {.error = RMAD_ERROR_REQUEST_INVALID, .state_case = GetStateCase()};
}
// There's nothing in |ProvisionDeviceState|.
state_ = state;
// TODO(chenghan): This is currently fake.
return {.error = RMAD_ERROR_OK,
.state_case = RmadState::StateCase::kWpEnablePhysical};
}
} // namespace rmad