AVRCP: Fixes wrt to player switch for various players
- Keep a static whitelist of Browsable players for
AVRCP_Browse feature as many of the player claiming
support Browsing indeed misbehave and doesn't allow
MBS Connection via BT OR partially support Browsing
features.
- Disallow sending browse events CHANGED response for
non-Browsable to non-Browsable player switch.
- Ensure Browsable feature bits are not set for non-
Browsable Players.
- Ensure Now_playing_content change and non-zero track
value is sent for Browsable Players only.
CRs-Fixed: 2539461
Change-Id: I61f22cf1d34542770fb24497d337b0f7b65fa244
diff --git a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
index 74e6aad..16772d5 100644
--- a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
@@ -199,6 +199,12 @@
"Porsche"
};
+
+ private static final ArrayList<String> playerBrowseWhiteListDB =
+ new ArrayList<String>(Arrays.asList(
+ "com.google.android.music"
+ ));
+
/* UID counter to be shared across different files. */
static short sUIDCounter = AvrcpConstants_ext.DEFAULT_UID_COUNTER;
@@ -2347,34 +2353,45 @@
deviceFeatures[index].mReportedPlayerID != mCurrAddrPlayerID) {
Log.v(TAG, "Update player id: " + deviceFeatures[index].mReportedPlayerID +
"-> " + mCurrAddrPlayerID);
- mPlayerSwitching = true;
- if (deviceFeatures[index].mAvailablePlayersChangedNT ==
- AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
- registerNotificationRspAvalPlayerChangedNative(
- AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, addr);
- mAvailablePlayerViewChanged = false;
- deviceFeatures[index].mAvailablePlayersChangedNT =
+ String currPkg = getPackageName(mCurrAddrPlayerID);
+ String prevPkg = getPackageName(deviceFeatures[index].mReportedPlayerID);
+ if ((currPkg != null && !currPkg.isEmpty() &&
+ playerBrowseWhiteListDB.contains(currPkg))
+ || (prevPkg != null && !prevPkg.isEmpty() &&
+ playerBrowseWhiteListDB.contains(prevPkg))) {
+ if (deviceFeatures[index].mAvailablePlayersChangedNT ==
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
+ registerNotificationRspAvalPlayerChangedNative(
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, addr);
+ mAvailablePlayerViewChanged = false;
+ deviceFeatures[index].mAvailablePlayersChangedNT =
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ }
+ if (deviceFeatures[index].mAddrPlayerChangedNT ==
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
+ registerNotificationRspAddrPlayerChangedNative(
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
+ sUIDCounter, addr);
+ deviceFeatures[index].mAddrPlayerChangedNT =
+ AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ }
+
+ // Update the now playing list without sending the notification
+ deviceFeatures[index].mNowPlayingListChangedNT =
AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
- }
- if (deviceFeatures[index].mAddrPlayerChangedNT ==
- AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM) {
- registerNotificationRspAddrPlayerChangedNative(
- AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED, mCurrAddrPlayerID,
- sUIDCounter, addr);
- deviceFeatures[index].mAddrPlayerChangedNT =
- AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
+ mAddressedMediaPlayer.updateNowPlayingList(mMediaController);
+ deviceFeatures[index].mNowPlayingListChangedNT =
+ AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
}
deviceFeatures[index].mReportedPlayerID = mCurrAddrPlayerID;
-
- // Update the now playing list without sending the notification
- deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
- mAddressedMediaPlayer.updateNowPlayingList(mMediaController);
- deviceFeatures[index].mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
}
// Dont send now playing list changed if the player doesn't support browsing
MediaPlayerInfo_ext info = getAddressedPlayerInfo();
- if (info != null && info.isBrowseSupported()) {
+ String pkg = (info != null) ? info.getPackageName():"";
+ boolean isPlayerInBrowseList = (pkg != null) && (!pkg.isEmpty()) &&
+ playerBrowseWhiteListDB.contains(pkg);
+ if (isPlayerInBrowseList) {
Log.v(TAG, "Check if NowPlayingList is updated");
mAddressedMediaPlayer.updateNowPlayingList(mMediaController);
}
@@ -2675,8 +2692,12 @@
deviceFeatures[deviceIndex].mTrackChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_INTERIM;
byte[] byteAddr = getByteAddress(deviceFeatures[deviceIndex].mCurrentDevice);
+ MediaPlayerInfo_ext info = getAddressedPlayerInfo();
+ String currPkg = (info != null) ? info.getPackageName():"";
+ boolean isPlayerInBrowseList = (currPkg != null) && (!currPkg.isEmpty()) &&
+ playerBrowseWhiteListDB.contains(currPkg);
// for non-browsable players or no player
- if (!isPlayerInBrowseList() ||
+ if (!isPlayerInBrowseList ||
(deviceFeatures[deviceIndex].mFeatures & BTRC_FEAT_BROWSE) == 0) {
byte[] track = AvrcpConstants_ext.TRACK_IS_SELECTED;
if (!mMediaAttributes.exists) track = AvrcpConstants_ext.NO_TRACK_SELECTED;
@@ -3802,7 +3823,7 @@
if (!isPackageNameValid(browsedPackage)) {
Log.w(TAG, " Invalid package for id:" + mCurrBrowsePlayerID);
status = AvrcpConstants_ext.RSP_INV_PLAYER;
- } else if (!isBrowseSupported(browsedPackage)) {
+ } else if (!playerBrowseWhiteListDB.contains(browsedPackage)) {
Log.w(TAG, "Browse unsupported for id:" + mCurrBrowsePlayerID
+ ", packagename : " + browsedPackage);
status = AvrcpConstants_ext.RSP_PLAY_NOT_BROW;
@@ -4378,8 +4399,8 @@
String browsedPackage = getPackageName(mCurrAddrPlayerID);
BrowsedMediaPlayer_ext player =
mAvrcpBrowseManager.getBrowsedMediaPlayer(dummyaddr);
- if ((player != null) && (!browsedPackage.isEmpty()) &&
- player.isPackageInMBSList(browsedPackage)) {
+ String currPkg = (info != null) ? info.getPackageName():"";
+ if (playerBrowseWhiteListDB.contains(currPkg)) {
for (int numBit = 0; numBit < featureBits.length; numBit++) {
/* gives which octet this belongs to */
byte octet = (byte) (featureBits[numBit] / 8);
@@ -5161,15 +5182,9 @@
return;
}
- if (!isPlayerInBrowseList() && !mPlayerSwitching) {
- Log.e(TAG,"Disallow sending changed response to non Browsable Players");
- return;
- }
-
if (!registerNotificationRspNowPlayingChangedNative(type, addr)) {
Log.e(TAG, "registerNotificationRspNowPlayingChangedNative failed!");
}
- mPlayerSwitching = false;
mNowPlayingListChangedNT = AvrcpConstants_ext.NOTIFICATION_TYPE_CHANGED;
}