Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.app.role; |
| 18 | |
| 19 | import android.annotation.SystemApi; |
Hai Zhang | 6329be4 | 2018-11-19 11:05:34 -0800 | [diff] [blame] | 20 | import android.annotation.TestApi; |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 21 | |
Eugene Susla | 92b88c7 | 2019-01-11 13:31:20 -0800 | [diff] [blame] | 22 | import java.util.concurrent.CompletableFuture; |
| 23 | |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Callback for a {@link RoleManager} request. |
| 26 | * |
| 27 | * @hide |
| 28 | */ |
| 29 | @SystemApi |
Hai Zhang | 6329be4 | 2018-11-19 11:05:34 -0800 | [diff] [blame] | 30 | @TestApi |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 31 | public interface RoleManagerCallback { |
| 32 | |
| 33 | /** |
| 34 | * Signals a success. |
| 35 | */ |
| 36 | void onSuccess(); |
| 37 | |
| 38 | /** |
| 39 | * Signals a failure. |
| 40 | */ |
| 41 | void onFailure(); |
Eugene Susla | 92b88c7 | 2019-01-11 13:31:20 -0800 | [diff] [blame] | 42 | |
| 43 | /** @hide */ |
| 44 | class Future extends CompletableFuture<Void> implements RoleManagerCallback { |
| 45 | |
| 46 | @Override |
| 47 | public void onSuccess() { |
| 48 | complete(null); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void onFailure() { |
| 53 | completeExceptionally(new RuntimeException()); |
| 54 | } |
| 55 | } |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 56 | } |