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 package android.os.image;
17 
18 import android.gsi.AvbPublicKey;
19 import android.gsi.GsiProgress;
20 
21 /** {@hide} */
22 interface IDynamicSystemService
23 {
24     /**
25      * Start DynamicSystem installation.
26      * @param dsuSlot Name used to identify this installation
27      * @return true if the call succeeds
28      */
startInstallation(@tf8InCpp String dsuSlot)29     boolean startInstallation(@utf8InCpp String dsuSlot);
30 
31     /**
32      * Create a DSU partition. This call may take 60~90 seconds. The caller
33      * may use another thread to call the getStartProgress() to get the progress.
34      * @param name The DSU partition name
35      * @param size Size of the DSU image in bytes
36      * @param readOnly True if this partition is readOnly
37      * @return true if the call succeeds
38      */
createPartition(@tf8InCpp String name, long size, boolean readOnly)39     boolean createPartition(@utf8InCpp String name, long size, boolean readOnly);
40 
41     /**
42      * Finish a previously started installation. Installations without
43      * a cooresponding finishInstallation() will be cleaned up during device boot.
44      */
finishInstallation()45     boolean finishInstallation();
46 
47     /**
48      * Query the progress of the current installation operation. This can be called while
49      * the installation is in progress.
50      *
51      * @return GsiProgress
52      */
getInstallationProgress()53     GsiProgress getInstallationProgress();
54 
55     /**
56      * Abort the installation process. Note this method must be called in a thread other
57      * than the one calling the startInstallation method as the startInstallation
58      * method will not return until it is finished.
59      *
60      * @return true if the call succeeds
61      */
abort()62     boolean abort();
63 
64     /**
65      * @return true if the device is running an DynamicAnroid image
66      */
isInUse()67     boolean isInUse();
68 
69     /**
70      * @return true if the device has an DynamicSystem image installed
71      */
isInstalled()72     boolean isInstalled();
73 
74     /**
75      * @return true if the device has an DynamicSystem image enabled
76      */
isEnabled()77     boolean isEnabled();
78 
79     /**
80      * Remove DynamicSystem installation if present
81      *
82      * @return true if the call succeeds
83      */
remove()84     boolean remove();
85 
86     /**
87      * Enable or disable DynamicSystem.
88      *
89      * @param oneShot       If true, the GSI will boot once and then disable itself.
90      *
91      * @return true if the call succeeds
92      */
setEnable(boolean enable, boolean oneShot)93     boolean setEnable(boolean enable, boolean oneShot);
94 
95     /**
96      * Set the file descriptor that points to a ashmem which will be used
97      * to fetch data during the submitFromAshmem.
98      *
99      * @param fd            fd that points to a ashmem
100      * @param size          size of the ashmem file
101      */
setAshmem(in ParcelFileDescriptor fd, long size)102     boolean setAshmem(in ParcelFileDescriptor fd, long size);
103 
104     /**
105      * Submit bytes to the DSU partition from the ashmem previously set with
106      * setAshmem.
107      *
108      * @param bytes         number of bytes that can be read from stream.
109      * @return              true on success, false otherwise.
110      */
submitFromAshmem(long bytes)111     boolean submitFromAshmem(long bytes);
112 
113     /**
114      * Retrieve AVB public key from installing partition.
115      *
116      * @param dst           Output the AVB public key.
117      * @return              true on success, false if partition doesn't have a
118      *                      valid VBMeta block to retrieve the AVB key from.
119      */
getAvbPublicKey(out AvbPublicKey dst)120     boolean getAvbPublicKey(out AvbPublicKey dst);
121 }
122