1 /* 2 * Copyright (C) 2017 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 android.car; 17 18 import android.Manifest; 19 import android.annotation.RequiresPermission; 20 import android.content.Context; 21 import android.os.IBinder; 22 import android.os.RemoteException; 23 24 /** 25 * CarBluetoothManager - Provides an API to interact with Car specific Bluetooth Device Management 26 * 27 * @hide 28 */ 29 public final class CarBluetoothManager implements CarManagerBase { 30 private static final String TAG = "CarBluetoothManager"; 31 private final Context mContext; 32 private final ICarBluetooth mService; 33 34 /** 35 * Initiate automatated connecting of devices based on the prioritized device lists for each 36 * profile. 37 * 38 * The device lists for each profile are maintained by CarBluetoothService. Devices are added to 39 * the end of a profile's list when the device bonds, if the device supports the given profile. 40 * Devices are removed when unbond. These lists are specific to the current foreground user. 41 * 42 * If you are calling this function, you may want to disable CarBluetoothService's default 43 * device connection policy by setting the "useDefaultBluetoothConnectionPolicy" resource 44 * overlay flag to false. 45 * 46 * @hide 47 */ 48 @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) connectDevices()49 public void connectDevices() { 50 try { 51 mService.connectDevices(); 52 } catch (RemoteException e) { 53 throw e.rethrowFromSystemServer(); 54 } 55 } 56 57 /** 58 * Create an instance of CarBluetoothManager 59 * 60 * @hide 61 */ CarBluetoothManager(IBinder service, Context context)62 public CarBluetoothManager(IBinder service, Context context) { 63 mContext = context; 64 mService = ICarBluetooth.Stub.asInterface(service); 65 } 66 67 @Override onCarDisconnected()68 public void onCarDisconnected() { 69 } 70 } 71