Home | History | Annotate | Download | only in car
      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 com.android.car;
     17 
     18 import android.content.Context;
     19 import android.util.Log;
     20 
     21 import java.io.PrintWriter;
     22 
     23 /**
     24  * CarBluetoothService - deals with the automatically connecting to a known device via bluetooth.
     25  * Interacts with a policy -{@link BluetoothDeviceConnectionPolicy} -to initiate connections and
     26  * update status.
     27  * The {@link BluetoothDeviceConnectionPolicy} is responsible for finding the appropriate device to
     28  * connect for a specific profile.
     29  */
     30 
     31 public class CarBluetoothService implements CarServiceBase {
     32 
     33     private static final String TAG = "CarBluetoothService";
     34     private final Context mContext;
     35     private final BluetoothDeviceConnectionPolicy mBluetoothDeviceConnectionPolicy;
     36 
     37     public CarBluetoothService(Context context, CarCabinService carCabinService,
     38             CarSensorService carSensorService, PerUserCarServiceHelper userSwitchService) {
     39         mContext = context;
     40         mBluetoothDeviceConnectionPolicy = BluetoothDeviceConnectionPolicy.create(mContext,
     41                 carCabinService, carSensorService, userSwitchService);
     42     }
     43 
     44     @Override
     45     public void init() {
     46         mBluetoothDeviceConnectionPolicy.init();
     47     }
     48 
     49     @Override
     50     public synchronized void release() {
     51         mBluetoothDeviceConnectionPolicy.release();
     52     }
     53 
     54     @Override
     55     public synchronized void dump(PrintWriter writer) {
     56         mBluetoothDeviceConnectionPolicy.dump(writer);
     57     }
     58 
     59 }
     60