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

Commit 0487263c authored by hughchen's avatar hughchen
Browse files

Add getMediaDeviceById() method

Add getMediaDeviceById() for get MediaDevice through unique id.

Bug: 121083246
Test: build pass
Change-Id: I8e44c3167cfe7d0fc84e8132219dd17c76b4360c
parent b88c7977
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -188,6 +188,23 @@ public class LocalMediaManager implements BluetoothCallback {
        mInfoMediaManager.stopScan();
    }

    /**
     * Find the MediaDevice through id.
     *
     * @param devices the list of MediaDevice
     * @param id the unique id of MediaDevice
     * @return MediaDevice
     */
    public MediaDevice getMediaDeviceById(List<MediaDevice> devices, String id) {
        for (MediaDevice mediaDevice : devices) {
            if (mediaDevice.getId().equals(id)) {
                return mediaDevice;
            }
        }
        Log.i(TAG, "getMediaDeviceById() can't found device");
        return null;
    }

    class MediaDeviceCallback implements MediaManager.MediaDeviceCallback {
        @Override
        public void onDeviceAdded(MediaDevice device) {