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

Commit 3f7e8c1a authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes from topic "bluetooth_server_configurable_flag" into main

* changes:
  Health based action: Enable first native flag
  [le audio] Add counter metrics for le audio health status
  [le audio] Add allow list check when le audio device connected
parents 2cbb6b8b aa0fe202
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ cc_library_shared {
        "libnativehelper",
        "libstatssocket",
        "libvndksupport",
        "server_configurable_flags",
    ],
    sanitize: {
        scs: true,
+40 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.bluetooth.le_audio;

import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.bluetooth.IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID;

import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.modules.utils.build.SdkLevel.isAtLeastU;

@@ -34,6 +35,7 @@ import android.bluetooth.BluetoothLeBroadcastMetadata;
import android.bluetooth.BluetoothLeBroadcastSettings;
import android.bluetooth.BluetoothLeBroadcastSubgroupSettings;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.bluetooth.BluetoothStatusCodes;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.IBluetoothLeAudio;
@@ -67,6 +69,7 @@ import android.util.Pair;

import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.btservice.storage.DatabaseManager;
@@ -1729,20 +1732,28 @@ public class LeAudioService extends ProfileService {
    }

    private void handleDeviceHealthAction(BluetoothDevice device, int action) {
        // To implement
        if (DBG) {
            Log.d(
                    TAG,
                    "handleDeviceHealthAction: "
                    "handleDeviceHealthAction: device: "
                            + device
                            + " action: "
                            + action
                            + ", not implemented");
        }
        if (action == LeAudioStackEvent.HEALTH_RECOMMENDATION_ACTION_DISABLE) {
            MetricsLogger.getInstance()
                    .count(
                            mAdapterService.isLeAudioAllowed(device)
                                    ? BluetoothProtoEnums
                                            .LE_AUDIO_ALLOWLIST_DEVICE_HEALTH_STATUS_BAD
                                    : BluetoothProtoEnums
                                            .LE_AUDIO_NONALLOWLIST_DEVICE_HEALTH_STATUS_BAD,
                            1);
        }
    }

    private void handleGroupHealthAction(int groupId, int action) {
        // To implement
        if (DBG) {
            Log.d(
                    TAG,
@@ -1752,6 +1763,31 @@ public class LeAudioService extends ProfileService {
                            + action
                            + ", not implemented");
        }
        BluetoothDevice device = getLeadDeviceForTheGroup(groupId);
        switch (action) {
            case LeAudioStackEvent.HEALTH_RECOMMENDATION_ACTION_DISABLE:
                MetricsLogger.getInstance()
                        .count(
                                mAdapterService.isLeAudioAllowed(device)
                                        ? BluetoothProtoEnums
                                                .LE_AUDIO_ALLOWLIST_GROUP_HEALTH_STATUS_BAD
                                        : BluetoothProtoEnums
                                                .LE_AUDIO_NONALLOWLIST_GROUP_HEALTH_STATUS_BAD,
                                1);
                break;
            case LeAudioStackEvent.HEALTH_RECOMMENDATION_ACTION_CONSIDER_DISABLING:
                MetricsLogger.getInstance()
                        .count(
                                mAdapterService.isLeAudioAllowed(device)
                                        ? BluetoothProtoEnums
                                                .LE_AUDIO_ALLOWLIST_GROUP_HEALTH_STATUS_TRENDING_BAD
                                        : BluetoothProtoEnums
                                                .LE_AUDIO_NONALLOWLIST_GROUP_HEALTH_STATUS_TRENDING_BAD,
                                1);
                break;
            default:
                break;
        }
    }

    private void handleGroupTransitToActive(int groupId) {
@@ -2197,7 +2233,7 @@ public class LeAudioService extends ProfileService {
                == LeAudioStackEvent.EVENT_TYPE_HEALTH_BASED_DEV_RECOMMENDATION) {
            handleDeviceHealthAction(stackEvent.device, stackEvent.valueInt1);
        } else if (stackEvent.type
                == LeAudioStackEvent.EVENT_TYPE_HEALTH_BASED_DEV_RECOMMENDATION) {
                == LeAudioStackEvent.EVENT_TYPE_HEALTH_BASED_GROUP_RECOMMENDATION) {
            handleGroupHealthAction(stackEvent.valueInt1, stackEvent.valueInt2);
        } else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_BROADCAST_CREATED) {
            int broadcastId = stackEvent.valueInt1;
+2 −2
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ public class LeAudioStackEvent {
                return "{group_id: " + value + "}";
            case EVENT_TYPE_HEALTH_BASED_DEV_RECOMMENDATION:
                switch (value) {
                    case HEALTH_RECOMMENDATION_ACTION_NONE:
                    case HEALTH_RECOMMENDATION_ACTION_DISABLE:
                        return "ACTION_DISABLE";
                    case HEALTH_RECOMMENDATION_ACTION_CONSIDER_DISABLING:
                        return "ACTION_CONSIDER_DISABLING";
@@ -236,7 +236,7 @@ public class LeAudioStackEvent {
                return "{state:" + broadcastStateToString(value) + "}";
            case EVENT_TYPE_HEALTH_BASED_GROUP_RECOMMENDATION:
                switch (value) {
                    case HEALTH_RECOMMENDATION_ACTION_NONE:
                    case HEALTH_RECOMMENDATION_ACTION_DISABLE:
                        return "ACTION_DISABLE";
                    case HEALTH_RECOMMENDATION_ACTION_CONSIDER_DISABLING:
                        return "ACTION_CONSIDER_DISABLING";
+13 −0
Original line number Diff line number Diff line
@@ -29,3 +29,16 @@ java_aconfig_library {
    ],
    min_sdk_version: "Tiramisu",
}

cc_aconfig_library {
    name: "bluetooth_flags_c_lib",
    aconfig_declarations: "bluetooth_aconfig_flags",
    host_supported: true,
    visibility: [
        "//packages/modules/Bluetooth/system:__subpackages__",
    ],
    apex_available: [
        "com.android.btservices",
    ],
    min_sdk_version: "Tiramisu",
}
+7 −0
Original line number Diff line number Diff line
@@ -13,3 +13,10 @@ flag {
    description: "Allow volume control for connected devices"
    bug: "307408418"
}

flag {
    name: "leaudio_enable_health_based_actions"
    namespace: "bluetooth"
    description: "Le audio device and group health actions for fallback mechanism"
    bug: "290845728"
}
 No newline at end of file
Loading