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

Commit a2d70c88 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Offset browsing media entry UID by one

Offset AVRCP UID by one for browsing since UID 0 is reserved for
getElementAttributes.

Bug: 31962824
Change-Id: I7efcd0546ebb0d02b4b1bfb05038a86d9fa0835f
parent 1e06bd57
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -741,22 +741,23 @@ class BrowsedMediaPlayer {

    /* convert uid to mediaId */
    private String byteToString(byte[] byteArray) {
        int key = new BigInteger(byteArray).intValue();
        String value = mHmap.get(key);
        return value;
        int uid = new BigInteger(byteArray).intValue();
        String mediaId = mHmap.get(uid);
        return mediaId;
    }

    /* convert mediaId to uid */
    private byte[] stringToByte(String mediaId) {
        /* check if this mediaId already exists in hashmap */
        if (!mHmap.containsValue(mediaId)) { /* add to hashmap */
            int key = mHmap.size();
            mHmap.put(key, mediaId);
            return intToByteArray(key);
            // Offset by one as uid 0 is reserved
            int uid = mHmap.size() + 1;
            mHmap.put(uid, mediaId);
            return intToByteArray(uid);
        } else { /* search key for give mediaId */
            for (int key : mHmap.keySet()) {
                if (mHmap.get(key).equals(mediaId)) {
                    return intToByteArray(key);
            for (int uid : mHmap.keySet()) {
                if (mHmap.get(uid).equals(mediaId)) {
                    return intToByteArray(uid);
                }
            }
        }