Bug 1142408 - Add data length parameter for Register Notification Response Command. r=tzimmermann

This commit is contained in:
Shawn Huang 2015-03-18 02:52:00 -04:00
Родитель 8610c13659
Коммит 528865edc6
2 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -265,8 +265,9 @@ BluetoothDaemonAvrcpModule::RegisterNotificationRspCmd(
1 + // Data length
256)); // Maximum data length
nsresult rv = PackPDU(aEvent, aType,
BluetoothAvrcpEventParamPair(aEvent, aParam), *pdu);
BluetoothAvrcpEventParamPair data(aEvent, aParam);
nsresult rv = PackPDU(aEvent, aType, static_cast<uint8_t>(data.GetLength()),
data, *pdu);
if (NS_FAILED(rv)) {
return rv;
}

Просмотреть файл

@ -85,6 +85,37 @@ struct BluetoothAvrcpEventParamPair {
, mParam(aParam)
{ }
size_t GetLength()
{
size_t size;
switch(mEvent) {
case AVRCP_EVENT_PLAY_STATUS_CHANGED:
/* PackPDU casts ControlPlayStatus to uint8_t */
size = sizeof(static_cast<uint8_t>(mParam.mPlayStatus));
break;
case AVRCP_EVENT_TRACK_CHANGE:
size = sizeof(mParam.mTrack);
break;
case AVRCP_EVENT_TRACK_REACHED_END:
case AVRCP_EVENT_TRACK_REACHED_START:
/* no data to pack */
size = 0;
break;
case AVRCP_EVENT_PLAY_POS_CHANGED:
size = sizeof(mParam.mSongPos);
break;
case AVRCP_EVENT_APP_SETTINGS_CHANGED:
size = (sizeof(mParam.mIds[0]) + sizeof(mParam.mValues[0])) * mParam.mNumAttr;
break;
default:
size = 0;
break;
}
return size;
}
BluetoothAvrcpEvent mEvent;
const BluetoothAvrcpNotificationParam& mParam;
};