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 android.media;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.app.StatusBarManager;
22 
23 import java.util.List;
24 import java.util.function.Consumer;
25 
26 /**
27  * An interface that provides information about nearby devices that are able to play media.
28  * <p>
29  * External clients can implement this interface and pass it to the system via
30  * {@link StatusBarManager#registerNearbyMediaDevicesProvider} to inform the system of nearby media
31  * devices.
32  * <p>
33  * @hide
34  */
35 @SystemApi
36 public interface NearbyMediaDevicesProvider {
37     /**
38      * Registers a callback that should be notified each time nearby media device(s) change.
39      * <p>
40      * When a callback is newly registered, it should be immediately notified of the current nearby
41      * media devices. Afterwards, the list of devices passed to the callback should always contain
42      * the full set of nearby media devices any time you get an update. If a device is no longer
43      * valid (went offline, e.g.) then it should be omitted from the list in the next update.
44      * <p>
45      * @param callback the callback that will consume updates to the nearby media devices.
46      */
registerNearbyDevicesCallback(@onNull Consumer<List<NearbyDevice>> callback)47     void registerNearbyDevicesCallback(@NonNull Consumer<List<NearbyDevice>> callback);
48 
49     /**
50      * Unregisters a callback. @see #registerNearbyDevicesCallback.
51      * <p>
52      * @param callback the callback to unregister.
53      */
unregisterNearbyDevicesCallback(@onNull Consumer<List<NearbyDevice>> callback)54     void unregisterNearbyDevicesCallback(@NonNull Consumer<List<NearbyDevice>> callback);
55 }
56