在Android4.2中实现bluetooth A2dp Sink(二)——移植Android5.0蓝牙协议栈

在Android中,蓝牙系统的结构如下图所示:

在这个体系结构中,从下往上依次是模块驱动、蓝牙协议栈、Bluetooth.apk、Framework和各种蓝牙应用。其中,内核中的驱动是直接和硬件打交道的,一般由模块厂商提供。Android层中,最下面的是处理具体蓝牙协议的协议栈,里面包含了蓝牙各种profile的具体实现,Bluetooth.apk是蓝牙协议栈和framework之间的纽带,使用jni接口沟通了用java实现的framework和c实现的协议栈,并且实现了状态机来控制各种profile的各种工作状态。Framwork为应用提供各种接口。这样的功能划分不一定准确,只是我个人的一点理解。

能够的前提是模块硬件上要支持A2DP Sink,所以移植之前需要和厂商进行沟通,看硬件上支持不支持Sink的功能。

蓝牙协议栈是整个体系中最复杂的部分,是具体实现各种profile协议处理的地方,相对来说,使用java实现的Bluetooth.apk和Framework都要简单一些。所以移植的过程中,协议栈是原封不动的从5.0上复制过来的,然后再在Bluetooth.apk和Framework中进行一些修改以与协议栈想配合。这就是移植的大致思路。

时间: 2024-07-30 18:27:10

在Android4.2中实现bluetooth A2dp Sink(二)——移植Android5.0蓝牙协议栈的相关文章

在Android4.2中实现bluetooth A2dp Sink(一)——移植Android5.0蓝牙协议栈

一直以来,Android对于蓝牙的支持都很混乱,简直可以说是一坨shit.各个版本的协议栈都不一样,最早用的是bluez,进入4.x时代之后,换成了谷歌自己的bluedroid.换就换吧,至少等做完了再用吧,结果4.2.4.3.4.4的bluedroid全都不一样.这就对我等非专业蓝牙开发人员开发蓝牙制造了巨大的麻烦. 好了,吐槽到此为止,该说正事了.因为公司在做智能家居项目,需要在Android上实现蓝牙A2dp Sink的profile,这样我们的设备就能当蓝牙音箱来用了.我们是用的平台是全

Android bluetooth介绍(二): android 蓝牙代码架构及其uart 到rfcomm流程

关键词:蓝牙blueZ  UART  HCI_UART H4  HCI  L2CAP RFCOMM  版本:基于android4.2之前版本 bluez内核:linux/linux3.08系统:android/android4.1.3.4作者:xubin341719(欢迎转载,请注明作者,请尊重版权谢谢)欢迎指正错误,共同学习.共同进步!!一.Android Bluetooth Architecture蓝牙代码架构部分(google 官方蓝牙框架) Android的蓝牙系统,自下而上包括以下一些

Android bluetooth介绍(两): android 蓝牙源架构和uart 至rfcomm过程

关键词:蓝牙blueZ  UART  HCI_UART H4  HCI  L2CAP RFCOMM  版本号:基于android4.2先前版本 bluez内核:linux/linux3.08系统:android/android4.1.3.4作者:xubin341719(欢迎转载,请注明作者.请尊重版权谢谢)欢迎指正错误,共同学习.共同进步!! Android bluetooth介绍(一):基本概念及硬件接口Android bluetooth介绍(二): android 蓝牙代码架构及其uart

The Implementation of A2DP Sink in Android 4.4

A2DP Sink was not supported in Android 4.4. We implemented this feature which can be applied in the scenarios below. You can get the code from https://android-review.googlesource.com/#/c/98161/. We tested the solution on Nexus 5. Our solution include

A2DP Sink, AVRCP Controller and HFP Client in Android L

The APIs of A2DP sink, AVRCP controller and HFP client are not published in Android L, but the code which implements the  profiles  is indeed in Android L. You can set the configuration for the car to build the code. Where is the code? A2DP sink /fra

Android4.4中不能发送SD卡就绪广播

当在Android上进行图片的扫描功能开发时一般会使用:sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(“file://”+ Environment.getExternalStorageDirectory()+ picPath)));的广播. 但是在Android4.4及以上版本中,执行上面的代码出现异常:W/ActivityManager( 498): Permission Denial: not allowed

Android4.4中获取资源路径问题

关于Android4.4的图片路径获取,如果回来的Uri的格式有两种 [java] view plaincopy content://com.android.providers.media.documents/document/image:3951 [java] view plaincopy content://media/external/images/media/3951 出现第一种Uri的操作方式如下图所示: 直接点选最近的图片,应该是Android4.4 特有的Api . 找到了一个更全

Android4.4中拒绝发送Intent.ACTION_MEDIA_MOUNTED扫描SD卡的广播

通常在我们的项目中,可能会遇到写本地文件,最常用的就是图片文件,在这之后需要通知系统重新扫描SD卡,在Android4.4之前也就是以发送一个Action为"Intent.ACTION_MEDIA_MOUNTED"的广播通知执行扫描.如下: this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDir

解决android4.4 中添加Menu的icon时,没有显示的问题

我的Activity是继承了ActionBarActivity,你可以重写你的ActionBarActivity,然后每一个Activity都继承你的BaseActionBarActivity 只需要在Activity里面重写下面的方法即可 @Override public boolean onMenuOpened(int featureId, Menu menu) { if (featureId == Window.FEATURE_ACTION_BAR && menu != null)