Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0b6ced3 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12755599 from f304c1fc to 25Q1-release

Change-Id: Ied257f640e8b4d7ee3d065c4a5031fc32bedc4ff
parents a8b0cbd3 f304c1fc
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -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);
@@ -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 {
@@ -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__);
@@ -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) {
@@ -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},
+10 −22
Original line number Diff line number Diff line
@@ -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);
    }

@@ -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(
@@ -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()) {
+9 −8
Original line number Diff line number Diff line
@@ -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) {
+3 −4
Original line number Diff line number Diff line
@@ -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}. */
+1 −2
Original line number Diff line number Diff line
@@ -709,7 +709,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
                            + device
                            + ", mHfpActiveDevice="
                            + mHfpActiveDevice);

            if (!Objects.equals(mHfpActiveDevice, device)) {
                if (device != null) {
                    setHearingAidActiveDevice(null, true);
@@ -717,7 +716,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac

                updateLeAudioActiveDeviceIfDualMode(mHfpActiveDevice, device);

                if (!Utils.isDualModeAudioEnabled() || device == null) {
                if ((!Utils.isDualModeAudioEnabled() && device == null)) {
                    Log.d(TAG, "HFP active device is null. Try to fallback to the active device.");
                    synchronized (mLock) {
                        setFallbackDeviceActiveLocked(null);
Loading