1 /* 2 * Copyright 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 package com.android.settingslib.media; 17 18 import android.bluetooth.BluetoothDevice; 19 20 import androidx.mediarouter.media.MediaRouter; 21 22 import com.android.settingslib.bluetooth.CachedBluetoothDevice; 23 24 /** 25 * MediaDeviceUtils provides utility function for MediaDevice 26 */ 27 public class MediaDeviceUtils { 28 /** 29 * Use CachedBluetoothDevice address to represent unique id 30 * 31 * @param cachedDevice the CachedBluetoothDevice 32 * @return CachedBluetoothDevice address 33 */ getId(CachedBluetoothDevice cachedDevice)34 public static String getId(CachedBluetoothDevice cachedDevice) { 35 return cachedDevice.getAddress(); 36 } 37 38 /** 39 * Use BluetoothDevice address to represent unique id 40 * 41 * @param bluetoothDevice the BluetoothDevice 42 * @return BluetoothDevice address 43 */ getId(BluetoothDevice bluetoothDevice)44 public static String getId(BluetoothDevice bluetoothDevice) { 45 return bluetoothDevice.getAddress(); 46 } 47 48 /** 49 * Use RouteInfo id to represent unique id 50 * 51 * @param route the RouteInfo 52 * @return RouteInfo id 53 */ getId(MediaRouter.RouteInfo route)54 public static String getId(MediaRouter.RouteInfo route) { 55 return route.getId(); 56 } 57 } 58