ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:24.86KB ,
资源ID:30006391      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/30006391.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Android 蓝牙AVRCP功能的实现.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Android 蓝牙AVRCP功能的实现.docx

1、Android 蓝牙AVRCP功能的实现Android蓝牙AVRCP功能的实现作者:MacroLiuAVRCP的按键定义:sdkemulatorkeymapsAVRCP.klkey200MEDIA_PLAY_PAUSEWAKEkey201MEDIA_PLAY_PAUSEWAKEkey166MEDIA_STOPWAKEkey163MEDIA_NEXTWAKEkey165MEDIA_PREVIOUSWAKEkey168MEDIA_REWINDWAKEkey208MEDIA_FAST_FORWARDWAKEBCM(broadcom)宏定义需要打开:BOARD_HAVE_BLUETOOTH_BCM:=

2、trueBT音频控制的代码externalbluetoothbluezaudiocontrol.c(1)按键的MAPstaticstruct constchar*name; uint8_tavrcp; uint16_tuinput;key_map= PLAY, PLAY_OP, KEY_PLAYCD, STOP, STOP_OP, KEY_STOPCD, PAUSE, PAUSE_OP, KEY_PAUSECD, FORWARD, FORWARD_OP, KEY_NEXTSONG, BACKWARD, BACKWARD_OP, KEY_PREVIOUSSONG, REWIND, REWIND_

3、OP, KEY_REWIND, FASTFORWARD, FAST_FORWARD_OP, KEY_FASTFORWARD, NULL;(2)按键处理staticvoidhandle_panel_passthrough(structcontrol*control, for(i=0;key_mapi.name!=NULL;i+) uint8_tkey_quirks; if(operands0&0x7F)!=key_mapi.avrcp) continue; DBG(AVRCP:%s%s,key_mapi.name,status); key_quirks=control-key_quirkskey

4、_mapi.avrcp; if(key_quirks&QUIRK_NO_RELEASE) if(!pressed) DBG(AVRCP:Ignoringrelease); break; DBG(AVRCP:treatingkeypressaspress+release); send_key(control-uinput,key_mapi.uinput,1); send_key(control-uinput,key_mapi.uinput,0); break; send_key(control-uinput,key_mapi.uinput,pressed); break; HCIDUMP数据分析

5、以Sony耳机DRC-BT15为例#adbshell#hcidumpX左键:ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8psm00000:30110e00487c4c000.H|L.HCICommand:ExitSniffMode(0x02|0x0004)plen20000:0c00.HCIEvent:MaxSlotsChange(0x1b)plen30000:0c0005.HCIEvent:ModeChange(0x14)plen60000:000c00000000.HCIEvent:CommandStatus(0x0f)plen

6、40000:0c010408.ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8psm00000:40110e00487ccc00.H|?HCIEvent:NumberofCompletedPackets(0x13)plen50000:010c000200.播放/暂停:ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8psm00000:50110e00487c4b00P.H|K.ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8

7、psm00000:60110e00487ccb00.H|?HCIEvent:NumberofCompletedPackets(0x13)plen50000:010c000200.右键:ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8psm00000:70110e00487c4600p.H|F.ACLdata:handle12flags0x02dlen12L2CAP(d):cid0x0042len8psm00000:80110e00487cc600.H|?HCIEvent:NumberofCompletedPackets(0x13)ple

8、n50000:010c000200.HCIEvent:MaxSlotsChange(0x1b)plen30000:0c0001.HCIEvent:ModeChange(0x14)plen60000:000c0002c800.?然后将control.c的日志打印出来:按一次”“播放/暂停键”:D/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=46对应PAUSE_OPD/ACRVP(237):key_quirks=0,pressed=1按键按下D/ACRVP(237):control-uinput=fffffffe,send

9、_key=201对应MEDIA_PLAY_PAUSED/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=c6(=0x460x80表示按键释放了)D/ACRVP(237):key_quirks=0,pressed=0按键释放D/ACRVP(237):control-uinput=fffffffe,send_key=201对应MEDIA_PLAY_PAUSE再按一次”“播放/暂停键”:D/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=44对应PLAY_O

10、PD/ACRVP(237):key_quirks=0,pressed=1按键按下D/ACRVP(237):control-uinput=fffffffe,send_key=200对应MEDIA_PLAY_PAUSED/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=c4D/ACRVP(237):key_quirks=0,pressed=0按键释放D/ACRVP(237):control-uinput=fffffffe,send_key=200对应MEDIA_PLAY_PAUSEnextkey:D/ACRVP(237):-h

11、andle_panel_passthrough-D/ACRVP(237):operands0=4b对应FORWARD_OPD/ACRVP(237):key_quirks=0,pressed=1D/ACRVP(237):control-uinput=fffffffe,send_key=163对应MEDIA_NEXTD/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=cbD/ACRVP(237):key_quirks=0,pressed=0D/ACRVP(237):control-uinput=fffffffe,send_ke

12、y=163prevkey:D/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=4c对应BACKWARD_OPD/ACRVP(237):key_quirks=0,pressed=1D/ACRVP(237):control-uinput=fffffffe,send_key=165对应D/ACRVP(237):-handle_panel_passthrough-D/ACRVP(237):operands0=ccD/ACRVP(237):key_quirks=0,pressed=0D/ACRVP(237):control-uinp

13、ut=fffffffe,send_key=165MEDIA_PREVIOUS从上面可以看到bluetooth的协议栈blueZ是没有问题的将frameworksbaselibsuiEventHub.cpp的LOG打开,只能看到了control.c的日志,EventHub的getEvent完全不响应观察所有log日志发现,openDevice里也没有装载AVRCP.kl初步判断event有问题event分析:$adbshell#cd/proc/bus/input#catdevicescatdevices#catdevicescatdevicesI:Bus=0019Vendor=0001Produ

