BT: Use Converged AVRCP files for multi-connection FR
Using converged AVRCP files in QTI stack.
CRs-Fixed: 2445228
Change-Id: I2fe8c857c66eb7dd2fe1e70c50a176a444c384e0
diff --git a/packages_apps_bluetooth_ext/AddressedMediaPlayer_ext.java b/packages_apps_bluetooth_ext/src/avrcp/AddressedMediaPlayer_ext.java
similarity index 81%
rename from packages_apps_bluetooth_ext/AddressedMediaPlayer_ext.java
rename to packages_apps_bluetooth_ext/src/avrcp/AddressedMediaPlayer_ext.java
index 5e61b75..a650069 100644
--- a/packages_apps_bluetooth_ext/AddressedMediaPlayer_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/AddressedMediaPlayer_ext.java
@@ -50,7 +50,7 @@
static private final String GPM_BUNDLE_METADATA_KEY =
"com.google.android.music.mediasession.music_metadata";
- private AvrcpMediaRspInterface mMediaInterface;
+ private AvrcpMediaRspInterface_ext mMediaInterface;
private Avrcp_ext mAvrcp = null;
@NonNull private List<MediaSession.QueueItem> mNowPlayingList;
@@ -58,14 +58,14 @@
private long mLastTrackIdSent;
- public AddressedMediaPlayer(AvrcpMediaRspInterface mediaInterface) {
+ public AddressedMediaPlayer_ext(AvrcpMediaRspInterface_ext mediaInterface) {
mEmptyNowPlayingList = new ArrayList<MediaSession.QueueItem>();
mNowPlayingList = mEmptyNowPlayingList;
mMediaInterface = mediaInterface;
mLastTrackIdSent = MediaSession.QueueItem.UNKNOWN_ID;
}
- public AddressedMediaPlayer(AvrcpMediaRspInterface mediaInterface, Avrcp_ext mAvrcp_ext) {
+ public AddressedMediaPlayer_ext(AvrcpMediaRspInterface_ext mediaInterface, Avrcp_ext mAvrcp_ext) {
this(mediaInterface);
mAvrcp = mAvrcp_ext;
}
@@ -80,29 +80,29 @@
}
/* get now playing list from addressed player */
- void getFolderItemsNowPlaying(byte[] bdaddr, AvrcpCmd.FolderItemsCmd reqObj,
+ void getFolderItemsNowPlaying(byte[] bdaddr, AvrcpCmd_ext.FolderItemsCmd reqObj,
@Nullable MediaController mediaController) {
if (mediaController == null) {
// No players (if a player exists, we would have selected it)
Log.e(TAG, "mediaController = null, sending no available players response");
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_NO_AVBL_PLAY, null);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_NO_AVBL_PLAY, null);
return;
}
List<MediaSession.QueueItem> items = updateNowPlayingList(mediaController);
- getFolderItemsFilterAttr(bdaddr, reqObj, items, AvrcpConstants.BTRC_SCOPE_NOW_PLAYING,
+ getFolderItemsFilterAttr(bdaddr, reqObj, items, AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING,
reqObj.mStartItem, reqObj.mEndItem, mediaController);
}
/* get item attributes for item in now playing list */
- void getItemAttr(byte[] bdaddr, AvrcpCmd.ItemAttrCmd itemAttr,
+ void getItemAttr(byte[] bdaddr, AvrcpCmd_ext.ItemAttrCmd itemAttr,
@Nullable MediaController mediaController) {
- int status = AvrcpConstants.RSP_NO_ERROR;
+ int status = AvrcpConstants_ext.RSP_NO_ERROR;
long mediaId = ByteBuffer.wrap(itemAttr.mUid).getLong();
List<MediaSession.QueueItem> items = updateNowPlayingList(mediaController);
// NOTE: this is out-of-spec (AVRCP 1.6.1 sec 6.10.4.3, p90) but we answer it anyway
// because some CTs ask for it.
- if (Arrays.equals(itemAttr.mUid, AvrcpConstants.TRACK_IS_SELECTED)) {
+ if (Arrays.equals(itemAttr.mUid, AvrcpConstants_ext.TRACK_IS_SELECTED)) {
mediaId = getActiveQueueItemId(mediaController);
if (DEBUG) {
Log.d(TAG, "getItemAttr: Remote requests for now playing contents, sending UID: "
@@ -121,7 +121,7 @@
}
// Couldn't find it, so the id is invalid
- mMediaInterface.getItemAttrRsp(bdaddr, AvrcpConstants.RSP_INV_ITEM, null);
+ mMediaInterface.getItemAttrRsp(bdaddr, AvrcpConstants_ext.RSP_INV_ITEM, null);
}
/* Refresh and get the queue of now playing.
@@ -177,7 +177,7 @@
if (DEBUG) {
Log.d(TAG, "sendNowPlayingListChanged()");
}
- mMediaInterface.nowPlayingChangedRsp(AvrcpConstants.NOTIFICATION_TYPE_CHANGED);
+ mMediaInterface.nowPlayingChangedRsp(AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED);
}
private Bundle fillBundle(MediaMetadata metadata, Bundle currentExtras) {
@@ -224,7 +224,7 @@
if (mediaController == null) {
Log.e(TAG, "No mediaController when PlayItem " + qid + " requested");
- mMediaInterface.playItemRsp(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ mMediaInterface.playItemRsp(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
return;
}
@@ -233,7 +233,7 @@
if (items == null) {
Log.w(TAG, "nowPlayingItems is null");
- mMediaInterface.playItemRsp(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ mMediaInterface.playItemRsp(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
return;
}
@@ -243,13 +243,13 @@
Log.d(TAG, "Skipping to ID " + qid);
}
mediaControllerCntrl.skipToQueueItem(qid);
- mMediaInterface.playItemRsp(bdaddr, AvrcpConstants.RSP_NO_ERROR);
+ mMediaInterface.playItemRsp(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR);
return;
}
}
Log.w(TAG, "Invalid now playing Queue ID " + qid);
- mMediaInterface.playItemRsp(bdaddr, AvrcpConstants.RSP_INV_ITEM);
+ mMediaInterface.playItemRsp(bdaddr, AvrcpConstants_ext.RSP_INV_ITEM);
}
void getTotalNumOfItems(byte[] bdaddr, @Nullable MediaController mediaController) {
@@ -257,21 +257,21 @@
if (DEBUG) {
Log.d(TAG, "getTotalNumOfItems: " + items.size() + " items.");
}
- mMediaInterface.getTotalNumOfItemsRsp(bdaddr, AvrcpConstants.RSP_NO_ERROR, 0, items.size());
+ mMediaInterface.getTotalNumOfItemsRsp(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR, 0, items.size());
}
void sendTrackChangeWithId(int type, @Nullable MediaController mediaController) {
Log.d(TAG, "sendTrackChangeWithId (" + type + "): controller " + mediaController);
long qid = getActiveQueueItemId(mediaController);
- byte[] track = ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(qid).array();
+ byte[] track = ByteBuffer.allocate(AvrcpConstants_ext.UID_SIZE).putLong(qid).array();
Log.d(TAG, "qid: " + qid );
- if ((type == AvrcpConstants.NOTIFICATION_TYPE_INTERIM) &&
+ if ((type == AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) &&
(qid != MediaSession.QueueItem.UNKNOWN_ID) &&
(qid != mLastTrackIdSent)) {
byte[] lastTrack =
- ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(mLastTrackIdSent).array();
+ ByteBuffer.allocate(AvrcpConstants_ext.UID_SIZE).putLong(mLastTrackIdSent).array();
mMediaInterface.trackChangedRsp(type, lastTrack);
- type = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ type = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
// The nowPlayingList changed: the new list has the full data for the current item
Log.d(TAG, "last_sent_qid: " + mLastTrackIdSent);
@@ -286,15 +286,15 @@
return;
}
long qid = getActiveQueueItemId(mediaController);
- byte[] track = ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(qid).array();
+ byte[] track = ByteBuffer.allocate(AvrcpConstants_ext.UID_SIZE).putLong(qid).array();
Log.d(TAG, "qid: " + qid );
- if ((type == AvrcpConstants.NOTIFICATION_TYPE_INTERIM) &&
+ if ((type == AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) &&
(qid != MediaSession.QueueItem.UNKNOWN_ID) &&
(qid != mLastTrackIdSent)) {
byte[] lastTrack =
- ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(mLastTrackIdSent).array();
+ ByteBuffer.allocate(AvrcpConstants_ext.UID_SIZE).putLong(mLastTrackIdSent).array();
mAvrcp.trackChangedAddressedRsp(type, lastTrack, bdaddr);
- type = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ type = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
// The nowPlayingList changed: the new list has the full data for the current item
Log.d(TAG, "last_sent_qid: " + mLastTrackIdSent);
@@ -335,7 +335,7 @@
* helper method to filter required attibutes before sending GetFolderItems
* response
*/
- private void getFolderItemsFilterAttr(byte[] bdaddr, AvrcpCmd.FolderItemsCmd folderItemsReqObj,
+ private void getFolderItemsFilterAttr(byte[] bdaddr, AvrcpCmd_ext.FolderItemsCmd folderItemsReqObj,
@NonNull List<MediaSession.QueueItem> items, byte scope, long startItem, long endItem,
@NonNull MediaController mediaController) {
if (DEBUG) {
@@ -347,11 +347,11 @@
/* check for index out of bound errors */
if (resultItems == null) {
Log.w(TAG, "getFolderItemsFilterAttr: resultItems is empty");
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_INV_RANGE, null);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_INV_RANGE, null);
return;
}
- FolderItemsData folderDataNative = new FolderItemsData(resultItems.size());
+ FolderItemsData_ext folderDataNative = new FolderItemsData_ext(resultItems.size());
/* variables to accumulate attrs */
ArrayList<String> attrArray = new ArrayList<String>();
@@ -361,27 +361,27 @@
MediaSession.QueueItem item = resultItems.get(itemIndex);
// get the queue id
long qid = item.getQueueId();
- byte[] uid = ByteBuffer.allocate(AvrcpConstants.UID_SIZE).putLong(qid).array();
+ byte[] uid = ByteBuffer.allocate(AvrcpConstants_ext.UID_SIZE).putLong(qid).array();
// get the array of uid from 2d to array 1D array
- for (int idx = 0; idx < AvrcpConstants.UID_SIZE; idx++) {
- folderDataNative.mItemUid[itemIndex * AvrcpConstants.UID_SIZE + idx] = uid[idx];
+ for (int idx = 0; idx < AvrcpConstants_ext.UID_SIZE; idx++) {
+ folderDataNative.mItemUid[itemIndex * AvrcpConstants_ext.UID_SIZE + idx] = uid[idx];
}
/* Set display name for current item */
folderDataNative.mDisplayNames[itemIndex] =
- getAttrValue(AvrcpConstants.ATTRID_TITLE, item, mediaController);
+ getAttrValue(bdaddr, AvrcpConstants_ext.ATTRID_TITLE, item, mediaController);
int maxAttributesRequested = 0;
boolean isAllAttribRequested = false;
/* check if remote requested for attributes */
- if (folderItemsReqObj.mNumAttr != AvrcpConstants.NUM_ATTR_NONE) {
+ if (folderItemsReqObj.mNumAttr != AvrcpConstants_ext.NUM_ATTR_NONE) {
int attrCnt = 0;
/* add requested attr ids to a temp array */
- if (folderItemsReqObj.mNumAttr == AvrcpConstants.NUM_ATTR_ALL) {
+ if (folderItemsReqObj.mNumAttr == AvrcpConstants_ext.NUM_ATTR_ALL) {
isAllAttribRequested = true;
- maxAttributesRequested = AvrcpConstants.MAX_NUM_ATTR;
+ maxAttributesRequested = AvrcpConstants_ext.MAX_NUM_ATTR;
} else {
/* get only the requested attribute ids from the request */
maxAttributesRequested = folderItemsReqObj.mNumAttr;
@@ -394,7 +394,7 @@
int attribId =
isAllAttribRequested ? (idx + 1) : folderItemsReqObj.mAttrIDs[idx];
- value = getAttrValue(attribId, item, mediaController);
+ value = getAttrValue(bdaddr, attribId, item, mediaController);
if (value != null) {
attrArray.add(value);
attrId.add(attribId);
@@ -407,7 +407,7 @@
}
/* copy filtered attr ids and attr values to response parameters */
- if (folderItemsReqObj.mNumAttr != AvrcpConstants.NUM_ATTR_NONE) {
+ if (folderItemsReqObj.mNumAttr != AvrcpConstants_ext.NUM_ATTR_NONE) {
folderDataNative.mAttrIds = new int[attrId.size()];
for (int attrIndex = 0; attrIndex < attrId.size(); attrIndex++) {
folderDataNative.mAttrIds[attrIndex] = attrId.get(attrIndex);
@@ -422,17 +422,17 @@
}
/* create rsp object and send response to remote device */
- FolderItemsRsp rspObj =
- new FolderItemsRsp(AvrcpConstants.RSP_NO_ERROR, Avrcp.sUIDCounter, scope,
+ FolderItemsRsp_ext rspObj =
+ new FolderItemsRsp_ext(AvrcpConstants_ext.RSP_NO_ERROR, Avrcp_ext.sUIDCounter, scope,
folderDataNative.mNumItems, folderDataNative.mFolderTypes,
folderDataNative.mPlayable, folderDataNative.mItemTypes,
folderDataNative.mItemUid, folderDataNative.mDisplayNames,
folderDataNative.mAttributesNum, folderDataNative.mAttrIds,
folderDataNative.mAttrValues);
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_NO_ERROR, rspObj);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR, rspObj);
}
- private String getAttrValue(int attr, MediaSession.QueueItem item,
+ private String getAttrValue(byte []bdaddr, int attr, MediaSession.QueueItem item,
@Nullable MediaController mediaController) {
String attrValue = null;
if (item == null) {
@@ -468,43 +468,50 @@
Log.d(TAG, "getAttrValue: item " + item + " : " + desc);
}
switch (attr) {
- case AvrcpConstants.ATTRID_TITLE:
+ case AvrcpConstants_ext.ATTRID_TITLE:
/* Title is mandatory attribute */
if (isCurrentTrack) {
attrValue = extras.getString(MediaMetadata.METADATA_KEY_TITLE);
} else {
attrValue = desc.getTitle().toString();
}
+ if (attrValue == null)
+ attrValue = "<Unknown Title>";
break;
- case AvrcpConstants.ATTRID_ARTIST:
+ case AvrcpConstants_ext.ATTRID_ARTIST:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_ARTIST);
break;
- case AvrcpConstants.ATTRID_ALBUM:
+ case AvrcpConstants_ext.ATTRID_ALBUM:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_ALBUM);
break;
- case AvrcpConstants.ATTRID_TRACK_NUM:
+ case AvrcpConstants_ext.ATTRID_TRACK_NUM:
attrValue =
Long.toString(extras.getLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER));
break;
- case AvrcpConstants.ATTRID_NUM_TRACKS:
+ case AvrcpConstants_ext.ATTRID_NUM_TRACKS:
attrValue =
Long.toString(extras.getLong(MediaMetadata.METADATA_KEY_NUM_TRACKS));
break;
- case AvrcpConstants.ATTRID_GENRE:
+ case AvrcpConstants_ext.ATTRID_GENRE:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_GENRE);
break;
- case AvrcpConstants.ATTRID_PLAY_TIME:
+ case AvrcpConstants_ext.ATTRID_PLAY_TIME:
attrValue = Long.toString(extras.getLong(MediaMetadata.METADATA_KEY_DURATION));
break;
- case AvrcpConstants.ATTRID_COVER_ART:
- attrValue = Avrcp_ext.getImgHandleFromTitle(desc.getTitle().toString());
+ case AvrcpConstants_ext.ATTRID_COVER_ART:
+ if (mAvrcp != null) {
+ attrValue = mAvrcp.getImgHandleFromTitle(bdaddr,
+ desc.getTitle().toString());
+ } else {
+ if (DEBUG) Log.d(TAG, " mAvrcp null ");
+ }
break;
default:
@@ -514,7 +521,7 @@
} catch (NullPointerException ex) {
Log.w(TAG, "getAttrValue: attr id not found in result");
/* checking if attribute is title, then it is mandatory and cannot send null */
- if (attr == AvrcpConstants.ATTRID_TITLE) {
+ if (attr == AvrcpConstants_ext.ATTRID_TITLE) {
attrValue = "<Unknown Title>";
} else {
return null;
@@ -526,7 +533,7 @@
return attrValue;
}
- private void getItemAttrFilterAttr(byte[] bdaddr, AvrcpCmd.ItemAttrCmd mItemAttrReqObj,
+ private void getItemAttrFilterAttr(byte[] bdaddr, AvrcpCmd_ext.ItemAttrCmd mItemAttrReqObj,
MediaSession.QueueItem mediaItem, @Nullable MediaController mediaController) {
/* Response parameters */
int[] attrIds = null; /* array of attr ids */
@@ -538,9 +545,9 @@
ArrayList<Integer> attrTempId = new ArrayList<Integer>();
/* check if remote device has requested for attributes */
- if (mItemAttrReqObj.mNumAttr != AvrcpConstants.NUM_ATTR_NONE) {
- if (mItemAttrReqObj.mNumAttr == AvrcpConstants.NUM_ATTR_ALL) {
- for (int idx = 1; idx < AvrcpConstants.MAX_NUM_ATTR; idx++) {
+ if (mItemAttrReqObj.mNumAttr != AvrcpConstants_ext.NUM_ATTR_NONE) {
+ if (mItemAttrReqObj.mNumAttr == AvrcpConstants_ext.NUM_ATTR_ALL) {
+ for (int idx = 1; idx < AvrcpConstants_ext.MAX_NUM_ATTR; idx++) {
attrTempId.add(idx); /* attr id 0x00 is unused */
}
} else {
@@ -561,7 +568,7 @@
/* lookup and copy values of attributes for ids requested above */
for (int idx = 0; idx < attrTempId.size(); idx++) {
/* check if media player provided requested attributes */
- String value = getAttrValue(attrTempId.get(idx), mediaItem, mediaController);
+ String value = getAttrValue(bdaddr, attrTempId.get(idx), mediaItem, mediaController);
if (value != null) {
attrArray.add(value);
attrId.add(attrTempId.get(idx));
@@ -569,7 +576,7 @@
}
/* copy filtered attr ids and attr values to response parameters */
- if (mItemAttrReqObj.mNumAttr != AvrcpConstants.NUM_ATTR_NONE) {
+ if (mItemAttrReqObj.mNumAttr != AvrcpConstants_ext.NUM_ATTR_NONE) {
attrIds = new int[attrId.size()];
for (int attrIndex = 0; attrIndex < attrId.size(); attrIndex++) {
@@ -579,8 +586,8 @@
attrValues = attrArray.toArray(new String[attrId.size()]);
/* create rsp object and send response */
- ItemAttrRsp rspObj = new ItemAttrRsp(AvrcpConstants.RSP_NO_ERROR, attrIds, attrValues);
- mMediaInterface.getItemAttrRsp(bdaddr, AvrcpConstants.RSP_NO_ERROR, rspObj);
+ ItemAttrRsp_ext rspObj = new ItemAttrRsp_ext(AvrcpConstants_ext.RSP_NO_ERROR, attrIds, attrValues);
+ mMediaInterface.getItemAttrRsp(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR, rspObj);
return;
}
}
@@ -609,19 +616,19 @@
sb.append("#");
sb.append(item.getQueueId());
sb.append(": ");
- sb.append(Utils.ellipsize(getAttrValue(AvrcpConstants.ATTRID_TITLE, item, null)));
+ sb.append(Utils.ellipsize(getAttrValue(null, AvrcpConstants_ext.ATTRID_TITLE, item, null)));
sb.append(" - ");
- sb.append(Utils.ellipsize(getAttrValue(AvrcpConstants.ATTRID_ALBUM, item, null)));
+ sb.append(Utils.ellipsize(getAttrValue(null, AvrcpConstants_ext.ATTRID_ALBUM, item, null)));
sb.append(" by ");
- sb.append(Utils.ellipsize(getAttrValue(AvrcpConstants.ATTRID_ARTIST, item, null)));
+ sb.append(Utils.ellipsize(getAttrValue(null, AvrcpConstants_ext.ATTRID_ARTIST, item, null)));
sb.append(" (");
- sb.append(getAttrValue(AvrcpConstants.ATTRID_PLAY_TIME, item, null));
+ sb.append(getAttrValue(null, AvrcpConstants_ext.ATTRID_PLAY_TIME, item, null));
sb.append(" ");
- sb.append(getAttrValue(AvrcpConstants.ATTRID_TRACK_NUM, item, null));
+ sb.append(getAttrValue(null, AvrcpConstants_ext.ATTRID_TRACK_NUM, item, null));
sb.append("/");
- sb.append(getAttrValue(AvrcpConstants.ATTRID_NUM_TRACKS, item, null));
+ sb.append(getAttrValue(null, AvrcpConstants_ext.ATTRID_NUM_TRACKS, item, null));
sb.append(") ");
- sb.append(getAttrValue(AvrcpConstants.ATTRID_GENRE, item, null));
+ sb.append(getAttrValue(null, AvrcpConstants_ext.ATTRID_GENRE, item, null));
return sb.toString();
}
diff --git a/packages_apps_bluetooth_ext/AvrcpConstants_ext.java b/packages_apps_bluetooth_ext/src/avrcp/AvrcpConstants_ext.java
similarity index 100%
rename from packages_apps_bluetooth_ext/AvrcpConstants_ext.java
rename to packages_apps_bluetooth_ext/src/avrcp/AvrcpConstants_ext.java
diff --git a/packages_apps_bluetooth_ext/AvrcpHelperClasses_ext.java b/packages_apps_bluetooth_ext/src/avrcp/AvrcpHelperClasses_ext.java
similarity index 89%
rename from packages_apps_bluetooth_ext/AvrcpHelperClasses_ext.java
rename to packages_apps_bluetooth_ext/src/avrcp/AvrcpHelperClasses_ext.java
index ea6d7b8..8aca354 100644
--- a/packages_apps_bluetooth_ext/AvrcpHelperClasses_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/AvrcpHelperClasses_ext.java
@@ -31,9 +31,9 @@
* 2) Stores information of Addressed and Browsed Media Players.
************************************************************************************************/
-class AvrcpCmd {
+class AvrcpCmd_ext {
- AvrcpCmd() {}
+ AvrcpCmd_ext() {}
/* Helper classes to pass parameters from callbacks to Avrcp handler */
class FolderItemsCmd {
@@ -115,7 +115,7 @@
}
/* Helper classes to pass parameters to native response */
-class MediaPlayerListRsp {
+class MediaPlayerListRsp_ext {
byte mStatus;
short mUIDCounter;
byte mItemType;
@@ -127,7 +127,7 @@
String[] mPlayerNameList;
int mNumItems;
- MediaPlayerListRsp(byte status, short uidCounter, int numItems, byte itemType, int[] playerIds,
+ MediaPlayerListRsp_ext(byte status, short uidCounter, int numItems, byte itemType, int[] playerIds,
byte[] playerTypes, int[] playerSubTypes, byte[] playStatusValues,
short[] featureBitMaskValues, String[] playerNameList) {
this.mStatus = status;
@@ -140,7 +140,7 @@
this.mPlayerSubTypes = playerSubTypes;
this.mPlayStatusValues = new byte[numItems];
this.mPlayStatusValues = playStatusValues;
- int bitMaskSize = AvrcpConstants.AVRC_FEATURE_MASK_SIZE;
+ int bitMaskSize = AvrcpConstants_ext.AVRC_FEATURE_MASK_SIZE;
this.mFeatureBitMaskValues = new short[numItems * bitMaskSize];
for (int bitMaskIndex = 0; bitMaskIndex < (numItems * bitMaskSize); bitMaskIndex++) {
this.mFeatureBitMaskValues[bitMaskIndex] = featureBitMaskValues[bitMaskIndex];
@@ -149,7 +149,7 @@
}
}
-class FolderItemsRsp {
+class FolderItemsRsp_ext {
byte mStatus;
short mUIDCounter;
byte mScope;
@@ -163,7 +163,7 @@
int[] mAttrIds;
String[] mAttrValues;
- FolderItemsRsp(byte status, short uidCounter, byte scope, int numItems, byte[] folderTypes,
+ FolderItemsRsp_ext(byte status, short uidCounter, byte scope, int numItems, byte[] folderTypes,
byte[] playable, byte[] itemTypes, byte[] itemsUid, String[] displayNameArray,
int[] attributesNum, int[] attrIds, String[] attrValues) {
this.mStatus = status;
@@ -181,13 +181,13 @@
}
}
-class ItemAttrRsp {
+class ItemAttrRsp_ext {
byte mStatus;
byte mNumAttr;
int[] mAttributesIds;
String[] mAttributesArray;
- ItemAttrRsp(byte status, int[] attributesIds, String[] attributesArray) {
+ ItemAttrRsp_ext(byte status, int[] attributesIds, String[] attributesArray) {
mStatus = status;
mNumAttr = (byte) attributesIds.length;
mAttributesIds = attributesIds;
@@ -196,7 +196,7 @@
}
/* stores information of Media Players in the system */
-class MediaPlayerInfo {
+class MediaPlayerInfo_ext {
private byte mMajorType;
private int mSubType;
@@ -206,7 +206,7 @@
@NonNull private String mDisplayableName;
@Nullable private MediaController mMediaController;
- MediaPlayerInfo(@Nullable MediaController controller, byte majorType, int subType,
+ MediaPlayerInfo_ext(@Nullable MediaController controller, byte majorType, int subType,
byte playStatus, short[] featureBitMask, @NonNull String packageName,
@Nullable String displayableName) {
this.setMajorType(majorType);
@@ -301,7 +301,7 @@
return false;
}
for (short bit : this.mFeatureBitMask) {
- if (bit == AvrcpConstants.AVRC_PF_BROWSE_BIT_NO) {
+ if (bit == AvrcpConstants_ext.AVRC_PF_BROWSE_BIT_NO) {
return true;
}
}
@@ -311,7 +311,7 @@
/** Tests if the view of this player presented to the controller is different enough to
* justify sending an Available Players Changed update */
- public boolean equalView(MediaPlayerInfo other) {
+ public boolean equalView(MediaPlayerInfo_ext other) {
return (this.mMajorType == other.getMajorType()) && (this.mSubType == other.getSubType())
&& Arrays.equals(this.mFeatureBitMask, other.getFeatureBitMask())
&& this.mDisplayableName.equals(other.getDisplayableName());
@@ -341,12 +341,12 @@
}
/* stores information for browsable Media Players available in the system */
-class BrowsePlayerInfo {
+class BrowsePlayerInfo_ext {
public String packageName;
public String displayableName;
public String serviceClass;
- BrowsePlayerInfo(String packageName, String displayableName, String serviceClass) {
+ BrowsePlayerInfo_ext(String packageName, String displayableName, String serviceClass) {
this.packageName = packageName;
this.displayableName = displayableName;
this.serviceClass = serviceClass;
@@ -355,7 +355,7 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("BrowsePlayerInfo ");
+ sb.append("BrowsePlayerInfo_ext ");
sb.append(packageName);
sb.append(" ( as '" + displayableName + "')");
sb.append(" service " + serviceClass);
@@ -363,7 +363,7 @@
}
}
-class FolderItemsData {
+class FolderItemsData_ext {
/* initialize sizes for rsp parameters */ int mNumItems;
int[] mAttributesNum;
byte[] mFolderTypes;
@@ -375,18 +375,18 @@
String[] mAttrValues;
int mAttrCounter;
- FolderItemsData(int size) {
+ FolderItemsData_ext(int size) {
mNumItems = size;
mAttributesNum = new int[size];
mFolderTypes = new byte[size]; /* folderTypes */
mItemTypes = new byte[size]; /* folder or media item */
mPlayable = new byte[size];
- Arrays.fill(mFolderTypes, AvrcpConstants.FOLDER_TYPE_MIXED);
- Arrays.fill(mItemTypes, AvrcpConstants.BTRC_ITEM_MEDIA);
- Arrays.fill(mPlayable, AvrcpConstants.ITEM_PLAYABLE);
+ Arrays.fill(mFolderTypes, AvrcpConstants_ext.FOLDER_TYPE_MIXED);
+ Arrays.fill(mItemTypes, AvrcpConstants_ext.BTRC_ITEM_MEDIA);
+ Arrays.fill(mPlayable, AvrcpConstants_ext.ITEM_PLAYABLE);
- mItemUid = new byte[size * AvrcpConstants.UID_SIZE];
+ mItemUid = new byte[size * AvrcpConstants_ext.UID_SIZE];
mDisplayNames = new String[size];
mAttrIds = null; /* array of attr ids */
@@ -399,20 +399,20 @@
* This is useful for keeping a FIFO queue of items where the items drop off the front, i.e. a log
* with a maximum size.
*/
-class EvictingQueue<E> extends ArrayDeque<E> {
+class EvictingQueue_ext<E> extends ArrayDeque<E> {
private int mMaxSize;
- EvictingQueue(int maxSize) {
+ EvictingQueue_ext(int maxSize) {
super();
mMaxSize = maxSize;
}
- EvictingQueue(int maxSize, int initialElements) {
+ EvictingQueue_ext(int maxSize, int initialElements) {
super(initialElements);
mMaxSize = maxSize;
}
- EvictingQueue(int maxSize, Collection<? extends E> c) {
+ EvictingQueue_ext(int maxSize, Collection<? extends E> c) {
super(c);
mMaxSize = maxSize;
}
diff --git a/packages_apps_bluetooth_ext/AvrcpMediaRspInterface_ext.java b/packages_apps_bluetooth_ext/src/avrcp/AvrcpMediaRspInterface_ext.java
similarity index 96%
rename from packages_apps_bluetooth_ext/AvrcpMediaRspInterface_ext.java
rename to packages_apps_bluetooth_ext/src/avrcp/AvrcpMediaRspInterface_ext.java
index 4be98d3..0eaa2fa 100644
--- a/packages_apps_bluetooth_ext/AvrcpMediaRspInterface_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/AvrcpMediaRspInterface_ext.java
@@ -28,13 +28,13 @@
void setBrowsedPlayerRsp(byte[] address, int rspStatus, byte depth, int numItems,
String[] textArray);
- void mediaPlayerListRsp(byte[] address, int rspStatus, MediaPlayerListRsp rspObj);
+ void mediaPlayerListRsp(byte[] address, int rspStatus, MediaPlayerListRsp_ext rspObj);
- void folderItemsRsp(byte[] address, int rspStatus, FolderItemsRsp rspObj);
+ void folderItemsRsp(byte[] address, int rspStatus, FolderItemsRsp_ext rspObj);
void changePathRsp(byte[] address, int rspStatus, int numItems);
- void getItemAttrRsp(byte[] address, int rspStatus, ItemAttrRsp rspObj);
+ void getItemAttrRsp(byte[] address, int rspStatus, ItemAttrRsp_ext rspObj);
void playItemRsp(byte[] address, int rspStatus);
diff --git a/packages_apps_bluetooth_ext/src/avrcp/AvrcpPlayerAppSettings.java b/packages_apps_bluetooth_ext/src/avrcp/AvrcpPlayerAppSettings.java
index 18fcd7e..0ca60a0 100644
--- a/packages_apps_bluetooth_ext/src/avrcp/AvrcpPlayerAppSettings.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/AvrcpPlayerAppSettings.java
@@ -31,7 +31,7 @@
import android.content.Context;
import android.bluetooth.BluetoothDevice;
import com.android.bluetooth.avrcp.AvrcpPlayerAppSettingsRspInterface;
-import com.android.bluetooth.avrcp.AvrcpConstants;
+import com.android.bluetooth.avrcp.AvrcpConstants_ext;
import android.content.BroadcastReceiver;
import com.android.bluetooth.Utils;
import java.util.ArrayList;
@@ -164,7 +164,7 @@
String action = intent.getAction();
if (action.equals(PLAYERSETTINGS_RESPONSE)) {
int getResponse = intent.getIntExtra(EXTRA_GET_RESPONSE,
- AvrcpConstants.GET_INVALID);
+ AvrcpConstants_ext.GET_INVALID);
byte [] data;
String [] text;
boolean isSetAttrValRsp = false;
@@ -173,7 +173,7 @@
synchronized (mPendingCmds) {
Integer val = new Integer(getResponse);
if (mPendingCmds.contains(val)) {
- if (getResponse == AvrcpConstants.SET_ATTRIBUTE_VALUES) {
+ if (getResponse == AvrcpConstants_ext.SET_ATTRIBUTE_VALUES) {
isSetAttrValRsp = true;
if (DEBUG) Log.v(TAG,"Response received for SET_ATTRIBUTE_VALUES");
}
@@ -187,7 +187,7 @@
if (DEBUG)
Log.v(TAG,"getResponse" + getResponse);
switch (getResponse) {
- case AvrcpConstants.GET_ATTRIBUTE_IDS:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_IDS:
if (device == null) {
Log.e(TAG,"ERROR!!! device is null");
return;
@@ -200,7 +200,7 @@
data ,getByteAddress(device));
break;
- case AvrcpConstants.GET_VALUE_IDS:
+ case AvrcpConstants_ext.GET_VALUE_IDS:
if (device == null) {
Log.e(TAG,"ERROR!!! device is null");
return;
@@ -220,7 +220,7 @@
mAvrcpPlayerAppSettingsRspInterface.getPlayerAppValueRsp(numAttr, data,
getByteAddress(device));
break;
- case AvrcpConstants.GET_ATTRIBUTE_VALUES:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_VALUES:
if (device == null) {
Log.e(TAG,"ERROR!!! device is null");
return;
@@ -233,7 +233,7 @@
mAvrcpPlayerAppSettingsRspInterface.SendCurrentPlayerValueRsp(numAttr ,
data, getByteAddress(device));
break;
- case AvrcpConstants.SET_ATTRIBUTE_VALUES:
+ case AvrcpConstants_ext.SET_ATTRIBUTE_VALUES:
boolean send_change_rsp_only = true;
data = intent.getByteArrayExtra(EXTRA_ATTRIB_VALUE_PAIRS);
updateLocalPlayerSettings(data);
@@ -243,19 +243,19 @@
Log.v(TAG,"Respond to SET_ATTRIBUTE_VALUES request");
if (checkPlayerAttributeResponse(data)) {
mAvrcpPlayerAppSettingsRspInterface.SendSetPlayerAppRsp(
- AvrcpConstants.RSP_NO_ERROR, getByteAddress(device));
+ AvrcpConstants_ext.RSP_NO_ERROR, getByteAddress(device));
} else {
mAvrcpPlayerAppSettingsRspInterface.SendSetPlayerAppRsp(
- AvrcpConstants.RSP_INTERNAL_ERR, getByteAddress(device));
+ AvrcpConstants_ext.RSP_INTERNAL_ERR, getByteAddress(device));
}
mPendingSetAttributes.clear();
}
if (send_change_rsp_only) {
mAvrcpPlayerAppSettingsRspInterface.SendSetPlayerAppRsp(
- AvrcpConstants.RSP_NO_ERROR, null);
+ AvrcpConstants_ext.RSP_NO_ERROR, null);
}
break;
- case AvrcpConstants.GET_ATTRIBUTE_TEXT:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_TEXT:
text = intent.getStringArrayExtra(EXTRA_ATTRIBUTE_STRING_ARRAY);
if (device == null) {
Log.e(TAG," ERROR!!! device is null");
@@ -268,7 +268,7 @@
Log.v(TAG,"mPlayerSettings.attrIds"
+ mPlayerSettings.attrIds.length);
break;
- case AvrcpConstants.GET_VALUE_TEXT:
+ case AvrcpConstants_ext.GET_VALUE_TEXT:
text = intent.getStringArrayExtra(EXTRA_VALUE_STRING_ARRAY);
if (device == null) {
Log.e(TAG,"ERROR!!! device is null");
@@ -293,12 +293,12 @@
mPendingCmds.remove(val);
}
switch (cmd) {
- case AvrcpConstants.GET_ATTRIBUTE_IDS:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_IDS:
mAvrcpPlayerAppSettingsRspInterface.getListPlayerappAttrRsp(
(byte)def_attrib.length ,
def_attrib, getByteAddress(device));
break;
- case AvrcpConstants.GET_VALUE_IDS:
+ case AvrcpConstants_ext.GET_VALUE_IDS:
byte attrib = 0;
if (!mPlayerSettingCmds.isEmpty()) {
attrib = mPlayerSettingCmds.get(0);
@@ -326,7 +326,7 @@
break;
}
break;
- case AvrcpConstants.GET_ATTRIBUTE_VALUES:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_VALUES:
int j = 0;
byte [] retVal = new byte [mPlayerSettings.attrIds.length*2];
for (int i = 0; i < mPlayerSettings.attrIds.length; i++) {
@@ -342,11 +342,11 @@
mAvrcpPlayerAppSettingsRspInterface.SendCurrentPlayerValueRsp((byte)retVal.length,
retVal, getByteAddress(device));
break;
- case AvrcpConstants.SET_ATTRIBUTE_VALUES :
+ case AvrcpConstants_ext.SET_ATTRIBUTE_VALUES :
mAvrcpPlayerAppSettingsRspInterface.SendSetPlayerAppRsp(
- AvrcpConstants.RSP_INTERNAL_ERR, getByteAddress(device));
+ AvrcpConstants_ext.RSP_INTERNAL_ERR, getByteAddress(device));
break;
- case AvrcpConstants.GET_ATTRIBUTE_TEXT:
+ case AvrcpConstants_ext.GET_ATTRIBUTE_TEXT:
String [] attribText = new String [mPlayerSettings.attrIds.length];
for (int i = 0; i < mPlayerSettings.attrIds.length; i++) {
attribText[i] = "";
@@ -355,7 +355,7 @@
mPlayerSettings.attrIds.length, mPlayerSettings.attrIds,
attribText.length, attribText, getByteAddress(device));
break;
- case AvrcpConstants.GET_VALUE_TEXT:
+ case AvrcpConstants_ext.GET_VALUE_TEXT:
String [] valueText = new String [mPlayerSettings.attrIds.length];
for (int i = 0; i < mPlayerSettings.attrIds.length; i++) {
valueText[i] = "";
@@ -374,19 +374,19 @@
public void onListPlayerAttributeRequest(byte[] address) {
Intent intent = new Intent(PLAYERSETTINGS_REQUEST);
intent.putExtra(COMMAND, CMDGET);
- intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants.GET_ATTRIBUTE_IDS);
+ intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants_ext.GET_ATTRIBUTE_IDS);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- mPendingCmds.add(new Integer(AvrcpConstants.GET_ATTRIBUTE_IDS));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.GET_ATTRIBUTE_IDS));
}
public void onListPlayerAttributeValues (byte attr, byte[] address) {
Intent intent = new Intent(PLAYERSETTINGS_REQUEST);
intent.putExtra(COMMAND, CMDGET);
- intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants.GET_VALUE_IDS);
+ intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants_ext.GET_VALUE_IDS);
intent.putExtra(EXTRA_ATTRIBUTE_ID, attr);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
mPlayerSettingCmds.add(attr);
- mPendingCmds.add(new Integer(AvrcpConstants.GET_VALUE_IDS));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.GET_VALUE_IDS));
}
public void onGetPlayerAttributeValues (byte attr ,int[] arr ,
@@ -400,10 +400,10 @@
mPlayerSettings.attrIds[i] = barray[i];
Intent intent = new Intent(PLAYERSETTINGS_REQUEST);
intent.putExtra(COMMAND, CMDGET);
- intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants.GET_ATTRIBUTE_VALUES);
+ intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants_ext.GET_ATTRIBUTE_VALUES);
intent.putExtra(EXTRA_ATTIBUTE_ID_ARRAY, barray);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- mPendingCmds.add(new Integer(AvrcpConstants.GET_ATTRIBUTE_VALUES));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.GET_ATTRIBUTE_VALUES));
}
public void setPlayerAppSetting( byte num, byte [] attr_id, byte [] attr_val,
@@ -419,34 +419,34 @@
intent.putExtra(COMMAND, CMDSET);
intent.putExtra(EXTRA_ATTRIB_VALUE_PAIRS, array);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- mPendingCmds.add(new Integer(AvrcpConstants.SET_ATTRIBUTE_VALUES));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.SET_ATTRIBUTE_VALUES));
}
public void getplayerattribute_text(byte attr , byte [] attrIds,
byte[] address) {
Intent intent = new Intent(PLAYERSETTINGS_REQUEST);
intent.putExtra(COMMAND, CMDGET);
- intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants.GET_ATTRIBUTE_TEXT);
+ intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants_ext.GET_ATTRIBUTE_TEXT);
intent.putExtra(EXTRA_ATTIBUTE_ID_ARRAY, attrIds);
mPlayerSettings.attrIds = new byte [attr];
for (int i = 0; i < attr; i++)
mPlayerSettings.attrIds[i] = attrIds[i];
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- mPendingCmds.add(new Integer(AvrcpConstants.GET_ATTRIBUTE_TEXT));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.GET_ATTRIBUTE_TEXT));
}
public void getplayervalue_text(byte attr_id , byte num_value , byte [] value,
byte[] address) {
Intent intent = new Intent(PLAYERSETTINGS_REQUEST);
intent.putExtra(COMMAND, CMDGET);
- intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants.GET_VALUE_TEXT);
+ intent.putExtra(EXTRA_GET_COMMAND, AvrcpConstants_ext.GET_VALUE_TEXT);
intent.putExtra(EXTRA_ATTRIBUTE_ID, attr_id);
intent.putExtra(EXTRA_VALUE_ID_ARRAY, value);
mPlayerSettings.attrIds = new byte [num_value];
for (int i = 0; i < num_value; i++)
mPlayerSettings.attrIds[i] = value[i];
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
- mPendingCmds.add(new Integer(AvrcpConstants.GET_VALUE_TEXT));
+ mPendingCmds.add(new Integer(AvrcpConstants_ext.GET_VALUE_TEXT));
}
public void sendPlayerAppChangedRsp(int rsptype, BluetoothDevice device) {
diff --git a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
index 8724986..2c6d9d7 100644
--- a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
@@ -8,7 +8,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -169,7 +169,7 @@
private static final String [] BlacklistDeviceAddrToMediaAttr = {"00:17:53"/*Toyota Etios*/};
private boolean ignore_play;
private byte changePathFolderType;
- private FolderItemsRsp saveRspObj;
+ private FolderItemsRsp_ext saveRspObj;
private int changePathDepth;
private byte changePathDirection;
HashMap<BluetoothDevice, Integer> mVolumeMap = new HashMap();
@@ -191,7 +191,7 @@
};
/* UID counter to be shared across different files. */
- static short sUIDCounter = AvrcpConstants.DEFAULT_UID_COUNTER;
+ static short sUIDCounter = AvrcpConstants_ext.DEFAULT_UID_COUNTER;
/* BTRC features */
public static final int BTRC_FEAT_METADATA = 0x01;
@@ -250,17 +250,17 @@
private static final int SET_MEDIA_SESSION_DELAY = 300;
/* Communicates with MediaPlayer to fetch media content */
- private BrowsedMediaPlayer mBrowsedMediaPlayer;
+ private BrowsedMediaPlayer_ext mBrowsedMediaPlayer;
/* Addressed player handling */
- private AddressedMediaPlayer mAddressedMediaPlayer;
+ private AddressedMediaPlayer_ext mAddressedMediaPlayer;
/* List of Media player instances, useful for retrieving MediaPlayerList or MediaPlayerInfo */
- private SortedMap<Integer, MediaPlayerInfo> mMediaPlayerInfoList;
+ private SortedMap<Integer, MediaPlayerInfo_ext> mMediaPlayerInfoList;
private boolean mAvailablePlayerViewChanged;
/* List of media players which supports browse */
- private List<BrowsePlayerInfo> mBrowsePlayerInfoList;
+ private List<BrowsePlayerInfo_ext> mBrowsePlayerInfoList;
/* Manage browsed players */
private AvrcpBrowseManager mAvrcpBrowseManager;
@@ -277,7 +277,7 @@
/* Recording passthrough key dispatches */
static private final int PASSTHROUGH_LOG_MAX_SIZE = DEBUG ? 50 : 10;
- private EvictingQueue<MediaKeyLog> mPassthroughLogs; // Passthorugh keys dispatched
+ private EvictingQueue_ext<MediaKeyLog> mPassthroughLogs; // Passthorugh keys dispatched
private List<MediaKeyLog> mPassthroughPending; // Passthrough keys sent not dispatched yet
private int mPassthroughDispatched; // Number of keys dispatched
@@ -368,16 +368,16 @@
mContext = context;
mCurrentDevice = null;
mCurrentPlayState = new PlaybackState.Builder().setState(PlaybackState.STATE_NONE, -1L, 0.0f).build();;
- mPlayStatusChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mAddrPlayerChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mTrackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mPlayerStatusChangeNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ mPlayStatusChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mAddrPlayerChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mPlayerStatusChangeNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mNextPosMs = -1;
mPrevPosMs = -1;
mPlaybackIntervalMs = 0L;
mLastReportedPosition = -1;
- mPlayPosChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ mPlayPosChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mFeatures = 0;
mLastDirection = 0;
mAbsoluteVolume = -1;
@@ -387,12 +387,12 @@
mVolCmdSetInProgress = false;
isAbsoluteVolumeSupportingDevice = false;
mAbsVolRetryTimes = 0;
- keyPressState = AvrcpConstants.KEY_STATE_RELEASE; //Key release state
+ keyPressState = AvrcpConstants_ext.KEY_STATE_RELEASE; //Key release state
mRemoteVolume = -1;
mMusicAppCmdResponsePending = new HashMap<Integer, Integer>();
- mAvailablePlayersChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mAddrPlayerChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mUidsChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ mAvailablePlayersChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mAddrPlayerChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mUidsChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mLastStateUpdate = -1;
mInitialRemoteVolume = -1;
mBlackListVolume = -1;
@@ -431,12 +431,12 @@
mReportedPlayStatus = PLAYSTATUS_ERROR;
mA2dpState = BluetoothA2dp.STATE_NOT_PLAYING;
mAudioManagerIsPlaying = false;
- mPlayStatusChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mPlayerStatusChangeNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mTrackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mPlayPosChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mAddrPlayerChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ mPlayStatusChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mPlayerStatusChangeNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mPlayPosChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mAddrPlayerChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mPlaybackIntervalMs = 0L;
mLastReportedPosition = -1;
mNextPosMs = -1;
@@ -537,11 +537,11 @@
mMediaControllerCb = new MediaControllerListener();
mAvrcpMediaRsp = new AvrcpMediaRsp();
mAvrcpPlayerAppSettingsRsp = new AvrcpPlayerAppSettingsRsp();
- mMediaPlayerInfoList = new TreeMap<Integer, MediaPlayerInfo>();
+ mMediaPlayerInfoList = new TreeMap<Integer, MediaPlayerInfo_ext>();
mAvailablePlayerViewChanged = false;
- mBrowsePlayerInfoList = Collections.synchronizedList(new ArrayList<BrowsePlayerInfo>());
+ mBrowsePlayerInfoList = Collections.synchronizedList(new ArrayList<BrowsePlayerInfo_ext>());
mPassthroughDispatched = 0;
- mPassthroughLogs = new EvictingQueue<MediaKeyLog>(PASSTHROUGH_LOG_MAX_SIZE);
+ mPassthroughLogs = new EvictingQueue_ext<MediaKeyLog>(PASSTHROUGH_LOG_MAX_SIZE);
mPassthroughPending = Collections.synchronizedList(new ArrayList<MediaKeyLog>());
if (mMediaSessionManager != null) {
mMediaSessionManager.addOnActiveSessionsChangedListener(mActiveSessionListener, null,
@@ -581,7 +581,7 @@
}
/* create object to communicate with addressed player */
- mAddressedMediaPlayer = new AddressedMediaPlayer(mAvrcpMediaRsp, mAvrcp);
+ mAddressedMediaPlayer = new AddressedMediaPlayer_ext(mAvrcpMediaRsp, mAvrcp);
/* initialize BrowseMananger which manages Browse commands and response */
mAvrcpBrowseManager = new AvrcpBrowseManager(mContext, mAvrcpMediaRsp);
@@ -674,7 +674,7 @@
Log.d(TAG, "Enter clearDeviceDependentFeature()");
for (int i = 0; i < maxAvrcpConnections; i++) {
deviceFeatures[i].keyPressState =
- AvrcpConstants.KEY_STATE_RELEASE; //Key release state
+ AvrcpConstants_ext.KEY_STATE_RELEASE; //Key release state
if (deviceFeatures[i].mMusicAppCmdResponsePending != null)
deviceFeatures[i].mMusicAppCmdResponsePending.clear();
}
@@ -1004,7 +1004,7 @@
case MSG_NATIVE_REQ_GET_ELEM_ATTRS:
{
String[] textArray;
- AvrcpCmd.ElementAttrCmd elem = (AvrcpCmd.ElementAttrCmd) msg.obj;
+ AvrcpCmd_ext.ElementAttrCmd elem = (AvrcpCmd_ext.ElementAttrCmd) msg.obj;
byte numAttr = elem.mNumAttr;
int[] attrIds = elem.mAttrIDs;
byte[] remoteAddr = elem.mAddress;
@@ -1038,9 +1038,9 @@
textArray[i]= new String();
}
responseDebug.append("[" + attrIds[i] + "=");
- if (attrIds[i] == AvrcpConstants.ATTRID_TITLE
- || attrIds[i] == AvrcpConstants.ATTRID_ARTIST
- || attrIds[i] == AvrcpConstants.ATTRID_ALBUM) {
+ if (attrIds[i] == AvrcpConstants_ext.ATTRID_TITLE
+ || attrIds[i] == AvrcpConstants_ext.ATTRID_ARTIST
+ || attrIds[i] == AvrcpConstants_ext.ATTRID_ALBUM) {
responseDebug.append(Utils.ellipsize(textArray[i]) + "] ");
} else {
responseDebug.append(textArray[i] + "] ");
@@ -1410,21 +1410,21 @@
break;
case MSG_NATIVE_REQ_GET_FOLDER_ITEMS: {
- AvrcpCmd.FolderItemsCmd folderObj = (AvrcpCmd.FolderItemsCmd) msg.obj;
+ AvrcpCmd_ext.FolderItemsCmd folderObj = (AvrcpCmd_ext.FolderItemsCmd) msg.obj;
if (DEBUG) Log.v(TAG, "MSG_NATIVE_REQ_GET_FOLDER_ITEMS " + folderObj);
switch (folderObj.mScope) {
- case AvrcpConstants.BTRC_SCOPE_PLAYER_LIST:
+ case AvrcpConstants_ext.BTRC_SCOPE_PLAYER_LIST:
handleMediaPlayerListRsp(folderObj);
break;
- case AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM:
- case AvrcpConstants.BTRC_SCOPE_NOW_PLAYING:
+ case AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM:
+ case AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING:
handleGetFolderItemBrowseResponse(folderObj, folderObj.mAddress);
break;
default:
Log.e(TAG, "unknown scope for getfolderitems. scope = "
+ folderObj.mScope);
getFolderItemsRspNative(folderObj.mAddress,
- AvrcpConstants.RSP_INV_SCOPE, (short) 0, (byte) 0, 0,
+ AvrcpConstants_ext.RSP_INV_SCOPE, (short) 0, (byte) 0, 0,
null, null, null, null, null, null, null, null);
}
break;
@@ -1438,7 +1438,7 @@
case MSG_NATIVE_REQ_GET_ITEM_ATTR:
// msg object contains the item attribute object
- AvrcpCmd.ItemAttrCmd cmd = (AvrcpCmd.ItemAttrCmd) msg.obj;
+ AvrcpCmd_ext.ItemAttrCmd cmd = (AvrcpCmd_ext.ItemAttrCmd) msg.obj;
if (DEBUG) Log.v(TAG, "MSG_NATIVE_REQ_GET_ITEM_ATTR " + cmd);
handleGetItemAttr(cmd);
break;
@@ -1457,7 +1457,7 @@
byte[] bdaddr = data.getByteArray("BdAddress");
byte[] folderUid = data.getByteArray("folderUid");
byte direction = data.getByte("direction");
- byte[] tempUid = new byte[AvrcpConstants.UID_SIZE];
+ byte[] tempUid = new byte[AvrcpConstants_ext.UID_SIZE];
if (mAvrcpBrowseManager.getBrowsedMediaPlayer(bdaddr) != null) {
changePathDirection = direction;
if(direction == 1)
@@ -1466,8 +1466,8 @@
direction);
if ((direction == 1) && (changePathDepth > 0)) {
for (int index=0; index<saveRspObj.mDisplayNames.length; index++) {
- for (int size=0; size < AvrcpConstants.UID_SIZE; size++)
- tempUid[size] = saveRspObj.mItemUid[index* AvrcpConstants.UID_SIZE + size];
+ for (int size=0; size < AvrcpConstants_ext.UID_SIZE; size++)
+ tempUid[size] = saveRspObj.mItemUid[index* AvrcpConstants_ext.UID_SIZE + size];
if (Arrays.equals(folderUid, tempUid)) {
changePathFolderType = saveRspObj.mFolderTypes[index];
break;
@@ -1482,7 +1482,7 @@
} else {
Log.e(TAG, "Remote requesting change path before setbrowsedplayer");
- changePathRspNative(bdaddr, AvrcpConstants.RSP_BAD_CMD, 0);
+ changePathRspNative(bdaddr, AvrcpConstants_ext.RSP_BAD_CMD, 0);
}
break;
}
@@ -1594,7 +1594,7 @@
byte newStatus = getBluetoothPlayState(state);
/* update play status in global media player list */
- MediaPlayerInfo player = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext player = getAddressedPlayerInfo();
if (player != null) {
player.setPlayStatus(newStatus);
}
@@ -1641,11 +1641,11 @@
deviceFeatures[deviceIndex].mLastPassthroughcmd = KeyEvent.KEYCODE_UNKNOWN;
if ((deviceFeatures[deviceIndex].mPlayStatusChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) &&
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) &&
(oldPlayStatus != newPlayStatus) && deviceFeatures[deviceIndex].mCurrentDevice != null) {
Log.w(TAG, "Sending PlayStatus CHANGED Rsp !!!");
deviceFeatures[deviceIndex].mPlayStatusChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
registerNotificationRspPlayStatusNative(
deviceFeatures[deviceIndex].mPlayStatusChangedNT,
newPlayStatus,
@@ -2091,31 +2091,31 @@
Log.v(TAG, "Update player id: " + deviceFeatures[index].mReportedPlayerID +
"-> " + mCurrAddrPlayerID);
if (deviceFeatures[index].mAvailablePlayersChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
registerNotificationRspAvalPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED, addr);
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, addr);
mAvailablePlayerViewChanged = false;
deviceFeatures[index].mAvailablePlayersChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
if (deviceFeatures[index].mAddrPlayerChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
registerNotificationRspAddrPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
sUIDCounter, addr);
deviceFeatures[index].mAddrPlayerChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
deviceFeatures[index].mReportedPlayerID = mCurrAddrPlayerID;
// Update the now playing list without sending the notification
- deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mAddressedMediaPlayer.updateNowPlayingList(mMediaController);
- deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
}
// Dont send now playing list changed if the player doesn't support browsing
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
if (info != null && info.isBrowseSupported()) {
Log.v(TAG, "Check if NowPlayingList is updated");
mAddressedMediaPlayer.updateNowPlayingList(mMediaController);
@@ -2131,7 +2131,7 @@
mLastQueueId = newQueueId;
for (int i = 0; i < maxAvrcpConnections; i++) {
if ((deviceFeatures[i].mCurrentDevice != null) &&
- (deviceFeatures[i].mTrackChangedNT == AvrcpConstants.NOTIFICATION_TYPE_INTERIM)) {
+ (deviceFeatures[i].mTrackChangedNT == AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM)) {
deviceFeatures[i].mTracksPlayed++;
Log.v(TAG,"sending track change for device " + i);
sendTrackChangedRsp(false, deviceFeatures[i].mCurrentDevice);
@@ -2188,8 +2188,8 @@
private void getElementAttrRequestFromNative(byte[] address, byte numAttr, int[] attrs) {
if (DEBUG) Log.v(TAG, "getElementAttrRequestFromNative: numAttr=" + numAttr);
- AvrcpCmd avrcpCmdobj = new AvrcpCmd();
- AvrcpCmd.ElementAttrCmd elemAttr = avrcpCmdobj.new ElementAttrCmd(address, numAttr, attrs);
+ AvrcpCmd_ext avrcpCmdobj = new AvrcpCmd_ext();
+ AvrcpCmd_ext.ElementAttrCmd elemAttr = avrcpCmdobj.new ElementAttrCmd(address, numAttr, attrs);
Message msg = mHandler.obtainMessage(MSG_NATIVE_REQ_GET_ELEM_ATTRS);
msg.obj = elemAttr;
mHandler.sendMessage(msg);
@@ -2232,7 +2232,7 @@
return;
}
deviceFeatures[deviceIndex].mPlayStatusChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
mHandler.removeMessages(MSG_PLAY_STATUS_CMD_TIMEOUT);
deviceFeatures[deviceIndex].isPlayStatusTimeOut = false;
if(avrcp_playstatus_blacklist && isPlayerStateUpdateBlackListed(
@@ -2268,7 +2268,7 @@
Log.d(TAG, "playback Status has changed from last playstatus response " +
"send CHANGED event with current playback status");
deviceFeatures[deviceIndex].mPlayStatusChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
if (!deviceFeatures[deviceIndex].isPlayStatusTimeOut) {
Message msg = mHandler.obtainMessage(MSG_PLAY_STATUS_CMD_TIMEOUT,
0, 0, deviceFeatures[deviceIndex].mCurrentDevice);
@@ -2283,7 +2283,7 @@
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
Log.v(TAG, "Sending Stopped in INTERIM response when current_play_status is playing and device just got connected");
deviceFeatures[deviceIndex].mPlayStatusChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
if (!deviceFeatures[deviceIndex].isPlayStatusTimeOut) {
Message msg = mHandler.obtainMessage(MSG_PLAY_STATUS_CMD_TIMEOUT,
0, 0, deviceFeatures[deviceIndex].mCurrentDevice);
@@ -2304,7 +2304,7 @@
return;
}
deviceFeatures[deviceIndex].mTrackChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
sendTrackChangedRsp(true, deviceFeatures[deviceIndex].mCurrentDevice);
break;
@@ -2339,7 +2339,7 @@
update_interval = SystemProperties.getLong("persist.vendor.btstack.avrcp.pos_time", 1000L);
}
deviceFeatures[deviceIndex].mPlayPosChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
update_interval = Math.max((long)param * 1000L, update_interval);
deviceFeatures[deviceIndex].mPlaybackIntervalMs = update_interval;
sendPlayPosNotificationRsp(true, deviceIndex);
@@ -2350,7 +2350,7 @@
case EVT_APP_SETTINGS_CHANGED:
deviceFeatures[deviceIndex].mPlayerStatusChangeNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
mAvrcpPlayerAppSettings.sendPlayerAppChangedRsp(
deviceFeatures[deviceIndex].mPlayerStatusChangeNT, device);
break;
@@ -2363,9 +2363,9 @@
return;
}
deviceFeatures[deviceIndex].mAvailablePlayersChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
registerNotificationRspAvalPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
break;
@@ -2377,9 +2377,9 @@
return;
}
deviceFeatures[deviceIndex].mAddrPlayerChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
registerNotificationRspAddrPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM,
mCurrAddrPlayerID, sUIDCounter,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
deviceFeatures[deviceIndex].mReportedPlayerID = mCurrAddrPlayerID;
@@ -2392,9 +2392,9 @@
return;
}
deviceFeatures[deviceIndex].mUidsChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
registerNotificationRspUIDsChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM, sUIDCounter,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM, sUIDCounter,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
break;
@@ -2405,9 +2405,9 @@
return;
}
/* send interim response to remote device */
- mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
if (!registerNotificationRspNowPlayingChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice))) {
Log.e(TAG, "EVENT_NOW_PLAYING_CONTENT_CHANGED: " +
"registerNotificationRspNowPlayingChangedNative for Interim rsp failed!");
@@ -2430,23 +2430,23 @@
private void sendTrackChangedRsp(boolean registering, BluetoothDevice device) {
int deviceIndex = getIndexForDevice(device);
Log.d(TAG, "Enter sendTrackChangedRsp");
- if (deviceFeatures[deviceIndex].mTrackChangedNT != AvrcpConstants.NOTIFICATION_TYPE_INTERIM
+ if (deviceFeatures[deviceIndex].mTrackChangedNT != AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM
&& !registering) {
if (DEBUG) Log.d(TAG, "sendTrackChangedRsp: Not registered or registering.");
return;
}
- deviceFeatures[deviceIndex].mTrackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[deviceIndex].mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
if (registering)
- deviceFeatures[deviceIndex].mTrackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_INTERIM;
+ deviceFeatures[deviceIndex].mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
byte[] byteAddr = getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice);
// for non-browsable players or no player
if ((info != null && !info.isBrowseSupported()) ||
(deviceFeatures[deviceIndex].mFeatures & BTRC_FEAT_BROWSE) == 0) {
- byte[] track = AvrcpConstants.TRACK_IS_SELECTED;
- if (!mMediaAttributes.exists) track = AvrcpConstants.NO_TRACK_SELECTED;
+ byte[] track = AvrcpConstants_ext.TRACK_IS_SELECTED;
+ if (!mMediaAttributes.exists) track = AvrcpConstants_ext.NO_TRACK_SELECTED;
registerNotificationRspTrackChangeNative(
deviceFeatures[deviceIndex].mTrackChangedNT,
track,
@@ -2583,7 +2583,7 @@
*/
private void sendPlayPosNotificationRsp(boolean requested, int i) {
Log.d(TAG, "Enter sendPlayPosNotificationRsp");
- if (!requested && deviceFeatures[i].mPlayPosChangedNT != AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ if (!requested && deviceFeatures[i].mPlayPosChangedNT != AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
if (DEBUG) Log.d(TAG, "sendPlayPosNotificationRsp: Not registered or requesting.");
return;
}
@@ -2629,7 +2629,7 @@
mHandler.removeMessages(currMsgPlayIntervalTimeout);
if ((deviceFeatures[i].mCurrentDevice != null) &&
- (deviceFeatures[i].mPlayPosChangedNT == AvrcpConstants.NOTIFICATION_TYPE_INTERIM) &&
+ (deviceFeatures[i].mPlayPosChangedNT == AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) &&
(isPlayingState(deviceFeatures[i].mCurrentPlayState)) && !isPlayerPaused()) {
Message msg = mHandler.obtainMessage(currMsgPlayIntervalTimeout, 0, 0,
deviceFeatures[i].mCurrentDevice);
@@ -2724,18 +2724,18 @@
Log.d(TAG, "Vol Passthrough Up");
avrcpCtrlService.sendPassThroughCmd(
deviceFeatures[i].mCurrentDevice, AVRC_ID_VOL_UP,
- AvrcpConstants.KEY_STATE_PRESS);
+ AvrcpConstants_ext.KEY_STATE_PRESS);
avrcpCtrlService.sendPassThroughCmd(
deviceFeatures[i].mCurrentDevice, AVRC_ID_VOL_UP,
- AvrcpConstants.KEY_STATE_RELEASE);
+ AvrcpConstants_ext.KEY_STATE_RELEASE);
} else if (volume < mLocalVolume) {
Log.d(TAG, "Vol Passthrough Down");
avrcpCtrlService.sendPassThroughCmd(
deviceFeatures[i].mCurrentDevice, AVRC_ID_VOL_DOWN,
- AvrcpConstants.KEY_STATE_PRESS);
+ AvrcpConstants_ext.KEY_STATE_PRESS);
avrcpCtrlService.sendPassThroughCmd(
deviceFeatures[i].mCurrentDevice, AVRC_ID_VOL_DOWN,
- AvrcpConstants.KEY_STATE_RELEASE);
+ AvrcpConstants_ext.KEY_STATE_RELEASE);
}
mLocalVolume = volume;
}
@@ -2771,9 +2771,9 @@
private void getFolderItemsRequestFromNative(
byte[] address, byte scope, long startItem, long endItem, byte numAttr, int[] attrIds) {
if (DEBUG) Log.v(TAG, "getFolderItemsRequestFromNative: scope=" + scope + ", numAttr=" + numAttr);
- AvrcpCmd avrcpCmdobj = new AvrcpCmd();
+ AvrcpCmd_ext avrcpCmdobj = new AvrcpCmd_ext();
Log.v(TAG, "Enter getFolderItemsRequestFromNative");
- AvrcpCmd.FolderItemsCmd folderObj = avrcpCmdobj.new FolderItemsCmd(address, scope,
+ AvrcpCmd_ext.FolderItemsCmd folderObj = avrcpCmdobj.new FolderItemsCmd(address, scope,
startItem, endItem, numAttr, attrIds);
Message msg = mHandler.obtainMessage(MSG_NATIVE_REQ_GET_FOLDER_ITEMS, 0, 0);
msg.obj = folderObj;
@@ -2811,9 +2811,9 @@
private void getItemAttrRequestFromNative(byte[] address, byte scope, byte[] itemUid, int uidCounter,
byte numAttr, int[] attrs) {
- AvrcpCmd avrcpCmdobj = new AvrcpCmd();
+ AvrcpCmd_ext avrcpCmdobj = new AvrcpCmd_ext();
Log.v(TAG, "Enter getItemAttrRequestFromNative");
- AvrcpCmd.ItemAttrCmd itemAttr = avrcpCmdobj.new ItemAttrCmd(address, scope,
+ AvrcpCmd_ext.ItemAttrCmd itemAttr = avrcpCmdobj.new ItemAttrCmd(address, scope,
itemUid, uidCounter, numAttr, attrs);
Message msg = mHandler.obtainMessage(MSG_NATIVE_REQ_GET_ITEM_ATTR);
msg.obj = itemAttr;
@@ -2824,7 +2824,7 @@
private void searchRequestFromNative(byte[] address, int charsetId, byte[] searchStr) {
/* Search is not supported */
Log.w(TAG, "searchRequestFromNative: search is not supported");
- searchRspNative(address, AvrcpConstants.RSP_SRCH_NOT_SPRTD, 0, 0);
+ searchRspNative(address, AvrcpConstants_ext.RSP_SRCH_NOT_SPRTD, 0, 0);
}
private void playItemRequestFromNative(byte[] address, byte scope, int uidCounter, byte[] uid) {
@@ -2843,7 +2843,7 @@
private void addToPlayListRequestFromNative(byte[] address, byte scope, byte[] uid, int uidCounter) {
/* add to NowPlaying not supported */
Log.w(TAG, "addToPlayListRequestFromNative: not supported! scope=" + scope);
- addToNowPlayingRspNative(address, AvrcpConstants.RSP_INTERNAL_ERR);
+ addToNowPlayingRspNative(address, AvrcpConstants_ext.RSP_INTERNAL_ERR);
}
private void getTotalNumOfItemsRequestFromNative(byte[] address, byte scope) {
@@ -2886,10 +2886,10 @@
Log.e(TAG,"invalid index for device");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.GET_ATTRIBUTE_IDS,
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.GET_ATTRIBUTE_IDS,
deviceIndex, true);
mAvrcpPlayerAppSettings.onListPlayerAttributeRequest(address);
- SendPlayerSettingMsg(AvrcpConstants.GET_ATTRIBUTE_IDS, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.GET_ATTRIBUTE_IDS, address);
}
//PDU ID 0x12
@@ -2902,9 +2902,9 @@
Log.e(TAG,"invalid index for device");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.GET_VALUE_IDS, deviceIndex, true);
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.GET_VALUE_IDS, deviceIndex, true);
mAvrcpPlayerAppSettings.onListPlayerAttributeValues(attr, address);
- SendPlayerSettingMsg(AvrcpConstants.GET_VALUE_IDS, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.GET_VALUE_IDS, address);
}
//PDU ID 0x13
@@ -2920,10 +2920,10 @@
Log.e(TAG,"invalid index for device");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.GET_ATTRIBUTE_VALUES,
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.GET_ATTRIBUTE_VALUES,
deviceIndex, true);
mAvrcpPlayerAppSettings.onGetPlayerAttributeValues(attr, arr, address);
- SendPlayerSettingMsg(AvrcpConstants.GET_ATTRIBUTE_VALUES, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.GET_ATTRIBUTE_VALUES, address);
}
//PDU 0x14
@@ -2940,15 +2940,15 @@
return;
}
if (!deviceFeatures[deviceIndex].isActiveDevice) {
- SendSetPlayerAppRspNative(AvrcpConstants.RSP_INTERNAL_ERR, address);
+ SendSetPlayerAppRspNative(AvrcpConstants_ext.RSP_INTERNAL_ERR, address);
Log.e(TAG,"Set Command from inactive device reject it");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.SET_ATTRIBUTE_VALUES,
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.SET_ATTRIBUTE_VALUES,
deviceIndex, true);
mAvrcpPlayerAppSettings.setPlayerAppSetting(num, attr_id, attr_val, address);
- SendPlayerSettingMsg(AvrcpConstants.SET_ATTRIBUTE_VALUES, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.SET_ATTRIBUTE_VALUES, address);
}
//PDU 0x15
@@ -2964,10 +2964,10 @@
Log.e(TAG,"invalid index for device");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.GET_ATTRIBUTE_TEXT,
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.GET_ATTRIBUTE_TEXT,
deviceIndex, true);
mAvrcpPlayerAppSettings.getplayerattribute_text(attr, attrIds, address);
- SendPlayerSettingMsg(AvrcpConstants.GET_ATTRIBUTE_TEXT, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.GET_ATTRIBUTE_TEXT, address);
}
//PDU 0x16
@@ -2981,9 +2981,9 @@
Log.e(TAG,"invalid index for device");
return;
}
- CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants.GET_VALUE_TEXT, deviceIndex, true);
+ CreateMusicSettingsAppCmdLookupOrUpdate(AvrcpConstants_ext.GET_VALUE_TEXT, deviceIndex, true);
mAvrcpPlayerAppSettings.getplayervalue_text(attr_id, num_value, value, address);
- SendPlayerSettingMsg(AvrcpConstants.GET_VALUE_TEXT, address);
+ SendPlayerSettingMsg(AvrcpConstants_ext.GET_VALUE_TEXT, address);
}
private void SendPlayerSettingMsg(Integer cmd, byte[] address) {
@@ -3387,7 +3387,7 @@
int browseInfoID = 0;
synchronized (this) {
synchronized (mBrowsePlayerInfoList) {
- for (BrowsePlayerInfo info : mBrowsePlayerInfoList) {
+ for (BrowsePlayerInfo_ext info : mBrowsePlayerInfoList) {
if (info.packageName.equals(packageName)) {
response = true;
break;
@@ -3414,34 +3414,34 @@
synchronized (mMediaPlayerInfoList) {
if (mMediaPlayerInfoList.isEmpty()) {
Log.w(TAG, functionTag + "no players, send no available players");
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_NO_AVBL_PLAY);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_AVBL_PLAY);
return;
}
if (selectedId == NO_PLAYER_ID) {
Log.w(TAG, functionTag + "Respond dummy pass response ");
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_NO_ERROR);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR);
return;
}
if (!mMediaPlayerInfoList.containsKey(selectedId)) {
Log.w(TAG, functionTag + "invalid id, sending response back ");
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_INV_PLAYER);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_INV_PLAYER);
return;
}
if (isPlayerAlreadyAddressed(selectedId)) {
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
Log.i(TAG, functionTag + "player already addressed: " + info);
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_NO_ERROR);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR);
return;
}
// register new Media Controller Callback and update the current IDs
if (!updateCurrentController(selectedId, mCurrBrowsePlayerID)) {
Log.e(TAG, functionTag + "updateCurrentController failed!");
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
return;
}
// If we don't have a controller, try to launch the player
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
if (info.getMediaController() == null) {
Intent launch = mPackageManager.getLaunchIntentForPackage(info.getPackageName());
Log.i(TAG, functionTag + "launching player " + launch);
@@ -3449,12 +3449,12 @@
}
}
}
- setAddressedPlayerRspNative(bdaddr, AvrcpConstants.RSP_NO_ERROR);
+ setAddressedPlayerRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR);
Log.d(TAG, "Exit setAddressedPlayer");
}
private void setBrowsedPlayer(byte[] bdaddr, int selectedId) {
- int status = AvrcpConstants.RSP_NO_ERROR;
+ int status = AvrcpConstants_ext.RSP_NO_ERROR;
Log.d(TAG, "Enter setBrowsedPlayer");
String address = Utils.getAddressStringFromByte(bdaddr);
@@ -3462,10 +3462,10 @@
// checking for error cases
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bdaddr);
if (mBrowsingActiveDevice != null && !device.equals(mBrowsingActiveDevice)) {
- status = AvrcpConstants.RSP_INTERNAL_ERR;
+ status = AvrcpConstants_ext.RSP_INTERNAL_ERR;
Log.w(TAG, "setBrowsedPlayer: Cmd from browse inactive device reject it");
} else if (mMediaPlayerInfoList.isEmpty()) {
- status = AvrcpConstants.RSP_NO_AVBL_PLAY;
+ status = AvrcpConstants_ext.RSP_NO_AVBL_PLAY;
Log.w(TAG, "setBrowsedPlayer: No available players! ");
} else {
// Workaround for broken controllers selecting ID 0
@@ -3480,19 +3480,19 @@
if (!isPackageNameValid(browsedPackage)) {
Log.w(TAG, " Invalid package for id:" + mCurrBrowsePlayerID);
- status = AvrcpConstants.RSP_INV_PLAYER;
+ status = AvrcpConstants_ext.RSP_INV_PLAYER;
} else if (!isBrowseSupported(browsedPackage)) {
Log.w(TAG, "Browse unsupported for id:" + mCurrBrowsePlayerID
+ ", packagename : " + browsedPackage);
- status = AvrcpConstants.RSP_PLAY_NOT_BROW;
+ status = AvrcpConstants_ext.RSP_PLAY_NOT_BROW;
} else if (!startBrowseService(bdaddr, browsedPackage)) {
Log.e(TAG, "service cannot be started for browse player id:" + mCurrBrowsePlayerID
+ ", packagename : " + browsedPackage);
- status = AvrcpConstants.RSP_INTERNAL_ERR;
+ status = AvrcpConstants_ext.RSP_INTERNAL_ERR;
}
}
- if (status != AvrcpConstants.RSP_NO_ERROR) {
+ if (status != AvrcpConstants_ext.RSP_NO_ERROR) {
setBrowsedPlayerRspNative(bdaddr, status, (byte) 0x00, 0, null);
}
@@ -3557,7 +3557,7 @@
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
if (entry.getValue().getPackageName().equals(packageName)) {
int newAddrID = entry.getKey();
if (DEBUG) Log.v(TAG, "Set addressed #" + newAddrID + " " + entry.getValue());
@@ -3663,10 +3663,10 @@
String packageName = info.serviceInfo.packageName;
if (DEBUG) Log.d(TAG, "Adding " + serviceName + " to list of browsable players");
- BrowsePlayerInfo currentPlayer =
- new BrowsePlayerInfo(packageName, displayableName, serviceName);
+ BrowsePlayerInfo_ext currentPlayer =
+ new BrowsePlayerInfo_ext(packageName, displayableName, serviceName);
mBrowsePlayerInfoList.add(currentPlayer);
- MediaPlayerInfo playerInfo = getMediaPlayerInfo(packageName);
+ MediaPlayerInfo_ext playerInfo = getMediaPlayerInfo(packageName);
MediaController controller =
(playerInfo == null) ? null : playerInfo.getMediaController();
// Refresh the media player entry so it notices we can browse
@@ -3717,7 +3717,7 @@
new ArrayList<android.media.session.MediaController>();
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
- for (MediaPlayerInfo info : mMediaPlayerInfoList.values()) {
+ for (MediaPlayerInfo_ext info : mMediaPlayerInfoList.values()) {
MediaController controller = info.getMediaController();
if (controller != null) {
controllers.add(controller.getWrappedInstance());
@@ -3730,8 +3730,8 @@
/** Add (or update) a player to the media player list without a controller */
private boolean addMediaPlayerPackage(String packageName) {
- MediaPlayerInfo info = new MediaPlayerInfo(null, AvrcpConstants.PLAYER_TYPE_AUDIO,
- AvrcpConstants.PLAYER_SUBTYPE_NONE, PLAYSTATUS_STOPPED,
+ MediaPlayerInfo_ext info = new MediaPlayerInfo_ext(null, AvrcpConstants_ext.PLAYER_TYPE_AUDIO,
+ AvrcpConstants_ext.PLAYER_SUBTYPE_NONE, PLAYSTATUS_STOPPED,
getFeatureBitMask(packageName), packageName, getAppLabel(packageName));
return addMediaPlayerInfo(info);
}
@@ -3739,8 +3739,8 @@
/** Add (or update) a player to the media player list given an active controller */
private boolean addMediaPlayerController(android.media.session.MediaController controller) {
String packageName = controller.getPackageName();
- MediaPlayerInfo info = new MediaPlayerInfo(MediaControllerFactory.wrap(controller), /*MediaController not present*/
- AvrcpConstants.PLAYER_TYPE_AUDIO, AvrcpConstants.PLAYER_SUBTYPE_NONE,
+ MediaPlayerInfo_ext info = new MediaPlayerInfo_ext(MediaControllerFactory.wrap(controller), /*MediaController not present*/
+ AvrcpConstants_ext.PLAYER_TYPE_AUDIO, AvrcpConstants_ext.PLAYER_SUBTYPE_NONE,
getBluetoothPlayState(controller.getPlaybackState()),
getFeatureBitMask(packageName), controller.getPackageName(),
getAppLabel(packageName));
@@ -3750,7 +3750,7 @@
/** Add or update a player to the media player list given the MediaPlayerInfo object.
* @return true if an item was updated, false if it was added instead
*/
- private boolean addMediaPlayerInfo(MediaPlayerInfo info) {
+ private boolean addMediaPlayerInfo(MediaPlayerInfo_ext info) {
int updateId = -1;
boolean updated = false;
boolean currentRemoved = false;
@@ -3760,8 +3760,8 @@
}
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
- MediaPlayerInfo current = entry.getValue();
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
+ MediaPlayerInfo_ext current = entry.getValue();
int id = entry.getKey();
if (info.getPackageName().equals(current.getPackageName())) {
if (!current.equalView(info)) {
@@ -3793,11 +3793,11 @@
}
/** Remove all players related to |packageName| from the media player info list */
- private MediaPlayerInfo removeMediaPlayerInfo(String packageName) {
+ private MediaPlayerInfo_ext removeMediaPlayerInfo(String packageName) {
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
int removeKey = -1;
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
if (entry.getValue().getPackageName().equals(packageName)) {
removeKey = entry.getKey();
break;
@@ -3820,8 +3820,8 @@
if (controller == null) return;
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
- MediaPlayerInfo info = entry.getValue();
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
+ MediaPlayerInfo_ext info = entry.getValue();
MediaController c = info.getMediaController();
if (c != null && c.equals(controller)) {
info.setMediaController(null);
@@ -3881,23 +3881,23 @@
ArrayList<Short> featureBitsList = new ArrayList<Short>();
/* adding default feature bits */
- featureBitsList.add(AvrcpConstants.AVRC_PF_PLAY_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_STOP_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_PAUSE_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_REWIND_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_FAST_FWD_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_FORWARD_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_BACKWARD_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_ADV_CTRL_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_PLAY_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_STOP_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_PAUSE_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_REWIND_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_FAST_FWD_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_FORWARD_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_BACKWARD_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_ADV_CTRL_BIT_NO);
/* Add/Modify browse player supported features. */
if (isBrowseSupported(packageName)) {
- featureBitsList.add(AvrcpConstants.AVRC_PF_BROWSE_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_UID_UNIQUE_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_NOW_PLAY_BIT_NO);
- featureBitsList.add(AvrcpConstants.AVRC_PF_GET_NUM_OF_ITEMS_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_BROWSE_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_UID_UNIQUE_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_NOW_PLAY_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_GET_NUM_OF_ITEMS_BIT_NO);
if (mAvrcpBipRsp != null)
- featureBitsList.add(AvrcpConstants.AVRC_PF_COVER_ART_BIT_NO);
+ featureBitsList.add(AvrcpConstants_ext.AVRC_PF_COVER_ART_BIT_NO);
}
// converting arraylist to array for response
@@ -3920,7 +3920,7 @@
synchronized (this) {
synchronized (mBrowsePlayerInfoList) {
/* check if Browsable Player's list contains this package name */
- for (BrowsePlayerInfo info : mBrowsePlayerInfoList) {
+ for (BrowsePlayerInfo_ext info : mBrowsePlayerInfoList) {
if (info.packageName.equals(packageName)) {
if (DEBUG) Log.v(TAG, "isBrowseSupported for " + packageName + ": true");
return true;
@@ -3934,7 +3934,7 @@
}
private String getPackageName(int id) {
- MediaPlayerInfo player = null;
+ MediaPlayerInfo_ext player = null;
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
player = mMediaPlayerInfoList.getOrDefault(id, null);
@@ -3957,7 +3957,7 @@
private String getCurrentBrowsedPlayer(byte[] bdaddr) {
String browsedPlayerPackage = "";
- Map<String, BrowsedMediaPlayer> connList = mAvrcpBrowseManager.getConnList();
+ Map<String, BrowsedMediaPlayer_ext> connList = mAvrcpBrowseManager.getConnList();
String bdaddrStr = new String(bdaddr);
if(connList.containsKey(bdaddrStr)){
browsedPlayerPackage = connList.get(bdaddrStr).getPackageName();
@@ -3967,7 +3967,7 @@
}
/* Returns the MediaPlayerInfo for the currently addressed media player */
- private MediaPlayerInfo getAddressedPlayerInfo() {
+ private MediaPlayerInfo_ext getAddressedPlayerInfo() {
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
return mMediaPlayerInfoList.getOrDefault(mCurrAddrPlayerID, null);
@@ -3979,7 +3979,7 @@
* Utility function to get the Media player info from package name returns
* null if package name not found in media players list
*/
- private MediaPlayerInfo getMediaPlayerInfo(String packageName) {
+ private MediaPlayerInfo_ext getMediaPlayerInfo(String packageName) {
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
if (mMediaPlayerInfoList.isEmpty()) {
@@ -3987,7 +3987,7 @@
return null;
}
- for (MediaPlayerInfo info : mMediaPlayerInfoList.values()) {
+ for (MediaPlayerInfo_ext info : mMediaPlayerInfoList.values()) {
if (packageName.equals(info.getPackageName())) {
if (DEBUG) Log.v(TAG, "getMediaPlayerInfo: Found " + packageName);
return info;
@@ -4000,7 +4000,7 @@
}
/* prepare media list & return the media player list response object */
- private MediaPlayerListRsp prepareMediaPlayerRspObj() {
+ private MediaPlayerListRsp_ext prepareMediaPlayerRspObj() {
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
// TODO(apanicke): This hack will go away as soon as a developer
@@ -4016,18 +4016,18 @@
String[] displayableNameArray = new String[numPlayers];
byte[] playStatusValues = new byte[numPlayers];
short[] featureBitMaskValues =
- new short[numPlayers * AvrcpConstants.AVRC_FEATURE_MASK_SIZE];
+ new short[numPlayers * AvrcpConstants_ext.AVRC_FEATURE_MASK_SIZE];
// Reserve the first spot for the currently addressed player if
// we have one
int players = mMediaPlayerInfoList.containsKey(mCurrAddrPlayerID) ? 1 : 0;
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
int idx = players;
if (entry.getKey() == mCurrAddrPlayerID)
idx = 0;
else
continue; // TODO(apanicke): Remove, see above note
- MediaPlayerInfo info = entry.getValue();
+ MediaPlayerInfo_ext info = entry.getValue();
playerIds[idx] = entry.getKey();
playerTypes[idx] = info.getMajorType();
playerSubTypes[idx] = info.getSubType();
@@ -4040,7 +4040,7 @@
byte octet = (byte) (featureBits[numBit] / 8);
/* gives the bit position within the octet */
byte bit = (byte) (featureBits[numBit] % 8);
- featureBitMaskValues[(idx * AvrcpConstants.AVRC_FEATURE_MASK_SIZE) + octet] |=
+ featureBitMaskValues[(idx * AvrcpConstants_ext.AVRC_FEATURE_MASK_SIZE) + octet] |=
(1 << bit);
}
@@ -4056,28 +4056,28 @@
if (DEBUG) Log.d(TAG, "prepareMediaPlayerRspObj: numPlayers = " + numPlayers);
- return new MediaPlayerListRsp(AvrcpConstants.RSP_NO_ERROR, sUIDCounter, players,
- AvrcpConstants.BTRC_ITEM_PLAYER, playerIds, playerTypes, playerSubTypes,
+ return new MediaPlayerListRsp_ext(AvrcpConstants_ext.RSP_NO_ERROR, sUIDCounter, players,
+ AvrcpConstants_ext.BTRC_ITEM_PLAYER, playerIds, playerTypes, playerSubTypes,
playStatusValues, featureBitMaskValues, displayableNameArray);
}
}
}
/* build media player list and send it to remote. */
- private void handleMediaPlayerListRsp(AvrcpCmd.FolderItemsCmd folderObj) {
- MediaPlayerListRsp rspObj = null;
+ private void handleMediaPlayerListRsp(AvrcpCmd_ext.FolderItemsCmd folderObj) {
+ MediaPlayerListRsp_ext rspObj = null;
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
int numPlayers = mMediaPlayerInfoList.size();
if (numPlayers == 0) {
- mediaPlayerListRspNative(folderObj.mAddress, AvrcpConstants.RSP_NO_AVBL_PLAY,
+ mediaPlayerListRspNative(folderObj.mAddress, AvrcpConstants_ext.RSP_NO_AVBL_PLAY,
(short) 0, (byte) 0, 0, null, null, null, null, null, null);
return;
}
if (folderObj.mStartItem >= numPlayers || folderObj.mStartItem >= 1) {
Log.i(TAG, "handleMediaPlayerListRsp: start = " + folderObj.mStartItem
+ " > num of items = " + numPlayers);
- mediaPlayerListRspNative(folderObj.mAddress, AvrcpConstants.RSP_INV_RANGE,
+ mediaPlayerListRspNative(folderObj.mAddress, AvrcpConstants_ext.RSP_INV_RANGE,
(short) 0, (byte) 0, 0, null, null, null, null, null, null);
return;
}
@@ -4085,9 +4085,9 @@
short[] featureBitsArray = {0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0x01, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Log.i(TAG, "handleMediaPlayerListRsp: Send dummy player response");
- mediaPlayerListRspNative(folderObj.mAddress, (int)AvrcpConstants.RSP_NO_ERROR,
- (int)sUIDCounter, AvrcpConstants.BTRC_ITEM_PLAYER, 1, new int[] {0},
- new byte[] {AvrcpConstants.PLAYER_TYPE_AUDIO}, new int[] {1},
+ mediaPlayerListRspNative(folderObj.mAddress, (int)AvrcpConstants_ext.RSP_NO_ERROR,
+ (int)sUIDCounter, AvrcpConstants_ext.BTRC_ITEM_PLAYER, 1, new int[] {0},
+ new byte[] {AvrcpConstants_ext.PLAYER_TYPE_AUDIO}, new int[] {1},
new byte[] {PLAYSTATUS_STOPPED}, featureBitsArray,
new String[] {"Dummy Player"});
return;
@@ -4111,7 +4111,7 @@
updateNewIds(addrId, browseId);
MediaController newController = null;
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
if (info != null) newController = info.getMediaController();
if (DEBUG)
@@ -4135,36 +4135,36 @@
}
/* Handle getfolderitems for scope = VFS, Search, NowPlayingList */
- private void handleGetFolderItemBrowseResponse(AvrcpCmd.FolderItemsCmd folderObj, byte[] bdaddr) {
- int status = AvrcpConstants.RSP_NO_ERROR;
+ private void handleGetFolderItemBrowseResponse(AvrcpCmd_ext.FolderItemsCmd folderObj, byte[] bdaddr) {
+ int status = AvrcpConstants_ext.RSP_NO_ERROR;
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bdaddr);
/* Browsed player is already set */
- if (folderObj.mScope == AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM) {
+ if (folderObj.mScope == AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM) {
if (mBrowsingActiveDevice != null && !device.equals(mBrowsingActiveDevice)) {
Log.e(TAG, "handleGetFolderItemBrowse: Cmd from browse inactive device, reject it");
- getFolderItemsRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR, (short) 0,
+ getFolderItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, (short) 0,
(byte) 0x00, 0, null, null, null, null, null, null, null, null);
return;
}
if (mAvrcpBrowseManager.getBrowsedMediaPlayer(bdaddr) == null) {
Log.e(TAG, "handleGetFolderItemBrowseResponse: no browsed player set for "
+ Utils.getAddressStringFromByte(bdaddr));
- getFolderItemsRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR, (short) 0,
+ getFolderItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, (short) 0,
(byte) 0x00, 0, null, null, null, null, null, null, null, null);
return;
}
mAvrcpBrowseManager.getBrowsedMediaPlayer(bdaddr).getFolderItemsVFS(folderObj);
return;
}
- if (folderObj.mScope == AvrcpConstants.BTRC_SCOPE_NOW_PLAYING) {
+ if (folderObj.mScope == AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING) {
mAddressedMediaPlayer.getFolderItemsNowPlaying(bdaddr, folderObj, mMediaController);
return;
}
/* invalid scope */
Log.e(TAG, "handleGetFolderItemBrowseResponse: unknown scope " + folderObj.mScope);
- getFolderItemsRspNative(bdaddr, AvrcpConstants.RSP_INV_SCOPE, (short) 0, (byte) 0x00, 0,
+ getFolderItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_INV_SCOPE, (short) 0, (byte) 0x00, 0,
null, null, null, null, null, null, null, null);
}
@@ -4195,24 +4195,24 @@
HeadsetService mService = HeadsetService.getHeadsetService();
if ((mService != null) && mService.isScoOrCallActive()) {
Log.w(TAG, "Remote requesting play item while call is active");
- playItemRspNative(bdaddr, AvrcpConstants.RSP_MEDIA_IN_USE);
+ playItemRspNative(bdaddr, AvrcpConstants_ext.RSP_MEDIA_IN_USE);
return;
}
if (mBrowsingActiveDevice != null && !device.equals(mBrowsingActiveDevice)) {
Log.w(TAG, "play item Cmd from browse inactive device, reject it");
- playItemRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ playItemRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
return;
}
- if (scope == AvrcpConstants.BTRC_SCOPE_NOW_PLAYING) {
+ if (scope == AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING) {
mAddressedMediaPlayer.playItem(bdaddr, uid, mMediaController);
}
else {
if(!isAddrPlayerSameAsBrowsed(bdaddr)) {
Log.w(TAG, "Remote requesting play item on uid which may not be recognized by" +
"current addressed player");
- playItemRspNative(bdaddr, AvrcpConstants.RSP_INV_ITEM);
+ playItemRspNative(bdaddr, AvrcpConstants_ext.RSP_INV_ITEM);
return;
}
@@ -4221,12 +4221,12 @@
} else {
Log.e(TAG, "handlePlayItemResponse: Remote requested playitem " +
"before setbrowsedplayer");
- playItemRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ playItemRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
}
}
}
- private void handleGetItemAttr(AvrcpCmd.ItemAttrCmd itemAttr) {
+ private void handleGetItemAttr(AvrcpCmd_ext.ItemAttrCmd itemAttr) {
if (itemAttr.mUidCounter != sUIDCounter) {
itemAttr.mUidCounter = sUIDCounter;
Log.e(TAG, "handleGetItemAttr: invalid uid counter, assign new value = " + itemAttr.mUidCounter);
@@ -4236,13 +4236,13 @@
if (mBrowsingActiveDevice != null && !device.equals(mBrowsingActiveDevice)) {
Log.e(TAG, "Item attributes from browse inactive device, reject it");
getItemAttrRspNative(
- itemAttr.mAddress, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0, null, null);
+ itemAttr.mAddress, AvrcpConstants_ext.RSP_INTERNAL_ERR, (byte) 0, null, null);
return;
}
- if (itemAttr.mScope == AvrcpConstants.BTRC_SCOPE_NOW_PLAYING) {
+ if (itemAttr.mScope == AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING) {
if (mCurrAddrPlayerID == NO_PLAYER_ID) {
getItemAttrRspNative(
- itemAttr.mAddress, AvrcpConstants.RSP_NO_AVBL_PLAY, (byte) 0, null, null);
+ itemAttr.mAddress, AvrcpConstants_ext.RSP_NO_AVBL_PLAY, (byte) 0, null, null);
return;
}
mAddressedMediaPlayer.getItemAttr(itemAttr.mAddress, itemAttr, mMediaController);
@@ -4254,20 +4254,20 @@
} else {
Log.e(TAG, "Could not get attributes. mBrowsedMediaPlayer is null");
getItemAttrRspNative(
- itemAttr.mAddress, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0, null, null);
+ itemAttr.mAddress, AvrcpConstants_ext.RSP_INTERNAL_ERR, (byte) 0, null, null);
}
}
private void handleGetTotalNumOfItemsResponse(byte[] bdaddr, byte scope) {
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bdaddr);
if (mBrowsingActiveDevice != null && !device.equals(mBrowsingActiveDevice)) {
- getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR, 0, 0);
+ getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, 0, 0);
Log.w(TAG, "GetTotalNumOfItems: Cmd from browse inactive device reject it");
return;
}
// for scope as media player list
- if (scope == AvrcpConstants.BTRC_SCOPE_PLAYER_LIST) {
+ if (scope == AvrcpConstants_ext.BTRC_SCOPE_PLAYER_LIST) {
int numPlayers = 0;
synchronized(this) {
synchronized (mMediaPlayerInfoList) {
@@ -4275,11 +4275,11 @@
}
}
if (DEBUG) Log.d(TAG, "handleGetTotalNumOfItemsResponse: " + numPlayers + " players.");
- getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants.RSP_NO_ERROR, 0, numPlayers);
- } else if (scope == AvrcpConstants.BTRC_SCOPE_NOW_PLAYING) {
+ getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR, 0, numPlayers);
+ } else if (scope == AvrcpConstants_ext.BTRC_SCOPE_NOW_PLAYING) {
if (mMediaController == null) {
Log.e(TAG, "Could not get Total NumOfItems. mMediaController is null");
- getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants.RSP_NO_AVBL_PLAY, 0, 0);
+ getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_NO_AVBL_PLAY, 0, 0);
return;
}
mAddressedMediaPlayer.getTotalNumOfItems(bdaddr, mMediaController);
@@ -4289,7 +4289,7 @@
mAvrcpBrowseManager.getBrowsedMediaPlayer(bdaddr).getTotalNumOfItems(scope);
} else {
Log.e(TAG, "Could not get Total NumOfItems. mBrowsedMediaPlayer is null");
- getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants.RSP_INTERNAL_ERR, 0, 0);
+ getTotalNumOfItemsRspNative(bdaddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, 0, 0);
}
}
@@ -4304,7 +4304,7 @@
return false;
}
- MediaPlayerInfo info = getAddressedPlayerInfo();
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
String packageName = (info == null) ? "<none>" : info.getPackageName();
if (info == null || !packageName.equals(browsedPlayer)) {
if (DEBUG) Log.d(TAG, browsedPlayer + " is not addressed player " + packageName);
@@ -4337,12 +4337,12 @@
Log.i(TAG,"cleanupDeviceFeaturesIndex index:" + index);
deviceFeatures[index].mCurrentDevice = null;
deviceFeatures[index].mCurrentPlayState = new PlaybackState.Builder().setState(PlaybackState.STATE_NONE, -1L, 0.0f).build();;
- deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- deviceFeatures[index].mPlayStatusChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- deviceFeatures[index].mPlayerStatusChangeNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- deviceFeatures[index].mTrackChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mPlayStatusChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mPlayerStatusChangeNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
deviceFeatures[index].mPlaybackIntervalMs = 0L;
- deviceFeatures[index].mPlayPosChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mPlayPosChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
deviceFeatures[index].mFeatures = 0;
deviceFeatures[index].mAbsoluteVolume = -1;
deviceFeatures[index].mLastRspPlayStatus = -1;
@@ -4351,13 +4351,13 @@
deviceFeatures[index].mVolCmdSetInProgress = false;
deviceFeatures[index].mVolCmdAdjustInProgress = false;
deviceFeatures[index].mAbsVolRetryTimes = 0;
- deviceFeatures[index].mAvailablePlayersChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mAvailablePlayersChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
deviceFeatures[index].isActiveDevice = false;
- deviceFeatures[index].mAddrPlayerChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
- deviceFeatures[index].mUidsChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mAddrPlayerChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mUidsChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
deviceFeatures[index].mLastPassthroughcmd = KeyEvent.KEYCODE_UNKNOWN;
deviceFeatures[index].isAbsoluteVolumeSupportingDevice = false;
- deviceFeatures[index].keyPressState = AvrcpConstants.KEY_STATE_RELEASE; //Key release state
+ deviceFeatures[index].keyPressState = AvrcpConstants_ext.KEY_STATE_RELEASE; //Key release state
deviceFeatures[index].mReportedPlayerID = NO_PLAYER_ID;
deviceFeatures[index].isPlayStatusTimeOut = false;
deviceFeatures[index].mInitialRemoteVolume = -1;
@@ -4427,7 +4427,7 @@
ProfileService.println(sb, "Media Players:");
synchronized (this) {
synchronized (mMediaPlayerInfoList) {
- for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
+ for (Map.Entry<Integer, MediaPlayerInfo_ext> entry : mMediaPlayerInfoList.entrySet()) {
int key = entry.getKey();
ProfileService.println(sb, ((mCurrAddrPlayerID == key) ? " *#" : " #")
+ entry.getKey() + ": " + entry.getValue());
@@ -4469,11 +4469,11 @@
}
public class AvrcpBrowseManager {
- Map<String, BrowsedMediaPlayer> connList = new HashMap<String, BrowsedMediaPlayer>();
- private AvrcpMediaRspInterface mMediaInterface;
+ Map<String, BrowsedMediaPlayer_ext> connList = new HashMap<String, BrowsedMediaPlayer_ext>();
+ private AvrcpMediaRspInterface_ext mMediaInterface;
private Context mContext;
- public AvrcpBrowseManager(Context context, AvrcpMediaRspInterface mediaInterface) {
+ public AvrcpBrowseManager(Context context, AvrcpMediaRspInterface_ext mediaInterface) {
mContext = context;
mMediaInterface = mediaInterface;
}
@@ -4482,7 +4482,7 @@
Iterator entries = connList.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
- BrowsedMediaPlayer browsedMediaPlayer = (BrowsedMediaPlayer) entry.getValue();
+ BrowsedMediaPlayer_ext browsedMediaPlayer = (BrowsedMediaPlayer_ext) entry.getValue();
if (browsedMediaPlayer != null) {
browsedMediaPlayer.cleanup();
}
@@ -4494,13 +4494,13 @@
// get the a free media player interface based on the passed bd address
// if the no items is found for the passed media player then it assignes a
// available media player interface
- public BrowsedMediaPlayer getBrowsedMediaPlayer(byte[] bdaddr) {
- BrowsedMediaPlayer mediaPlayer;
+ public BrowsedMediaPlayer_ext getBrowsedMediaPlayer(byte[] bdaddr) {
+ BrowsedMediaPlayer_ext mediaPlayer;
String bdaddrStr = new String(bdaddr);
if (connList.containsKey(bdaddrStr)) {
mediaPlayer = connList.get(bdaddrStr);
} else {
- mediaPlayer = new BrowsedMediaPlayer(bdaddr, mContext, mMediaInterface);
+ mediaPlayer = new BrowsedMediaPlayer_ext(bdaddr, mContext, mMediaInterface);
connList.put(bdaddrStr, mediaPlayer);
}
return mediaPlayer;
@@ -4516,7 +4516,7 @@
return false;
}
- public Map<String, BrowsedMediaPlayer> getConnList() {
+ public Map<String, BrowsedMediaPlayer_ext> getConnList() {
return connList;
}
@@ -4554,14 +4554,14 @@
}
public void SendSetPlayerAppRsp(int attr_status, byte[] address) {
- if (attr_status != AvrcpConstants.RSP_INTERNAL_ERR) {
+ if (attr_status != AvrcpConstants_ext.RSP_INTERNAL_ERR) {
for (int i = 0; i < maxAvrcpConnections; i++) {
if (deviceFeatures[i].mCurrentDevice != null &&
deviceFeatures[i].mPlayerStatusChangeNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
Log.v(TAG,"device has registered for mPlayerAppSettingStatusChangeNT");
deviceFeatures[i].mPlayerStatusChangeNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
mAvrcpPlayerAppSettings.sendPlayerAppChangedRsp(
deviceFeatures[i].mPlayerStatusChangeNT,
deviceFeatures[i].mCurrentDevice);
@@ -4616,7 +4616,7 @@
* private class which handles responses from AvrcpMediaManager. Maps responses to native
* responses. This class implements the AvrcpMediaRspInterface interface.
*/
- private class AvrcpMediaRsp implements AvrcpMediaRspInterface {
+ private class AvrcpMediaRsp implements AvrcpMediaRspInterface_ext {
private static final String TAG = "AvrcpMediaRsp";
public void setAddrPlayerRsp(byte[] address, int rspStatus) {
@@ -4638,8 +4638,8 @@
}
}
- public void mediaPlayerListRsp(byte[] address, int rspStatus, MediaPlayerListRsp rspObj) {
- if (rspObj != null && rspStatus == AvrcpConstants.RSP_NO_ERROR) {
+ public void mediaPlayerListRsp(byte[] address, int rspStatus, MediaPlayerListRsp_ext rspObj) {
+ if (rspObj != null && rspStatus == AvrcpConstants_ext.RSP_NO_ERROR) {
if (!mediaPlayerListRspNative(address, rspStatus, sUIDCounter, rspObj.mItemType,
rspObj.mNumItems, rspObj.mPlayerIds, rspObj.mPlayerTypes,
rspObj.mPlayerSubTypes, rspObj.mPlayStatusValues,
@@ -4653,24 +4653,24 @@
}
}
- public void folderItemsRsp(byte[] address, int rspStatus, FolderItemsRsp rspObj) {
- if (rspObj != null && rspStatus == AvrcpConstants.RSP_NO_ERROR) {
+ public void folderItemsRsp(byte[] address, int rspStatus, FolderItemsRsp_ext rspObj) {
+ if (rspObj != null && rspStatus == AvrcpConstants_ext.RSP_NO_ERROR) {
String Album = new String("Albums");
String Artist = new String("Artists");
String Playlist = new String("Playlists");
for (int index = 0; index < rspObj.mDisplayNames.length; index++) {
if (rspObj.mDisplayNames[index].equals(Album))
- rspObj.mFolderTypes[index] = AvrcpConstants.FOLDER_TYPE_ALBUMS;
+ rspObj.mFolderTypes[index] = AvrcpConstants_ext.FOLDER_TYPE_ALBUMS;
else if (rspObj.mDisplayNames[index].equals(Artist))
- rspObj.mFolderTypes[index] = AvrcpConstants.FOLDER_TYPE_ARTISTS;
+ rspObj.mFolderTypes[index] = AvrcpConstants_ext.FOLDER_TYPE_ARTISTS;
else if (rspObj.mDisplayNames[index].equals(Playlist))
- rspObj.mFolderTypes[index] = AvrcpConstants.FOLDER_TYPE_PLAYLISTS;
+ rspObj.mFolderTypes[index] = AvrcpConstants_ext.FOLDER_TYPE_PLAYLISTS;
/*by default for every folder filling folder type Titles*/
else
if (changePathFolderType > 0)
rspObj.mFolderTypes[index] = changePathFolderType;
else
- rspObj.mFolderTypes[index] = AvrcpConstants.FOLDER_TYPE_TITLES;
+ rspObj.mFolderTypes[index] = AvrcpConstants_ext.FOLDER_TYPE_TITLES;
}
Log.v(TAG, " changePathDepth " + changePathDepth +
" changePathFolderType " + changePathFolderType);
@@ -4694,7 +4694,7 @@
public void changePathRsp(byte[] address, int rspStatus, int numItems) {
/*to handle changePath invalid uid scenario or any error sceanrio */
- if (rspStatus != AvrcpConstants.RSP_NO_ERROR && changePathDepth>0) {
+ if (rspStatus != AvrcpConstants_ext.RSP_NO_ERROR && changePathDepth>0) {
if(changePathDirection == 1)
changePathDepth--;
else
@@ -4704,8 +4704,8 @@
Log.e(TAG, "changePathRspNative failed!");
}
- public void getItemAttrRsp(byte[] address, int rspStatus, ItemAttrRsp rspObj) {
- if (rspObj != null && rspStatus == AvrcpConstants.RSP_NO_ERROR) {
+ public void getItemAttrRsp(byte[] address, int rspStatus, ItemAttrRsp_ext rspObj) {
+ if (rspObj != null && rspStatus == AvrcpConstants_ext.RSP_NO_ERROR) {
if (!getItemAttrRspNative(address, rspStatus, rspObj.mNumAttr,
rspObj.mAttributesIds, rspObj.mAttributesArray))
Log.e(TAG, "getItemAttrRspNative failed!");
@@ -4726,7 +4726,7 @@
return;
}
- if((rspStatus == AvrcpConstants.RSP_NO_ERROR) && ((mA2dpService != null) &&
+ if((rspStatus == AvrcpConstants_ext.RSP_NO_ERROR) && ((mA2dpService != null) &&
!Objects.equals(mA2dpService.getActiveDevice(), device))) {
Log.d(TAG, "Trigger Handoff by playItem");
startSHO(device, true);
@@ -4773,7 +4773,7 @@
}
if ((index != INVALID_DEVICE_INDEX) &&
- (deviceFeatures[index].mUidsChangedNT != AvrcpConstants.NOTIFICATION_TYPE_INTERIM)) {
+ (deviceFeatures[index].mUidsChangedNT != AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM)) {
if (DEBUG) Log.d(TAG, "uidsChangedRsp: Not registered or requesting.");
return;
}
@@ -4786,7 +4786,7 @@
Log.e(TAG, "registerNotificationRspUIDsChangedNative failed!");
}
if (index != INVALID_DEVICE_INDEX)
- deviceFeatures[index].mUidsChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ deviceFeatures[index].mUidsChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
public void nowPlayingChangedRsp(int type) {
@@ -4806,7 +4806,7 @@
Log.e(TAG,"uidsChangedRsp:No active device found");
return;
}
- if (mNowPlayingListChangedNT != AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ if (mNowPlayingListChangedNT != AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
if (DEBUG) Log.d(TAG, "NowPlayingListChanged: Not registered or requesting.");
return;
}
@@ -4814,7 +4814,7 @@
if (!registerNotificationRspNowPlayingChangedNative(type, addr)) {
Log.e(TAG, "registerNotificationRspNowPlayingChangedNative failed!");
}
- mNowPlayingListChangedNT = AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
public void trackChangedRsp(int type, byte[] uid) {
@@ -5004,21 +5004,21 @@
deviceFeatures[deviceIndex].mReportedPlayerID +
", mCurrAddrPlayerID: " + mCurrAddrPlayerID);
if (deviceFeatures[deviceIndex].mAvailablePlayersChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
registerNotificationRspAvalPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
mAvailablePlayerViewChanged = false;
deviceFeatures[deviceIndex].mAvailablePlayersChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}
if (deviceFeatures[deviceIndex].mAddrPlayerChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
registerNotificationRspAddrPlayerChangedNative(
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
sUIDCounter, getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
deviceFeatures[deviceIndex].mAddrPlayerChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
// send track change event becasue some carkits will refresh metadata
// while receive addressed player change event. Track change event to
// make remote get metadata correctly.
@@ -5116,7 +5116,7 @@
Log.d(TAG, "Active device: " + mA2dpService.getActiveDevice());
int action = KeyEvent.ACTION_DOWN;
- if (state == AvrcpConstants.KEY_STATE_RELEASE) action = KeyEvent.ACTION_UP;
+ if (state == AvrcpConstants_ext.KEY_STATE_RELEASE) action = KeyEvent.ACTION_UP;
BluetoothDevice a2dp_active_device = null;
boolean skip = false;;
if (mA2dpService != null) a2dp_active_device = mA2dpService.getActiveDevice();
@@ -5211,7 +5211,7 @@
} else {
if (code == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
if ((state == deviceFeatures[deviceIndex].keyPressState) &&
- (state == AvrcpConstants.KEY_STATE_RELEASE)) {
+ (state == AvrcpConstants_ext.KEY_STATE_RELEASE)) {
Log.e(TAG, "Ignore fast forward key release event");
return;
}
@@ -5223,7 +5223,7 @@
deviceFeatures[deviceIndex].keyPressState = state;
} else if (code == KeyEvent.KEYCODE_MEDIA_REWIND) {
if ((state == deviceFeatures[deviceIndex].keyPressState) &&
- (state == AvrcpConstants.KEY_STATE_RELEASE)) {
+ (state == AvrcpConstants_ext.KEY_STATE_RELEASE)) {
Log.e(TAG, "Ignore rewind key release event");
return;
}
@@ -5243,7 +5243,7 @@
* changed response at the time of Release of Fast-Forward/Rewind Button */
if ((code == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || code == KeyEvent.KEYCODE_MEDIA_REWIND)
&& (deviceFeatures[deviceIndex].mPlayStatusChangedNT ==
- AvrcpConstants.NOTIFICATION_TYPE_INTERIM) && (action == KeyEvent.ACTION_UP)) {
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) && (action == KeyEvent.ACTION_UP)) {
int currentPlayState =
convertPlayStateToPlayStatus(deviceFeatures[deviceIndex].mCurrentPlayState);
Log.d(TAG, " currentPlayState: " + currentPlayState + " mLastRspPlayStatus: " +
@@ -5251,7 +5251,7 @@
if (deviceFeatures[deviceIndex].mCurrentDevice != null &&
deviceFeatures[deviceIndex].mLastRspPlayStatus != currentPlayState) {
deviceFeatures[deviceIndex].mPlayStatusChangedNT =
- AvrcpConstants.NOTIFICATION_TYPE_CHANGED;
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
registerNotificationRspPlayStatusNative(deviceFeatures[deviceIndex].mPlayStatusChangedNT
,currentPlayState,
getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice));
diff --git a/packages_apps_bluetooth_ext/BrowsedMediaPlayer_ext.java b/packages_apps_bluetooth_ext/src/avrcp/BrowsedMediaPlayer_ext.java
similarity index 76%
rename from packages_apps_bluetooth_ext/BrowsedMediaPlayer_ext.java
rename to packages_apps_bluetooth_ext/src/avrcp/BrowsedMediaPlayer_ext.java
index d6d4b25..8f1801d 100644
--- a/packages_apps_bluetooth_ext/BrowsedMediaPlayer_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/BrowsedMediaPlayer_ext.java
@@ -49,17 +49,20 @@
private static final int SUSPENDED = 2;
private static final int BROWSED_ITEM_ID_INDEX = 2;
-
+ private static final int BROWSED_FOLDER_ID_INDEX = 4;
private static final String[] ROOT_FOLDER = {"root"};
-
+ private static boolean mPlayerRoot = false;
/* package and service name of target Media Player which is set for browsing */
private String mPackageName;
private String mConnectingPackageName;
private String mClassName;
private Context mContext;
- private AvrcpMediaRspInterface mMediaInterface;
+ private AvrcpMediaRspInterface_ext mMediaInterface;
private byte[] mBDAddr;
+ private String mCurrentBrowsePackage;
+ private String mCurrentBrowseClass;
+
/* Object used to connect to MediaBrowseService of Media Player */
private MediaBrowser mMediaBrowser = null;
private MediaController mMediaController = null;
@@ -71,7 +74,7 @@
/* stores the path trail during changePath */
private Stack<String> mPathStack = null;
-
+ private Stack<String> mLocalPathCache = null;
/* Number of items in current folder */
private int mCurrFolderNumItems = 0;
@@ -82,7 +85,7 @@
private HashMap<Integer, String> mFolderHmap = new HashMap<Integer, String>();
/* command objects from avrcp handler */
- private AvrcpCmd.FolderItemsCmd mFolderItemsReqObj;
+ private AvrcpCmd_ext.FolderItemsCmd mFolderItemsReqObj;
/* store result of getfolderitems with scope="vfs" */
private List<MediaBrowser.MediaItem> mFolderItems = null;
@@ -120,7 +123,7 @@
mBrowser = null;
Log.e(TAG, "mediaBrowser Connection failed with " + mPackageName
+ ", Sending fail response!");
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR,
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR,
(byte) 0x00, 0, null);
}
@@ -151,13 +154,14 @@
if (DEBUG) {
Log.d(TAG, "sending setbrowsed player rsp");
}
+ Log.w(TAG, "sending setbrowsed player rsp");
mFolderItems = children;
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants.RSP_NO_ERROR,
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants_ext.RSP_NO_ERROR,
(byte) 0x00, children.size(), ROOT_FOLDER);
} else {
mFolderItems = children;
mCurrFolderNumItems = mFolderItems.size();
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_NO_ERROR,
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_NO_ERROR,
mCurrFolderNumItems);
}
refreshFolderItems(mFolderItems);
@@ -168,7 +172,7 @@
@Override
public void onError(String id) {
Log.e(TAG, "set browsed player rsp. Could not get root folder items");
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR,
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR,
(byte) 0x00, 0, null);
}
};
@@ -176,9 +180,9 @@
/* callback from media player in response to getitemAttr request */
private class ItemAttribSubscriber extends MediaBrowser.SubscriptionCallback {
private String mMediaId;
- private AvrcpCmd.ItemAttrCmd mAttrReq;
+ private AvrcpCmd_ext.ItemAttrCmd mAttrReq;
- ItemAttribSubscriber(@NonNull AvrcpCmd.ItemAttrCmd attrReq, @NonNull String mediaId) {
+ ItemAttribSubscriber(@NonNull AvrcpCmd_ext.ItemAttrCmd attrReq, @NonNull String mediaId) {
mAttrReq = attrReq;
mMediaId = mediaId;
}
@@ -189,7 +193,7 @@
if (DEBUG) {
Log.d(TAG, logprefix + "OnChildren Loaded");
}
- int status = AvrcpConstants.RSP_INV_ITEM;
+ int status = AvrcpConstants_ext.RSP_INV_ITEM;
if (children == null) {
Log.w(TAG, logprefix + "children list is null parentId: " + parentId);
@@ -201,13 +205,13 @@
Log.d(TAG, logprefix + "found item");
}
getItemAttrFilterAttr(item);
- status = AvrcpConstants.RSP_NO_ERROR;
+ status = AvrcpConstants_ext.RSP_NO_ERROR;
break;
}
}
}
/* Send only error from here, in case of success, getItemAttrFilterAttr sends */
- if (status != AvrcpConstants.RSP_NO_ERROR) {
+ if (status != AvrcpConstants_ext.RSP_NO_ERROR) {
Log.e(TAG, logprefix + "not able to find item from " + parentId);
mMediaInterface.getItemAttrRsp(mBDAddr, status, null);
}
@@ -217,7 +221,7 @@
@Override
public void onError(String id) {
Log.e(TAG, "Could not get attributes from media player id: " + id);
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, null);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, null);
}
/* helper method to filter required attibuteand send GetItemAttr response */
@@ -231,17 +235,17 @@
ArrayList<String> attrValueArray = new ArrayList<String>();
ArrayList<Integer> attrReqIds = new ArrayList<Integer>();
- if (mAttrReq.mNumAttr == AvrcpConstants.NUM_ATTR_NONE) {
+ if (mAttrReq.mNumAttr == AvrcpConstants_ext.NUM_ATTR_NONE) {
// Note(jamuraa): the stack should never send this, remove?
Log.i(TAG, "getItemAttrFilterAttr: No attributes requested");
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_BAD_PARAM, null);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_BAD_PARAM, null);
return;
}
/* check if remote device has requested all attributes */
- if (mAttrReq.mNumAttr == AvrcpConstants.NUM_ATTR_ALL
- || mAttrReq.mNumAttr == AvrcpConstants.MAX_NUM_ATTR) {
- for (int idx = 1; idx <= AvrcpConstants.MAX_NUM_ATTR; idx++) {
+ if (mAttrReq.mNumAttr == AvrcpConstants_ext.NUM_ATTR_ALL
+ || mAttrReq.mNumAttr == AvrcpConstants_ext.MAX_NUM_ATTR) {
+ for (int idx = 1; idx <= AvrcpConstants_ext.MAX_NUM_ATTR; idx++) {
attrReqIds.add(idx); /* attr id 0x00 is unused */
}
} else {
@@ -254,7 +258,7 @@
/* lookup and copy values of attributes for ids requested above */
for (int attrId : attrReqIds) {
/* check if media player provided requested attributes */
- String value = getAttrValue(attrId, mediaItem);
+ String value = getAttrValue(mBDAddr, attrId, mediaItem);
if (value != null) {
attrIdArray.add(attrId);
attrValueArray.add(value);
@@ -270,14 +274,14 @@
attrValues = attrValueArray.toArray(new String[attrIdArray.size()]);
/* create rsp object and send response */
- ItemAttrRsp rspObj = new ItemAttrRsp(AvrcpConstants.RSP_NO_ERROR, attrIds, attrValues);
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_NO_ERROR, rspObj);
+ ItemAttrRsp_ext rspObj = new ItemAttrRsp_ext(AvrcpConstants_ext.RSP_NO_ERROR, attrIds, attrValues);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_NO_ERROR, rspObj);
}
}
/* Constructor */
- BrowsedMediaPlayer(byte[] address, Context context,
- AvrcpMediaRspInterface mAvrcpMediaRspInterface) {
+ BrowsedMediaPlayer_ext(byte[] address, Context context,
+ AvrcpMediaRspInterface_ext mAvrcpMediaRspInterface) {
mContext = context;
mMediaInterface = mAvrcpMediaRspInterface;
mBDAddr = address;
@@ -289,14 +293,14 @@
Log.w(TAG, "onBrowseConnect: recieved callback for package" + mConnectingPackageName +
"we aren't connecting to " + connectedPackage);
mMediaInterface.setBrowsedPlayerRsp(
- mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0x00, 0, null);
+ mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, (byte) 0x00, 0, null);
return;
}
mConnectingPackageName = null;
if (browser == null) {
Log.e(TAG, "onBrowseConnect: received a null browser for " + connectedPackage);
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR,
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR,
(byte) 0x00, 0, null);
return;
}
@@ -323,7 +327,7 @@
if (mMediaId == null || mMediaId.length() == 0) {
Log.e(TAG, "onBrowseConnect: root value is empty or null");
mMediaInterface.setBrowsedPlayerRsp(
- mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0x00, 0, null);
+ mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, (byte) 0x00, 0, null);
return;
}
@@ -333,7 +337,21 @@
mRootFolderUid = mMediaId;
/* store root folder uid to stack */
mPathStack.push(mMediaId);
+ String [] ExternalPath = mMediaId.split("/");
+ if (ExternalPath != null) {
+ Log.d(TAG,"external path length: " + ExternalPath.length);
+ if (ExternalPath.length == 1) {
+ mLocalPathCache.push(mMediaId);
+ } else if (ExternalPath.length == 0 && mMediaId.equals("/")) {
+ mPlayerRoot = true;
+ mLocalPathCache.push(mMediaId);
+ } else {
+ //to trim the root in GMP which comes as "com.google.android.music.generic/root"
+ mLocalPathCache.push(ExternalPath[ExternalPath.length - 1]);
+ }
+ }
/* get root folder items */
+ Log.e(TAG, "onBrowseConnect: subscribe event for FolderCb");
mMediaBrowser.subscribe(mRootFolderUid, mFolderItemsCb);
}
@@ -345,7 +363,7 @@
ex.printStackTrace();
}
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, (byte) 0x00,
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, (byte) 0x00,
0, null);
}
@@ -362,11 +380,13 @@
mFolderItems = null;
mMediaId = null;
mRootFolderUid = null;
+ mPlayerRoot = false;
/*
* create stack to store the navigation trail (current folder ID). This
* will be required while navigating up the folder
*/
mPathStack = new Stack<String>();
+ mLocalPathCache = new Stack<String>();
/* Bind to MediaBrowseService of MediaPlayer */
MediaConnectionCallback callback = new MediaConnectionCallback(packageName);
MediaBrowser tempBrowser = new MediaBrowser(
@@ -376,7 +396,7 @@
} else if (mFolderItems != null) {
mPackageName = packageName;
mClassName = cls;
- int rsp_status = AvrcpConstants.RSP_NO_ERROR;
+ int rsp_status = AvrcpConstants_ext.RSP_NO_ERROR;
int folder_depth = (mPathStack.size() > 0) ? (mPathStack.size() - 1) : 0;
if (!mPathStack.empty()) {
Log.d(TAG, "~~current Path = " + mPathStack.peek());
@@ -386,13 +406,36 @@
String path = mPathStack.peek();
mPathStack.push(top);
String [] ExternalPath = path.split("/");
- String [] folderPath = new String[ExternalPath.length - 1];
- for (int i = 0; i < (ExternalPath.length - 1); i++) {
- folderPath[i] = ExternalPath[i + 1];
- Log.d(TAG,"folderPath[" + i + "] = " + folderPath[i]);
- }
- mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status,
+ if (!mPlayerRoot && ExternalPath != null && ExternalPath.length > 1) {
+ Log.d(TAG,"external path length: " + ExternalPath.length);
+ String [] folderPath = new String[ExternalPath.length - 1];
+ for (int i = 0; i < (ExternalPath.length - 1); i++) {
+ folderPath[i] = ExternalPath[i + 1];
+ Log.d(TAG,"folderPath[" + i + "] = " + folderPath[i]);
+ }
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status,
(byte)folder_depth, mFolderItems.size(), folderPath);
+ } else if (!mPlayerRoot && mLocalPathCache.size() > 1 && ExternalPath.length == 1) {
+ String [] folderPath = new String[mLocalPathCache.size() - 1];
+ folderPath = mLocalPathCache.toArray(folderPath);
+ for (int i = 0; i < mLocalPathCache.size() - 1; i++) {
+ Log.d(TAG,"folderPath[" + i + "] = " + folderPath[i]);
+ }
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status,
+ (byte)folder_depth, mFolderItems.size(), folderPath);
+ } else if (mPlayerRoot && mLocalPathCache.size() > 1) {
+ String [] folderPath = new String[mLocalPathCache.size() - 1];
+ folderPath = mLocalPathCache.toArray(folderPath);
+ for (int i = 0; i < mLocalPathCache.size() - 1; i++) {
+ Log.d(TAG,"folderPath[" + i + "] = " + folderPath[i]);
+ }
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status,
+ (byte)folder_depth, mFolderItems.size(), folderPath);
+ } else {
+ Log.e(TAG, "sending internal error !!!");
+ rsp_status = AvrcpConstants_ext.RSP_INTERNAL_ERR;
+ mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status, (byte)0x00, 0, null);
+ }
} else if (mPathStack.size() == 1) {
Log.d(TAG, "On root send SetBrowse response with root properties");
mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status, (byte)folder_depth,
@@ -400,13 +443,47 @@
}
} else {
Log.e(TAG, "Path Stack empty sending internal error !!!");
- rsp_status = AvrcpConstants.RSP_INTERNAL_ERR;
+ rsp_status = AvrcpConstants_ext.RSP_INTERNAL_ERR;
mMediaInterface.setBrowsedPlayerRsp(mBDAddr, rsp_status, (byte)0x00, 0, null);
}
Log.d(TAG, "send setbrowse rsp status=" + rsp_status + " folder_depth=" + folder_depth);
}
}
+ public void TryReconnectBrowse(String packageName, String cls) {
+ Log.w(TAG, "Try reconnection with Browser service for package = " + packageName);
+ mConnectingPackageName = packageName;
+ mPackageName = packageName;
+ mClassName = cls;
+
+ /* cleanup variables from previous browsed calls */
+ mFolderItems = null;
+ mMediaId = null;
+ mRootFolderUid = null;
+ mPlayerRoot = false;
+
+ if (mPathStack != null)
+ mPathStack = null;
+ mPathStack = new Stack<String>();
+
+ if (mLocalPathCache != null)
+ mLocalPathCache = null;
+ mLocalPathCache = new Stack<String>();
+
+ MediaConnectionCallback callback = new MediaConnectionCallback(packageName);
+ MediaBrowser tempBrowser = new MediaBrowser(
+ mContext, new ComponentName(packageName, cls), callback, null);
+ callback.setBrowser(tempBrowser);
+ tempBrowser.connect();
+ Log.w(TAG, "Reconnected with Browser service");
+ }
+
+ public void setCurrentPackage(String packageName, String cls) {
+ Log.w(TAG, "Set current Browse based on Addr Player as " + packageName);
+ mCurrentBrowsePackage = packageName;
+ mCurrentBrowseClass = cls;
+ }
+
/* called when connection to media player is closed */
public void cleanup() {
if (DEBUG) {
@@ -422,6 +499,8 @@
mMediaController = null;
mMediaBrowser = null;
mPathStack = null;
+ mLocalPathCache = null;
+ mPlayerRoot = false;
}
public boolean isPlayerConnected() {
@@ -444,54 +523,75 @@
if (!isPlayerConnected()) {
Log.w(TAG, "changePath: disconnected from player service, sending internal error");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, 0);
return;
}
if (mMediaBrowser == null) {
Log.e(TAG, "Media browser is null, sending internal error");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, 0);
return;
}
/* check direction and change the path */
- if (direction == AvrcpConstants.DIR_DOWN) { /* move down */
+ if (direction == AvrcpConstants_ext.DIR_DOWN) { /* move down */
if ((newPath = byteToStringFolder(folderUid)) == null) {
Log.e(TAG, "Could not get media item from folder Uid, sending err response");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INV_ITEM, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_ITEM, 0);
} else if (!isBrowsableFolderDn(newPath)) {
/* new path is not browsable */
Log.e(TAG, "ItemUid received from changePath cmd is not browsable");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INV_DIRECTORY, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_DIRECTORY, 0);
} else if (mPathStack.peek().equals(newPath)) {
/* new_folder is same as current folder */
Log.e(TAG, "new_folder is same as current folder, Invalid direction!");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INV_DIRN, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_DIRN, 0);
} else {
mMediaBrowser.subscribe(newPath, mFolderItemsCb);
+ String [] ExternalPath = newPath.split("/");
+ if (ExternalPath != null) {
+ Log.d(TAG,"external path length: " + ExternalPath.length);
+ if (ExternalPath.length == 1) {
+ //when external path length is 1 then extract the folder name from index 4
+ String folder_name = parseQueueId(newPath, BROWSED_FOLDER_ID_INDEX);
+ Log.d(TAG,"folder path: " + folder_name);
+ if (folder_name != null) {
+ mLocalPathCache.push(folder_name);
+ } else {
+ mLocalPathCache.push(newPath);
+ }
+ } else {
+ String folderPath = ExternalPath[ExternalPath.length - 1];
+ if (folderPath != null) {
+ Log.d(TAG,"folder path: " + folderPath);
+ mLocalPathCache.push(folderPath);
+ }
+ }
+ }
/* assume that call is success and update stack with new folder path */
mPathStack.push(newPath);
}
- } else if (direction == AvrcpConstants.DIR_UP) { /* move up */
+ } else if (direction == AvrcpConstants_ext.DIR_UP) { /* move up */
if (!isBrowsableFolderUp()) {
/* Already on the root, cannot allow up: PTS: test case TC_TG_MCN_CB_BI_02_C
* This is required, otherwise some CT will keep on sending change path up
* until they receive error */
Log.w(TAG, "Cannot go up from now, already in the root, Invalid direction!");
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INV_DIRN, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_DIRN, 0);
} else {
/* move folder up */
mPathStack.pop();
+ mLocalPathCache.pop();
newPath = mPathStack.peek();
mMediaBrowser.subscribe(newPath, mFolderItemsCb);
}
} else { /* invalid direction */
Log.w(TAG, "changePath : Invalid direction " + direction);
- mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INV_DIRN, 0);
+ mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_DIRN, 0);
}
}
- public void getItemAttr(AvrcpCmd.ItemAttrCmd itemAttr) {
+ public void getItemAttr(AvrcpCmd_ext.ItemAttrCmd itemAttr) {
String mediaID;
if (DEBUG) {
Log.d(TAG, "getItemAttr");
@@ -501,20 +601,20 @@
mediaID = byteToStringMedia(itemAttr.mUid);
if (mediaID == null) {
Log.e(TAG, "uid is invalid");
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_INV_ITEM, null);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_ITEM, null);
return;
}
/* check scope */
- if (itemAttr.mScope != AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM) {
+ if (itemAttr.mScope != AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM) {
Log.e(TAG, "invalid scope");
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_INV_SCOPE, null);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_SCOPE, null);
return;
}
if (mMediaBrowser == null) {
Log.e(TAG, "mMediaBrowser is null");
- mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, null);
+ mMediaInterface.getItemAttrRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, null);
return;
}
@@ -526,47 +626,46 @@
if (DEBUG) {
Log.d(TAG, "getTotalNumOfItems scope = " + scope);
}
- if (scope != AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM) {
+ if (scope != AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM) {
Log.e(TAG, "getTotalNumOfItems error" + scope);
- mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants.RSP_INV_SCOPE, 0, 0);
+ mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_SCOPE, 0, 0);
return;
}
if (mFolderItems == null) {
Log.e(TAG, "mFolderItems is null, sending internal error");
/* folderitems were not fetched during change path */
- mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, 0, 0);
+ mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, 0, 0);
return;
}
/* find num items using size of already cached folder items */
- mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants.RSP_NO_ERROR, 0,
+ mMediaInterface.getTotalNumOfItemsRsp(mBDAddr, AvrcpConstants_ext.RSP_NO_ERROR, 0,
mFolderItems.size());
}
- public void getFolderItemsVFS(AvrcpCmd.FolderItemsCmd reqObj) {
- if (!isPlayerConnected()) {
- Log.e(TAG, "unable to connect to media player, sending internal error");
- /* unable to connect to media player. Send error response to remote device */
- mMediaInterface.folderItemsRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, null);
- return;
- }
-
+ public void getFolderItemsVFS(AvrcpCmd_ext.FolderItemsCmd reqObj) {
if (DEBUG) {
Log.d(TAG, "getFolderItemsVFS");
}
mFolderItemsReqObj = reqObj;
+ if ((mCurrentBrowsePackage != null) && (!mCurrentBrowsePackage.equals(mPackageName))) {
+ Log.w(TAG, "Try reconnection with Browser service as addressed pkg is changed = "
+ + mCurrentBrowsePackage + "from " + mPackageName);
+ TryReconnectBrowse(mCurrentBrowsePackage, mCurrentBrowseClass);
+ }
+
if (mFolderItems == null) {
/* Failed to fetch folder items from media player. Send error to remote device */
Log.e(TAG, "Failed to fetch folder items during getFolderItemsVFS");
- mMediaInterface.folderItemsRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, null);
+ mMediaInterface.folderItemsRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR, null);
return;
}
/* Filter attributes based on the request and send response to remote device */
getFolderItemsFilterAttr(mBDAddr, reqObj, mFolderItems,
- AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM, mFolderItemsReqObj.mStartItem,
+ AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM, mFolderItemsReqObj.mStartItem,
mFolderItemsReqObj.mEndItem);
}
@@ -578,7 +677,7 @@
/* check if uid is valid */
if ((folderUid = byteToStringMedia(uid)) == null) {
Log.e(TAG, "uid is invalid!");
- mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants.RSP_INV_ITEM);
+ mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_ITEM);
return;
}
@@ -589,20 +688,20 @@
Log.d(TAG, "Sending playID: " + folderUid);
}
- if (scope == AvrcpConstants.BTRC_SCOPE_FILE_SYSTEM) {
+ if (scope == AvrcpConstants_ext.BTRC_SCOPE_FILE_SYSTEM) {
mediaControllerCntrl.playFromMediaId(folderUid, null);
- mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants.RSP_NO_ERROR);
+ mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants_ext.RSP_NO_ERROR);
} else {
Log.e(TAG, "playItem received for invalid scope!");
- mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants.RSP_INV_SCOPE);
+ mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants_ext.RSP_INV_SCOPE);
}
} else {
Log.e(TAG, "mediaController is null");
- mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
}
} else {
Log.e(TAG, "playItem: Not connected to media player");
- mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR);
+ mMediaInterface.playItemRsp(mBDAddr, AvrcpConstants_ext.RSP_INTERNAL_ERR);
}
}
@@ -640,7 +739,7 @@
/*
* helper method to filter required attibutes before sending GetFolderItems response
*/
- public void getFolderItemsFilterAttr(byte[] bdaddr, AvrcpCmd.FolderItemsCmd mFolderItemsReqObj,
+ public void getFolderItemsFilterAttr(byte[] bdaddr, AvrcpCmd_ext.FolderItemsCmd mFolderItemsReqObj,
List<MediaBrowser.MediaItem> children, byte scope, long startItem, long endItem) {
if (DEBUG) {
Log.d(TAG,
@@ -651,7 +750,7 @@
if (children == null) {
Log.e(TAG, "Error: children are null in getFolderItemsFilterAttr");
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_INV_RANGE, null);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_INV_RANGE, null);
return;
}
@@ -659,10 +758,10 @@
resultItems = checkIndexOutofBounds(bdaddr, children, startItem, endItem);
if (resultItems == null) {
Log.w(TAG, "resultItems is null.");
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_INV_RANGE, null);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_INV_RANGE, null);
return;
}
- FolderItemsData folderDataNative = new FolderItemsData(resultItems.size());
+ FolderItemsData_ext folderDataNative = new FolderItemsData_ext(resultItems.size());
/* variables to temperorily add attrs */
ArrayList<String> attrArray = new ArrayList<String>();
@@ -673,42 +772,42 @@
MediaBrowser.MediaItem item = resultItems.get(itemIndex);
int flags = item.getFlags();
if ((flags & MediaBrowser.MediaItem.FLAG_BROWSABLE) != 0) {
- folderDataNative.mItemTypes[itemIndex] = AvrcpConstants.BTRC_ITEM_FOLDER;
+ folderDataNative.mItemTypes[itemIndex] = AvrcpConstants_ext.BTRC_ITEM_FOLDER;
} else {
- folderDataNative.mItemTypes[itemIndex] = AvrcpConstants.BTRC_ITEM_MEDIA;
+ folderDataNative.mItemTypes[itemIndex] = AvrcpConstants_ext.BTRC_ITEM_MEDIA;
}
/* set playable */
if ((flags & MediaBrowser.MediaItem.FLAG_PLAYABLE) != 0) {
- folderDataNative.mPlayable[itemIndex] = AvrcpConstants.ITEM_PLAYABLE;
+ folderDataNative.mPlayable[itemIndex] = AvrcpConstants_ext.ITEM_PLAYABLE;
} else {
- folderDataNative.mPlayable[itemIndex] = AvrcpConstants.ITEM_NOT_PLAYABLE;
+ folderDataNative.mPlayable[itemIndex] = AvrcpConstants_ext.ITEM_NOT_PLAYABLE;
}
/* set uid for current item */
byte[] uid;
- if (folderDataNative.mItemTypes[itemIndex] == AvrcpConstants.BTRC_ITEM_MEDIA)
- uid = stringToByteMedia(item.getDescription().getMediaId());
+ if (folderDataNative.mItemTypes[itemIndex] == AvrcpConstants_ext.BTRC_ITEM_MEDIA)
+ uid = stringToByteMedia(item.getDescription().getMediaId(), BROWSED_ITEM_ID_INDEX);
else
uid = stringToByteFolder(item.getDescription().getMediaId());
- for (int idx = 0; idx < AvrcpConstants.UID_SIZE; idx++) {
- folderDataNative.mItemUid[itemIndex * AvrcpConstants.UID_SIZE + idx] = uid[idx];
+ for (int idx = 0; idx < AvrcpConstants_ext.UID_SIZE; idx++) {
+ folderDataNative.mItemUid[itemIndex * AvrcpConstants_ext.UID_SIZE + idx] = uid[idx];
}
/* Set display name for current item */
folderDataNative.mDisplayNames[itemIndex] =
- getAttrValue(AvrcpConstants.ATTRID_TITLE, item);
+ getAttrValue(bdaddr, AvrcpConstants_ext.ATTRID_TITLE, item);
int maxAttributesRequested = 0;
boolean isAllAttribRequested = false;
/* check if remote requested for attributes */
- if (mFolderItemsReqObj.mNumAttr != AvrcpConstants.NUM_ATTR_NONE) {
+ if (mFolderItemsReqObj.mNumAttr != AvrcpConstants_ext.NUM_ATTR_NONE) {
int attrCnt = 0;
/* add requested attr ids to a temp array */
- if (mFolderItemsReqObj.mNumAttr == AvrcpConstants.NUM_ATTR_ALL) {
+ if (mFolderItemsReqObj.mNumAttr == AvrcpConstants_ext.NUM_ATTR_ALL) {
isAllAttribRequested = true;
- maxAttributesRequested = AvrcpConstants.MAX_NUM_ATTR;
+ maxAttributesRequested = AvrcpConstants_ext.MAX_NUM_ATTR;
} else {
/* get only the requested attribute ids from the request */
maxAttributesRequested = mFolderItemsReqObj.mNumAttr;
@@ -721,7 +820,7 @@
int attribId =
isAllAttribRequested ? (idx + 1) : mFolderItemsReqObj.mAttrIDs[idx];
- value = getAttrValue(attribId, resultItems.get(itemIndex));
+ value = getAttrValue(bdaddr, attribId, resultItems.get(itemIndex));
if (value != null) {
attrArray.add(value);
attrId.add(attribId);
@@ -743,53 +842,54 @@
}
/* create rsp object and send response to remote device */
- FolderItemsRsp rspObj =
- new FolderItemsRsp(AvrcpConstants.RSP_NO_ERROR, Avrcp.sUIDCounter, scope,
+ FolderItemsRsp_ext rspObj =
+ new FolderItemsRsp_ext(AvrcpConstants_ext.RSP_NO_ERROR, Avrcp_ext.sUIDCounter, scope,
folderDataNative.mNumItems, folderDataNative.mFolderTypes,
folderDataNative.mPlayable, folderDataNative.mItemTypes,
folderDataNative.mItemUid, folderDataNative.mDisplayNames,
folderDataNative.mAttributesNum, folderDataNative.mAttrIds,
folderDataNative.mAttrValues);
- mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants.RSP_NO_ERROR, rspObj);
+ mMediaInterface.folderItemsRsp(bdaddr, AvrcpConstants_ext.RSP_NO_ERROR, rspObj);
}
- public static String getAttrValue(int attr, MediaBrowser.MediaItem item) {
+ public String getAttrValue(byte []bdaddr, int attr, MediaBrowser.MediaItem item) {
String attrValue = null;
try {
MediaDescription desc = item.getDescription();
Bundle extras = desc.getExtras();
switch (attr) {
/* Title is mandatory attribute */
- case AvrcpConstants.ATTRID_TITLE:
+ case AvrcpConstants_ext.ATTRID_TITLE:
attrValue = desc.getTitle().toString();
break;
- case AvrcpConstants.ATTRID_ARTIST:
+ case AvrcpConstants_ext.ATTRID_ARTIST:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_ARTIST);
break;
- case AvrcpConstants.ATTRID_ALBUM:
+ case AvrcpConstants_ext.ATTRID_ALBUM:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_ALBUM);
break;
- case AvrcpConstants.ATTRID_TRACK_NUM:
+ case AvrcpConstants_ext.ATTRID_TRACK_NUM:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_TRACK_NUMBER);
break;
- case AvrcpConstants.ATTRID_NUM_TRACKS:
+ case AvrcpConstants_ext.ATTRID_NUM_TRACKS:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_NUM_TRACKS);
break;
- case AvrcpConstants.ATTRID_GENRE:
+ case AvrcpConstants_ext.ATTRID_GENRE:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_GENRE);
break;
- case AvrcpConstants.ATTRID_PLAY_TIME:
+ case AvrcpConstants_ext.ATTRID_PLAY_TIME:
attrValue = extras.getString(MediaMetadata.METADATA_KEY_DURATION);
break;
- case AvrcpConstants.ATTRID_COVER_ART:
- attrValue = Avrcp_ext.getImgHandleFromTitle(desc.getTitle().toString());
+ case AvrcpConstants_ext.ATTRID_COVER_ART:
+ attrValue = Avrcp_ext.getImgHandleFromTitle(bdaddr,
+ desc.getTitle().toString());
break;
default:
@@ -799,7 +899,7 @@
} catch (NullPointerException ex) {
Log.w(TAG, "getAttrValue: attr id not found in result");
/* checking if attribute is title, then it is mandatory and cannot send null */
- if (attr == AvrcpConstants.ATTRID_TITLE) {
+ if (attr == AvrcpConstants_ext.ATTRID_TITLE) {
attrValue = "<Unknown Title>";
} else {
return null;
@@ -839,15 +939,15 @@
return true;
}
- private String parseQueueId(String mediaId) {
+ private String parseQueueId(String mediaId, int mId) {
if (isNumeric(mediaId)) {
Log.d(TAG, "Get queue id: " + mediaId);
return mediaId.trim();
} else {
String[] mediaIdItems = mediaId.split(",");
- if (mediaIdItems != null && mediaIdItems.length > BROWSED_ITEM_ID_INDEX) {
- Log.d(TAG, "Get queue id: " + mediaIdItems[BROWSED_ITEM_ID_INDEX]);
- return mediaIdItems[BROWSED_ITEM_ID_INDEX].trim();
+ if (mediaIdItems != null && mediaIdItems.length > mId) {
+ Log.d(TAG, "Get queue id: " + mediaIdItems[mId]);
+ return mediaIdItems[mId].trim();
}
}
@@ -870,11 +970,11 @@
}
/* convert mediaId to uid for Media item*/
- private byte[] stringToByteMedia(String mediaId) {
+ private byte[] stringToByteMedia(String mediaId, int id) {
/* check if this mediaId already exists in hashmap */
if (!mMediaHmap.containsValue(mediaId)) { /* add to hashmap */
int uid;
- String queueId = parseQueueId(mediaId);
+ String queueId = parseQueueId(mediaId, id);
if (queueId == null) {
uid = mMediaHmap.size() + 1;
} else {
@@ -919,7 +1019,7 @@
Log.d(TAG, "Folder item, no need refresh hashmap from mediaId to uid");
} else {
Log.d(TAG, "Media item, refresh haspmap from mediaId to uid");
- stringToByteMedia(item.getDescription().getMediaId());
+ stringToByteMedia(item.getDescription().getMediaId(), BROWSED_ITEM_ID_INDEX);
}
}
}
@@ -944,7 +1044,7 @@
/* convert integer to byte array of size 8 bytes */
public byte[] intToByteArray(int value) {
int index = 0;
- byte[] encodedValue = new byte[AvrcpConstants.UID_SIZE];
+ byte[] encodedValue = new byte[AvrcpConstants_ext.UID_SIZE];
encodedValue[index++] = (byte) 0x00;
encodedValue[index++] = (byte) 0x00;