• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.adservices.common;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 
22 import com.android.adservices.flags.Flags;
23 
24 /**
25  * Callback interface intended for use when an asynchronous operation may result in a failure. Exact
26  * copy of the {@link android.os.OutcomeReceiver} class, re-defined in the AdServices package for
27  * backwards compatibility to Android R.
28  *
29  * <p>This interface may be used in cases where an asynchronous API may complete either with a value
30  * or with a {@link Throwable} that indicates an error.
31  *
32  * @param <R> The type of the result that's being sent.
33  * @param <E> The type of the {@link Throwable} that contains more information about the error.
34  * @deprecated use {@link android.os.OutcomeReceiver} instead. Android R is no longer supported.
35  */
36 @Deprecated
37 @FlaggedApi(Flags.FLAG_ADSERVICES_OUTCOMERECEIVER_R_API_DEPRECATED)
38 public interface AdServicesOutcomeReceiver<R, E extends Throwable> {
39     /**
40      * Called when the asynchronous operation succeeds and delivers a result value.
41      *
42      * @param result The value delivered by the asynchronous operation.
43      */
onResult(R result)44     void onResult(R result);
45 
46     /**
47      * Called when the asynchronous operation fails. The mode of failure is indicated by the {@link
48      * Throwable} passed as an argument to this method.
49      *
50      * @param error A subclass of {@link Throwable} with more details about the error that occurred.
51      */
onError(@onNull E error)52     default void onError(@NonNull E error) {}
53 }
54