blob: 25cb0400a38d82952020809c2441a30c5491002e [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;
Alex Buynytskyy04f73912020-02-10 08:34:18 -080020import android.content.pm.IDataLoaderStatusListener;
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080021import android.os.incremental.IncrementalNewFileParams;
Songchun Fanf5c894f2019-11-29 15:43:58 -080022
23/** @hide */
Alex Buynytskyy716588d2020-02-04 13:42:59 -080024interface IIncrementalService {
Songchun Fanf5c894f2019-11-29 15:43:58 -080025 /**
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 Buynytskyy04f73912020-02-10 08:34:18 -080037 int createStorage(in @utf8InCpp String path, in DataLoaderParamsParcel params, in IDataLoaderStatusListener listener, int createMode);
Songchun Fanf5c894f2019-11-29 15:43:58 -080038 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 Zubrytskyi4a25dfb2020-01-10 11:53:24 -080045 int makeBindMount(int storageId, in @utf8InCpp String sourcePath, in @utf8InCpp String targetFullPath, int bindType);
Songchun Fanf5c894f2019-11-29 15:43:58 -080046
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 Zubrytskyi4a25dfb2020-01-10 11:53:24 -080053 * Creates a directory under a storage. The target directory is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080054 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080055 int makeDirectory(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080056
57 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080058 * Recursively creates a directory under a storage. The target directory is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080059 * All the parent directories of the target directory will be created if they do not exist already.
60 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080061 int makeDirectories(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080062
63 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080064 * Creates a file under a storage.
Songchun Fanf5c894f2019-11-29 15:43:58 -080065 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080066 int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params);
Songchun Fanf5c894f2019-11-29 15:43:58 -080067
68 /**
69 * Creates a file under a storage. Content of the file is from a range inside another file.
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080070 * Both files are specified by their paths.
Songchun Fanf5c894f2019-11-29 15:43:58 -080071 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080072 int makeFileFromRange(int storageId, in @utf8InCpp String targetPath, in @utf8InCpp String sourcePath, long start, long end);
Songchun Fanf5c894f2019-11-29 15:43:58 -080073
74 /**
75 * Creates a hard link between two files in two storage instances.
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080076 * Source and dest specified by parent storage IDs and their paths.
Songchun Fanf5c894f2019-11-29 15:43:58 -080077 * The source and dest storage instances should be in the same fs mount.
78 * Note: destStorageId can be the same as sourceStorageId.
79 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080080 int makeLink(int sourceStorageId, in @utf8InCpp String sourcePath, int destStorageId, in @utf8InCpp String destPath);
Songchun Fanf5c894f2019-11-29 15:43:58 -080081
82 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080083 * Deletes a hard link in a storage, specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080084 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080085 int unlink(int storageId, in @utf8InCpp String path);
Songchun Fanf5c894f2019-11-29 15:43:58 -080086
87 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080088 * Checks if a file's certain range is loaded. File is specified by its path.
Songchun Fanf5c894f2019-11-29 15:43:58 -080089 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080090 boolean isFileRangeLoaded(int storageId, in @utf8InCpp String path, long start, long end);
Songchun Fanf5c894f2019-11-29 15:43:58 -080091
92 /**
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080093 * Reads the metadata of a file. File is specified by either its path or 16 byte id.
Songchun Fanf5c894f2019-11-29 15:43:58 -080094 */
Yurii Zubrytskyi4a25dfb2020-01-10 11:53:24 -080095 byte[] getMetadataByPath(int storageId, in @utf8InCpp String path);
96 byte[] getMetadataById(int storageId, in byte[] fileId);
Songchun Fanf5c894f2019-11-29 15:43:58 -080097
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 Fan0f8b6fe2020-02-05 17:41:25 -0800107
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 Zubrytskyida208012020-04-07 15:35:21 -0700112
113 /**
114 * Waits until all native library extraction is done for the storage
115 */
116 boolean waitForNativeBinariesExtraction(int storageId);
Songchun Fanf5c894f2019-11-29 15:43:58 -0800117}