• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.gsi;
18 
19 import android.gsi.GsiInstallParams;
20 import android.gsi.GsiProgress;
21 import android.os.ParcelFileDescriptor;
22 
23 /** {@hide} */
24 interface IGsiService {
25     /* Status codes for GsiProgress.status */
26     const int STATUS_NO_OPERATION = 0;
27     const int STATUS_WORKING = 1;
28     const int STATUS_COMPLETE = 2;
29 
30     /* Install succeeded. */
31     const int INSTALL_OK = 0;
32     /* Install failed with a generic system error. */
33     const int INSTALL_ERROR_GENERIC = 1;
34     /* Install failed because there was no free space. */
35     const int INSTALL_ERROR_NO_SPACE = 2;
36     /**
37      * Install failed because the file system was too fragmented or did not
38      * have enough additional free space.
39      */
40     const int INSTALL_ERROR_FILE_SYSTEM_CLUTTERED = 3;
41 
42     /**
43      * Starts a GSI installation. Use beginGsiInstall() to target external
44      * media.
45      *
46      * If wipeUserData is true, a clean userdata image is always created to the
47      * desired size.
48      *
49      * If wipeUserData is false, a userdata image is only created if one does
50      * not already exist. If the size is zero, a default size of 8GiB is used.
51      * If there is an existing image smaller than the desired size, it is
52      * resized automatically.
53      *
54      * @param gsiSize       The size of the on-disk GSI image.
55      * @param userdataSize  The desired size of the userdata partition.
56      * @param wipeUserdata  True to wipe destination userdata.
57      * @return              0 on success, an error code on failure.
58      */
startGsiInstall(long gsiSize, long userdataSize, boolean wipeUserdata)59     int startGsiInstall(long gsiSize, long userdataSize, boolean wipeUserdata);
60 
61     /**
62      * Write bytes from a stream to the on-disk GSI.
63      *
64      * @param stream        Stream descriptor.
65      * @param bytes         Number of bytes that can be read from stream.
66      * @return              true on success, false otherwise.
67      */
commitGsiChunkFromStream(in ParcelFileDescriptor stream, long bytes)68     boolean commitGsiChunkFromStream(in ParcelFileDescriptor stream, long bytes);
69 
70     /**
71      * Query the progress of the current asynchronous install operation. This
72      * can be called while another operation is in progress.
73      */
getInstallProgress()74     GsiProgress getInstallProgress();
75 
76     /**
77      * Write bytes from memory to the on-disk GSI.
78      *
79      * @param bytes         Byte array.
80      * @return              true on success, false otherwise.
81      */
commitGsiChunkFromMemory(in byte[] bytes)82     boolean commitGsiChunkFromMemory(in byte[] bytes);
83 
84     /**
85      * Complete a GSI installation and mark it as bootable. The caller is
86      * responsible for rebooting the device as soon as possible.
87      *
88      * @param oneShot       If true, the GSI will boot once and then disable itself.
89      *                      It can still be re-enabled again later with setGsiBootable.
90      * @return              INSTALL_* error code.
91      */
setGsiBootable(boolean oneShot)92     int setGsiBootable(boolean oneShot);
93 
94     /**
95      * @return              True if Gsi is enabled
96      */
isGsiEnabled()97     boolean isGsiEnabled();
98 
99     /**
100      * Cancel an in-progress GSI install.
101      */
cancelGsiInstall()102     boolean cancelGsiInstall();
103 
104     /**
105      * Return if a GSI installation is currently in-progress.
106      */
isGsiInstallInProgress()107     boolean isGsiInstallInProgress();
108 
109     /**
110      * Remove a GSI install. This will completely remove and reclaim space used
111      * by the GSI and its userdata. If currently running a GSI, space will be
112      * reclaimed on the reboot.
113      *
114      * @return              true on success, false otherwise.
115      */
removeGsiInstall()116     boolean removeGsiInstall();
117 
118     /**
119      * Disables a GSI install. The image and userdata will be retained, but can
120      * be re-enabled at any time with setGsiBootable.
121      */
disableGsiInstall()122     boolean disableGsiInstall();
123 
124     /**
125      * Return the size of the userdata partition for an installed GSI. If there
126      * is no image, 0 is returned. On error, -1 is returned.
127      */
getUserdataImageSize()128     long getUserdataImageSize();
129 
130     /**
131      * Returns true if the gsi is currently running, false otherwise.
132      */
isGsiRunning()133     boolean isGsiRunning();
134 
135     /**
136      * Returns true if a gsi is installed.
137      */
isGsiInstalled()138     boolean isGsiInstalled();
139 
140     /* No GSI is installed. */
141     const int BOOT_STATUS_NOT_INSTALLED = 0;
142     /* GSI is installed, but booting is disabled. */
143     const int BOOT_STATUS_DISABLED = 1;
144     /* GSI is installed, but will only boot once. */
145     const int BOOT_STATUS_SINGLE_BOOT = 2;
146     /* GSI is installed and bootable. */
147     const int BOOT_STATUS_ENABLED = 3;
148     /* GSI will be wiped next boot. */
149     const int BOOT_STATUS_WILL_WIPE = 4;
150 
151     /**
152      * Returns the boot status of a GSI. See the BOOT_STATUS constants in IGsiService.
153      *
154      * GSI_STATE_NOT_INSTALLED will be returned if no GSI installation has been
155      * fully completed. Any other value indicates a GSI is installed. If a GSI
156      * currently running, DISABLED or SINGLE_BOOT can still be returned.
157      */
getGsiBootStatus()158     int getGsiBootStatus();
159 
160     /**
161      * If a GSI is installed, returns the directory where the installed images
162      * are located. Otherwise, returns an empty string.
163      */
getInstalledGsiImageDir()164      @utf8InCpp String getInstalledGsiImageDir();
165 
166     /**
167      * Begin a GSI installation.
168      *
169      * This is a replacement for startGsiInstall, in order to supply additional
170      * options.
171      *
172      * @return              0 on success, an error code on failure.
173      */
beginGsiInstall(in GsiInstallParams params)174     int beginGsiInstall(in GsiInstallParams params);
175 
176     /**
177      * Wipe the userdata of an existing GSI install. This will not work if the
178      * GSI is currently running. The userdata image will not be removed, but the
179      * first block will be zeroed ensuring that the next GSI boot formats /data.
180      *
181      * @return              0 on success, an error code on failure.
182      */
wipeGsiUserdata()183     int wipeGsiUserdata();
184 }
185