blob: 2b6cd1478da8e90fac3249c8dde2d8e4394aa0b1 [file] [log] [blame]
Songchun Fanf5c894f2019-11-29 15:43:58 -08001/*
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
17package android.os.incremental;
18
Alex Buynytskyyea14d192019-12-13 15:42:18 -080019import android.content.pm.DataLoaderParamsParcel;
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080020import android.os.incremental.IncrementalNewFileParams;
Songchun Fanf5c894f2019-11-29 15:43:58 -080021
22/** @hide */
23interface 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 Buynytskyyea14d192019-12-13 15:42:18 -080036 int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, int createMode);
Songchun Fanf5c894f2019-11-29 15:43:58 -080037 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 Zubrytskyi4a25dfb2020-01-10 11:53:24 -080044 int makeBindMount(int storageId, in @utf8InCpp String sourcePath, in @utf8InCpp String targetFullPath, int bindType);
Songchun Fanf5c894f2019-11-29 15:43:58 -080045
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 Zubrytskyi4a25dfb2020-01-10 11:53:24 -080052 * Creates a directory under a storage. The target directory is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080053 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080054 int makeDirectory(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080055
56 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080057 * Recursively creates a directory under a storage. The target directory is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080058 * All the parent directories of the target directory will be created if they do not exist already.
59 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080060 int makeDirectories(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080061
62 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080063 * Creates a file under a storage.
Songchun Fanf5c894f2019-11-29 15:43:58 -080064 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080065 int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params);
Songchun Fanf5c894f2019-11-29 15:43:58 -080066
67 /**
68 * Creates a file under a storage. Content of the file is from a range inside another file.
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080069 * Both files are specified by their paths.
Songchun Fanf5c894f2019-11-29 15:43:58 -080070 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080071 int makeFileFromRange(int storageId, in @utf8InCpp String targetPath, in @utf8InCpp String sourcePath, long start, long end);
Songchun Fanf5c894f2019-11-29 15:43:58 -080072
73 /**
74 * Creates a hard link between two files in two storage instances.
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080075 * Source and dest specified by parent storage IDs and their paths.
Songchun Fanf5c894f2019-11-29 15:43:58 -080076 * The source and dest storage instances should be in the same fs mount.
77 * Note: destStorageId can be the same as sourceStorageId.
78 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080079 int makeLink(int sourceStorageId, in @utf8InCpp String sourcePath, int destStorageId, in @utf8InCpp String destPath);
Songchun Fanf5c894f2019-11-29 15:43:58 -080080
81 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080082 * Deletes a hard link in a storage, specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080083 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080084 int unlink(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080085
86 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080087 * Checks if a file's certain range is loaded. File is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080088 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080089 boolean isFileRangeLoaded(int storageId, in @utf8InCpp String path, long start, long end);
Songchun Fanf5c894f2019-11-29 15:43:58 -080090
91 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080092 * Reads the metadata of a file. File is specified by either its path or 16 byte id.
Songchun Fanf5c894f2019-11-29 15:43:58 -080093 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080094 byte[] getMetadataByPath(int storageId, in @utf8InCpp String path);
95 byte[] getMetadataById(int storageId, in byte[] fileId);
Songchun Fanf5c894f2019-11-29 15:43:58 -080096
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}