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

Commit fcb58dac authored by Jakub Rotkiewicz (xWF)'s avatar Jakub Rotkiewicz (xWF) Committed by Gerrit Code Review
Browse files

Merge changes I273ae658,I1231a9e6,I326d9762 into main

* changes:
  24Q4: Removal of headset_client_am_hf_volume_symmetric
  24Q4: Removal of adm_fallback_when_wired_audio_disconnected
  24Q4: Removal of adm_always_fallback_to_available_device
parents 9b2d5aa7 887acd0f
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -867,9 +867,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
        @Override
        public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
            Log.d(TAG, "onAudioDevicesRemoved");
            if (!Flags.admFallbackWhenWiredAudioDisconnected()) {
                return;
            }
            if (!Arrays.stream(removedDevices)
                    .anyMatch(AudioManagerAudioDeviceCallback::isWiredAudioHeadset)) {
                return;
@@ -1236,15 +1233,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
            if (Objects.equals(a2dpFallbackDevice, device)) {
                Log.d(TAG, "Found an A2DP fallback device: " + device);
                setA2dpActiveDevice(device);
                if (Flags.admAlwaysFallbackToAvailableDevice()) {
                setHfpActiveDevice(headsetFallbackDevice);
                } else {
                    if (Objects.equals(headsetFallbackDevice, device)) {
                        setHfpActiveDevice(device);
                    } else {
                        setHfpActiveDevice(null);
                    }
                }
                /* If dual mode is enabled, LEA will be made active once all supported
                classic audio profiles are made active for the device. */
                if (!Utils.isDualModeAudioEnabled()) {
@@ -1275,15 +1264,7 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
            if (Objects.equals(headsetFallbackDevice, device)) {
                Log.d(TAG, "Found a HFP fallback device: " + device);
                setHfpActiveDevice(device);
                if (Flags.admAlwaysFallbackToAvailableDevice()) {
                    setA2dpActiveDevice(a2dpFallbackDevice);
                } else {
                    if (Objects.equals(a2dpFallbackDevice, device)) {
                setA2dpActiveDevice(a2dpFallbackDevice);
                    } else {
                        setA2dpActiveDevice(null, true);
                    }
                }
                if (!Utils.isDualModeAudioEnabled()) {
                    setLeAudioActiveDevice(null, true);
                }
+9 −22
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

@@ -180,18 +179,12 @@ public class HeadsetClientService extends ProfileService {
    int hfToAmVol(int hfVol) {
        int amRange = mMaxAmVcVol - mMinAmVcVol;
        int hfRange = MAX_HFP_SCO_VOICE_CALL_VOLUME - MIN_HFP_SCO_VOICE_CALL_VOLUME;
        int amVol = 0;
        if (Flags.headsetClientAmHfVolumeSymmetric()) {
            amVol =
        int amVol =
                (int)
                                Math.round(
                                        (hfVol - MIN_HFP_SCO_VOICE_CALL_VOLUME)
                                                * ((double) amRange / hfRange))
                        + mMinAmVcVol;
        } else {
            int amOffset = (amRange * (hfVol - MIN_HFP_SCO_VOICE_CALL_VOLUME)) / hfRange;
            amVol = mMinAmVcVol + amOffset;
        }
        Log.d(TAG, "HF -> AM " + hfVol + " " + amVol);
        return amVol;
    }
@@ -199,15 +192,9 @@ public class HeadsetClientService extends ProfileService {
    int amToHfVol(int amVol) {
        int amRange = (mMaxAmVcVol > mMinAmVcVol) ? (mMaxAmVcVol - mMinAmVcVol) : 1;
        int hfRange = MAX_HFP_SCO_VOICE_CALL_VOLUME - MIN_HFP_SCO_VOICE_CALL_VOLUME;
        int hfVol = 0;
        if (Flags.headsetClientAmHfVolumeSymmetric()) {
            hfVol =
        int hfVol =
                (int) Math.round((amVol - mMinAmVcVol) * ((double) hfRange / amRange))
                        + MIN_HFP_SCO_VOICE_CALL_VOLUME;
        } else {
            int hfOffset = (hfRange * (amVol - mMinAmVcVol)) / amRange;
            hfVol = MIN_HFP_SCO_VOICE_CALL_VOLUME + hfOffset;
        }
        Log.d(TAG, "AM -> HF " + amVol + " " + hfVol);
        return hfVol;
    }
+0 −2
Original line number Diff line number Diff line
@@ -589,7 +589,6 @@ public class ActiveDeviceManagerTest {
    }

    @Test
    @EnableFlags(Flags.FLAG_ADM_ALWAYS_FALLBACK_TO_AVAILABLE_DEVICE)
    public void a2dpHeadsetActivated_checkFallbackMeachanismOneA2dpOneHeadset() {
        // Active call
        when(mAudioManager.getMode()).thenReturn(AudioManager.MODE_IN_CALL);
@@ -1721,7 +1720,6 @@ public class ActiveDeviceManagerTest {

    /** A wired audio device is disconnected. Check if falls back to connected A2DP. */
    @Test
    @EnableFlags(Flags.FLAG_ADM_FALLBACK_WHEN_WIRED_AUDIO_DISCONNECTED)
    public void wiredAudioDeviceDisconnected_setFallbackDevice() throws Exception {
        AudioDeviceInfo[] testDevices = createAudioDeviceInfoTestDevices();

+0 −6
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.BatteryManager;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;

import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;
@@ -49,7 +47,6 @@ import com.android.bluetooth.TestUtils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.RemoteDevices;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.flags.Flags;

import org.junit.After;
import org.junit.Assert;
@@ -71,7 +68,6 @@ import java.util.concurrent.TimeUnit;
@RunWith(AndroidJUnit4.class)
public class HeadsetClientServiceTest {
    @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
    @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    @Mock private AdapterService mAdapterService;
    @Mock private HeadsetClientStateMachine mStateMachine;
@@ -211,7 +207,6 @@ public class HeadsetClientServiceTest {
     * back HF values and checks if they match AM. This proves that the conversion is symmetric.
     */
    @Test
    @EnableFlags(Flags.FLAG_HEADSET_CLIENT_AM_HF_VOLUME_SYMMETRIC)
    public void testAmHfVolumeSymmetric_AmLowerRange() {
        int amMin = 1;
        int amMax = 10;
@@ -241,7 +236,6 @@ public class HeadsetClientServiceTest {
     * back AM values and checks if they match HF. This proves that the conversion is symmetric.
     */
    @Test
    @EnableFlags(Flags.FLAG_HEADSET_CLIENT_AM_HF_VOLUME_SYMMETRIC)
    public void testAmHfVolumeSymmetric_HfLowerRange() {
        int amMin = 1;
        int amMax = 20;
+0 −20
Original line number Diff line number Diff line
package: "com.android.bluetooth.flags"
container: "com.android.bt"

flag {
    name: "adm_fallback_when_wired_audio_disconnected"
    namespace: "bluetooth"
    description: "Fallback to other connected device when wired audio device disconnects"
    bug: "348124361"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "adm_always_fallback_to_available_device"
    namespace: "bluetooth"
    description: "Fix audio path and always fallback to available device"
    bug: "351820274"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "adm_verify_active_fallback_device"
    namespace: "bluetooth"
Loading