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

Commit 5e8e1531 authored by William Escande's avatar William Escande
Browse files

Revert^2 "Use Collections for empty list return"

This reverts commit a9ddf816.

Reason for revert: Relanding the feature after proper testing

Delta with original CL is in audio_util/helpers/Util.java
The toMetadataList should return a modifiable list and not an immutable
collection

Bug: 331250048
Bug: 331494257
Test: atest BluetoothInstrumentationTests
Flag: Exempt, code cleanup
Change-Id: I84b1eab66dc7f4da3ef4e65d4bdaa8f5a0f847f9
parent c47a45d3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@@ -1364,7 +1365,7 @@ public class A2dpService extends ProfileService {
        public List<BluetoothDevice> getConnectedDevices(AttributionSource source) {
            A2dpService service = getService(source);
            if (service == null) {
                return new ArrayList<>();
                return Collections.emptyList();
            }

            return service.getConnectedDevices();
@@ -1375,7 +1376,7 @@ public class A2dpService extends ProfileService {
                int[] states, AttributionSource source) {
            A2dpService service = getService(source);
            if (service == null) {
                return new ArrayList<>();
                return Collections.emptyList();
            }

            return service.getDevicesMatchingConnectionStates(states);
@@ -1467,7 +1468,7 @@ public class A2dpService extends ProfileService {
        public List<BluetoothCodecType> getSupportedCodecTypes(AttributionSource source) {
            A2dpService service = getService(source);
            if (service == null) {
                return new ArrayList<>();
                return Collections.emptyList();
            }

            enforceBluetoothPrivilegedPermission(service);
+3 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -248,7 +249,7 @@ public class A2dpSinkService extends ProfileService {
        public List<BluetoothDevice> getConnectedDevices(AttributionSource source) {
            A2dpSinkService service = getService(source);
            if (service == null) {
                return new ArrayList<BluetoothDevice>(0);
                return Collections.emptyList();
            }
            return service.getConnectedDevices();
        }
@@ -258,7 +259,7 @@ public class A2dpSinkService extends ProfileService {
                int[] states, AttributionSource source) {
            A2dpSinkService service = getService(source);
            if (service == null) {
                return new ArrayList<BluetoothDevice>(0);
                return Collections.emptyList();
            }
            return service.getDevicesMatchingConnectionStates(states);
        }
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ class Util {
     */
    public static List<Metadata> toMetadataList(Context context,
            List<MediaSession.QueueItem> items) {
        ArrayList<Metadata> list = new ArrayList<Metadata>();
        ArrayList<Metadata> list = new ArrayList<>();

        if (items == null) return list;

@@ -125,7 +125,7 @@ class Util {
            Metadata data = toMetadata(context, items.get(i));
            if (isEmptyData(data)) {
                Log.e(TAG, "Received an empty Metadata item in list. Returning an empty queue");
                return new ArrayList<Metadata>();
                return new ArrayList<>();
            }
            data.trackNum = "" + (i + 1);
            data.numTracks = "" + items.size();
+3 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -382,7 +383,7 @@ public class AvrcpControllerService extends ProfileService {
        public List<BluetoothDevice> getConnectedDevices(AttributionSource source) {
            AvrcpControllerService service = getService(source);
            if (service == null) {
                return new ArrayList<BluetoothDevice>(0);
                return Collections.emptyList();
            }
            return service.getConnectedDevices();
        }
@@ -392,7 +393,7 @@ public class AvrcpControllerService extends ProfileService {
                int[] states, AttributionSource source) {
            AvrcpControllerService service = getService(source);
            if (service == null) {
                return new ArrayList<BluetoothDevice>(0);
                return Collections.emptyList();
            }
            return service.getDevicesMatchingConnectionStates(states);
        }
+1 −1
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ class AvrcpControllerStateMachine extends StateMachine {
        if (mCoverArtManager == null) return;
        AvrcpItem currentTrack = getCurrentTrack();
        String currentTrackUuid = currentTrack != null ? currentTrack.getCoverArtUuid() : null;
        ArrayList<String> unusedArtwork = mBrowseTree.getAndClearUnusedCoverArt();
        List<String> unusedArtwork = mBrowseTree.getAndClearUnusedCoverArt();
        for (String uuid : unusedArtwork) {
            if (!uuid.equals(currentTrackUuid)) {
                mCoverArtManager.removeImage(mDevice, uuid);
Loading