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

Commit 78d250f8 authored by ELIYAZ MOMIN's avatar ELIYAZ MOMIN Committed by Gerrit Code Review
Browse files

Merge "Revert "HCI Vendor Specific Interface needs to be mocked for testing"" into main

parents 75aee19b cabf7ea8
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -278,6 +278,10 @@ 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;
@@ -342,7 +346,6 @@ public class AdapterService extends Service {
    private BassClientService mBassClientService;
    private BatteryService mBatteryService;
    private BluetoothQualityReportNativeInterface mBluetoothQualityReportNativeInterface;
    private BluetoothHciVendorSpecificNativeInterface mBluetoothHciVendorSpecificNativeInterface;
    private GattService mGattService;
    private ScanController mScanController;

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

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

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

package com.android.bluetooth.btservice;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

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

    @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;
        }
    }

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

    private BluetoothHciVendorSpecificDispatcher mDispatcher;

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

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