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

Commit 0a066413 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Add logging for LE Audio toggle enable/disable" into main

parents 3b5b88f6 c79f368d
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settings.bluetooth;

import static android.bluetooth.BluetoothDevice.METADATA_MODEL_NAME;

import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
@@ -83,6 +84,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
    private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true;
    private static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY =
            "persist.bluetooth.leaudio.toggle_visible";
    private static final String BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY =
            "persist.bluetooth.leaudio.bypass_allow_list";

    private Set<String> mInvisibleProfiles = Collections.emptySet();
    private final AtomicReference<Set<String>> mAdditionalInvisibleProfiles =
@@ -378,6 +381,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
        return result;
    }

    private boolean isCurrentDeviceInOrByPassAllowList() {
        if (!SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true)) {
            return false;
        }
        return SystemProperties.getBoolean(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, false)
                || isModelNameInAllowList(
                BluetoothUtils.getStringMetaData(
                        mCachedDevice.getDevice(), METADATA_MODEL_NAME));
    }

    /**
     * Disable the Le Audio profile for each of the Le Audio devices.
     *
@@ -389,6 +402,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            return;
        }

        mMetricsFeatureProvider.action(
                mContext,
                SettingsEnums.ACTION_BLUETOOTH_PROFILE_LE_AUDIO_OFF,
                isCurrentDeviceInOrByPassAllowList());

        LocalBluetoothProfile asha = mProfileManager.getHearingAidProfile();
        LocalBluetoothProfile broadcastAssistant =
                mProfileManager.getLeAudioBroadcastAssistantProfile();
@@ -427,6 +445,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            return;
        }

        mMetricsFeatureProvider.action(
                mContext,
                SettingsEnums.ACTION_BLUETOOTH_PROFILE_LE_AUDIO_ON,
                isCurrentDeviceInOrByPassAllowList());

        if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) {
            Log.i(TAG, "Disabling classic audio profiles because dual mode is disabled");
            disableProfileBeforeUserEnablesLeAudio(mProfileManager.getA2dpProfile());