Debian Codegraph @

core/java/android/content/res/loader/AssetsProvider.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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.content.res.loader;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.res.AssetFileDescriptor;
22 import android.content.res.AssetManager;
23 import android.os.ParcelFileDescriptor;
24
25 /**
26 * Provides callbacks that allow for the value of a file-based resources or assets of a
27 * {@link ResourcesProvider} to be specified or overridden.
28 */
29 public interface AssetsProvider {
30
31 /**
32 * Callback that allows the value of a file-based resources or asset to be specified or
33 * overridden.
34 *
35 * <p>The system will take ownership of the file descriptor returned from this method, so
36 * {@link ParcelFileDescriptor#dup() dup} the file descriptor before returning if the system
37 * should not own it.
38 *
39 * <p>There are two situations in which this method will be called:
40 * <ul>
41 * <li>AssetManager is queried for an InputStream of an asset using APIs like
42 * {@link AssetManager#open} and {@link AssetManager#openXmlResourceParser}.
43 * <li>AssetManager is resolving the value of a file-based resource provided by the
44 * {@link ResourcesProvider} this instance is associated with.
45 * </ul>
46 *
47 * <p>If the value retrieved from this callback is null, AssetManager will attempt to find the
48 * file-based resource or asset within the APK provided by the ResourcesProvider this instance
49 * is associated with.
50 *
51 * @param path the asset path being loaded
52 * @param accessMode the {@link AssetManager} access mode
53 *
54 * @see AssetManager#open
55 */
56 @Nullable
57 default AssetFileDescriptor loadAssetFd(@NonNull String path, int accessMode) {
58 return null;
59 }
60 }