[E 2015 Original Android Development] spiked_mistborn:
BT AVRCP

I've had a problem with Bluetooth audio playback controls (play, pause, next track, previous track) failing to work on the CM 13 ROMS. I think they used to work sometimes on CM 12.1. I checked the bt_hci log and the commands are getting passed through using the Bluetooth Audio/Video Remote Control Profile as seen in the screenshot. The logcat shows that the commands are received, and they show the correct keypress, but then there is a mapping error. I think this is preventing the command from getting to the playback application; in this case it was the CM Music app.

02-10 19:37:38.479 D/bt_btif (18850): LCB lcb=1 event=6 state=2
02-10 19:37:38.479 D/bt_btif (18850): bta_av_rc_msg_cback handle: 0 opcode=0x7c
02-10 19:37:38.479 D/bt_btif (18850): LCB lcb=1 event=2 state=2
02-10 19:37:38.480 D/bt_btif (18850): btif_av_state_started_handler event:BTA_AV_REMOTE_CMD_EVT flags 0 index =0
02-10 19:37:38.480 D/bt_btif (18850): btif_rc_handler event:BTA_AV_REMOTE_CMD_EVT
02-10 19:37:38.480 W/bt_btif (18850): Passthrough on the playing device
02-10 19:37:38.480 D/bt_btif (18850): AVRCP: Send key 163 (1) fd=131
02-10 19:37:38.485 D/bt_btif (18850): LCB lcb=1 event=6 state=2
02-10 19:37:38.485 D/bt_btif (18850): bta_av_rc_msg_cback handle: 0 opcode=0x7c
02-10 19:37:38.486 D/bt_btif (18850): LCB lcb=1 event=2 state=2
02-10 19:37:38.486 D/bt_btif (18850): btif_av_state_started_handler event:BTA_AV_REMOTE_CMD_EVT flags 0 index =0
02-10 19:37:38.486 D/bt_btif (18850): btif_rc_handler event:BTA_AV_REMOTE_CMD_EVT
02-10 19:37:38.486 W/bt_btif (18850): Passthrough on the playing device
02-10 19:37:38.486 D/bt_btif (18850): AVRCP: Send key 163 (0) fd=131
02-10 19:37:38.493 D/EmojiAltPhysicalKeyDetector(15929): onKeyUp() : KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_NEXT, scanCode=163, metaState=0, flags=0x8, repeatCount=0, eventTime=92855626, downTime=92855620, deviceId=11, source=0x101 }
02-10 19:37:38.493 D/EmojiAltPhysicalKeyDetector(15929): onKeyUp() : Not Mapped: 87

Edit: here's a logcat from CM12.1 where the controls are working correctly.

