1 /*
2  * Copyright (C) 2022 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 com.android.networkstack.apishim.common;
18 
19 import androidx.annotation.NonNull;
20 import androidx.annotation.Nullable;
21 
22 import java.util.concurrent.Executor;
23 
24 /**
25  * Interface for accessing API methods in {@link android.bluetooth.BluetoothPan} by different SDK
26  * level.
27  */
28 public interface BluetoothPanShim {
29     /** Use to deal with the TetheringManager#TetheredInterfaceRequest by different sdk version. */
30     public interface TetheredInterfaceRequestShim {
31         /** Release the request to tear down tethered interface */
release()32         default void release() {}
33     }
34 
35     /** Use to deal with the TetheringManager#TetheredInterfaceCallback by different sdk version. */
36     public interface TetheredInterfaceCallbackShim {
37         /** Called when the tethered interface is available. */
onAvailable(@onNull String iface)38         default void onAvailable(@NonNull String iface) {}
39 
40         /** Called when the tethered interface is now unavailable. */
onUnavailable()41         default void onUnavailable() {}
42     }
43 
44     /**
45      * Use to deal with the BluetoothPan#setBluetoothTethering and
46      * BluetoothPan#requestTetheredInterface by different sdk version. This can return null if the
47      * service is not available.
48      */
49     @Nullable
requestTetheredInterface(@onNull Executor executor, @NonNull TetheredInterfaceCallbackShim callback)50     TetheredInterfaceRequestShim requestTetheredInterface(@NonNull Executor executor,
51             @NonNull TetheredInterfaceCallbackShim callback) throws UnsupportedApiLevelException;
52 }
53