Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 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.os.incremental; |
| 18 | |
Alex Buynytskyy | ea14d19 | 2019-12-13 15:42:18 -0800 | [diff] [blame] | 19 | import android.content.pm.DataLoaderParamsParcel; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 20 | import android.os.incremental.IncrementalNewFileParams; |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 21 | |
| 22 | /** @hide */ |
| 23 | interface IIncrementalManagerNative { |
| 24 | /** |
| 25 | * A set of flags for the |createMode| parameters when creating a new Incremental storage. |
| 26 | */ |
| 27 | const int CREATE_MODE_TEMPORARY_BIND = 1; |
| 28 | const int CREATE_MODE_PERMANENT_BIND = 2; |
| 29 | const int CREATE_MODE_CREATE = 4; |
| 30 | const int CREATE_MODE_OPEN_EXISTING = 8; |
| 31 | |
| 32 | /** |
| 33 | * Opens or creates a storage given a target path and data loader params. Returns the storage ID. |
| 34 | */ |
| 35 | int openStorage(in @utf8InCpp String path); |
Alex Buynytskyy | ea14d19 | 2019-12-13 15:42:18 -0800 | [diff] [blame] | 36 | int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, int createMode); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 37 | int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode); |
| 38 | |
| 39 | /** |
| 40 | * Bind-mounts a path under a storage to a full path. Can be permanent or temporary. |
| 41 | */ |
| 42 | const int BIND_TEMPORARY = 0; |
| 43 | const int BIND_PERMANENT = 1; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 44 | int makeBindMount(int storageId, in @utf8InCpp String sourcePath, in @utf8InCpp String targetFullPath, int bindType); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Deletes an existing bind mount on a path under a storage. Returns 0 on success, and -errno on failure. |
| 48 | */ |
| 49 | int deleteBindMount(int storageId, in @utf8InCpp String targetFullPath); |
| 50 | |
| 51 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 52 | * Creates a directory under a storage. The target directory is specified by its path. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 53 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 54 | int makeDirectory(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 55 | |
| 56 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 57 | * Recursively creates a directory under a storage. The target directory is specified by its path. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 58 | * All the parent directories of the target directory will be created if they do not exist already. |
| 59 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 60 | int makeDirectories(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 61 | |
| 62 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 63 | * Creates a file under a storage. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 64 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 65 | int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Creates a file under a storage. Content of the file is from a range inside another file. |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 69 | * Both files are specified by their paths. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 70 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 71 | int makeFileFromRange(int storageId, in @utf8InCpp String targetPath, in @utf8InCpp String sourcePath, long start, long end); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Creates a hard link between two files in two storage instances. |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 75 | * Source and dest specified by parent storage IDs and their paths. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 76 | * The source and dest storage instances should be in the same fs mount. |
| 77 | * Note: destStorageId can be the same as sourceStorageId. |
| 78 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 79 | int makeLink(int sourceStorageId, in @utf8InCpp String sourcePath, int destStorageId, in @utf8InCpp String destPath); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 80 | |
| 81 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 82 | * Deletes a hard link in a storage, specified by its path. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 83 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 84 | int unlink(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 85 | |
| 86 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 87 | * Checks if a file's certain range is loaded. File is specified by its path. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 88 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 89 | boolean isFileRangeLoaded(int storageId, in @utf8InCpp String path, long start, long end); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 92 | * Reads the metadata of a file. File is specified by either its path or 16 byte id. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 93 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 94 | byte[] getMetadataByPath(int storageId, in @utf8InCpp String path); |
| 95 | byte[] getMetadataById(int storageId, in byte[] fileId); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Starts loading data for a storage. |
| 99 | */ |
| 100 | boolean startLoading(int storageId); |
| 101 | |
| 102 | /** |
| 103 | * Deletes a storage given its ID. Deletes its bind mounts and unmount it. Stop its data loader. |
| 104 | */ |
| 105 | void deleteStorage(int storageId); |
| 106 | } |