从Android 4.2开始,Bluetooth stack发生了重大改变:从Bluez换成了由Google和Broadcom联合开发的Bluedroid(当然,核心的部分还是Broadcom的,Google主要是做了和上层Framework相关的部分)。通过http://source.android.com/devices/bluetooth.html可以大概了解新的Bluetooth stack的架构,总的来说相关文档很少,主要靠阅读代码进行深入了解。

Bluedroid和Bluez相比,有如下优点:

  1. 层次结构清晰。各个profile对上层接口统一,便于增加新的profile;增加了HAL层,便于移植。
  2. 去掉了DBus,Framework的Java代码直接调用到Bluedroid的Native代码。

但是Android 4.2中的Bluedroid与Android 4.1中的Bluez相比,功能要少,例如不支持AVRCP 1.3; Bug较多,例如某些蓝牙耳机不能重拨最后一个电话。最重要的是4.2的Bluedroid不支持BLE。不过在刚刚发布的Android 4.3中已经有了很多改进,AVRCP 1.3和BLE都得到了支持。

目前有一些Android 4.1或4.2的设备是支持BLE的,但是都是采用的Vendor自己的解决方案,比如Bluetooth stack采用Bluez 5.x,再提供Vendor BLE Android SDK. 现在Android 4.3已经发布,从未来发展趋势来看,如果有人要学习Bluetooth in Android,建议不要再研究Bluez,最好转向Bluedroid。

以下是Android 4.2中Bluetooth相关代码之分布:

android.bluetooth frameworks/base/core/java/android/bluetooth implements public API for the Bluetooth adapter and profiles
Bluetooth system service packages/apps/Bluetooth/src implements service and profiles at the Android fraework layer
Bluetooth JNI packages/apps/Bluetooth/jni defines Bluetooth adapter and profiles service JNI: calls into HAL and receives callback from HAL
Bluetooth HAL hardware/libhardware/include/hardware/bt_*.h files defines the standard interface that the android.bluetooth adapter and  profiles APIs
Bluetooth stack external/bluetooth/bluedroid implement bluetooth stack: core and profiles

以Pan profile为例,我们可以看看代码的具体分布和类及文件的命名方式:

android.bluetooth frameworks public class BluetoothPan implements BluetoothProfile
Bluetooth System Service packages/apps public class PanService extends ProfileService
Bluetooth JNI packages/apps com_android_bluetooth_pan.cpp
Bluetooth HAL hardware/libhardware include/hardware/bt_pan.h
Bluetooth stack external/bluetooth bluedroid/btif/src/btif_pan.c(implements bt_pan.h)
    bluedroid/bta/pan (Broadcom BTA)
    bluedroid/stack/pan (Broadcom BTE)

Bluetooth in Android 4.2 and 4.3(一):综述的更多相关文章

  1. Bluetooth in Android 4.2 and 4.3(三):Enable Bluetooth

    以下是基于Android 4.2代码,对Bluetooth BR/EDR Enable process的分析.BluetoothAdapter类代表的是local device Bluetooth a ...

  2. Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)

    背景 在学习BLE的过程中,积累了一些心得的DEMO,放到Github,形成本文.感兴趣的同学可以下载到源代码. github: https://github.com/vir56k/bluetooth ...

  3. android -- 蓝牙 bluetooth (四)OPP文件传输

    在前面android -- 蓝牙 bluetooth (一) 入门文章结尾中提到了会按四个方面来写这系列的文章,前面已写了蓝牙打开和蓝牙搜索,这次一起来看下蓝牙文件分享的流程,也就是蓝牙应用opp目录 ...

  4. android 蓝牙连接与通讯(Bluetooth)

    最近做了一个小项目,关于蓝牙的一个智能硬件.其中涉及到了蓝牙模块的操作.特记下蓝牙模块的操作过程.只记录下关于蓝牙部分的操作,具体业务逻辑不涉及其中.重点是记录下蓝牙的扫描.链接.通讯. 在使用蓝牙模 ...

  5. 深入了解Android蓝牙Bluetooth——《进阶篇》

    在 [深入了解Android蓝牙Bluetooth--<基础篇>](http://blog.csdn.net/androidstarjack/article/details/6046846 ...

  6. 【Android 应用开发】Android之Bluetooth编程

    Android Bluetopth 编程大牛文章 http://my.oschina.net/u/994235/blog?catalog=313604 ViewGroup 相关资料 : http:// ...

  7. Android BLE与终端通信(二)——Android Bluetooth基础科普以及搜索蓝牙设备显示列表

    Android BLE与终端通信(二)--Android Bluetooth基础搜索蓝牙设备显示列表 摘要 第一篇算是个热身,这一片开始来写些硬菜了,这篇就是实际和蓝牙打交道了,所以要用到真机调试哟, ...

  8. Android BLE与终端通信(一)——Android Bluetooth基础API以及简单使用获取本地蓝牙名称地址

    Android BLE与终端通信(一)--Android Bluetooth基础API以及简单使用获取本地蓝牙名称地址 Hello,工作需要,也必须开始向BLE方向学习了,公司的核心技术就是BLE终端 ...

  9. Android学习笔记——Bluetooth的使用

    蓝牙应该是现在每一部智能手机的标配了.想当年在山寨机横行的年代里,蓝牙都可以做为一个卖点~~~ 废话不多说了,进入正题: 使用蓝牙功能是需要权限的,关于蓝牙的权限也就两个: <uses-perm ...

随机推荐

  1. IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)

    一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...

  2. VS启用IIS调试的方法及可能碰到的问题。

    经常有这种情况, 开发机本地正常, 但是一旦发布到服务上后, 就出现各种问题. 这是由于开发机和服务器环境不一样造成的, 所以开发时要尽可能的模拟真实性.  这时候, VS的这个功能就帮大忙了. 如何 ...

  3. (转)python 优先队列

    #!/usr/bin/python from Queue import Queue from Queue import PriorityQueue a1='a1' a2='a2' a3='a3' a4 ...

  4. phonegap 百度云推

    1 创建新工程 -----获取api key 和secret key 2,推送设置 3,新建安卓项目,并把应用包名 和 推送中设置的包名设置一致 4,下载百度云客户端sdk 5,解压,并添加libs文 ...

  5. 【转】MIPS交叉编译环境的建立

    原文网址:http://imgtec.eetrend.com/forum/2371 我觉得对于MIPS处理起来说最令新手头疼的应该就是编译环境的建立了,这点MIPS做的确实不是很好,不像ARM那样有许 ...

  6. vs2012编译出错“LC.exe”已退出解决方法

    “LC.exe”已退出,代码为 -1. 解决方法: 将项目Properties下的licenses.licx文件删除,重新编译即可.

  7. poj 3254(状态压缩基础题)

    题意:就是你给一个n行m列的矩阵,矩阵里的元素由0和1组成,1代表肥沃的土地可以种植作物,0则不可以种植作物,并且相邻的土地不能同时种植作物,问你有多少种种植方案. 分析:这是我做的第一道状态压缩dp ...

  8. (C#)RichTextBox控件

    RichTextBox(有格式文本)控件可实现TextBox控件的所有功能. ❶在RichTextBox控件中显示滚动条 RichTextBox可设置Multiline属性来控制是否显示滚动套,tru ...

  9. 【LeetCode】14 - Longest Common Prefix

    Write a function to find the longest common prefix string amongst an array of strings. Solution: cla ...

  10. scala 连接 mysql

    code: import java.sql.{ResultSet, DriverManager} import com.mysql.jdbc.Connection object hoursAvg { ...