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

Commit 8efba3fe authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not disable LE audio offload as the developer option being disabled" into main

parents b8388cd9 4251ebec
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.development;

import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_SUPPORTED_PROPERTY;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_DISABLED_PROPERTY;

import android.bluetooth.BluetoothAdapter;
@@ -105,13 +106,14 @@ public class BluetoothLeAudioHwOffloadPreferenceController
                (mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
        final boolean leAudioOffloadSupported =
                SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false);
        final boolean a2dpOffloadDisabled =
                SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);
        if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
            ((TwoStatePreference) mPreference).setChecked(true);
            SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true");
        } else {
        final boolean a2dpOffloadSupported =
                SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false);

        if(!leAudioEnabled || !leAudioOffloadSupported || !a2dpOffloadSupported) {
            mPreference.setEnabled(false);
        } else {
            ((TwoStatePreference) mPreference).setChecked(false);
            SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "false");
        }
    }

+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED;

import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController
        .A2DP_OFFLOAD_DISABLED_PROPERTY;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController
        .A2DP_OFFLOAD_SUPPORTED_PROPERTY;
import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController
        .LE_AUDIO_OFFLOAD_DISABLED_PROPERTY;
import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController
@@ -120,4 +122,17 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest {
        leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false);
        assertThat(leAueioDisabled).isTrue();
    }

    @Test
    public void asDisableDeveloperOption_ResetLEOffloadBasedOnA2dpLeAudioOffloadSupported() {
        SystemProperties.set(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true));
        SystemProperties.set(A2DP_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true));

        SystemProperties.set(
                LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true));
        mController.onDeveloperOptionsSwitchDisabled();
        boolean leAueioDisabled =
                SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false);
        assertThat(leAueioDisabled).isFalse();
    }
}