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

Commit a438c096 authored by Iván Budnik's avatar Iván Budnik Committed by Android (Google) Code Review
Browse files

Merge changes I03558fce,Ib0f0c4dc,Ia6b2fb2a into main

* changes:
  Remove MediaDeviceUtils and MediaDeviceUtilsTest
  Remove unused method in MediaDeviceUtils
  Inline MediaDeviceUtils methods
parents 037bc736 0dda43c0
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECT

import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHearingAid;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
@@ -98,7 +99,12 @@ public class BluetoothMediaDevice extends MediaDevice {

    @Override
    public String getId() {
        return MediaDeviceUtils.getId(mCachedDevice);
        if (mCachedDevice.isHearingAidDevice()) {
            if (mCachedDevice.getHiSyncId() != BluetoothHearingAid.HI_SYNC_ID_INVALID) {
                return Long.toString(mCachedDevice.getHiSyncId());
            }
        }
        return mCachedDevice.getAddress();
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class ComplexMediaDevice extends MediaDevice {

    @Override
    public String getId() {
        return MediaDeviceUtils.getId(mRouteInfo);
        return mRouteInfo.getId();
    }

    public boolean isConnected() {
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public class InfoMediaDevice extends MediaDevice {

    @Override
    public String getId() {
        return MediaDeviceUtils.getId(mRouteInfo);
        return mRouteInfo.getId();
    }

    public boolean isConnected() {
+0 −62
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.settingslib.media;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHearingAid;
import android.media.MediaRoute2Info;

import com.android.settingslib.bluetooth.CachedBluetoothDevice;

/**
 * MediaDeviceUtils provides utility function for MediaDevice
 */
public class MediaDeviceUtils {
    /**
     * Use CachedBluetoothDevice address to represent unique id
     *
     * @param cachedDevice the CachedBluetoothDevice
     * @return CachedBluetoothDevice address
     */
    public static String getId(CachedBluetoothDevice cachedDevice) {
        if (cachedDevice.isHearingAidDevice()) {
            if (cachedDevice.getHiSyncId() != BluetoothHearingAid.HI_SYNC_ID_INVALID) {
                return Long.toString(cachedDevice.getHiSyncId());
            }
        }
        return cachedDevice.getAddress();
    }

    /**
     * Use BluetoothDevice address to represent unique id
     *
     * @param bluetoothDevice the BluetoothDevice
     * @return BluetoothDevice address
     */
    public static String getId(BluetoothDevice bluetoothDevice) {
        return bluetoothDevice.getAddress();
    }

    /**
     * Use MediaRoute2Info id to represent unique id
     *
     * @param route the MediaRoute2Info
     * @return MediaRoute2Info id
     */
    public static String getId(MediaRoute2Info route) {
        return route.getId();
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class BluetoothMediaDeviceTest {

    private static final String TEST_ADDRESS = "11:22:33:44:55:66";

    @Mock
    private CachedBluetoothDevice mDevice;

@@ -111,4 +113,10 @@ public class BluetoothMediaDeviceTest {

        assertThat(mBluetoothMediaDevice.getIcon() instanceof BitmapDrawable).isFalse();
    }

    @Test
    public void getId_returnsCachedBluetoothDeviceAddress() {
        when(mDevice.getAddress()).thenReturn(TEST_ADDRESS);
        assertThat(mBluetoothMediaDevice.getId()).isEqualTo(TEST_ADDRESS);
    }
}
Loading