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 com.android.settings.connecteddevice.audiosharing.audiostreams; 18 19 import android.bluetooth.BluetoothDevice; 20 import android.bluetooth.BluetoothLeBroadcastAssistant; 21 import android.bluetooth.BluetoothLeBroadcastMetadata; 22 import android.bluetooth.BluetoothLeBroadcastReceiveState; 23 import android.util.Log; 24 25 import com.android.settingslib.bluetooth.BluetoothUtils; 26 27 public class AudioStreamsBroadcastAssistantCallback 28 implements BluetoothLeBroadcastAssistant.Callback { 29 30 private static final String TAG = "AudioStreamsBroadcastAssistantCallback"; 31 private static final boolean DEBUG = BluetoothUtils.D; 32 33 @Override onReceiveStateChanged( BluetoothDevice sink, int sourceId, BluetoothLeBroadcastReceiveState state)34 public void onReceiveStateChanged( 35 BluetoothDevice sink, int sourceId, BluetoothLeBroadcastReceiveState state) { 36 if (DEBUG) { 37 Log.d( 38 TAG, 39 "onReceiveStateChanged() sink : " 40 + sink.getAddress() 41 + " sourceId: " 42 + sourceId 43 + " state: " 44 + state); 45 } 46 } 47 48 @Override onSearchStartFailed(int reason)49 public void onSearchStartFailed(int reason) { 50 Log.w(TAG, "onSearchStartFailed() reason : " + reason); 51 } 52 53 @Override onSearchStarted(int reason)54 public void onSearchStarted(int reason) { 55 if (DEBUG) { 56 Log.d(TAG, "onSearchStarted() reason : " + reason); 57 } 58 } 59 60 @Override onSearchStopFailed(int reason)61 public void onSearchStopFailed(int reason) { 62 Log.w(TAG, "onSearchStopFailed() reason : " + reason); 63 } 64 65 @Override onSearchStopped(int reason)66 public void onSearchStopped(int reason) { 67 if (DEBUG) { 68 Log.d(TAG, "onSearchStopped() reason : " + reason); 69 } 70 } 71 72 @Override onSourceAddFailed( BluetoothDevice sink, BluetoothLeBroadcastMetadata source, int reason)73 public void onSourceAddFailed( 74 BluetoothDevice sink, BluetoothLeBroadcastMetadata source, int reason) { 75 if (DEBUG) { 76 Log.d( 77 TAG, 78 "onSourceAddFailed() sink : " 79 + sink.getAddress() 80 + " source: " 81 + source 82 + " reason: " 83 + reason); 84 } 85 } 86 87 @Override onSourceAdded(BluetoothDevice sink, int sourceId, int reason)88 public void onSourceAdded(BluetoothDevice sink, int sourceId, int reason) { 89 if (DEBUG) { 90 Log.d( 91 TAG, 92 "onSourceAdded() sink : " 93 + sink.getAddress() 94 + " sourceId: " 95 + sourceId 96 + " reason: " 97 + reason); 98 } 99 } 100 101 @Override onSourceFound(BluetoothLeBroadcastMetadata source)102 public void onSourceFound(BluetoothLeBroadcastMetadata source) { 103 if (DEBUG) { 104 Log.d( 105 TAG, 106 "onSourceFound() broadcastId : " 107 + source.getBroadcastId() 108 + " broadcastName : " 109 + source.getBroadcastName()); 110 } 111 } 112 113 @Override onSourceLost(int broadcastId)114 public void onSourceLost(int broadcastId) { 115 if (DEBUG) { 116 Log.d(TAG, "onSourceLost() broadcastId : " + broadcastId); 117 } 118 } 119 120 @Override onSourceModified(BluetoothDevice sink, int sourceId, int reason)121 public void onSourceModified(BluetoothDevice sink, int sourceId, int reason) {} 122 123 @Override onSourceModifyFailed(BluetoothDevice sink, int sourceId, int reason)124 public void onSourceModifyFailed(BluetoothDevice sink, int sourceId, int reason) {} 125 126 @Override onSourceRemoveFailed(BluetoothDevice sink, int sourceId, int reason)127 public void onSourceRemoveFailed(BluetoothDevice sink, int sourceId, int reason) { 128 Log.w(TAG, "onSourceRemoveFailed() sourceId : " + sourceId + " reason : " + reason); 129 } 130 131 @Override onSourceRemoved(BluetoothDevice sink, int sourceId, int reason)132 public void onSourceRemoved(BluetoothDevice sink, int sourceId, int reason) { 133 if (DEBUG) { 134 Log.d(TAG, "onSourceRemoved() sourceId : " + sourceId + " reason : " + reason); 135 } 136 } 137 } 138