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

來源:互聯網
上載者:User

    從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)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.