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

Commit f19b01e5 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12763142 from da3f18f2 to 25Q1-release

Change-Id: I91b9e0303abd4f1bdde7ac478d900375b30d9cb7
parents e0b6ced3 da3f18f2
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -279,10 +279,6 @@ public class AdapterService extends Service {


    private final BluetoothHciVendorSpecificDispatcher mBluetoothHciVendorSpecificDispatcher =
    private final BluetoothHciVendorSpecificDispatcher mBluetoothHciVendorSpecificDispatcher =
            new BluetoothHciVendorSpecificDispatcher();
            new BluetoothHciVendorSpecificDispatcher();
    private final BluetoothHciVendorSpecificNativeInterface
            mBluetoothHciVendorSpecificNativeInterface =
                    new BluetoothHciVendorSpecificNativeInterface(
                            mBluetoothHciVendorSpecificDispatcher);


    private final Looper mLooper;
    private final Looper mLooper;
    private final AdapterServiceHandler mHandler;
    private final AdapterServiceHandler mHandler;
@@ -347,6 +343,7 @@ public class AdapterService extends Service {
    private BassClientService mBassClientService;
    private BassClientService mBassClientService;
    private BatteryService mBatteryService;
    private BatteryService mBatteryService;
    private BluetoothQualityReportNativeInterface mBluetoothQualityReportNativeInterface;
    private BluetoothQualityReportNativeInterface mBluetoothQualityReportNativeInterface;
    private BluetoothHciVendorSpecificNativeInterface mBluetoothHciVendorSpecificNativeInterface;
    private GattService mGattService;
    private GattService mGattService;
    private ScanController mScanController;
    private ScanController mScanController;


@@ -697,7 +694,11 @@ public class AdapterService extends Service {
        mBluetoothQualityReportNativeInterface.init();
        mBluetoothQualityReportNativeInterface.init();


        if (Flags.hciVendorSpecificExtension()) {
        if (Flags.hciVendorSpecificExtension()) {
            mBluetoothHciVendorSpecificNativeInterface.init();
            mBluetoothHciVendorSpecificNativeInterface =
                    requireNonNull(
                            mBluetoothHciVendorSpecificNativeInterface.getInstance(),
                            "mBluetoothHciVendorSpecificNativeInterface cannot be null");
            mBluetoothHciVendorSpecificNativeInterface.init(mBluetoothHciVendorSpecificDispatcher);
        }
        }


        mSdpManager = new SdpManager(this, mLooper);
        mSdpManager = new SdpManager(this, mLooper);
+29 −6
Original line number Original line Diff line number Diff line
@@ -16,16 +16,39 @@


package com.android.bluetooth.btservice;
package com.android.bluetooth.btservice;


class BluetoothHciVendorSpecificNativeInterface {
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

public class BluetoothHciVendorSpecificNativeInterface {
    private static final String TAG = "BluetoothHciVendorSpecificNativeInterface";
    private static final String TAG = "BluetoothHciVendorSpecificNativeInterface";
    private final BluetoothHciVendorSpecificDispatcher mDispatcher;


    public BluetoothHciVendorSpecificNativeInterface(
    @GuardedBy("INSTANCE_LOCK")
            BluetoothHciVendorSpecificDispatcher dispatcher) {
    private static BluetoothHciVendorSpecificNativeInterface sInstance;
        mDispatcher = dispatcher;

    private static final Object INSTANCE_LOCK = new Object();

    /** Get singleton instance. */
    public static BluetoothHciVendorSpecificNativeInterface getInstance() {
        synchronized (INSTANCE_LOCK) {
            if (sInstance == null) {
                sInstance = new BluetoothHciVendorSpecificNativeInterface();
            }
            return sInstance;
        }
    }
    }


    void init() {
    /** Set singleton instance. */
    @VisibleForTesting
    static void setInstance(BluetoothHciVendorSpecificNativeInterface instance) {
        synchronized (INSTANCE_LOCK) {
            sInstance = instance;
        }
    }

    private BluetoothHciVendorSpecificDispatcher mDispatcher;

    void init(BluetoothHciVendorSpecificDispatcher dispatcher) {
        mDispatcher = dispatcher;
        initNative();
        initNative();
    }
    }


+60 −1
Original line number Original line Diff line number Diff line
@@ -1334,6 +1334,13 @@ public class GattService extends ProfileService {
        if (app != null) {
        if (app != null) {
            app.callback.onClientConnectionState(
            app.callback.onClientConnectionState(
                    status, clientIf, (status == BluetoothGatt.GATT_SUCCESS), address);
                    status, clientIf, (status == BluetoothGatt.GATT_SUCCESS), address);
            MetricsLogger.getInstance()
                    .logBluetoothEvent(
                            getDevice(address),
                            BluetoothStatsLog
                                    .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA,
                            connectionStatusToState(status),
                            app.appUid);
        }
        }
        statsLogGattConnectionStateChange(
        statsLogGattConnectionStateChange(
                BluetoothProfile.GATT, address, clientIf, connectionState, status);
                BluetoothProfile.GATT, address, clientIf, connectionState, status);
@@ -1379,6 +1386,13 @@ public class GattService extends ProfileService {


        if (app != null) {
        if (app != null) {
            app.callback.onClientConnectionState(status, clientIf, false, address);
            app.callback.onClientConnectionState(status, clientIf, false, address);
            MetricsLogger.getInstance()
                    .logBluetoothEvent(
                            getDevice(address),
                            BluetoothStatsLog
                                    .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA,
                            BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS,
                            app.appUid);
        }
        }
        statsLogGattConnectionStateChange(
        statsLogGattConnectionStateChange(
                BluetoothProfile.GATT,
                BluetoothProfile.GATT,
@@ -1930,7 +1944,6 @@ public class GattService extends ProfileService {
        for (Map.Entry<Integer, String> entry : connMap.entrySet()) {
        for (Map.Entry<Integer, String> entry : connMap.entrySet()) {
            Log.d(TAG, "disconnecting addr:" + entry.getValue());
            Log.d(TAG, "disconnecting addr:" + entry.getValue());
            clientDisconnect(entry.getKey(), entry.getValue(), attributionSource);
            clientDisconnect(entry.getKey(), entry.getValue(), attributionSource);
            // clientDisconnect(int clientIf, String address)
        }
        }
    }
    }


@@ -2156,6 +2169,15 @@ public class GattService extends ProfileService {
        }
        }


        Log.d(TAG, "unregisterClient() - clientIf=" + clientIf);
        Log.d(TAG, "unregisterClient() - clientIf=" + clientIf);
        for (ContextMap.Connection conn : mClientMap.getConnectionByApp(clientIf)) {
            MetricsLogger.getInstance()
                    .logBluetoothEvent(
                            getDevice(conn.address),
                            BluetoothStatsLog
                                    .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA,
                            BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__END,
                            attributionSource.getUid());
        }
        mClientMap.remove(clientIf);
        mClientMap.remove(clientIf);
        mNativeInterface.gattClientUnregisterApp(clientIf);
        mNativeInterface.gattClientUnregisterApp(clientIf);
    }
    }
@@ -2198,6 +2220,18 @@ public class GattService extends ProfileService {
                BluetoothProtoEnums.CONNECTION_STATE_CONNECTING,
                BluetoothProtoEnums.CONNECTION_STATE_CONNECTING,
                -1);
                -1);


        MetricsLogger.getInstance()
                .logBluetoothEvent(
                        getDevice(address),
                        BluetoothStatsLog
                                .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA,
                        isDirect
                                ? BluetoothStatsLog
                                        .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__DIRECT_CONNECT
                                : BluetoothStatsLog
                                        .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__INDIRECT_CONNECT,
                        attributionSource.getUid());

        int preferredMtu = 0;
        int preferredMtu = 0;


        // Some applications expect MTU to be exchanged immediately on connections
        // Some applications expect MTU to be exchanged immediately on connections
@@ -2248,6 +2282,13 @@ public class GattService extends ProfileService {
                clientIf,
                clientIf,
                BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING,
                BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING,
                -1);
                -1);
        MetricsLogger.getInstance()
                .logBluetoothEvent(
                        getDevice(address),
                        BluetoothStatsLog
                                .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA,
                        BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__START,
                        attributionSource.getUid());
        mNativeInterface.gattClientDisconnect(clientIf, address, connId != null ? connId : 0);
        mNativeInterface.gattClientDisconnect(clientIf, address, connId != null ? connId : 0);
    }
    }


@@ -3797,6 +3838,24 @@ public class GattService extends ProfileService {
        mTransitionalScanHelper.dumpProto(builder);
        mTransitionalScanHelper.dumpProto(builder);
    }
    }


    private BluetoothDevice getDevice(String address) {
        byte[] addressBytes = Utils.getBytesFromAddress(address);
        return mAdapterService.getDeviceFromByte(addressBytes);
    }

    private static int connectionStatusToState(int status) {
        return switch (status) {
                // GATT_SUCCESS
            case 0x00 -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS;
                // GATT_CONNECTION_TIMEOUT
            case 0x93 ->
                    BluetoothStatsLog
                            .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__CONNECTION_TIMEOUT;
                // For now all other errors are bucketed together.
            default -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__FAIL;
        };
    }

    /**************************************************************************
    /**************************************************************************
     * GATT Test functions
     * GATT Test functions
     *************************************************************************/
     *************************************************************************/
