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 */ 29 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") startInstallation(@tf8InCpp String dsuSlot)30 boolean startInstallation(@utf8InCpp String dsuSlot); 31 32 /** 33 * Create a DSU partition. This call may take 60~90 seconds. The caller 34 * may use another thread to call the getStartProgress() to get the progress. 35 * @param name The DSU partition name 36 * @param size Size of the DSU image in bytes 37 * @param readOnly True if this partition is readOnly 38 * @return IGsiService.INSTALL_* status code 39 */ 40 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") createPartition(@tf8InCpp String name, long size, boolean readOnly)41 int createPartition(@utf8InCpp String name, long size, boolean readOnly); 42 43 /** 44 * Complete the current partition installation. 45 * 46 * @return true if the partition installation completes without error. 47 */ 48 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") closePartition()49 boolean closePartition(); 50 51 /** 52 * Finish a previously started installation. Installations without 53 * a cooresponding finishInstallation() will be cleaned up during device boot. 54 */ 55 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") finishInstallation()56 boolean finishInstallation(); 57 58 /** 59 * Query the progress of the current installation operation. This can be called while 60 * the installation is in progress. 61 * 62 * @return GsiProgress 63 */ 64 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") getInstallationProgress()65 GsiProgress getInstallationProgress(); 66 67 /** 68 * Abort the installation process. Note this method must be called in a thread other 69 * than the one calling the startInstallation method as the startInstallation 70 * method will not return until it is finished. 71 * 72 * @return true if the call succeeds 73 */ 74 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") abort()75 boolean abort(); 76 77 /** 78 * @return true if the device is running an DynamicAnroid image 79 */ 80 @RequiresNoPermission isInUse()81 boolean isInUse(); 82 83 /** 84 * @return true if the device has an DynamicSystem image installed 85 */ 86 @RequiresNoPermission isInstalled()87 boolean isInstalled(); 88 89 /** 90 * @return true if the device has an DynamicSystem image enabled 91 */ 92 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") isEnabled()93 boolean isEnabled(); 94 95 /** 96 * Remove DynamicSystem installation if present 97 * 98 * @return true if the call succeeds 99 */ 100 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") remove()101 boolean remove(); 102 103 /** 104 * Enable or disable DynamicSystem. 105 * 106 * @param oneShot If true, the GSI will boot once and then disable itself. 107 * 108 * @return true if the call succeeds 109 */ 110 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") setEnable(boolean enable, boolean oneShot)111 boolean setEnable(boolean enable, boolean oneShot); 112 113 /** 114 * Set the file descriptor that points to a ashmem which will be used 115 * to fetch data during the submitFromAshmem. 116 * 117 * @param fd fd that points to a ashmem 118 * @param size size of the ashmem file 119 */ 120 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") setAshmem(in ParcelFileDescriptor fd, long size)121 boolean setAshmem(in ParcelFileDescriptor fd, long size); 122 123 /** 124 * Submit bytes to the DSU partition from the ashmem previously set with 125 * setAshmem. 126 * 127 * @param bytes number of bytes that can be read from stream. 128 * @return true on success, false otherwise. 129 */ 130 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") submitFromAshmem(long bytes)131 boolean submitFromAshmem(long bytes); 132 133 /** 134 * Retrieve AVB public key from installing partition. 135 * 136 * @param dst Output the AVB public key. 137 * @return true on success, false if partition doesn't have a 138 * valid VBMeta block to retrieve the AVB key from. 139 */ 140 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") getAvbPublicKey(out AvbPublicKey dst)141 boolean getAvbPublicKey(out AvbPublicKey dst); 142 143 /** 144 * Returns the suggested scratch partition size for overlayFS. 145 */ 146 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") suggestScratchSize()147 long suggestScratchSize(); 148 149 /** 150 * Get the active DSU slot 151 */ 152 @EnforcePermission("MANAGE_DYNAMIC_SYSTEM") getActiveDsuSlot()153 String getActiveDsuSlot(); 154 } 155