1// Copyright (C) 2020 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16package android.snapshot;
17
18import "update_engine/update_metadata.proto";
19
20// Controls the behavior of IDeviceInfo.
21// Next: 6
22message FuzzDeviceInfoData {
23    bool slot_suffix_is_a = 1;
24    bool is_overlayfs_setup = 2;
25    bool allow_set_boot_control_merge_status = 3;
26    bool allow_set_slot_as_unbootable = 4;
27    bool is_recovery = 5;
28}
29
30// Controls the behavior of the test SnapshotManager.
31// Next: 2
32message FuzzSnapshotManagerData {
33    bool is_local_image_manager = 1;
34}
35
36// A simplified version of CreateLogicalPartitionParams for fuzzing.
37// Next: 9
38message CreateLogicalPartitionParamsProto {
39    bool use_correct_super = 1;
40    string block_device = 2;
41    bool has_metadata_slot = 3;
42    uint32 metadata_slot = 4;
43    string partition_name = 5;
44    bool force_writable = 6;
45    int64 timeout_millis = 7;
46    string device_name = 8;
47}
48
49// Mimics the API of ISnapshotManager. Defines one action on the snapshot
50// manager.
51// Next: 18
52message SnapshotManagerActionProto {
53    message NoArgs {}
54    message ProcessUpdateStateArgs {
55        bool has_before_cancel = 1;
56        bool fail_before_cancel = 2;
57    }
58    message CreateLogicalAndSnapshotPartitionsArgs {
59        bool use_correct_super = 1;
60        string super = 2;
61        int64 timeout_millis = 3;
62    }
63    message RecoveryCreateSnapshotDevicesArgs {
64        bool has_metadata_device_object = 1;
65        bool metadata_mounted = 2;
66    }
67    reserved 18 to 9999;
68    oneof value {
69        NoArgs begin_update = 1;
70        NoArgs cancel_update = 2;
71        bool finished_snapshot_writes = 3;
72        NoArgs initiate_merge = 4;
73        ProcessUpdateStateArgs process_update_state = 5;
74        bool get_update_state = 6;
75        chromeos_update_engine.DeltaArchiveManifest create_update_snapshots = 7;
76        CreateLogicalPartitionParamsProto map_update_snapshot = 8;
77        string unmap_update_snapshot = 9;
78        NoArgs need_snapshots_in_first_stage_mount = 10;
79        CreateLogicalAndSnapshotPartitionsArgs create_logical_and_snapshot_partitions = 11;
80        bool handle_imminent_data_wipe = 12;
81        NoArgs recovery_create_snapshot_devices = 13;
82        RecoveryCreateSnapshotDevicesArgs recovery_create_snapshot_devices_with_metadata = 14;
83        NoArgs dump = 15;
84        NoArgs ensure_metadata_mounted = 16;
85        NoArgs get_snapshot_merge_stats_instance = 17;
86
87        // Test directives that has nothing to do with ISnapshotManager API surface.
88        NoArgs switch_slot = 10000;
89    }
90}
91
92// Includes all data that needs to be fuzzed.
93message SnapshotFuzzData {
94    FuzzDeviceInfoData device_info_data = 1;
95    FuzzSnapshotManagerData manager_data = 2;
96
97    // If true:
98    // - if super_data is empty, create empty super partition metadata.
99    // - otherwise, create super partition metadata accordingly.
100    // If false, no valid super partition metadata (it is zeroed)
101    bool is_super_metadata_valid = 3;
102    chromeos_update_engine.DeltaArchiveManifest super_data = 4;
103
104    // Whether the directory that mocks /metadata/ota/snapshot is created.
105    bool has_metadata_snapshots_dir = 5;
106
107    // More data used to prep the test before running actions.
108    reserved 6 to 9999;
109    repeated SnapshotManagerActionProto actions = 10000;
110}
111