1 /* 2 * Copyright (C) 2019 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.tv.settings.accessories; 18 19 import android.bluetooth.BluetoothDevice; 20 21 /** Local provider proxy to customize events. */ 22 abstract class LocalBluetoothDeviceProvider implements BluetoothDeviceProvider { 23 getHostBluetoothDeviceProvider()24 abstract BluetoothDeviceProvider getHostBluetoothDeviceProvider(); 25 26 @Override connectDevice(BluetoothDevice device)27 public void connectDevice(BluetoothDevice device) { 28 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 29 if (provider != null) { 30 provider.connectDevice(device); 31 } 32 } 33 34 @Override disconnectDevice(BluetoothDevice device)35 public void disconnectDevice(BluetoothDevice device) { 36 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 37 if (provider != null) { 38 provider.disconnectDevice(device); 39 } 40 } 41 42 @Override forgetDevice(BluetoothDevice device)43 public void forgetDevice(BluetoothDevice device) { 44 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 45 if (provider != null) { 46 provider.forgetDevice(device); 47 } 48 } 49 50 @Override renameDevice(BluetoothDevice device, String newName)51 public void renameDevice(BluetoothDevice device, String newName) { 52 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 53 if (provider != null) { 54 provider.renameDevice(device, newName); 55 } 56 } 57 58 @Override addListener(Listener listener)59 public void addListener(Listener listener) { 60 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 61 if (provider != null) { 62 provider.addListener(listener); 63 } 64 } 65 66 @Override removeListener(Listener listener)67 public void removeListener(Listener listener) { 68 BluetoothDeviceProvider provider = getHostBluetoothDeviceProvider(); 69 if (provider != null) { 70 provider.removeListener(listener); 71 } 72 } 73 } 74