blob: 2beaededf8b1eb62cdcb201535d3eaf483cdb67b [file] [log] [blame]
Sergey Volnov6e049012020-01-10 18:10:48 +00001/*
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
17package android.view.contentcapture;
18
19import android.annotation.NonNull;
Sergey Volnov6e049012020-01-10 18:10:48 +000020import android.os.ParcelFileDescriptor;
21
22/** Adapter class used by apps to share data with the Content Capture service. */
23public interface DataShareWriteAdapter {
24
Sergey Volnov6e049012020-01-10 18:10:48 +000025 /**
26 * Method invoked when the data share session has been started and the app needs to start
27 * writing into the file used for sharing.
28 *
29 * <p>App needs to handle explicitly cases when the file descriptor is closed and handle
30 * gracefully if IOExceptions happen.
31 *
Sergey Volnov43929442020-01-28 15:36:59 +000032 * @param destination file descriptor used to write data into.
Sergey Volnov6e049012020-01-10 18:10:48 +000033 */
Sergey Volnov43929442020-01-28 15:36:59 +000034 void onWrite(@NonNull ParcelFileDescriptor destination);
Sergey Volnov6e049012020-01-10 18:10:48 +000035
36 /** Data share sessions has been rejected by the Content Capture service. */
37 void onRejected();
38
39 /**
40 * Method invoked when an error occurred, for example sessions has not been started or
41 * terminated unsuccessfully.
42 *
43 * @param errorCode the error code corresponding to an ERROR_* value.
44 */
45 default void onError(int errorCode) {
46 /* do nothing - stub */
47 }
48}