| // Copyright 2024 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SRC_STORAGE_LIB_PAVER_ANDROID_H_ |
| #define SRC_STORAGE_LIB_PAVER_ANDROID_H_ |
| |
| #include "src/storage/lib/paver/abr-client.h" |
| #include "src/storage/lib/paver/gpt.h" |
| |
| namespace paver { |
| |
| // DevicePartitioner implementation for Android devices. |
| class AndroidDevicePartitioner : public DevicePartitioner { |
| public: |
| static zx::result<std::unique_ptr<DevicePartitioner>> Initialize( |
| const BlockDevices& devices, fidl::UnownedClientEnd<fuchsia_io::Directory> svc_root, |
| const PaverConfig& config, fidl::ClientEnd<fuchsia_device::Controller> block_device, |
| std::shared_ptr<Context> context); |
| |
| zx::result<std::unique_ptr<abr::Client>> CreateAbrClient() const override; |
| |
| const paver::BlockDevices& Devices() const override; |
| |
| fidl::UnownedClientEnd<fuchsia_io::Directory> SvcRoot() const override; |
| |
| bool IsFvmWithinFtl() const override { return false; } |
| |
| bool SupportsPartition(const PartitionSpec& spec) const override; |
| |
| zx::result<std::unique_ptr<PartitionClient>> FindPartition( |
| const PartitionSpec& spec) const override; |
| |
| zx::result<> WipeFvm() const override; |
| |
| zx::result<> ResetPartitionTables() const override; |
| |
| zx::result<> ValidatePayload(const PartitionSpec& spec, |
| std::span<const uint8_t> data) const override; |
| |
| zx::result<> Flush() const override { return zx::ok(); } |
| |
| zx::result<> OnStop() const override; |
| |
| private: |
| AndroidDevicePartitioner(std::unique_ptr<GptDevicePartitioner> gpt, const PaverConfig& config, |
| std::shared_ptr<Context> context) |
| : gpt_(std::move(gpt)), config_(config), context_(std::move(context)) {} |
| |
| std::unique_ptr<GptDevicePartitioner> gpt_; |
| const PaverConfig config_; |
| std::shared_ptr<Context> context_; |
| }; |
| |
| class AndroidPartitionerFactory : public DevicePartitionerFactory { |
| public: |
| zx::result<std::unique_ptr<DevicePartitioner>> New( |
| const BlockDevices& devices, fidl::UnownedClientEnd<fuchsia_io::Directory> svc_root, |
| const PaverConfig& config, std::shared_ptr<Context> context, |
| fidl::ClientEnd<fuchsia_device::Controller> block_device) final; |
| }; |
| |
| } // namespace paver |
| |
| #endif // SRC_STORAGE_LIB_PAVER_ANDROID_H_ |