Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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.os; |
| 18 | |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 19 | import android.os.incremental.IncrementalFileSystemControlParcel; |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 20 | import android.os.IVoldListener; |
Zim | 5048b4b | 2019-11-19 09:16:03 +0000 | [diff] [blame] | 21 | import android.os.IVoldMountCallback; |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 22 | import android.os.IVoldTaskListener; |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 23 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 24 | /** {@hide} */ |
| 25 | interface IVold { |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 26 | void setListener(IVoldListener listener); |
| 27 | |
Martijn Coenen | 23c0445 | 2020-04-29 07:49:41 +0200 | [diff] [blame] | 28 | void abortFuse(); |
Jeff Sharkey | cbe69fc | 2017-09-15 16:50:28 -0600 | [diff] [blame] | 29 | void monitor(); |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 30 | void reset(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 31 | void shutdown(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 32 | |
| 33 | void onUserAdded(int userId, int userSerial); |
| 34 | void onUserRemoved(int userId); |
Sudheer Shanka | 5fceb48 | 2019-04-29 10:46:35 -0700 | [diff] [blame] | 35 | void onUserStarted(int userId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 36 | void onUserStopped(int userId); |
| 37 | |
Sudheer Shanka | d484aa9 | 2018-07-31 10:07:34 -0700 | [diff] [blame] | 38 | void addAppIds(in @utf8InCpp String[] packageNames, in int[] appIds); |
| 39 | void addSandboxIds(in int[] appIds, in @utf8InCpp String[] sandboxIds); |
| 40 | |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 41 | void onSecureKeyguardStateChanged(boolean isShowing); |
| 42 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 43 | void partition(@utf8InCpp String diskId, int partitionType, int ratio); |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 44 | void forgetPartition(@utf8InCpp String partGuid, @utf8InCpp String fsUuid); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 45 | |
Zim | 5048b4b | 2019-11-19 09:16:03 +0000 | [diff] [blame] | 46 | void mount(@utf8InCpp String volId, int mountFlags, int mountUserId, |
Zim | 9d1425c | 2019-11-27 18:15:14 +0000 | [diff] [blame] | 47 | @nullable IVoldMountCallback callback); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 48 | void unmount(@utf8InCpp String volId); |
| 49 | void format(@utf8InCpp String volId, @utf8InCpp String fsType); |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 50 | void benchmark(@utf8InCpp String volId, IVoldTaskListener listener); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 51 | |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 52 | void moveStorage(@utf8InCpp String fromVolId, @utf8InCpp String toVolId, |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 53 | IVoldTaskListener listener); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 54 | |
| 55 | void remountUid(int uid, int remountMode); |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 56 | void remountAppStorageDirs(int uid, int pid, in @utf8InCpp String[] packageNames); |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 57 | void unmountAppStorageDirs(int uid, int pid, in @utf8InCpp String[] packageNames); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 58 | |
Martijn Coenen | 8a68a07 | 2020-02-12 15:29:02 +0100 | [diff] [blame] | 59 | void setupAppDir(@utf8InCpp String path, int appUid); |
Martijn Coenen | 816f4d9 | 2020-02-18 15:06:37 +0100 | [diff] [blame] | 60 | void fixupAppDir(@utf8InCpp String path, int appUid); |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 61 | void ensureAppDirsCreated(in @utf8InCpp String[] paths, int appUid); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 62 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 63 | @utf8InCpp String createObb(@utf8InCpp String sourcePath, @utf8InCpp String sourceKey, |
| 64 | int ownerGid); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 65 | void destroyObb(@utf8InCpp String volId); |
| 66 | |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 67 | void fstrim(int fstrimFlags, IVoldTaskListener listener); |
Jin Qian | a370c14 | 2017-10-17 15:41:45 -0700 | [diff] [blame] | 68 | void runIdleMaint(IVoldTaskListener listener); |
| 69 | void abortIdleMaint(IVoldTaskListener listener); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 70 | |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 71 | FileDescriptor mountAppFuse(int uid, int mountId); |
| 72 | void unmountAppFuse(int uid, int mountId); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 73 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 74 | void fdeCheckPassword(@utf8InCpp String password); |
| 75 | void fdeRestart(); |
| 76 | int fdeComplete(); |
| 77 | void fdeEnable(int passwordType, @utf8InCpp String password, int encryptionFlags); |
| 78 | void fdeChangePassword(int passwordType, @utf8InCpp String password); |
| 79 | void fdeVerifyPassword(@utf8InCpp String password); |
| 80 | @utf8InCpp String fdeGetField(@utf8InCpp String key); |
| 81 | void fdeSetField(@utf8InCpp String key, @utf8InCpp String value); |
| 82 | int fdeGetPasswordType(); |
| 83 | @utf8InCpp String fdeGetPassword(); |
| 84 | void fdeClearPassword(); |
| 85 | |
| 86 | void fbeEnable(); |
| 87 | |
| 88 | void mountDefaultEncrypted(); |
| 89 | void initUser0(); |
| 90 | boolean isConvertibleToFbe(); |
Paul Lawrence | 236e5e8 | 2019-06-25 14:44:33 -0700 | [diff] [blame] | 91 | void mountFstab(@utf8InCpp String blkDevice, @utf8InCpp String mountPoint); |
Jaegeuk Kim | 0c52c71 | 2020-12-15 09:00:49 -0800 | [diff] [blame] | 92 | void encryptFstab(@utf8InCpp String blkDevice, @utf8InCpp String mountPoint, boolean shouldFormat, @utf8InCpp String fsType); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 93 | |
Seth Moore | 5a43d61 | 2021-01-19 17:51:51 +0000 | [diff] [blame] | 94 | void setStorageBindingSeed(in byte[] seed); |
| 95 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 96 | void createUserKey(int userId, int userSerial, boolean ephemeral); |
| 97 | void destroyUserKey(int userId); |
| 98 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 99 | void addUserKeyAuth(int userId, int userSerial, @utf8InCpp String token, |
| 100 | @utf8InCpp String secret); |
Barani Muthukumaran | 9ad51ad | 2019-10-31 22:59:34 -0700 | [diff] [blame] | 101 | void clearUserKeyAuth(int userId, int userSerial, @utf8InCpp String token, |
| 102 | @utf8InCpp String secret); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 103 | void fixateNewestUserKeyAuth(int userId); |
| 104 | |
Eric Biggers | 1799deb | 2021-04-06 12:02:56 -0700 | [diff] [blame] | 105 | int[] getUnlockedUsers(); |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 106 | void unlockUserKey(int userId, int userSerial, @utf8InCpp String token, |
| 107 | @utf8InCpp String secret); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 108 | void lockUserKey(int userId); |
| 109 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 110 | void prepareUserStorage(@nullable @utf8InCpp String uuid, int userId, int userSerial, |
| 111 | int storageFlags); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 112 | void destroyUserStorage(@nullable @utf8InCpp String uuid, int userId, int storageFlags); |
| 113 | |
Sudheer Shanka | fa6a174 | 2018-10-04 16:26:22 -0700 | [diff] [blame] | 114 | void prepareSandboxForApp(in @utf8InCpp String packageName, int appId, |
| 115 | in @utf8InCpp String sandboxId, int userId); |
Sudheer Shanka | 69bc40f | 2018-10-25 11:06:55 -0700 | [diff] [blame] | 116 | void destroySandboxForApp(in @utf8InCpp String packageName, |
Sudheer Shanka | fa6a174 | 2018-10-04 16:26:22 -0700 | [diff] [blame] | 117 | in @utf8InCpp String sandboxId, int userId); |
Sudheer Shanka | c756209 | 2018-08-24 10:20:56 -0700 | [diff] [blame] | 118 | |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 119 | void startCheckpoint(int retry); |
Daniel Rosenberg | 4f68471 | 2018-08-28 01:58:49 -0700 | [diff] [blame] | 120 | boolean needsCheckpoint(); |
Daniel Rosenberg | d399249 | 2018-10-02 17:40:44 -0700 | [diff] [blame] | 121 | boolean needsRollback(); |
David Anderson | 23850d3 | 2020-06-10 23:51:17 -0700 | [diff] [blame] | 122 | boolean isCheckpointing(); |
Daniel Rosenberg | a59e439 | 2019-03-20 17:02:47 -0700 | [diff] [blame] | 123 | void abortChanges(in @utf8InCpp String device, boolean retry); |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 124 | void commitChanges(); |
| 125 | void prepareCheckpoint(); |
| 126 | void restoreCheckpoint(@utf8InCpp String device); |
Daniel Rosenberg | dda5981 | 2019-03-06 17:45:17 -0800 | [diff] [blame] | 127 | void restoreCheckpointPart(@utf8InCpp String device, int count); |
Daniel Rosenberg | e334aab | 2018-10-10 18:52:04 -0700 | [diff] [blame] | 128 | void markBootAttempt(); |
Daniel Rosenberg | 9b667fb | 2019-01-22 17:27:25 -0800 | [diff] [blame] | 129 | boolean supportsCheckpoint(); |
Paul Lawrence | c5c79c5 | 2019-03-18 13:36:40 -0700 | [diff] [blame] | 130 | boolean supportsBlockCheckpoint(); |
| 131 | boolean supportsFileCheckpoint(); |
Nikita Ioffe | a5798fc | 2019-10-11 16:38:21 +0100 | [diff] [blame] | 132 | void resetCheckpoint(); |
Daniel Rosenberg | 4f68471 | 2018-08-28 01:58:49 -0700 | [diff] [blame] | 133 | |
Martijn Coenen | eed957f | 2020-11-12 10:59:13 +0100 | [diff] [blame] | 134 | void earlyBootEnded(); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 135 | @utf8InCpp String createStubVolume(@utf8InCpp String sourcePath, |
| 136 | @utf8InCpp String mountPath, @utf8InCpp String fsType, |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 137 | @utf8InCpp String fsUuid, @utf8InCpp String fsLabel, int flags); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 138 | void destroyStubVolume(@utf8InCpp String volId); |
| 139 | |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 140 | FileDescriptor openAppFuseFile(int uid, int mountId, int fileId, int flags); |
| 141 | |
Yurii Zubrytskyi | 3497cb5 | 2020-01-10 11:54:06 -0800 | [diff] [blame] | 142 | boolean incFsEnabled(); |
Songchun Fan | 046e68a | 2021-04-27 12:46:02 -0700 | [diff] [blame^] | 143 | IncrementalFileSystemControlParcel mountIncFs(@utf8InCpp String backingPath, @utf8InCpp String targetDir, int flags, @utf8InCpp String sysfsName); |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 144 | void unmountIncFs(@utf8InCpp String dir); |
Alex Buynytskyy | dcfeaa1 | 2021-04-01 13:43:14 -0700 | [diff] [blame] | 145 | void setIncFsMountOptions(in IncrementalFileSystemControlParcel control, boolean enableReadLogs, boolean enableReadTimeouts); |
Songchun Fan | ab55cec | 2019-12-02 10:50:12 -0800 | [diff] [blame] | 146 | void bindMount(@utf8InCpp String sourceDir, @utf8InCpp String targetDir); |
| 147 | |
Yo Chiang | 0af25a3 | 2020-10-07 14:20:00 +0800 | [diff] [blame] | 148 | void destroyDsuMetadataKey(@utf8InCpp String dsuSlot); |
| 149 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 150 | const int ENCRYPTION_FLAG_NO_UI = 4; |
| 151 | |
| 152 | const int ENCRYPTION_STATE_NONE = 1; |
| 153 | const int ENCRYPTION_STATE_OK = 0; |
| 154 | const int ENCRYPTION_STATE_ERROR_UNKNOWN = -1; |
| 155 | const int ENCRYPTION_STATE_ERROR_INCOMPLETE = -2; |
| 156 | const int ENCRYPTION_STATE_ERROR_INCONSISTENT = -3; |
| 157 | const int ENCRYPTION_STATE_ERROR_CORRUPT = -4; |
| 158 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 159 | const int FSTRIM_FLAG_DEEP_TRIM = 1; |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 160 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 161 | const int MOUNT_FLAG_PRIMARY = 1; |
| 162 | const int MOUNT_FLAG_VISIBLE = 2; |
| 163 | |
| 164 | const int PARTITION_TYPE_PUBLIC = 0; |
| 165 | const int PARTITION_TYPE_PRIVATE = 1; |
| 166 | const int PARTITION_TYPE_MIXED = 2; |
| 167 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 168 | const int PASSWORD_TYPE_PASSWORD = 0; |
| 169 | const int PASSWORD_TYPE_DEFAULT = 1; |
Paul Crowley | ca08c0a | 2018-07-03 11:49:00 -0700 | [diff] [blame] | 170 | const int PASSWORD_TYPE_PATTERN = 2; |
| 171 | const int PASSWORD_TYPE_PIN = 3; |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 172 | |
| 173 | const int STORAGE_FLAG_DE = 1; |
| 174 | const int STORAGE_FLAG_CE = 2; |
| 175 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 176 | const int REMOUNT_MODE_NONE = 0; |
| 177 | const int REMOUNT_MODE_DEFAULT = 1; |
Abhijeet Kaur | e715ec1 | 2021-02-24 12:33:25 +0000 | [diff] [blame] | 178 | const int REMOUNT_MODE_INSTALLER = 2; |
| 179 | const int REMOUNT_MODE_PASS_THROUGH = 3; |
| 180 | const int REMOUNT_MODE_ANDROID_WRITABLE = 4; |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 181 | |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 182 | const int VOLUME_STATE_UNMOUNTED = 0; |
| 183 | const int VOLUME_STATE_CHECKING = 1; |
| 184 | const int VOLUME_STATE_MOUNTED = 2; |
| 185 | const int VOLUME_STATE_MOUNTED_READ_ONLY = 3; |
| 186 | const int VOLUME_STATE_FORMATTING = 4; |
| 187 | const int VOLUME_STATE_EJECTING = 5; |
| 188 | const int VOLUME_STATE_UNMOUNTABLE = 6; |
| 189 | const int VOLUME_STATE_REMOVED = 7; |
| 190 | const int VOLUME_STATE_BAD_REMOVAL = 8; |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 191 | |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 192 | const int VOLUME_TYPE_PUBLIC = 0; |
| 193 | const int VOLUME_TYPE_PRIVATE = 1; |
| 194 | const int VOLUME_TYPE_EMULATED = 2; |
| 195 | const int VOLUME_TYPE_ASEC = 3; |
| 196 | const int VOLUME_TYPE_OBB = 4; |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 197 | const int VOLUME_TYPE_STUB = 5; |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 198 | } |