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

Commit fd4e3503 authored by Antoine Soulier's avatar Antoine Soulier Committed by Automerger Merge Worker
Browse files

Merge "Revert^2 "HCI Vendor Specific Interface needs to be mocked for...

Merge "Revert^2 "HCI Vendor Specific Interface needs to be mocked for testing"" into main am: 01ffc4d7

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3394543



Change-Id: If9fef3c572a01267fa1cf995393f98b2b68f0dea
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dcec3dfa 01ffc4d7
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -278,10 +278,6 @@ public class AdapterService extends Service {

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

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

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

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

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

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 final BluetoothHciVendorSpecificDispatcher mDispatcher;

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

    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();
    }

+3 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ public class AdapterServiceTest {
    private @Mock AdapterNativeInterface mNativeInterface;
    private @Mock BluetoothKeystoreNativeInterface mKeystoreNativeInterface;
    private @Mock BluetoothQualityReportNativeInterface mQualityNativeInterface;
    private @Mock BluetoothHciVendorSpecificNativeInterface mHciVendorSpecificNativeInterface;
    private @Mock SdpManagerNativeInterface mSdpNativeInterface;
    private @Mock AdvertiseManagerNativeInterface mAdvertiseNativeInterface;
    private @Mock DistanceMeasurementNativeInterface mDistanceNativeInterface;
@@ -226,6 +227,7 @@ public class AdapterServiceTest {
        AdapterNativeInterface.setInstance(mNativeInterface);
        BluetoothKeystoreNativeInterface.setInstance(mKeystoreNativeInterface);
        BluetoothQualityReportNativeInterface.setInstance(mQualityNativeInterface);
        BluetoothHciVendorSpecificNativeInterface.setInstance(mHciVendorSpecificNativeInterface);
        SdpManagerNativeInterface.setInstance(mSdpNativeInterface);
        AdvertiseManagerNativeInterface.setInstance(mAdvertiseNativeInterface);
        DistanceMeasurementNativeInterface.setInstance(mDistanceNativeInterface);
@@ -354,6 +356,7 @@ public class AdapterServiceTest {
        AdapterNativeInterface.setInstance(null);
        BluetoothKeystoreNativeInterface.setInstance(null);
        BluetoothQualityReportNativeInterface.setInstance(null);
        BluetoothHciVendorSpecificNativeInterface.setInstance(null);
        SdpManagerNativeInterface.setInstance(null);
        AdvertiseManagerNativeInterface.setInstance(null);
        DistanceMeasurementNativeInterface.setInstance(null);