Sergey Volnov | 6e04901 | 2020-01-10 18:10:48 +0000 | [diff] [blame] | 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.view.contentcapture; |
| 18 | |
| 19 | import android.annotation.NonNull; |
Sergey Volnov | 6e04901 | 2020-01-10 18:10:48 +0000 | [diff] [blame] | 20 | import android.os.ParcelFileDescriptor; |
| 21 | |
| 22 | /** Adapter class used by apps to share data with the Content Capture service. */ |
| 23 | public interface DataShareWriteAdapter { |
| 24 | |
Sergey Volnov | 6e04901 | 2020-01-10 18:10:48 +0000 | [diff] [blame] | 25 | /** |
| 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 Volnov | 4392944 | 2020-01-28 15:36:59 +0000 | [diff] [blame] | 32 | * @param destination file descriptor used to write data into. |
Sergey Volnov | 6e04901 | 2020-01-10 18:10:48 +0000 | [diff] [blame] | 33 | */ |
Sergey Volnov | 4392944 | 2020-01-28 15:36:59 +0000 | [diff] [blame] | 34 | void onWrite(@NonNull ParcelFileDescriptor destination); |
Sergey Volnov | 6e04901 | 2020-01-10 18:10:48 +0000 | [diff] [blame] | 35 | |
| 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 | } |