Android provides a default Bluetooth stack, BlueDroid, that is divided into two layers: The Bluetooth Embedded System (BTE), which implements the core Bluetooth functionality and the Bluetooth Application Layer (BTA), which communicates with Android framework applications. A Bluetooth system service communicates with the Bluetooth stack through JNI and with applications through Binder IPC. The system service provides developers access to various Bluetooth profiles. The following diagram shows the general structure of the Bluetooth stack:

Application framework
At the application framework level is the app's code, which utilizes the android.bluetooth APIs to interact with the bluetooth hardware. Internally, this code calls the Bluetooth process through the Binder IPC mechanism.
Bluetooth system service
The Bluetooth system service, located in packages/apps/Bluetooth, is packaged as an Android app and implements the Bluetooth service and profiles at the Android framework layer. This app calls into the HAL layer via JNI.
JNI
The JNI code associated with android.bluetooth is located in packages/apps/Bluetooth/jni. The JNI code calls into the HAL layer and receives callbacks from the HAL when certain Bluetooth operations occur, such as when devices are discovered.
HAL
The hardware abstraction layer defines the standard interface that the android.bluetooth APIs and Bluetooth process calls into and that you must implement to have your bluetooth hardware function correctly. The header files for the Bluetooth HAL is located in the hardware/libhardware/include/hardware/bluetooth.h and hardware/libhardware/include/hardware/bt_*.h files.
Bluetooth stack
The default Bluetooth stack is provided for you and is located in external/bluetooth/bluedroid. The stack implements the generic Bluetooth HAL as well as customizes it with extensions and configuration changes.
Vendor extensions
To add custom extensions and an HCI layer for tracing, you can create a libbt-vendor module and specify these components.

Implementing the HAL


The Bluetooth HAL is located in the hardware/libhardware/include/hardware/ directory and consists of the following header files:

  • bluetooth.h: Contains the HAL for the Bluetooth hardware on the device
  • bt_av.h: Contains the HAL for the advanced audio profile.
  • bt_hf.h: Contains the HAL for the handsfree profile.
  • bt_hh.h: Contains the HAL for the HID host profile
  • bt_hl.h: Contains the HAL for the health profile
  • bt_pan.h: Contains the HAL for the pan profile
  • bt_sock.h: Contains the HAL for the socket profile.

Keep in mind that your Bluetooth implementation is not constrained to the features and profiles exposed in the HAL. You can find the default implementation located in the BlueDroid Bluetooth stack in the external/bluetooth/bluedroid directory, which implements the default HAL and also extra features and customizations.

Customizing the BlueDroid Stack


If you are using the default BlueDroid stack, but want to make a few customizations, you can do the following things:

  • Custom Bluetooth profiles - If you want to add Bluetooth profiles that do not have HAL interfaces provided by Android, you must supply an SDK add-on download to make the profile available to app developers, make the APIs available in the Bluetooth system process app (packages/apps/Bluetooth), and add them to the BlueDroid stack (external/bluetooth/bluedroid).
  • Custom vendor extensions and configuration changes - You can add things such as extra AT commands or device-specific configuration changes by creating a libbt-vendor module. See the vendor/broadcom/libbt-vendor directory for an example.
  • Host Controller Interface (HCI) - You can provide your own HCI by creating a libbt-hci module, which is mainly used for debug tracing. See the external/bluetooth/hci directory for an example.