14、ct=0001Version=0001参考s3c-keypad.cN:Name=s3c-keypad input_dev-name=DEVICE_NAME;P:Phys=s3c-keypad/input0input_dev-phys=s3c-keypad/input0;S:Sysfs=/devices/virtual/input/input0virtual的?U:Uniq=H:Handlers=event0B:EV=3B:KEY=40004000I:Bus=0019Vendor=0001Product=0001Version=0100参考vpad_buttons.cN:Name=s3c-ein

15、tkeyinput-name=pdev-name,gpio_keys_device_driver.name =s3c-eintkey,P:Phys=gpio-keys/input0input-phys=gpio-keys/input0S:Sysfs=/devices/platform/s3c-eintkey/input/input1为什么这里是platform目录?U:Uniq=H:Handlers=event1B:EV=3B:KEY=100000000I:Bus=0018Vendor=0000Product=0000Version=0000参考amri_ts.cN:Name=amri_tsa

16、mri_ts_driver.name=amri_tsP:Phys=没有定义S:Sysfs=/devices/platform/s3c2440-i2c.0/i2c-0/0-0033/input/input2为什么这里是platform目录?U:Uniq=H:Handlers=event2B:EV=bB:KEY=4000000040000800400010000B:ABS=26500000I:Bus=0000Vendor=0000Product=0000Version=0000N:Name=ecompass_dataP:Phys=S:Sysfs=/devices/virtual/input/inp

17、ut3U:Uniq=H:Handlers=event3B:EV=9B:ABS=307bf从上面可以看到,完全没有AVRCP的event。解决办法:Kernel$makemenuconfigCONFIG_INPUT_UINPUT解决后的状况:$adbshell#cd/proc/bus/input#catdevices显示增加了一个eventI:Bus=0005Vendor=0000Product=0000Version=0000N:Name=AVRCPP:Phys=S:Sysfs=/devices/virtual/input/input4U:Uniq=H:Handlers=event4B:EV=

18、100007B:KEY=1030016800000B:REL=0看openDevice的信息:D/EventHub(84):EventHub:readNotifynfd:87D/EventHub(84):Openingdevice:/dev/input/event4D/EventHub(84):Gettingkeys.D/EventHub(84):Gettingabsolutecontrollers.D/EventHub(84):keylayoutFilename=/system/usr/keylayout/AVRCP.klI/EventHub(84):Newkeyboard:device-i

19、d=0x10003devname=AVRCPpropName=hw.keyboards.65539.devnamekeylayout=/system/usr/keylayout/AVRCP.klI/EventHub(84):Newdevice:path=/dev/input/event4name=AVRCPid=0x10003(of0x4)index=4fd=196classes=0x1D/EventHub(84):Addingdevice/dev/input/event40x361800at4,id=3,classes=0x1D/EventHub(84):Reportingdeviceope

20、ned:id=0x10003,name=/dev/input/event4按键时也可以看到EventHub的信息了:Log如下:D/ACRVP(236):-handle_panel_passthrough-D/ACRVP(236):operands0=46D/ACRVP(236):key_quirks=0,pressed=1D/ACRVP(236):control-uinput=14,send_key=201control.c发出201号键,按键按下了D/EventHub(84):/dev/input/event4got:t0=937,t1=582930,type=1,code=201,v=1

21、表示从event4得到201号键MEDIA_PLAY_PAUSED/EventHub(84):iev.code=201keyCode=85flags=0x00000001err=0D/EventHub(84):/dev/input/event4got:t0=937,t1=600241,type=0,code=0,v=0D/AudioHardware(61):AudioStreamOutALSA:setParameters()routing=0D/ACRVP(236):-handle_panel_passthrough-D/ACRVP(236):operands0=c6D/ACRVP(236):

22、key_quirks=0,pressed=0D/ACRVP(236):control-uinput=14,send_key=c9D/EventHub(84):/dev/input/event4got:t0=937,t1=664391,type=1,code=201,v=0control.c发出201号键,按键释放了D/EventHub(84):iev.code=201keyCode=85flags=0x00000001err=0D/EventHub(84):/dev/input/event4got:t0=937,t1=664406,type=0,code=0,v=0D/A2DP(61):a2d

23、p_stopD/A2DP(61):bluetooth_stopE/BluetoothEventLoop.cpp(84):event_filter:Receivedsignalorg.bluez.AudioSink:Stoppedfrom/org/bluez/236/hci0/dev_00_1D_BA_A5_D8_1CE/BluetoothEventLoop.cpp(84):event_filter:Receivedsignalorg.bluez.AudioSink:PropertyChangedfrom/org/bluez/236/hci0/dev_00_1D_BA_A5_D8_1CE/Blu

24、etoothEventLoop.cpp(84):event_filter:Receivedsignalorg.bluez.AudioSink:PropertyChangedfrom/org/bluez/236/hci0/dev_00_1D_BA_A5_D8_1CV/BluetoothEventRedirector(244):Receivedandroid.bluetooth.a2dp.action.SINK_STATE_CHANGEDD/CachedBluetoothDevice(244):onProfileStateChanged:profileA2DPnewProfileState2D/BluetoothA2dpService(84):A2DPstate:device:00:1D:BA:A5:D8:1CState:4-2D/A2DP(61):ReceivedBT_RESPONSE-BT_STOP_STREAMD/dalvikvm(285):GC_EXPLICITfreed87K,56%free2640K/5895K,external1625K/2137K,paused75msMacroLiu2011-08-01

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1