summaryrefslogtreecommitdiff
path: root/aidl/android/gsi/IImageService.aidl
blob: 9f84e50376eb9555bea103a625ad067d52e67939 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.gsi;

import android.gsi.AvbPublicKey;
import android.gsi.MappedImage;
import android.gsi.IProgressCallback;

/** {@hide} */
interface IImageService {
    /* These flags match fiemap::ImageManager::CreateBackingImage. */
    const int CREATE_IMAGE_DEFAULT = 0x0;
    const int CREATE_IMAGE_READONLY = 0x1;
    const int CREATE_IMAGE_ZERO_FILL = 0x2;

    /* Successfully returned */
    const int IMAGE_OK = 0;
    /* Generic error code */
    const int IMAGE_ERROR = 1;

    /**
     * Create an image that can be mapped as a block device.
     *
     * This call will fail if running a GSI.
     *
     * @param name          Image name. If the image already exists, the call will fail.
     * @param size          Image size, in bytes. If too large, or not enough space is
     *                      free, the call will fail.
     * @param readonly      If readonly, MapBackingImage() will configure the device as
     *                      readonly.
     * @param on_progress   Progress callback. It is invoked when there is an interesting update.
     *                      For each invocation, |current| is the number of bytes actually written,
     *                      and |total| is set to |size|.
     * @throws ServiceSpecificException if any error occurs. Exception code is a
     *                      FiemapStatus::ErrorCode value.
     */
    void createBackingImage(@utf8InCpp String name, long size, int flags,
                            @nullable IProgressCallback on_progress);

    /**
     * Delete an image created with createBackingImage.
     *
     * @param name          Image name as passed to createBackingImage().
     * @throws ServiceSpecificException if any error occurs.
     */
    void deleteBackingImage(@utf8InCpp String name);

    /**
     * Map an image, created with createBackingImage, such that it is accessible as a
     * block device.
     *
     * @param name          Image name as passed to createBackingImage().
     * @param timeout_ms    Time to wait for a valid mapping, in milliseconds. This must be more
     *                      than zero; 10 seconds is recommended.
     * @param mapping       Information about the newly mapped block device.
     */
    void mapImageDevice(@utf8InCpp String name, int timeout_ms, out MappedImage mapping);

    /**
     * Unmap a block device previously mapped with mapBackingImage. This step is necessary before
     * calling deleteBackingImage.
     *
     * @param name          Image name as passed to createBackingImage().
     */
    void unmapImageDevice(@utf8InCpp String name);

    /**
     * Returns whether or not a backing image exists.
     *
     * @param name          Image name as passed to createBackingImage().
     */
    boolean backingImageExists(@utf8InCpp String name);

    /**
     * Returns whether or not the named image is mapped.
     *
     * @param name          Image name as passed to createBackingImage().
     */
    boolean isImageMapped(@utf8InCpp String name);

    /**
     * Retrieve AVB public key from an image.
     * If the image is already mapped then it works the same as
     * IGsiService::getAvbPublicKey(). Otherwise this will attempt to
     * map / unmap the partition image upon enter / return.
     *
     * @param name          Image name as passed to createBackingImage().
     * @param dst           Output of the AVB public key.
     * @return              0 on success, an error code on failure.
     */
    int getAvbPublicKey(@utf8InCpp String name, out AvbPublicKey dst);

    /**
     * Get all installed backing image names
     *
     * @return list of installed backing image names
     */
    @utf8InCpp List<String> getAllBackingImages();

    /**
     * Writes a given amount of zeros in image file.
     *
     * @param name          Image name. If the image does not exist, the call
     *                      will fail.
     * @param bytes         Number of zeros to be written, starting from the
     *                      beginning. If bytes is equal to 0, then the whole
     *                      image file is filled with zeros.
     * @throws ServiceSpecificException if any error occurs. Exception code is a
     *                      FiemapStatus::ErrorCode value.
     */
    void zeroFillNewImage(@utf8InCpp String name, long bytes);

    /**
     * Find and remove all images in the containing folder of this instance.
     */
    void removeAllImages();

    /**
     * Mark an image as disabled.
     */
    void disableImage(@utf8InCpp String name);

    /**
     * Remove all images that were marked as disabled.
     */
    void removeDisabledImages();

    /**
     * Return whether an image is disabled.
     */
    boolean isImageDisabled(@utf8InCpp String name);

    /**
     * Return the block device path of a mapped image, or an empty string if not mapped.
     */
    @utf8InCpp String getMappedImageDevice(@utf8InCpp String name);
}