Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 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; |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 19 | import android.annotation.RequiresPermission; |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.os.IBinder; |
| 22 | import android.os.RemoteException; |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 23 | |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 24 | /** |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 25 | * CarBluetoothManager - Provides an API to interact with Car specific Bluetooth Device Management |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 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 | |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 34 | /** |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 35 | * Initiate automatated connecting of devices based on the prioritized device lists for each |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 36 | * profile. |
| 37 | * |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 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 | * |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 46 | * @hide |
| 47 | */ |
| 48 | @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 49 | public void connectDevices() { |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 50 | try { |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 51 | mService.connectDevices(); |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 52 | } catch (RemoteException e) { |
Justin Paupore | 0dd3177 | 2019-02-07 21:22:34 -0800 | [diff] [blame] | 53 | throw e.rethrowFromSystemServer(); |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
Sal Savage | 703c46f | 2019-04-15 08:39:25 -0700 | [diff] [blame] | 58 | * Create an instance of CarBluetoothManager |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 59 | * |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 60 | * @hide |
| 61 | */ |
Ram Periathiruvadi | 76a8489 | 2017-07-27 18:10:35 -0700 | [diff] [blame] | 62 | public CarBluetoothManager(IBinder service, Context context) { |
| 63 | mContext = context; |
| 64 | mService = ICarBluetooth.Stub.asInterface(service); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void onCarDisconnected() { |
| 69 | } |
| 70 | } |