Bluetooth(android 4.2.2版本)的更多相关文章

  1. 【原创】Android 4.4前后版本读取图库图片方式的变化

    Android 4.4前后版本读取图库图片方式的变化   本文讲述Android 4.4(KitKat)前后访问图库以及访问后通过图片路径读取图片的变化   Android 4.4(KitKat)以前 ...

  2. Android SDK与API版本的对应关系

    看教程.开发Android程序等很多地方,需要设置Android SDK的版本,而其要我们写的却是API版本的数字, 为了方便查看 Android SDK与API版本的对应关系 我在SDK Manag ...

  3. 【Android】Android Studio3.1 Mac版本设置项目桌面icon

    近来项目处于测试阶段,工作少了许多,就装了个最新的Android Studio,想写一下安卓.新建好项目,想设置个桌面的icon.我先准备好自己的icon图片,然后复制粘贴到res/mipmap-hd ...

  4. Android Studio发布Release版本之坑--Unknown host 'd29vzk4ow07wi7.cloudfront.net'

    使用Android Studio发布Release版本时,出现Unknown host 'd29vzk4ow07wi7.cloudfront.net'...错误. 解决方法:修改本机的DNS为8.8. ...

  5. 【转】Android SDK,ADT,API 版本的对应关系

    写对应关系之前,先了解一下几个名字的含义. 一. Android ADT: 按照官方网站的开发介绍:Android Development Tools (ADT) is a plugin for th ...

  6. Android 打包出现jdk版本错误的问题

    Android 打包出现 jdk 版本错误的问题,本质上是 SDK 的问题,与 JDK 无关.如果 SDK 的 API 是24或者更高,就要求 jdk 1.8,我这里指定的 API 是22,所以去勾选 ...

  7. Xamarin Android项目提示SDK版本太老

    Xamarin Android项目提示SDK版本太老 错误信息:The installed Android SDK is too old.Version 24.3.4 or newer is requ ...

  8. 我的Android进阶之旅------>Android中高低API版本兼容使用@TargetApi或者@SuppressLint("NewApi")

    Android中高低API版本兼容使用@TargetApi或者@SuppressLint("NewApi") 例如:AndroidManifest.xml中,我们配置了sdk版本的 ...

  9. 对Android 8.0以上版本通知点击无效的一次分析

    版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/178 对Android 8.0以上版本通知点击无效的一次分 ...

随机推荐

  1. 如何使用JMX监控Kafka

    使用kafka做消息队列中间件时,为了实时监控其性能时,免不了要使用jmx调取kafka broker的内部数据,不管是自己重新做一个kafka集群的监控系统,还是使用一些开源的产品,比如yahoo的 ...

  2. Vjudge - B - 这是测试你会不会排序

    2017-07-14 22:44:11 writer:pprp 题目: 他们提出的比赛规则是这样的: 1.  每方派出n个人参赛: 2.  出赛的顺序必须是从弱到强(主要担心中国人擅长的田忌赛马):  ...

  3. Gym - 100712H Bridges(边—双连通分量)

    https://vjudge.net/problem/Gym-100712H 题意: 给出一个图,求添加一条边后最少的桥数量. 思路: 参考了ZSQ大神的题解http://blog.csdn.net/ ...

  4. NNCRF之NNSegmentation, NNPostagging, NNNameEntity

    这里主要介绍NNSegmentation 介绍: NNSegmentation是一个基于LibN3L的利用神经网络来进行分词的工具. 他可以通过不同的模型(NN, RNN, GatedNN, LSTM ...

  5. git拉取GitLab工程报错Repository not found

    # git clone http://xxx/jiqing/frog.git 正克隆到 'frog'... fatal: repository 'http://xxx/jiqing/frog.git/ ...

  6. Generator 函数的语法

    简介 § ⇧ 基本概念 Generator 函数是 ES6 提供的一种异步编程解决方案,语法行为与传统函数完全不同.本章详细介绍 Generator 函数的语法和 API,它的异步编程应用请看< ...

  7. MySQL表锁和行锁

    锁粒度 MySQL 不同的存储引擎支持不同的锁机制,所有的存储引擎都以自己的方式显现了锁机制,服务器层完全不了解存储引擎中的锁实现: InnoDB 存储引擎既支持行级锁(row-level locki ...

  8. [ES6]import 与export的用法 ,export 与export default 的 区别 以及用法

    一.import 与export export(导出):用于对外输出本模块(一个文件可以理解为一个模块)变量的接口: import(导入):用于在一个模块中加载另一个含有export接口的模块. 1. ...

  9. dapper-dot-net/Dapper NET40/SqlMapper.cs

    /* License: http://www.apache.org/licenses/LICENSE-2.0 Home page: http://code.google.com/p/dapper-do ...

  10. Kotlin Android Studio 环境搭建

    Kotlin 是一种在 Java 虚拟机上运行的静态类型编程语言,被称之为 Android 世界的Swift,由 JetBrains 设计开发并开源. Kotlin 可以编译成Java字节码,也可以编 ...