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

Commit adfab7d5 authored by ELIYAZ MOMIN's avatar ELIYAZ MOMIN Committed by Automerger Merge Worker
Browse files

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

Merge "Revert "HCI Vendor Specific Interface needs to be mocked for testing"" into main am: 78d250f8

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



Change-Id: I308097dc73458e3dddfce9cabf15defc0e4149c9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 39cc37e6 78d250f8
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -278,6 +278,10 @@ 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;
@@ -342,7 +346,6 @@ 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;


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


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


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


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


import com.android.internal.annotations.GuardedBy;
class BluetoothHciVendorSpecificNativeInterface {
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;


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

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

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


    private BluetoothHciVendorSpecificDispatcher mDispatcher;
    void init() {

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


+0 −3
Original line number Original line Diff line number Diff line
@@ -155,7 +155,6 @@ 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;
@@ -227,7 +226,6 @@ 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);
@@ -356,7 +354,6 @@ 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);