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; |
Alex Buynytskyy | 04f7391 | 2020-02-10 08:34:18 -0800 | [diff] [blame] | 20 | import android.content.pm.IDataLoaderStatusListener; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 21 | import android.os.incremental.IncrementalNewFileParams; |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 22 | |
| 23 | /** @hide */ |
Alex Buynytskyy | 716588d | 2020-02-04 13:42:59 -0800 | [diff] [blame] | 24 | interface IIncrementalService { |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 25 | /** |
| 26 | * A set of flags for the |createMode| parameters when creating a new Incremental storage. |
| 27 | */ |
| 28 | const int CREATE_MODE_TEMPORARY_BIND = 1; |
| 29 | const int CREATE_MODE_PERMANENT_BIND = 2; |
| 30 | const int CREATE_MODE_CREATE = 4; |
| 31 | const int CREATE_MODE_OPEN_EXISTING = 8; |
| 32 | |
| 33 | /** |
| 34 | * Opens or creates a storage given a target path and data loader params. Returns the storage ID. |
| 35 | */ |
| 36 | int openStorage(in @utf8InCpp String path); |
Alex Buynytskyy | 04f7391 | 2020-02-10 08:34:18 -0800 | [diff] [blame] | 37 | int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 38 | int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode); |
| 39 | |
| 40 | /** |
| 41 | * Bind-mounts a path under a storage to a full path. Can be permanent or temporary. |
| 42 | */ |
| 43 | const int BIND_TEMPORARY = 0; |
| 44 | const int BIND_PERMANENT = 1; |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 45 | 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] | 46 | |
| 47 | /** |
| 48 | * Deletes an existing bind mount on a path under a storage. Returns 0 on success, and -errno on failure. |
| 49 | */ |
| 50 | int deleteBindMount(int storageId, in @utf8InCpp String targetFullPath); |
| 51 | |
| 52 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 53 | * 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] | 54 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 55 | int makeDirectory(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 58 | * 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] | 59 | * All the parent directories of the target directory will be created if they do not exist already. |
| 60 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 61 | int makeDirectories(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 62 | |
| 63 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 64 | * Creates a file under a storage. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 65 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 66 | int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * 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] | 70 | * Both files are specified by their paths. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 71 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 72 | 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] | 73 | |
| 74 | /** |
| 75 | * Creates a hard link between two files in two storage instances. |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 76 | * Source and dest specified by parent storage IDs and their paths. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 77 | * The source and dest storage instances should be in the same fs mount. |
| 78 | * Note: destStorageId can be the same as sourceStorageId. |
| 79 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 80 | 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] | 81 | |
| 82 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 83 | * Deletes a hard link in a storage, specified by its path. |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 84 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 85 | int unlink(int storageId, in @utf8InCpp String path); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 86 | |
| 87 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 88 | * 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] | 89 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 90 | boolean isFileRangeLoaded(int storageId, in @utf8InCpp String path, long start, long end); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 93 | * 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] | 94 | */ |
Yurii Zubrytskyi | 4a25dfb | 2020-01-10 11:53:24 -0800 | [diff] [blame] | 95 | byte[] getMetadataByPath(int storageId, in @utf8InCpp String path); |
| 96 | byte[] getMetadataById(int storageId, in byte[] fileId); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Starts loading data for a storage. |
| 100 | */ |
| 101 | boolean startLoading(int storageId); |
| 102 | |
| 103 | /** |
| 104 | * Deletes a storage given its ID. Deletes its bind mounts and unmount it. Stop its data loader. |
| 105 | */ |
| 106 | void deleteStorage(int storageId); |
Songchun Fan | 0f8b6fe | 2020-02-05 17:41:25 -0800 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Setting up native library directories and extract native libs onto a storage. |
| 110 | */ |
| 111 | boolean configureNativeBinaries(int storageId, in @utf8InCpp String apkFullPath, in @utf8InCpp String libDirRelativePath, in @utf8InCpp String abi); |
Yurii Zubrytskyi | da20801 | 2020-04-07 15:35:21 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Waits until all native library extraction is done for the storage |
| 115 | */ |
| 116 | boolean waitForNativeBinariesExtraction(int storageId); |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 117 | } |