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