xref: /aosp_15_r20/system/gsid/aidl/android/gsi/IGsiService.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.GsiProgress;
21*4e2b41f1SAndroid Build Coastguard Worker import android.gsi.IGsiServiceCallback;
22*4e2b41f1SAndroid Build Coastguard Worker import android.gsi.IImageService;
23*4e2b41f1SAndroid Build Coastguard Worker import android.os.ParcelFileDescriptor;
24*4e2b41f1SAndroid Build Coastguard Worker 
25*4e2b41f1SAndroid Build Coastguard Worker /** {@hide} */
26*4e2b41f1SAndroid Build Coastguard Worker interface IGsiService {
27*4e2b41f1SAndroid Build Coastguard Worker     /* Status codes for GsiProgress.status */
28*4e2b41f1SAndroid Build Coastguard Worker     const int STATUS_NO_OPERATION = 0;
29*4e2b41f1SAndroid Build Coastguard Worker     const int STATUS_WORKING = 1;
30*4e2b41f1SAndroid Build Coastguard Worker     const int STATUS_COMPLETE = 2;
31*4e2b41f1SAndroid Build Coastguard Worker 
32*4e2b41f1SAndroid Build Coastguard Worker     /* Install succeeded. */
33*4e2b41f1SAndroid Build Coastguard Worker     const int INSTALL_OK = 0;
34*4e2b41f1SAndroid Build Coastguard Worker     /* Install failed with a generic system error. */
35*4e2b41f1SAndroid Build Coastguard Worker     const int INSTALL_ERROR_GENERIC = 1;
36*4e2b41f1SAndroid Build Coastguard Worker     /* Install failed because there was no free space. */
37*4e2b41f1SAndroid Build Coastguard Worker     const int INSTALL_ERROR_NO_SPACE = 2;
38*4e2b41f1SAndroid Build Coastguard Worker     /**
39*4e2b41f1SAndroid Build Coastguard Worker      * Install failed because the file system was too fragmented or did not
40*4e2b41f1SAndroid Build Coastguard Worker      * have enough additional free space.
41*4e2b41f1SAndroid Build Coastguard Worker      */
42*4e2b41f1SAndroid Build Coastguard Worker     const int INSTALL_ERROR_FILE_SYSTEM_CLUTTERED = 3;
43*4e2b41f1SAndroid Build Coastguard Worker 
44*4e2b41f1SAndroid Build Coastguard Worker     /**
45*4e2b41f1SAndroid Build Coastguard Worker      * Write bytes from a stream to the on-disk GSI.
46*4e2b41f1SAndroid Build Coastguard Worker      *
47*4e2b41f1SAndroid Build Coastguard Worker      * @param stream        Stream descriptor.
48*4e2b41f1SAndroid Build Coastguard Worker      * @param bytes         Number of bytes that can be read from stream.
49*4e2b41f1SAndroid Build Coastguard Worker      * @return              true on success, false otherwise.
50*4e2b41f1SAndroid Build Coastguard Worker      */
commitGsiChunkFromStream(in ParcelFileDescriptor stream, long bytes)51*4e2b41f1SAndroid Build Coastguard Worker     boolean commitGsiChunkFromStream(in ParcelFileDescriptor stream, long bytes);
52*4e2b41f1SAndroid Build Coastguard Worker 
53*4e2b41f1SAndroid Build Coastguard Worker     /**
54*4e2b41f1SAndroid Build Coastguard Worker      * Query the progress of the current asynchronous install operation. This
55*4e2b41f1SAndroid Build Coastguard Worker      * can be called while another operation is in progress.
56*4e2b41f1SAndroid Build Coastguard Worker      */
getInstallProgress()57*4e2b41f1SAndroid Build Coastguard Worker     GsiProgress getInstallProgress();
58*4e2b41f1SAndroid Build Coastguard Worker 
59*4e2b41f1SAndroid Build Coastguard Worker     /**
60*4e2b41f1SAndroid Build Coastguard Worker      * Set the file descriptor that points to a ashmem which will be used
61*4e2b41f1SAndroid Build Coastguard Worker      * to fetch data during the commitGsiChunkFromAshmem.
62*4e2b41f1SAndroid Build Coastguard Worker      *
63*4e2b41f1SAndroid Build Coastguard Worker      * @param stream        fd that points to a ashmem
64*4e2b41f1SAndroid Build Coastguard Worker      * @param size          size of the ashmem file
65*4e2b41f1SAndroid Build Coastguard Worker      */
setGsiAshmem(in ParcelFileDescriptor stream, long size)66*4e2b41f1SAndroid Build Coastguard Worker     boolean setGsiAshmem(in ParcelFileDescriptor stream, long size);
67*4e2b41f1SAndroid Build Coastguard Worker 
68*4e2b41f1SAndroid Build Coastguard Worker     /**
69*4e2b41f1SAndroid Build Coastguard Worker      * Write bytes from ashmem previously set with setGsiAshmem to GSI partition
70*4e2b41f1SAndroid Build Coastguard Worker      *
71*4e2b41f1SAndroid Build Coastguard Worker      * @param bytes         Number of bytes to submit
72*4e2b41f1SAndroid Build Coastguard Worker      * @return              true on success, false otherwise.
73*4e2b41f1SAndroid Build Coastguard Worker      */
commitGsiChunkFromAshmem(long bytes)74*4e2b41f1SAndroid Build Coastguard Worker     boolean commitGsiChunkFromAshmem(long bytes);
75*4e2b41f1SAndroid Build Coastguard Worker 
76*4e2b41f1SAndroid Build Coastguard Worker     /**
77*4e2b41f1SAndroid Build Coastguard Worker      * Mark a completed DSU installation as bootable. The caller is responsible
78*4e2b41f1SAndroid Build Coastguard Worker      * for rebooting the device as soon as possible.
79*4e2b41f1SAndroid Build Coastguard Worker      *
80*4e2b41f1SAndroid Build Coastguard Worker      * Could leave the installation in "disabled" state if failure.
81*4e2b41f1SAndroid Build Coastguard Worker      *
82*4e2b41f1SAndroid Build Coastguard Worker      * @param oneShot       If true, the GSI will boot once and then disable itself.
83*4e2b41f1SAndroid Build Coastguard Worker      *                      It can still be re-enabled again later with setGsiBootable.
84*4e2b41f1SAndroid Build Coastguard Worker      * @param dsuSlot       The DSU slot to be enabled. Possible values are available
85*4e2b41f1SAndroid Build Coastguard Worker      *                      with the getInstalledDsuSlots()
86*4e2b41f1SAndroid Build Coastguard Worker      *
87*4e2b41f1SAndroid Build Coastguard Worker      * @return              INSTALL_* error code.
88*4e2b41f1SAndroid Build Coastguard Worker      */
enableGsi(boolean oneShot, @utf8InCpp String dsuSlot)89*4e2b41f1SAndroid Build Coastguard Worker     int enableGsi(boolean oneShot, @utf8InCpp String dsuSlot);
90*4e2b41f1SAndroid Build Coastguard Worker 
91*4e2b41f1SAndroid Build Coastguard Worker     /**
92*4e2b41f1SAndroid Build Coastguard Worker      * Asynchronous enableGsi
93*4e2b41f1SAndroid Build Coastguard Worker      * @param result        callback for result
94*4e2b41f1SAndroid Build Coastguard Worker      */
95*4e2b41f1SAndroid Build Coastguard Worker     @SuppressWarnings(value={"mixed-oneway"})
enableGsiAsync(boolean oneShot, @utf8InCpp String dsuSlot, IGsiServiceCallback result)96*4e2b41f1SAndroid Build Coastguard Worker     oneway void enableGsiAsync(boolean oneShot, @utf8InCpp String dsuSlot, IGsiServiceCallback result);
97*4e2b41f1SAndroid Build Coastguard Worker 
98*4e2b41f1SAndroid Build Coastguard Worker     /**
99*4e2b41f1SAndroid Build Coastguard Worker      * @return              True if Gsi is enabled
100*4e2b41f1SAndroid Build Coastguard Worker      */
isGsiEnabled()101*4e2b41f1SAndroid Build Coastguard Worker     boolean isGsiEnabled();
102*4e2b41f1SAndroid Build Coastguard Worker 
103*4e2b41f1SAndroid Build Coastguard Worker     /**
104*4e2b41f1SAndroid Build Coastguard Worker      * Cancel an in-progress GSI install.
105*4e2b41f1SAndroid Build Coastguard Worker      */
cancelGsiInstall()106*4e2b41f1SAndroid Build Coastguard Worker     boolean cancelGsiInstall();
107*4e2b41f1SAndroid Build Coastguard Worker 
108*4e2b41f1SAndroid Build Coastguard Worker     /**
109*4e2b41f1SAndroid Build Coastguard Worker      * Return if a GSI installation is currently in-progress.
110*4e2b41f1SAndroid Build Coastguard Worker      */
isGsiInstallInProgress()111*4e2b41f1SAndroid Build Coastguard Worker     boolean isGsiInstallInProgress();
112*4e2b41f1SAndroid Build Coastguard Worker 
113*4e2b41f1SAndroid Build Coastguard Worker     /**
114*4e2b41f1SAndroid Build Coastguard Worker      * Remove a GSI install. This will completely remove and reclaim space used
115*4e2b41f1SAndroid Build Coastguard Worker      * by the GSI and its userdata. If currently running a GSI, space will be
116*4e2b41f1SAndroid Build Coastguard Worker      * reclaimed on the reboot.
117*4e2b41f1SAndroid Build Coastguard Worker      *
118*4e2b41f1SAndroid Build Coastguard Worker      * @return              true on success, false otherwise.
119*4e2b41f1SAndroid Build Coastguard Worker      */
removeGsi()120*4e2b41f1SAndroid Build Coastguard Worker     boolean removeGsi();
121*4e2b41f1SAndroid Build Coastguard Worker 
122*4e2b41f1SAndroid Build Coastguard Worker     /**
123*4e2b41f1SAndroid Build Coastguard Worker      * Asynchronous removeGsi
124*4e2b41f1SAndroid Build Coastguard Worker      * @param result        callback for result
125*4e2b41f1SAndroid Build Coastguard Worker      */
126*4e2b41f1SAndroid Build Coastguard Worker     @SuppressWarnings(value={"mixed-oneway"})
removeGsiAsync(IGsiServiceCallback result)127*4e2b41f1SAndroid Build Coastguard Worker     oneway void removeGsiAsync(IGsiServiceCallback result);
128*4e2b41f1SAndroid Build Coastguard Worker 
129*4e2b41f1SAndroid Build Coastguard Worker     /**
130*4e2b41f1SAndroid Build Coastguard Worker      * Disables a GSI install. The image and userdata will be retained, but can
131*4e2b41f1SAndroid Build Coastguard Worker      * be re-enabled at any time with setGsiBootable.
132*4e2b41f1SAndroid Build Coastguard Worker      */
disableGsi()133*4e2b41f1SAndroid Build Coastguard Worker     boolean disableGsi();
134*4e2b41f1SAndroid Build Coastguard Worker 
135*4e2b41f1SAndroid Build Coastguard Worker     /**
136*4e2b41f1SAndroid Build Coastguard Worker      * Returns true if a gsi is installed.
137*4e2b41f1SAndroid Build Coastguard Worker      */
isGsiInstalled()138*4e2b41f1SAndroid Build Coastguard Worker     boolean isGsiInstalled();
139*4e2b41f1SAndroid Build Coastguard Worker     /**
140*4e2b41f1SAndroid Build Coastguard Worker      * Returns true if the gsi is currently running, false otherwise.
141*4e2b41f1SAndroid Build Coastguard Worker      */
isGsiRunning()142*4e2b41f1SAndroid Build Coastguard Worker     boolean isGsiRunning();
143*4e2b41f1SAndroid Build Coastguard Worker 
144*4e2b41f1SAndroid Build Coastguard Worker     /**
145*4e2b41f1SAndroid Build Coastguard Worker      * Returns the active DSU slot if there is any DSU installed, empty string otherwise.
146*4e2b41f1SAndroid Build Coastguard Worker      */
getActiveDsuSlot()147*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp String getActiveDsuSlot();
148*4e2b41f1SAndroid Build Coastguard Worker 
149*4e2b41f1SAndroid Build Coastguard Worker     /**
150*4e2b41f1SAndroid Build Coastguard Worker      * If a GSI is installed, returns the directory where the installed images
151*4e2b41f1SAndroid Build Coastguard Worker      * are located. Otherwise, returns an empty string.
152*4e2b41f1SAndroid Build Coastguard Worker      */
getInstalledGsiImageDir()153*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp String getInstalledGsiImageDir();
154*4e2b41f1SAndroid Build Coastguard Worker 
155*4e2b41f1SAndroid Build Coastguard Worker     /**
156*4e2b41f1SAndroid Build Coastguard Worker      * Returns all installed DSU slots.
157*4e2b41f1SAndroid Build Coastguard Worker      */
getInstalledDsuSlots()158*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp List<String> getInstalledDsuSlots();
159*4e2b41f1SAndroid Build Coastguard Worker 
160*4e2b41f1SAndroid Build Coastguard Worker     /**
161*4e2b41f1SAndroid Build Coastguard Worker      * Open a DSU installation
162*4e2b41f1SAndroid Build Coastguard Worker      *
163*4e2b41f1SAndroid Build Coastguard Worker      * @param installDir The directory to install DSU images under. This must be
164*4e2b41f1SAndroid Build Coastguard Worker      *     either an empty string (which will use the default /data/gsi),
165*4e2b41f1SAndroid Build Coastguard Worker      *     "/data/gsi", or a mount under /mnt/media_rw. It may end in a trailing slash.
166*4e2b41f1SAndroid Build Coastguard Worker      *
167*4e2b41f1SAndroid Build Coastguard Worker      * @return              0 on success, an error code on failure.
168*4e2b41f1SAndroid Build Coastguard Worker      */
openInstall(in @tf8InCpp String installDir)169*4e2b41f1SAndroid Build Coastguard Worker     int openInstall(in @utf8InCpp String installDir);
170*4e2b41f1SAndroid Build Coastguard Worker 
171*4e2b41f1SAndroid Build Coastguard Worker     /**
172*4e2b41f1SAndroid Build Coastguard Worker      * Close a DSU installation. An installation is complete after the close been invoked.
173*4e2b41f1SAndroid Build Coastguard Worker      */
closeInstall()174*4e2b41f1SAndroid Build Coastguard Worker     int closeInstall();
175*4e2b41f1SAndroid Build Coastguard Worker 
176*4e2b41f1SAndroid Build Coastguard Worker     /**
177*4e2b41f1SAndroid Build Coastguard Worker      * Create a DSU partition within the current installation
178*4e2b41f1SAndroid Build Coastguard Worker      *
179*4e2b41f1SAndroid Build Coastguard Worker      * @param name The DSU partition name
180*4e2b41f1SAndroid Build Coastguard Worker      * @param size Bytes in the partition
181*4e2b41f1SAndroid Build Coastguard Worker      * @param readOnly True if the partition is readOnly when DSU is running
182*4e2b41f1SAndroid Build Coastguard Worker      */
createPartition(in @tf8InCpp String name, long size, boolean readOnly)183*4e2b41f1SAndroid Build Coastguard Worker     int createPartition(in @utf8InCpp String name, long size, boolean readOnly);
184*4e2b41f1SAndroid Build Coastguard Worker 
185*4e2b41f1SAndroid Build Coastguard Worker     /**
186*4e2b41f1SAndroid Build Coastguard Worker      * Complete the current partition installation. A partition installation is
187*4e2b41f1SAndroid Build Coastguard Worker      * complete after all pending bytes are written successfully.
188*4e2b41f1SAndroid Build Coastguard Worker      * Returns an error if current installation still have pending bytes.
189*4e2b41f1SAndroid Build Coastguard Worker      * Returns an error if there is any internal filesystem error.
190*4e2b41f1SAndroid Build Coastguard Worker      *
191*4e2b41f1SAndroid Build Coastguard Worker      * @return              0 on success, an error code on failure.
192*4e2b41f1SAndroid Build Coastguard Worker      */
closePartition()193*4e2b41f1SAndroid Build Coastguard Worker     int closePartition();
194*4e2b41f1SAndroid Build Coastguard Worker 
195*4e2b41f1SAndroid Build Coastguard Worker     /**
196*4e2b41f1SAndroid Build Coastguard Worker      * Wipe a partition. This will not work if the GSI is currently running.
197*4e2b41f1SAndroid Build Coastguard Worker      * The partition will not be removed, but the first block will be zeroed.
198*4e2b41f1SAndroid Build Coastguard Worker      *
199*4e2b41f1SAndroid Build Coastguard Worker      * @param name The DSU partition name
200*4e2b41f1SAndroid Build Coastguard Worker      *
201*4e2b41f1SAndroid Build Coastguard Worker      * @return              0 on success, an error code on failure.
202*4e2b41f1SAndroid Build Coastguard Worker      */
zeroPartition(in @tf8InCpp String name)203*4e2b41f1SAndroid Build Coastguard Worker     int zeroPartition(in @utf8InCpp String name);
204*4e2b41f1SAndroid Build Coastguard Worker 
205*4e2b41f1SAndroid Build Coastguard Worker     /**
206*4e2b41f1SAndroid Build Coastguard Worker      * Open a handle to an IImageService for the given metadata and data storage paths.
207*4e2b41f1SAndroid Build Coastguard Worker      *
208*4e2b41f1SAndroid Build Coastguard Worker      * @param prefix        A prefix used to organize images. The data path will become
209*4e2b41f1SAndroid Build Coastguard Worker      *                      /data/gsi/{prefix} and the metadata path will become
210*4e2b41f1SAndroid Build Coastguard Worker      *                      /metadata/gsi/{prefix}.
211*4e2b41f1SAndroid Build Coastguard Worker      */
openImageService(@tf8InCpp String prefix)212*4e2b41f1SAndroid Build Coastguard Worker     IImageService openImageService(@utf8InCpp String prefix);
213*4e2b41f1SAndroid Build Coastguard Worker 
214*4e2b41f1SAndroid Build Coastguard Worker     /**
215*4e2b41f1SAndroid Build Coastguard Worker      * Dump diagnostic information about device-mapper devices. This is intended
216*4e2b41f1SAndroid Build Coastguard Worker      * for dumpstate.
217*4e2b41f1SAndroid Build Coastguard Worker      */
dumpDeviceMapperDevices()218*4e2b41f1SAndroid Build Coastguard Worker     @utf8InCpp String dumpDeviceMapperDevices();
219*4e2b41f1SAndroid Build Coastguard Worker 
220*4e2b41f1SAndroid Build Coastguard Worker     /**
221*4e2b41f1SAndroid Build Coastguard Worker      * Retrieve AVB public key from the current mapped partition.
222*4e2b41f1SAndroid Build Coastguard Worker      * This works only while partition device is mapped and the end-of-partition
223*4e2b41f1SAndroid Build Coastguard Worker      * AVB footer has been written.
224*4e2b41f1SAndroid Build Coastguard Worker      * A call to createPartition() does the following things:
225*4e2b41f1SAndroid Build Coastguard Worker      * 1. Close the previous partition installer, thus unmap the partition.
226*4e2b41f1SAndroid Build Coastguard Worker      * 2. Open a new partition installer.
227*4e2b41f1SAndroid Build Coastguard Worker      * 3. Create and map the new partition.
228*4e2b41f1SAndroid Build Coastguard Worker      *
229*4e2b41f1SAndroid Build Coastguard Worker      * In other words, getAvbPublicKey() should be called after
230*4e2b41f1SAndroid Build Coastguard Worker      * createPartition() is called and before closePartition() is called.
231*4e2b41f1SAndroid Build Coastguard Worker      *
232*4e2b41f1SAndroid Build Coastguard Worker      * @param dst           Output the AVB public key.
233*4e2b41f1SAndroid Build Coastguard Worker      * @return              0 on success, an error code on failure.
234*4e2b41f1SAndroid Build Coastguard Worker      */
getAvbPublicKey(out AvbPublicKey dst)235*4e2b41f1SAndroid Build Coastguard Worker     int getAvbPublicKey(out AvbPublicKey dst);
236*4e2b41f1SAndroid Build Coastguard Worker 
237*4e2b41f1SAndroid Build Coastguard Worker     /**
238*4e2b41f1SAndroid Build Coastguard Worker      * Returns the suggested scratch partition size for overlayFS.
239*4e2b41f1SAndroid Build Coastguard Worker      */
suggestScratchSize()240*4e2b41f1SAndroid Build Coastguard Worker     long suggestScratchSize();
241*4e2b41f1SAndroid Build Coastguard Worker }
242