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

Commit 3183361e authored by Srinivas Patibandla's avatar Srinivas Patibandla Committed by Android (Google) Code Review
Browse files

Merge "24Q3: Remove Flag enable_hide_exclusively_managed_bluetooth_device" into main

parents fd00951f 402f2a6c
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -36,13 +36,6 @@ flag {
    bug: "388674074"
}

flag {
    name: "enable_hide_exclusively_managed_bluetooth_device"
    namespace: "dck_framework"
    description: "Hide exclusively managed Bluetooth devices in BT settings menu."
    bug: "324475542"
}

flag {
    name: "enable_set_preferred_transport_for_le_audio_device"
    namespace: "bluetooth"
+2 −5
Original line number Diff line number Diff line
@@ -99,10 +99,7 @@ public class HearingDevicesChecker {

    private boolean isExclusivelyManagedBluetoothDevice(
            @NonNull CachedBluetoothDevice cachedDevice) {
        if (com.android.settingslib.flags.Flags.enableHideExclusivelyManagedBluetoothDevice()) {
        return BluetoothUtils.isExclusivelyManagedBluetoothDevice(mContext,
                cachedDevice.getDevice());
    }
        return false;
    }
}
+10 −25
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context
import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.flags.Flags
import com.android.systemui.res.R

private val backgroundOn = R.drawable.settingslib_switch_bar_bg_on
@@ -222,12 +221,8 @@ internal class ConnectedDeviceItemFactory : DeviceItemFactory() {
        isOngoingCall: Boolean,
        audioSharingAvailable: Boolean,
    ): Boolean {
        return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
            !BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
        return !BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
            BluetoothUtils.isConnectedBluetoothDevice(cachedDevice, isOngoingCall)
        } else {
            BluetoothUtils.isConnectedBluetoothDevice(cachedDevice, isOngoingCall)
        }
    }

    override fun create(context: Context, cachedDevice: CachedBluetoothDevice): DeviceItem {
@@ -250,13 +245,9 @@ internal open class SavedDeviceItemFactory : DeviceItemFactory() {
        isOngoingCall: Boolean,
        audioSharingAvailable: Boolean,
    ): Boolean {
        return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
            !BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
        return !BluetoothUtils.isExclusivelyManagedBluetoothDevice(context, cachedDevice.device) &&
            cachedDevice.bondState == BluetoothDevice.BOND_BONDED &&
            !cachedDevice.isConnected
        } else {
            cachedDevice.bondState == BluetoothDevice.BOND_BONDED && !cachedDevice.isConnected
        }
    }

    override fun create(context: Context, cachedDevice: CachedBluetoothDevice): DeviceItem {
@@ -279,18 +270,12 @@ internal class SavedHearingDeviceItemFactory : SavedDeviceItemFactory() {
        isOngoingCall: Boolean,
        audioSharingAvailable: Boolean,
    ): Boolean {
        return if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
            !BluetoothUtils.isExclusivelyManagedBluetoothDevice(
        return !BluetoothUtils.isExclusivelyManagedBluetoothDevice(
            context,
            cachedDevice.getDevice(),
        ) &&
            cachedDevice.isHearingAidDevice &&
            cachedDevice.bondState == BluetoothDevice.BOND_BONDED &&
            !cachedDevice.isConnected
        } else {
            cachedDevice.isHearingAidDevice &&
                cachedDevice.bondState == BluetoothDevice.BOND_BONDED &&
                !cachedDevice.isConnected
        }
    }
}
+0 −72
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.systemui.bluetooth.qsdialog

import android.bluetooth.BluetoothDevice
import android.graphics.drawable.Drawable
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper
import android.util.Pair
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -29,7 +27,6 @@ import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.flags.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.res.R
import com.google.common.truth.Truth.assertThat
@@ -208,42 +205,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_bondedAndNotConnected_returnsTrue() {
        `when`(cachedDevice.bondState).thenReturn(BluetoothDevice.BOND_BONDED)
        `when`(cachedDevice.isConnected).thenReturn(false)

        assertThat(
                savedDeviceItemFactory.isFilterMatched(context, cachedDevice, isOngoingCall = false)
            )
            .isTrue()
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_connected_returnsFalse() {
        `when`(cachedDevice.bondState).thenReturn(BluetoothDevice.BOND_BONDED)
        `when`(cachedDevice.isConnected).thenReturn(true)

        assertThat(
                savedDeviceItemFactory.isFilterMatched(context, cachedDevice, isOngoingCall = false)
            )
            .isFalse()
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_notBonded_returnsFalse() {
        `when`(cachedDevice.bondState).thenReturn(BluetoothDevice.BOND_NONE)

        assertThat(
                savedDeviceItemFactory.isFilterMatched(context, cachedDevice, isOngoingCall = false)
            )
            .isFalse()
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_exclusivelyManaged_returnsFalse() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(true)
@@ -255,7 +216,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_notExclusiveManaged_returnsTrue() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(false)
@@ -269,7 +229,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testSavedFactory_isFilterMatched_notExclusivelyManaged_connected_returnsFalse() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(false)
@@ -283,35 +242,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testConnectedFactory_isFilterMatched_bondedAndConnected_returnsTrue() {
        `when`(BluetoothUtils.isConnectedBluetoothDevice(any(), any())).thenReturn(true)

        assertThat(
                connectedDeviceItemFactory.isFilterMatched(
                    context,
                    cachedDevice,
                    isOngoingCall = false,
                )
            )
            .isTrue()
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testConnectedFactory_isFilterMatched_notConnected_returnsFalse() {
        assertThat(
                connectedDeviceItemFactory.isFilterMatched(
                    context,
                    cachedDevice,
                    isOngoingCall = false,
                )
            )
            .isFalse()
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testConnectedFactory_isFilterMatched_exclusivelyManaged_returnsFalse() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(true)
@@ -327,7 +257,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testConnectedFactory_isFilterMatched_noExclusiveManager_returnsTrue() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(false)
@@ -344,7 +273,6 @@ class DeviceItemFactoryTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_HIDE_EXCLUSIVELY_MANAGED_BLUETOOTH_DEVICE)
    fun testConnectedFactory_isFilterMatched_notExclusivelyManaged_notConnected_returnsFalse() {
        `when`(cachedDevice.device).thenReturn(bluetoothDevice)
        `when`(BluetoothUtils.isExclusivelyManagedBluetoothDevice(any(), any())).thenReturn(false)