Android 蓝牙AVRCP功能的实现Word文档下载推荐.docx
《Android 蓝牙AVRCP功能的实现Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《Android 蓝牙AVRCP功能的实现Word文档下载推荐.docx(10页珍藏版)》请在冰豆网上搜索。
external\bluetooth\bluez\audio\control.c
(1)按键的MAP
staticstruct{
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_OP,KEY_REWIND},
FASTFORWARD"
FAST_FORWARD_OP,KEY_FASTFORWARD},
{NULL}
};
(2)按键处理
staticvoidhandle_panel_passthrough(structcontrol*control,
{
…
for(i=0;
key_map[i].name!
=NULL;
i++){
uint8_tkey_quirks;
if((operands[0]&
0x7F)!
=key_map[i].avrcp)
continue;
DBG("
AVRCP:
%s%s"
key_map[i].name,status);
key_quirks=control->
key_quirks[key_map[i].avrcp];
if(key_quirks&
QUIRK_NO_RELEASE){
if(!
pressed){
DBG("
Ignoringrelease"
);
break;
}
DBG("
treatingkeypressaspress+release"
send_key(control->
uinput,key_map[i].uinput,1);
uinput,key_map[i].uinput,0);
break;
}
send_key(control->
uinput,key_map[i].uinput,pressed);
break;
}
…
}
HCIDUMP数据分析
以Sony耳机DRC-BT15为例
#adbshell
#hcidump–X
左键:
>
ACLdata:
handle12flags0x02dlen12
L2CAP(d):
cid0x0042len8[psm0]
0000:
30110e00487c4c00
0...H|L.
<
HCICommand:
ExitSniffMode(0x02|0x0004)plen2
0c00
..
handle12flags0x00dlen12
08004b0032110e09
487c4c00
..K.2...H|L.
HCIEvent:
MaxSlotsChange(0x1b)plen3
0c0005
...
ModeChange(0x14)plen6
000c00000000
......
CommandStatus(0x0f)plen4
0c010408
....
40110e00487ccc00
@...H|?
08004b0042110e09
487ccc00
..K.B...H|?
NumberofCompletedPackets(0x13)plen5
010c000200
.....
播放/暂停:
50110e00487c4b00
P...H|K.
08004b0052110e09
487c4b00
..K.R...H|K.
60110e00487ccb00
`...H|?
08004b0062110e09
487ccb00
..K.b...H|?
右键:
70110e00487c4600
p...H|F.
08004b0072110e09
487c4600
..K.r...H|F.
80110e00487cc600
....H|?
08004b0082110e09
487cc600
..K.....H|?
0c0001
000c0002c800
....?
然后将control.c的日志打印出来:
按一次”“播放/暂停键”:
D/ACRVP(237):
---handle_panel_passthrough----
operands[0]=46对应PAUSE_OP
key_quirks=0,pressed=1按键按下
control->
uinput=fffffffe,send_key=201对应MEDIA_PLAY_PAUSE
operands[0]=c6(=0x46|0x80表示按键释放了)
key_quirks=0,pressed=0按键释放
uinput=fffffffe,send_key=201对应MEDIA_PLAY_PAUSE
再按一次”“播放/暂停键”:
operands[0]=44对应PLAY_OP
key_quirks=0,pressed=1按键按下
uinput=fffffffe,send_key=200对应MEDIA_PLAY_PAUSE
---handle_panel_passth