Loading android/app/jni/com_android_bluetooth_avrcp_target.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ static std::vector<SongInfo> getNowPlayingList(); static uint16_t getCurrentPlayerId(); static std::vector<MediaPlayerInfo> getMediaPlayerList(); using SetBrowsedPlayerCb = MediaInterface::SetBrowsedPlayerCallback; static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCb); static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb); static uint16_t setAddressedPlayer(uint16_t player_id); using GetFolderItemsCb = MediaInterface::FolderItemsCallback; static void getFolderItems(uint16_t player_id, std::string media_id, GetFolderItemsCb cb); Loading Loading @@ -165,9 +165,8 @@ public: cb.Run(current_player); } void SetBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCallback browse_cb) override { setBrowsedPlayer(player_id, current_path, browse_cb); void SetBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCallback browse_cb) override { setBrowsedPlayer(player_id, browse_cb); } void SetAddressedPlayer(uint16_t player_id, SetAddressedPlayerCallback addressed_cb) override { Loading Loading @@ -694,7 +693,7 @@ static std::vector<MediaPlayerInfo> getMediaPlayerList() { return ret_list; } static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCb cb) { static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb cb) { log::debug(""); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); Loading @@ -703,22 +702,21 @@ static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBr } set_browsed_player_cb = cb; jstring j_current_path = sCallbackEnv->NewStringUTF(current_path.c_str()); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setBrowsedPlayer, player_id, j_current_path); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setBrowsedPlayer, player_id); } static void setBrowsedPlayerResponseNative(JNIEnv* env, jobject /* object */, jint /* player_id */, jboolean success, jstring current_path, jint num_items) { jboolean success, jstring root_id, jint num_items) { log::debug(""); std::string path; if (current_path != nullptr) { const char* value = env->GetStringUTFChars(current_path, nullptr); path = std::string(value); env->ReleaseStringUTFChars(current_path, value); std::string root; if (root_id != nullptr) { const char* value = env->GetStringUTFChars(root_id, nullptr); root = std::string(value); env->ReleaseStringUTFChars(root_id, value); } set_browsed_player_cb.Run(success == JNI_TRUE, path, num_items); set_browsed_player_cb.Run(success == JNI_TRUE, root, num_items); } static uint16_t setAddressedPlayer(uint16_t player_id) { Loading Loading @@ -1103,7 +1101,7 @@ int register_com_android_bluetooth_avrcp_target(JNIEnv* env) { {"getNowPlayingList", "()Ljava/util/List;", &method_getNowPlayingList}, {"getCurrentPlayerId", "()I", &method_getCurrentPlayerId}, {"getMediaPlayerList", "()Ljava/util/List;", &method_getMediaPlayerList}, {"setBrowsedPlayer", "(ILjava/lang/String;)V", &method_setBrowsedPlayer}, {"setBrowsedPlayer", "(I)V", &method_setBrowsedPlayer}, {"setAddressedPlayer", "(I)I", &method_setAddressedPlayer}, {"getFolderItemsRequest", "(ILjava/lang/String;)V", &method_getFolderItemsRequest}, {"playItem", "(IZLjava/lang/String;)V", &method_playItem}, Loading android/app/src/com/android/bluetooth/audio_util/MediaPlayerList.java +10 −22 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ public class MediaPlayerList { void run(boolean availablePlayers, boolean addressedPlayers, boolean uids); } public interface SetBrowsedPlayerCallback { public interface GetPlayerRootCallback { void run(int playerId, boolean success, String rootId, int numItems); } Loading Loading @@ -371,19 +371,14 @@ public class MediaPlayerList { mMediaSessionManager.dispatchMediaKeyEvent(event, false); } /** Sets the {@link #mBrowsingPlayerId} and returns the number of items in current path */ public void setBrowsedPlayer(int playerId, String currentPath, SetBrowsedPlayerCallback cb) { public void getPlayerRoot(int playerId, GetPlayerRootCallback cb) { if (Flags.browsingRefactor()) { if (!haveMediaBrowser(playerId)) { cb.run(playerId, false, "", 0); return; } mBrowsingPlayerId = playerId; MediaBrowserWrapper wrapper = mMediaBrowserWrappers.get(playerId); // If player is different than actual or if the given path is wrong, process rootId if (playerId != mBrowsingPlayerId || currentPath.equals("")) { wrapper.getRootId( (rootId) -> { wrapper.getFolderItems( Loading @@ -392,13 +387,6 @@ public class MediaPlayerList { cb.run(playerId, true, rootId, itemList.size()); }); }); } else { wrapper.getFolderItems( currentPath, (parentId, itemList) -> { cb.run(playerId, true, currentPath, itemList.size()); }); } } else { // Fix PTS AVRCP/TG/MCN/CB/BI-02-C if (Utils.isPtsTestMode()) { Loading android/app/src/com/android/bluetooth/avrcp/AvrcpNativeInterface.java +9 −8 Original line number Diff line number Diff line Loading @@ -172,23 +172,24 @@ public class AvrcpNativeInterface { return mAvrcpService.getMediaPlayerList(); } void setBrowsedPlayer(int playerId, String currentPath) { d("setBrowsedPlayer: playerId=" + playerId + ", currentPath= " + currentPath); mAvrcpService.setBrowsedPlayer( playerId, currentPath, (a, b, c, d) -> setBrowsedPlayerResponse(a, b, c, d)); // TODO(apanicke): This shouldn't be named setBrowsedPlayer as it doesn't actually connect // anything internally. It just returns the number of items in the root folder. void setBrowsedPlayer(int playerId) { d("setBrowsedPlayer: playerId=" + playerId); mAvrcpService.getPlayerRoot(playerId, (a, b, c, d) -> setBrowsedPlayerResponse(a, b, c, d)); } void setBrowsedPlayerResponse(int playerId, boolean success, String currentPath, int numItems) { void setBrowsedPlayerResponse(int playerId, boolean success, String rootId, int numItems) { d( "setBrowsedPlayerResponse: playerId=" + playerId + " success=" + success + " currentPath=" + currentPath + " rootId=" + rootId + " numItems=" + numItems); setBrowsedPlayerResponseNative(playerId, success, currentPath, numItems); setBrowsedPlayerResponseNative(playerId, success, rootId, numItems); } int setAddressedPlayer(int playerId) { Loading android/app/src/com/android/bluetooth/avrcp/AvrcpTargetService.java +3 −4 Original line number Diff line number Diff line Loading @@ -461,10 +461,9 @@ public class AvrcpTargetService extends ProfileService { return mMediaPlayerList.getMediaPlayerList(); } /** See {@link MediaPlayerList#setBrowsedPlayer}. */ void setBrowsedPlayer( int playerId, String currentPath, MediaPlayerList.SetBrowsedPlayerCallback cb) { mMediaPlayerList.setBrowsedPlayer(playerId, currentPath, cb); /** See {@link MediaPlayerList#getPlayerRoot}. */ void getPlayerRoot(int playerId, MediaPlayerList.GetPlayerRootCallback cb) { mMediaPlayerList.getPlayerRoot(playerId, cb); } /** See {@link MediaPlayerList#setAddressedPlayer}. */ Loading system/btif/avrcp/avrcp_service.cc +2 −3 Original line number Diff line number Diff line Loading @@ -244,8 +244,7 @@ public: base::Bind(&MediaInterface::GetAddressedPlayer, base::Unretained(wrapped_), bound_cb)); } void SetBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCallback browse_cb) override { void SetBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCallback browse_cb) override { auto cb_lambda = [](SetBrowsedPlayerCallback cb, bool success, std::string root_id, uint32_t num_items) { do_in_main_thread(base::BindOnce(cb, success, root_id, num_items)); Loading @@ -254,7 +253,7 @@ public: auto bound_cb = base::Bind(cb_lambda, browse_cb); do_in_jni_thread(base::Bind(&MediaInterface::SetBrowsedPlayer, base::Unretained(wrapped_), player_id, current_path, bound_cb)); player_id, bound_cb)); } void SetAddressedPlayer(uint16_t player_id, SetAddressedPlayerCallback addressed_cb) override { Loading Loading
android/app/jni/com_android_bluetooth_avrcp_target.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ static std::vector<SongInfo> getNowPlayingList(); static uint16_t getCurrentPlayerId(); static std::vector<MediaPlayerInfo> getMediaPlayerList(); using SetBrowsedPlayerCb = MediaInterface::SetBrowsedPlayerCallback; static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCb); static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb); static uint16_t setAddressedPlayer(uint16_t player_id); using GetFolderItemsCb = MediaInterface::FolderItemsCallback; static void getFolderItems(uint16_t player_id, std::string media_id, GetFolderItemsCb cb); Loading Loading @@ -165,9 +165,8 @@ public: cb.Run(current_player); } void SetBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCallback browse_cb) override { setBrowsedPlayer(player_id, current_path, browse_cb); void SetBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCallback browse_cb) override { setBrowsedPlayer(player_id, browse_cb); } void SetAddressedPlayer(uint16_t player_id, SetAddressedPlayerCallback addressed_cb) override { Loading Loading @@ -694,7 +693,7 @@ static std::vector<MediaPlayerInfo> getMediaPlayerList() { return ret_list; } static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCb cb) { static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb cb) { log::debug(""); std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); Loading @@ -703,22 +702,21 @@ static void setBrowsedPlayer(uint16_t player_id, std::string current_path, SetBr } set_browsed_player_cb = cb; jstring j_current_path = sCallbackEnv->NewStringUTF(current_path.c_str()); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setBrowsedPlayer, player_id, j_current_path); sCallbackEnv->CallVoidMethod(mJavaInterface, method_setBrowsedPlayer, player_id); } static void setBrowsedPlayerResponseNative(JNIEnv* env, jobject /* object */, jint /* player_id */, jboolean success, jstring current_path, jint num_items) { jboolean success, jstring root_id, jint num_items) { log::debug(""); std::string path; if (current_path != nullptr) { const char* value = env->GetStringUTFChars(current_path, nullptr); path = std::string(value); env->ReleaseStringUTFChars(current_path, value); std::string root; if (root_id != nullptr) { const char* value = env->GetStringUTFChars(root_id, nullptr); root = std::string(value); env->ReleaseStringUTFChars(root_id, value); } set_browsed_player_cb.Run(success == JNI_TRUE, path, num_items); set_browsed_player_cb.Run(success == JNI_TRUE, root, num_items); } static uint16_t setAddressedPlayer(uint16_t player_id) { Loading Loading @@ -1103,7 +1101,7 @@ int register_com_android_bluetooth_avrcp_target(JNIEnv* env) { {"getNowPlayingList", "()Ljava/util/List;", &method_getNowPlayingList}, {"getCurrentPlayerId", "()I", &method_getCurrentPlayerId}, {"getMediaPlayerList", "()Ljava/util/List;", &method_getMediaPlayerList}, {"setBrowsedPlayer", "(ILjava/lang/String;)V", &method_setBrowsedPlayer}, {"setBrowsedPlayer", "(I)V", &method_setBrowsedPlayer}, {"setAddressedPlayer", "(I)I", &method_setAddressedPlayer}, {"getFolderItemsRequest", "(ILjava/lang/String;)V", &method_getFolderItemsRequest}, {"playItem", "(IZLjava/lang/String;)V", &method_playItem}, Loading
android/app/src/com/android/bluetooth/audio_util/MediaPlayerList.java +10 −22 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ public class MediaPlayerList { void run(boolean availablePlayers, boolean addressedPlayers, boolean uids); } public interface SetBrowsedPlayerCallback { public interface GetPlayerRootCallback { void run(int playerId, boolean success, String rootId, int numItems); } Loading Loading @@ -371,19 +371,14 @@ public class MediaPlayerList { mMediaSessionManager.dispatchMediaKeyEvent(event, false); } /** Sets the {@link #mBrowsingPlayerId} and returns the number of items in current path */ public void setBrowsedPlayer(int playerId, String currentPath, SetBrowsedPlayerCallback cb) { public void getPlayerRoot(int playerId, GetPlayerRootCallback cb) { if (Flags.browsingRefactor()) { if (!haveMediaBrowser(playerId)) { cb.run(playerId, false, "", 0); return; } mBrowsingPlayerId = playerId; MediaBrowserWrapper wrapper = mMediaBrowserWrappers.get(playerId); // If player is different than actual or if the given path is wrong, process rootId if (playerId != mBrowsingPlayerId || currentPath.equals("")) { wrapper.getRootId( (rootId) -> { wrapper.getFolderItems( Loading @@ -392,13 +387,6 @@ public class MediaPlayerList { cb.run(playerId, true, rootId, itemList.size()); }); }); } else { wrapper.getFolderItems( currentPath, (parentId, itemList) -> { cb.run(playerId, true, currentPath, itemList.size()); }); } } else { // Fix PTS AVRCP/TG/MCN/CB/BI-02-C if (Utils.isPtsTestMode()) { Loading
android/app/src/com/android/bluetooth/avrcp/AvrcpNativeInterface.java +9 −8 Original line number Diff line number Diff line Loading @@ -172,23 +172,24 @@ public class AvrcpNativeInterface { return mAvrcpService.getMediaPlayerList(); } void setBrowsedPlayer(int playerId, String currentPath) { d("setBrowsedPlayer: playerId=" + playerId + ", currentPath= " + currentPath); mAvrcpService.setBrowsedPlayer( playerId, currentPath, (a, b, c, d) -> setBrowsedPlayerResponse(a, b, c, d)); // TODO(apanicke): This shouldn't be named setBrowsedPlayer as it doesn't actually connect // anything internally. It just returns the number of items in the root folder. void setBrowsedPlayer(int playerId) { d("setBrowsedPlayer: playerId=" + playerId); mAvrcpService.getPlayerRoot(playerId, (a, b, c, d) -> setBrowsedPlayerResponse(a, b, c, d)); } void setBrowsedPlayerResponse(int playerId, boolean success, String currentPath, int numItems) { void setBrowsedPlayerResponse(int playerId, boolean success, String rootId, int numItems) { d( "setBrowsedPlayerResponse: playerId=" + playerId + " success=" + success + " currentPath=" + currentPath + " rootId=" + rootId + " numItems=" + numItems); setBrowsedPlayerResponseNative(playerId, success, currentPath, numItems); setBrowsedPlayerResponseNative(playerId, success, rootId, numItems); } int setAddressedPlayer(int playerId) { Loading
android/app/src/com/android/bluetooth/avrcp/AvrcpTargetService.java +3 −4 Original line number Diff line number Diff line Loading @@ -461,10 +461,9 @@ public class AvrcpTargetService extends ProfileService { return mMediaPlayerList.getMediaPlayerList(); } /** See {@link MediaPlayerList#setBrowsedPlayer}. */ void setBrowsedPlayer( int playerId, String currentPath, MediaPlayerList.SetBrowsedPlayerCallback cb) { mMediaPlayerList.setBrowsedPlayer(playerId, currentPath, cb); /** See {@link MediaPlayerList#getPlayerRoot}. */ void getPlayerRoot(int playerId, MediaPlayerList.GetPlayerRootCallback cb) { mMediaPlayerList.getPlayerRoot(playerId, cb); } /** See {@link MediaPlayerList#setAddressedPlayer}. */ Loading
system/btif/avrcp/avrcp_service.cc +2 −3 Original line number Diff line number Diff line Loading @@ -244,8 +244,7 @@ public: base::Bind(&MediaInterface::GetAddressedPlayer, base::Unretained(wrapped_), bound_cb)); } void SetBrowsedPlayer(uint16_t player_id, std::string current_path, SetBrowsedPlayerCallback browse_cb) override { void SetBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCallback browse_cb) override { auto cb_lambda = [](SetBrowsedPlayerCallback cb, bool success, std::string root_id, uint32_t num_items) { do_in_main_thread(base::BindOnce(cb, success, root_id, num_items)); Loading @@ -254,7 +253,7 @@ public: auto bound_cb = base::Bind(cb_lambda, browse_cb); do_in_jni_thread(base::Bind(&MediaInterface::SetBrowsedPlayer, base::Unretained(wrapped_), player_id, current_path, bound_cb)); player_id, bound_cb)); } void SetAddressedPlayer(uint16_t player_id, SetAddressedPlayerCallback addressed_cb) override { Loading