码迷,mamicode.com
首页 > 移动开发 > 详细

Bluetooth in Android 4.2 and 4.3(一):综述

时间:2014-08-12 17:44:15      阅读:411      评论:0      收藏:0      [点我收藏+]

标签:android   style   http   color   java   文件   for   ar   

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

  • 层次结构清晰。各个profile对上层接口统一,便于增加新的profile;增加了HAL层,便于移植。

  • 去掉了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(一):综述,布布扣,bubuko.com

Bluetooth in Android 4.2 and 4.3(一):综述

标签:android   style   http   color   java   文件   for   ar   

原文地址:http://my.oschina.net/u/994235/blog/300431

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!