xref: /aosp_15_r20/system/gsid/aidl/android/gsi/IImageService.aidl (revision 4e2b41f188908a2ae9d9a2089f1f10779d080021)
1*4e2b41f1SAndroid Build Coastguard Worker /*
2*4e2b41f1SAndroid Build Coastguard Worker  * Copyright (C) 2019 The Android Open Source Project
3*4e2b41f1SAndroid Build Coastguard Worker  *
4*4e2b41f1SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*4e2b41f1SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*4e2b41f1SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*4e2b41f1SAndroid Build Coastguard Worker  *
8*4e2b41f1SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*4e2b41f1SAndroid Build Coastguard Worker  *
10*4e2b41f1SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*4e2b41f1SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*4e2b41f1SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4e2b41f1SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*4e2b41f1SAndroid Build Coastguard Worker  * limitations under the License.
15*4e2b41f1SAndroid Build Coastguard Worker  */
16*4e2b41f1SAndroid Build Coastguard Worker 
17*4e2b41f1SAndroid Build Coastguard Worker package android.gsi;
18*4e2b41f1SAndroid Build Coastguard Worker 
19*4e2b41f1SAndroid Build Coastguard Worker import android.gsi.AvbPublicKey;
20*4e2b41f1SAndroid Build Coastguard Worker import android.gsi.MappedImage;
21*4e2b41f1SAndroid Build Coastguard Worker import android.gsi.IProgressCallback;
22*4e2b41f1SAndroid Build Coastguard Worker 
23*4e2b41f1SAndroid Build Coastguard Worker /** {@hide} */
24*4e2b41f1SAndroid Build Coastguard Worker interface IImageService {
25*4e2b41f1SAndroid Build Coastguard Worker     /* These flags match fiemap::ImageManager::CreateBackingImage. */
26*4e2b41f1SAndroid Build Coastguard Worker     const int CREATE_IMAGE_DEFAULT = 0x0;
27*4e2b41f1SAndroid Build Coastguard Worker     const int CREATE_IMAGE_READONLY = 0x1;
28*4e2b41f1SAndroid Build Coastguard Worker     const int CREATE_IMAGE_ZERO_FILL = 0x2;
29*4e2b41f1SAndroid Build Coastguard Worker 
30*4e2b41f1SAndroid Build Coastguard Worker     /* Successfully returned */
31*4e2b41f1SAndroid Build Coastguard Worker     const int IMAGE_OK = 0;
32*4e2b41f1SAndroid Build Coastguard Worker     /* Generic error code */
33*4e2b41f1SAndroid Build Coastguard Worker     const int IMAGE_ERROR = 1;
34*4e2b41f1SAndroid Build Coastguard Worker 
35*4e2b41f1SAndroid Build Coastguard Worker     /**
36*4e2b41f1SAndroid Build Coastguard Worker      * Create an image that can be mapped as a block device.
37*4e2b41f1SAndroid Build Coastguard Worker      *
38*4e2b41f1SAndroid Build Coastguard Worker      * This call will fail if running a GSI.
39*4e2b41f1SAndroid Build Coastguard Worker      *
40*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name. If the image already exists, the call will fail.
41*4e2b41f1SAndroid Build Coastguard Worker      * @param size          Image size, in bytes. If too large, or not enough space is
42*4e2b41f1SAndroid Build Coastguard Worker      *                      free, the call will fail.
43*4e2b41f1SAndroid Build Coastguard Worker      * @param readonly      If readonly, MapBackingImage() will configure the device as
44*4e2b41f1SAndroid Build Coastguard Worker      *                      readonly.
45*4e2b41f1SAndroid Build Coastguard Worker      * @param on_progress   Progress callback. It is invoked when there is an interesting update.
46*4e2b41f1SAndroid Build Coastguard Worker      *                      For each invocation, |current| is the number of bytes actually written,
47*4e2b41f1SAndroid Build Coastguard Worker      *                      and |total| is set to |size|.
48*4e2b41f1SAndroid Build Coastguard Worker      * @throws ServiceSpecificException if any error occurs. Exception code is a
49*4e2b41f1SAndroid Build Coastguard Worker      *                      FiemapStatus::ErrorCode value.
50*4e2b41f1SAndroid Build Coastguard Worker      */
createBackingImage(@tf8InCpp String name, long size, int flags, @nullable IProgressCallback on_progress)51*4e2b41f1SAndroid Build Coastguard Worker     void createBackingImage(@utf8InCpp String name, long size, int flags,
52*4e2b41f1SAndroid Build Coastguard Worker                             @nullable IProgressCallback on_progress);
53*4e2b41f1SAndroid Build Coastguard Worker 
54*4e2b41f1SAndroid Build Coastguard Worker     /**
55*4e2b41f1SAndroid Build Coastguard Worker      * Delete an image created with createBackingImage.
56*4e2b41f1SAndroid Build Coastguard Worker      *
57*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
58*4e2b41f1SAndroid Build Coastguard Worker      * @throws ServiceSpecificException if any error occurs.
59*4e2b41f1SAndroid Build Coastguard Worker      */
deleteBackingImage(@tf8InCpp String name)60*4e2b41f1SAndroid Build Coastguard Worker     void deleteBackingImage(@utf8InCpp String name);
61*4e2b41f1SAndroid Build Coastguard Worker 
62*4e2b41f1SAndroid Build Coastguard Worker     /**
63*4e2b41f1SAndroid Build Coastguard Worker      * Map an image, created with createBackingImage, such that it is accessible as a
64*4e2b41f1SAndroid Build Coastguard Worker      * block device.
65*4e2b41f1SAndroid Build Coastguard Worker      *
66*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
67*4e2b41f1SAndroid Build Coastguard Worker      * @param timeout_ms    Time to wait for a valid mapping, in milliseconds. This must be more
68*4e2b41f1SAndroid Build Coastguard Worker      *                      than zero; 10 seconds is recommended.
69*4e2b41f1SAndroid Build Coastguard Worker      * @param mapping       Information about the newly mapped block device.
70*4e2b41f1SAndroid Build Coastguard Worker      */
mapImageDevice(@tf8InCpp String name, int timeout_ms, out MappedImage mapping)71*4e2b41f1SAndroid Build Coastguard Worker     void mapImageDevice(@utf8InCpp String name, int timeout_ms, out MappedImage mapping);
72*4e2b41f1SAndroid Build Coastguard Worker 
73*4e2b41f1SAndroid Build Coastguard Worker     /**
74*4e2b41f1SAndroid Build Coastguard Worker      * Unmap a block device previously mapped with mapBackingImage. This step is necessary before
75*4e2b41f1SAndroid Build Coastguard Worker      * calling deleteBackingImage.
76*4e2b41f1SAndroid Build Coastguard Worker      *
77*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
78*4e2b41f1SAndroid Build Coastguard Worker      */
unmapImageDevice(@tf8InCpp String name)79*4e2b41f1SAndroid Build Coastguard Worker     void unmapImageDevice(@utf8InCpp String name);
80*4e2b41f1SAndroid Build Coastguard Worker 
81*4e2b41f1SAndroid Build Coastguard Worker     /**
82*4e2b41f1SAndroid Build Coastguard Worker      * Returns whether or not a backing image exists.
83*4e2b41f1SAndroid Build Coastguard Worker      *
84*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
85*4e2b41f1SAndroid Build Coastguard Worker      */
backingImageExists(@tf8InCpp String name)86*4e2b41f1SAndroid Build Coastguard Worker     boolean backingImageExists(@utf8InCpp String name);
87*4e2b41f1SAndroid Build Coastguard Worker 
88*4e2b41f1SAndroid Build Coastguard Worker     /**
89*4e2b41f1SAndroid Build Coastguard Worker      * Returns whether or not the named image is mapped.
90*4e2b41f1SAndroid Build Coastguard Worker      *
91*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
92*4e2b41f1SAndroid Build Coastguard Worker      */
isImageMapped(@tf8InCpp String name)93*4e2b41f1SAndroid Build Coastguard Worker     boolean isImageMapped(@utf8InCpp String name);
94*4e2b41f1SAndroid Build Coastguard Worker 
95*4e2b41f1SAndroid Build Coastguard Worker     /**
96*4e2b41f1SAndroid Build Coastguard Worker      * Retrieve AVB public key from an image.
97*4e2b41f1SAndroid Build Coastguard Worker      * If the image is already mapped then it works the same as
98*4e2b41f1SAndroid Build Coastguard Worker      * IGsiService::getAvbPublicKey(). Otherwise this will attempt to
99*4e2b41f1SAndroid Build Coastguard Worker      * map / unmap the partition image upon enter / return.
100*4e2b41f1SAndroid Build Coastguard Worker      *
101*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name as passed to createBackingImage().
102*4e2b41f1SAndroid Build Coastguard Worker      * @param dst           Output of the AVB public key.
103*4e2b41f1SAndroid Build Coastguard Worker      * @return              0 on success, an error code on failure.
104*4e2b41f1SAndroid Build Coastguard Worker      */
getAvbPublicKey(@tf8InCpp String name, out AvbPublicKey dst)105*4e2b41f1SAndroid Build Coastguard Worker     int getAvbPublicKey(@utf8InCpp String name, out AvbPublicKey dst);
106*4e2b41f1SAndroid Build Coastguard Worker 
107*4e2b41f1SAndroid Build Coastguard Worker     /**
108*4e2b41f1SAndroid Build Coastguard Worker      * Get all installed backing image names
109*4e2b41f1SAndroid Build Coastguard Worker      *
110*4e2b41f1SAndroid Build Coastguard Worker      * @return list of installed backing image names
111*4e2b41f1SAndroid Build Coastguard Worker      */
getAllBackingImages()112*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp List<String> getAllBackingImages();
113*4e2b41f1SAndroid Build Coastguard Worker 
114*4e2b41f1SAndroid Build Coastguard Worker     /**
115*4e2b41f1SAndroid Build Coastguard Worker      * Writes a given amount of zeros in image file.
116*4e2b41f1SAndroid Build Coastguard Worker      *
117*4e2b41f1SAndroid Build Coastguard Worker      * @param name          Image name. If the image does not exist, the call
118*4e2b41f1SAndroid Build Coastguard Worker      *                      will fail.
119*4e2b41f1SAndroid Build Coastguard Worker      * @param bytes         Number of zeros to be written, starting from the
120*4e2b41f1SAndroid Build Coastguard Worker      *                      beginning. If bytes is equal to 0, then the whole
121*4e2b41f1SAndroid Build Coastguard Worker      *                      image file is filled with zeros.
122*4e2b41f1SAndroid Build Coastguard Worker      * @throws ServiceSpecificException if any error occurs. Exception code is a
123*4e2b41f1SAndroid Build Coastguard Worker      *                      FiemapStatus::ErrorCode value.
124*4e2b41f1SAndroid Build Coastguard Worker      */
zeroFillNewImage(@tf8InCpp String name, long bytes)125*4e2b41f1SAndroid Build Coastguard Worker     void zeroFillNewImage(@utf8InCpp String name, long bytes);
126*4e2b41f1SAndroid Build Coastguard Worker 
127*4e2b41f1SAndroid Build Coastguard Worker     /**
128*4e2b41f1SAndroid Build Coastguard Worker      * Find and remove all images in the containing folder of this instance.
129*4e2b41f1SAndroid Build Coastguard Worker      */
removeAllImages()130*4e2b41f1SAndroid Build Coastguard Worker     void removeAllImages();
131*4e2b41f1SAndroid Build Coastguard Worker 
132*4e2b41f1SAndroid Build Coastguard Worker     /**
133*4e2b41f1SAndroid Build Coastguard Worker      * Mark an image as disabled.
134*4e2b41f1SAndroid Build Coastguard Worker      */
disableImage(@tf8InCpp String name)135*4e2b41f1SAndroid Build Coastguard Worker     void disableImage(@utf8InCpp String name);
136*4e2b41f1SAndroid Build Coastguard Worker 
137*4e2b41f1SAndroid Build Coastguard Worker     /**
138*4e2b41f1SAndroid Build Coastguard Worker      * Remove all images that were marked as disabled.
139*4e2b41f1SAndroid Build Coastguard Worker      */
removeDisabledImages()140*4e2b41f1SAndroid Build Coastguard Worker     void removeDisabledImages();
141*4e2b41f1SAndroid Build Coastguard Worker 
142*4e2b41f1SAndroid Build Coastguard Worker     /**
143*4e2b41f1SAndroid Build Coastguard Worker      * Return whether an image is disabled.
144*4e2b41f1SAndroid Build Coastguard Worker      */
isImageDisabled(@tf8InCpp String name)145*4e2b41f1SAndroid Build Coastguard Worker     boolean isImageDisabled(@utf8InCpp String name);
146*4e2b41f1SAndroid Build Coastguard Worker 
147*4e2b41f1SAndroid Build Coastguard Worker     /**
148*4e2b41f1SAndroid Build Coastguard Worker      * Return the block device path of a mapped image, or an empty string if not mapped.
149*4e2b41f1SAndroid Build Coastguard Worker      */
getMappedImageDevice(@tf8InCpp String name)150*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp String getMappedImageDevice(@utf8InCpp String name);
151*4e2b41f1SAndroid Build Coastguard Worker }
152