02-11 08:15:12.205 D/bt-btif ( 4258): LCB lcb=1 event=6 state=2
02-11 08:15:12.206 D/bt-btif ( 4258): bta_av_rc_msg_cback handle: 0 opcode=0x7c
02-11 08:15:12.206 D/bt-btif ( 4258): bta_av_rc_msg bta_av_rc_msg opcode: 7c
02-11 08:15:12.206 D/bt-btif ( 4258): LCB lcb=1 event=2 state=2
02-11 08:15:12.206 D/bt-btif ( 4258): btif_av_state_started_handler event:BTA_AV_REMOTE_CMD_EVT flags 0
02-11 08:15:12.206 D/bt-btif ( 4258): btif_rc_handler event:BTA_AV_REMOTE_CMD_EVT
02-11 08:15:12.206 D/bt-btif ( 4258): AVRCP: Send key 163 (1) fd=81
02-11 08:15:12.208 D/bt-btif ( 4258): LCB lcb=1 event=6 state=2
02-11 08:15:12.208 D/bt-btif ( 4258): bta_av_rc_msg_cback handle: 0 opcode=0x7c
02-11 08:15:12.208 D/bt-btif ( 4258): bta_av_rc_msg bta_av_rc_msg opcode: 7c
02-11 08:15:12.208 D/bt-btif ( 4258): LCB lcb=1 event=2 state=2
02-11 08:15:12.209 D/bt-btif ( 4258): btif_av_state_started_handler event:BTA_AV_REMOTE_CMD_EVT flags 0
02-11 08:15:12.209 D/bt-btif ( 4258): btif_rc_handler event:BTA_AV_REMOTE_CMD_EVT
02-11 08:15:12.212 D/bt-btif ( 4258): AVRCP: Send key 163 (0) fd=81
02-11 08:15:12.225 D/NuPlayerDriver( 326): reset(0xb5ae7100)
02-11 08:15:12.231 D/NuPlayerDriver( 326): notifyResetComplete(0xb5ae7100)
02-11 08:15:12.233 D/NuPlayerDriver( 326): reset(0xb5ae7100)
02-11 08:15:12.409 I/FFmpegExtractor( 326): android-source:0xb5b011a0
02-11 08:15:12.435 I/FFMPEG ( 326): [mp3 @ 0xb596c600] Skipping 0 bytes of junk at 126379.
02-11 08:15:12.466 I/FFMPEG ( 326): Input #0, mp3, from 'android-source:0xb5b011a0':
02-11 08:15:12.467 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.467 I/FFMPEG ( 326): title : Le Triomphant
02-11 08:15:12.467 I/FFMPEG ( 326): artist : Dubmood
02-11 08:15:12.467 I/FFMPEG ( 326): track : 13
02-11 08:15:12.467 I/FFMPEG ( 326): album : Force De Frappe (DATA045)
02-11 08:15:12.467 I/FFMPEG ( 326): TSRC : GBSMU2413638
02-11 08:15:12.467 I/FFMPEG ( 326): album_artist : Dubmood
02-11 08:15:12.467 I/FFMPEG ( 326): date : 2015
02-11 08:15:12.467 I/FFMPEG ( 326): Duration: 00:01:04.00, start: 0.025056, bitrate: 242 kb/s
02-11 08:15:12.467 I/FFMPEG ( 326): Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 226 kb/s
02-11 08:15:12.467 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.467 I/FFMPEG ( 326): encoder : LAME3.99r
02-11 08:15:12.467 I/FFMPEG ( 326): Side data:
02-11 08:15:12.467 I/FFMPEG ( 326): replaygain: track gain - 0.900000, track peak - unknown, album gain - unknown, album peak - unknown,
02-11 08:15:12.467 I/FFMPEG ( 326): Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 700x700 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
02-11 08:15:12.467 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.467 I/FFMPEG ( 326): title : cover
02-11 08:15:12.467 I/FFMPEG ( 326): comment : Cover (front)
02-11 08:15:12.467 D/FFmpegExtractor( 326): FFmpegExtrator, url: android-source:0xb5b011a0, format_name: mp3, format_long_name: MP2/3 (MPEG audio layer 2/3)
02-11 08:15:12.467 D/FFmpegExtractor( 326): suppoted codec(mp3) by official Stagefright
02-11 08:15:12.468 D/FFmpegExtractor( 326): ffmpeg detected media content as 'audio/mpeg' with confidence 0.08
02-11 08:15:12.469 D/ExtendedUtils( 326): extended extractor not needed, return default
02-11 08:15:12.470 E/MediaPlayer( 1787): Should have subtitle controller already set
02-11 08:15:12.486 D/NuPlayerDriver( 326): reset(0xb4d44e20)
02-11 08:15:12.488 D/NuPlayerDriver( 326): notifyResetComplete(0xb4d44e20)
02-11 08:15:12.491 E/ExtMediaPlayer-JNI( 1787): QCMediaPlayer could not be located....
02-11 08:15:12.491 E/MediaPlayer-JNI( 1787): QCMediaPlayer mediaplayer NOT present
02-11 08:15:12.503 D/Gmail ( 5572): Insert: content://com.google.android.gm.email.provider/body
02-11 08:15:12.527 I/FFmpegExtractor( 326): android-source:0xb5b012e0
02-11 08:15:12.548 I/FFMPEG ( 326): [mp3 @ 0xb5973e00] Skipping 0 bytes of junk at 126379.
02-11 08:15:12.579 I/FFMPEG ( 326): Input #0, mp3, from 'android-source:0xb5b012e0':
02-11 08:15:12.579 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.579 I/FFMPEG ( 326): title : Force De Frappe (feat. GEM TOS)
02-11 08:15:12.579 I/FFMPEG ( 326): artist : Dubmood
02-11 08:15:12.579 I/FFMPEG ( 326): track : 14
02-11 08:15:12.579 I/FFMPEG ( 326): album : Force De Frappe (DATA045)
02-11 08:15:12.579 I/FFMPEG ( 326): TSRC : GBSMU2413639
02-11 08:15:12.579 I/FFMPEG ( 326): album_artist : Dubmood
02-11 08:15:12.579 I/FFMPEG ( 326): date : 2015
02-11 08:15:12.579 I/FFMPEG ( 326): Duration: 00:04:34.52, start: 0.025056, bitrate: 271 kb/s
02-11 08:15:12.579 I/FFMPEG ( 326): Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 267 kb/s
02-11 08:15:12.579 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.579 I/FFMPEG ( 326): encoder : LAME3.99r
02-11 08:15:12.579 I/FFMPEG ( 326): Side data:
02-11 08:15:12.579 I/FFMPEG ( 326): replaygain: track gain - -4.100000, track peak - unknown, album gain - unknown, album peak - unknown,
02-11 08:15:12.579 I/FFMPEG ( 326): Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 700x700 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
02-11 08:15:12.579 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.579 I/FFMPEG ( 326): title : cover
02-11 08:15:12.579 I/FFMPEG ( 326): comment : Cover (front)
02-11 08:15:12.579 D/FFmpegExtractor( 326): FFmpegExtrator, url: android-source:0xb5b012e0, format_name: mp3, format_long_name: MP2/3 (MPEG audio layer 2/3)
02-11 08:15:12.579 D/FFmpegExtractor( 326): suppoted codec(mp3) by official Stagefright
02-11 08:15:12.580 D/FFmpegExtractor( 326): ffmpeg detected media content as 'audio/mpeg' with confidence 0.08
02-11 08:15:12.581 D/ExtendedUtils( 326): extended extractor not needed, return default
02-11 08:15:12.583 E/MediaPlayer( 1787): Should have subtitle controller already set
02-11 08:15:12.587 I/MediaFocusControl( 812): AudioFocus requestAudioFocus() from android.media.AudioManager@e9bcf6ecom.cyanogenmod.eleven.MusicPlaybackService$5@e9f060f req=1flags=0x0
02-11 08:15:12.590 I/HeadsetService( 1458): New audio session: 15
02-11 08:15:12.592 D/NuPlayerDriver( 326): reset(0xb5ae7100)
02-11 08:15:12.592 D/NuPlayerDriver( 326): notifyResetComplete(0xb5ae7100)
02-11 08:15:12.596 E/ExtMediaPlayer-JNI( 1787): QCMediaPlayer could not be located....
02-11 08:15:12.596 E/MediaPlayer-JNI( 1787): QCMediaPlayer mediaplayer NOT present
02-11 08:15:12.630 I/FFmpegExtractor( 326): android-source:0xb5b012e0
02-11 08:15:12.652 I/FFMPEG ( 326): [mp3 @ 0xb5973e00] Skipping 0 bytes of junk at 126379.
02-11 08:15:12.682 I/FFMPEG ( 326): Input #0, mp3, from 'android-source:0xb5b012e0':
02-11 08:15:12.682 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.682 I/FFMPEG ( 326): title : Force De Frappe (feat. GEM TOS)
02-11 08:15:12.682 I/FFMPEG ( 326): artist : Dubmood
02-11 08:15:12.682 I/FFMPEG ( 326): track : 14
02-11 08:15:12.682 I/FFMPEG ( 326): album : Force De Frappe (DATA045)
02-11 08:15:12.682 I/FFMPEG ( 326): TSRC : GBSMU2413639
02-11 08:15:12.682 I/FFMPEG ( 326): album_artist : Dubmood
02-11 08:15:12.682 I/FFMPEG ( 326): date : 2015
02-11 08:15:12.682 I/FFMPEG ( 326): Duration: 00:04:34.52, start: 0.025056, bitrate: 271 kb/s
02-11 08:15:12.682 I/FFMPEG ( 326): Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 267 kb/s
02-11 08:15:12.682 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.682 I/FFMPEG ( 326): encoder : LAME3.99r
02-11 08:15:12.682 I/FFMPEG ( 326): Side data:
02-11 08:15:12.682 I/FFMPEG ( 326): replaygain: track gain - -4.100000, track peak - unknown, album gain - unknown, album peak - unknown,
02-11 08:15:12.682 I/FFMPEG ( 326): Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 700x700 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
02-11 08:15:12.682 I/FFMPEG ( 326): Metadata:
02-11 08:15:12.682 I/FFMPEG ( 326): title : cover
02-11 08:15:12.682 I/FFMPEG ( 326): comment : Cover (front)
02-11 08:15:12.682 D/FFmpegExtractor( 326): FFmpegExtrator, url: android-source:0xb5b012e0, format_name: mp3, format_long_name: MP2/3 (MPEG audio layer 2/3)
02-11 08:15:12.682 D/FFmpegExtractor( 326): suppoted codec(mp3) by official Stagefright
02-11 08:15:12.683 D/FFmpegExtractor( 326): ffmpeg detected media content as 'audio/mpeg' with confidence 0.08
02-11 08:15:12.683 D/ExtendedUtils( 326): extended extractor not needed, return default
02-11 08:15:12.686 E/MediaPlayer( 1787): Should have subtitle controller already set
02-11 08:15:12.688 D/NuPlayerDriver( 326): start(0xb5ae7700)
02-11 08:15:12.688 I/GenericSource( 326): start
02-11 08:15:12.691 W/Utils ( 326): bool android::canOffloadStream(const android::sp<android::MetaData>&, bool, const android::sp<android::MetaData>&, bool, audio_stream_type_t) No sample bit depth info in meta data
02-11 08:15:12.691 I/ExtendedUtils( 326): No channel mask, try channel count
02-11 08:15:12.691 I/NuPlayer( 326): Could not offload audio decode, pcm offload decided :0
02-11 08:15:12.693 W/Utils ( 326): bool android::canOffloadStream(const android::sp<android::MetaData>&, bool, const android::sp<android::MetaData>&, bool, audio_stream_type_t) No sample bit depth info in meta data
02-11 08:15:12.697 I/ACodec ( 326): sampleRate=44100 channels=2 bits=16
02-11 08:15:12.716 E/AudioTrack( 326): AudioTrack::set : Exit
02-11 08:15:12.717 I/str_params( 326): key: 'routing' value: '128'
02-11 08:15:12.717 I/str_params( 326): key: 'a2dp_sink_address' value: '00:1E:AE:07:53:F1'
02-11 08:15:12.832 V/Avrcp ( 4258): old Metadata = Metadata[artist=Dubmood trackTitle=Interception Part II (feat. MisfitChris) albumTitle=Force De Frappe (DATA045) genre=null tracknum=12]
02-11 08:15:12.832 V/Avrcp ( 4258): new MetaData Metadata[artist=Dubmood trackTitle=Le Triomphant albumTitle=Force De Frappe (DATA045) genre=null tracknum=13]
02-11 08:15:12.832 V/Avrcp ( 4258): new mMetadata, mTrackNumber update to 14
02-11 08:15:12.842 D/Avrcp ( 4258): Update mPlayStartTimeMs: 324261 mCurrentPosMs: 72
02-11 08:15:12.898 W/WakefulBroadcastReceiver( 1787): No active wake lock id #7
02-11 08:15:12.910 W/art ( 1787): Long monitor contention event with owner method=void com.cyanogenmod.eleven.MusicPlaybackService.gotoNext(boolean) from MusicPlaybackService.java:2468 waiters=0 for 679ms
02-11 08:15:12.911 E/MediaPlayer( 1787): Should have subtitle controller already set
02-11 08:15:12.912 W/MediaPlayer( 1787): mediaplayer went away with unhandled events
02-11 08:15:12.912 E/MediaPlayer( 1787): Should have subtitle controller already set
02-11 08:15:12.991 I/art ( 812): Background partial concurrent mark sweep GC freed 5558(312KB) AllocSpace objects, 42(18MB) LOS objects, 29% free, 39MB/55MB, paused 2.407ms total 177.882ms