+3 −0
Original line number Original line Diff line number Diff line
@@ -155,6 +155,7 @@ public class AdapterServiceTest {
    private @Mock AdapterNativeInterface mNativeInterface;
    private @Mock AdapterNativeInterface mNativeInterface;
    private @Mock BluetoothKeystoreNativeInterface mKeystoreNativeInterface;
    private @Mock BluetoothKeystoreNativeInterface mKeystoreNativeInterface;
    private @Mock BluetoothQualityReportNativeInterface mQualityNativeInterface;
    private @Mock BluetoothQualityReportNativeInterface mQualityNativeInterface;
    private @Mock BluetoothHciVendorSpecificNativeInterface mHciVendorSpecificNativeInterface;
    private @Mock SdpManagerNativeInterface mSdpNativeInterface;
    private @Mock SdpManagerNativeInterface mSdpNativeInterface;
    private @Mock AdvertiseManagerNativeInterface mAdvertiseNativeInterface;
    private @Mock AdvertiseManagerNativeInterface mAdvertiseNativeInterface;
    private @Mock DistanceMeasurementNativeInterface mDistanceNativeInterface;
    private @Mock DistanceMeasurementNativeInterface mDistanceNativeInterface;
@@ -226,6 +227,7 @@ public class AdapterServiceTest {
        AdapterNativeInterface.setInstance(mNativeInterface);
        AdapterNativeInterface.setInstance(mNativeInterface);
        BluetoothKeystoreNativeInterface.setInstance(mKeystoreNativeInterface);
        BluetoothKeystoreNativeInterface.setInstance(mKeystoreNativeInterface);
        BluetoothQualityReportNativeInterface.setInstance(mQualityNativeInterface);
        BluetoothQualityReportNativeInterface.setInstance(mQualityNativeInterface);
        BluetoothHciVendorSpecificNativeInterface.setInstance(mHciVendorSpecificNativeInterface);
        SdpManagerNativeInterface.setInstance(mSdpNativeInterface);
        SdpManagerNativeInterface.setInstance(mSdpNativeInterface);
        AdvertiseManagerNativeInterface.setInstance(mAdvertiseNativeInterface);
        AdvertiseManagerNativeInterface.setInstance(mAdvertiseNativeInterface);
        DistanceMeasurementNativeInterface.setInstance(mDistanceNativeInterface);
        DistanceMeasurementNativeInterface.setInstance(mDistanceNativeInterface);
@@ -354,6 +356,7 @@ public class AdapterServiceTest {
        AdapterNativeInterface.setInstance(null);
        AdapterNativeInterface.setInstance(null);
        BluetoothKeystoreNativeInterface.setInstance(null);
        BluetoothKeystoreNativeInterface.setInstance(null);
        BluetoothQualityReportNativeInterface.setInstance(null);
        BluetoothQualityReportNativeInterface.setInstance(null);
        BluetoothHciVendorSpecificNativeInterface.setInstance(null);
        SdpManagerNativeInterface.setInstance(null);
        SdpManagerNativeInterface.setInstance(null);
        AdvertiseManagerNativeInterface.setInstance(null);
        AdvertiseManagerNativeInterface.setInstance(null);
        DistanceMeasurementNativeInterface.setInstance(null);
        DistanceMeasurementNativeInterface.setInstance(null);
+0 −2
Original line number Original line Diff line number Diff line
@@ -159,8 +159,6 @@ class Pbap(val context: Context) : PBAPImplBase(), Closeable {
            """
            """
                %d Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                %d Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                Vivamus condimentum rhoncus est volutpat venenatis.
                Vivamus condimentum rhoncus est volutpat venenatis.
                Fusce semper, sapien ut venenatis pellentesque,
                lorem dui aliquam sapien, non pharetra diam neque id mi.
            """
            """
    }
    }
}
}
Loading