• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.adservices.exceptions.AdServicesException;
20 import android.os.Build;
21 
22 /**
23  * Utility class to check if the version is RVC, and invoke callback onError method
24  *
25  * @hide
26  */
27 public final class AndroidRCommonUtil {
28 
29     // Intended to be a utility class that should not be instantiated.
AndroidRCommonUtil()30     private AndroidRCommonUtil() {}
31 
32     /**
33      * Checks if the current Build Version is RVC, and if so, invokes the callback onError method
34      *
35      * @return true if RVC, false otherwise
36      */
invokeCallbackOnErrorOnRvc( AdServicesOutcomeReceiver<T, Exception> callback)37     public static <T> boolean invokeCallbackOnErrorOnRvc(
38             AdServicesOutcomeReceiver<T, Exception> callback) {
39         if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
40             callback.onError(new AdServicesException("AdServices is not supported on Android R"));
41             return true;
42         }
43 
44         return false;
45     }
46 }
47