• 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 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      * Complete the current partition installation.
43      *
44      * @return true if the partition installation completes without error.
45      */
closePartition()46     boolean closePartition();
47 
48     /**
49      * Finish a previously started installation. Installations without
50      * a cooresponding finishInstallation() will be cleaned up during device boot.
51      */
finishInstallation()52     boolean finishInstallation();
53 
54     /**
55      * Query the progress of the current installation operation. This can be called while
56      * the installation is in progress.
57      *
58      * @return GsiProgress
59      */
getInstallationProgress()60     GsiProgress getInstallationProgress();
61 
62     /**
63      * Abort the installation process. Note this method must be called in a thread other
64      * than the one calling the startInstallation method as the startInstallation
65      * method will not return until it is finished.
66      *
67      * @return true if the call succeeds
68      */
abort()69     boolean abort();
70 
71     /**
72      * @return true if the device is running an DynamicAnroid image
73      */
isInUse()74     boolean isInUse();
75 
76     /**
77      * @return true if the device has an DynamicSystem image installed
78      */
isInstalled()79     boolean isInstalled();
80 
81     /**
82      * @return true if the device has an DynamicSystem image enabled
83      */
isEnabled()84     boolean isEnabled();
85 
86     /**
87      * Remove DynamicSystem installation if present
88      *
89      * @return true if the call succeeds
90      */
remove()91     boolean remove();
92 
93     /**
94      * Enable or disable DynamicSystem.
95      *
96      * @param oneShot       If true, the GSI will boot once and then disable itself.
97      *
98      * @return true if the call succeeds
99      */
setEnable(boolean enable, boolean oneShot)100     boolean setEnable(boolean enable, boolean oneShot);
101 
102     /**
103      * Set the file descriptor that points to a ashmem which will be used
104      * to fetch data during the submitFromAshmem.
105      *
106      * @param fd            fd that points to a ashmem
107      * @param size          size of the ashmem file
108      */
setAshmem(in ParcelFileDescriptor fd, long size)109     boolean setAshmem(in ParcelFileDescriptor fd, long size);
110 
111     /**
112      * Submit bytes to the DSU partition from the ashmem previously set with
113      * setAshmem.
114      *
115      * @param bytes         number of bytes that can be read from stream.
116      * @return              true on success, false otherwise.
117      */
submitFromAshmem(long bytes)118     boolean submitFromAshmem(long bytes);
119 
120     /**
121      * Retrieve AVB public key from installing partition.
122      *
123      * @param dst           Output the AVB public key.
124      * @return              true on success, false if partition doesn't have a
125      *                      valid VBMeta block to retrieve the AVB key from.
126      */
getAvbPublicKey(out AvbPublicKey dst)127     boolean getAvbPublicKey(out AvbPublicKey dst);
128 
129     /**
130      * Returns the suggested scratch partition size for overlayFS.
131      */
suggestScratchSize()132     long suggestScratchSize();
133 }
134