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

Commit 0c772477 authored by Kihong Seong's avatar Kihong Seong
Browse files

Merge constructor and start in multiple managers

This helps clean up code inside multiple managers. Their start functions
have only one reference each inside GattService.start(), where they are
called right after the constructors. Therefore, merging the start logic
into the constructor. Also fixing some wrong documentations in
PeriodicScanManager.

Bug: 301530940
Test: atest BluetoothInstrumentationTests
Change-Id: I63d540e2f4afb6a8e5441e4b8e552f5729d7bda5
parent b9c6ad99
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -71,12 +71,8 @@ public class AdvertiseManager {
        mNativeInterface = nativeInterface;
        mAdapterService = adapterService;
        mAdvertiserMap = advertiserMap;
    }

    /**
     * Start a {@link HandlerThread} that handles advertising operations.
     */
    void start() {
        // Start a HandlerThread that handles advertising operations
        mNativeInterface.init(this);
        HandlerThread thread = new HandlerThread("BluetoothAdvertiseManager");
        thread.start();
+1 −5
Original line number Diff line number Diff line
@@ -59,12 +59,8 @@ public class DistanceMeasurementManager {
     */
    DistanceMeasurementManager(AdapterService adapterService) {
        mAdapterService = adapterService;
    }

    /**
     * Start a {@link HandlerThread} that handles distnace measurement operations.
     */
    void start() {
        // Start a HandlerThread that handles distance measurement operations
        mHandlerThread = new HandlerThread("DistanceMeasurementManager");
        mHandlerThread.start();
        mDistanceMeasurementNativeInterface = DistanceMeasurementNativeInterface.getInstance();
+0 −3
Original line number Diff line number Diff line
@@ -355,18 +355,15 @@ public class GattService extends ProfileService {
                        AdvertiseManagerNativeInterface.getInstance(),
                        mAdapterService,
                        mAdvertiserMap);
        mAdvertiseManager.start();

        mScanManager = GattObjectsFactory.getInstance()
                .createScanManager(this, mAdapterService, mBluetoothAdapterProxy);

        mPeriodicScanManager = GattObjectsFactory.getInstance()
                .createPeriodicScanManager(mAdapterService);
        mPeriodicScanManager.start();

        mDistanceMeasurementManager = GattObjectsFactory.getInstance()
                .createDistanceMeasurementManager(mAdapterService);
        mDistanceMeasurementManager.start();

        mActivityManager = getSystemService(ActivityManager.class);

+2 −7
Original line number Diff line number Diff line
@@ -52,18 +52,13 @@ public class PeriodicScanManager {
    static int sTempRegistrationId = -1;
    private static final int PA_SOURCE_LOCAL = 1;
    private static final int PA_SOURCE_REMOTE = 2;
    /**
     * Constructor of {@link SyncManager}.
     */
    /** Constructor of {@link PeriodicScanManager}. */
    PeriodicScanManager(AdapterService adapterService) {
        if (DBG) {
            Log.d(TAG, "advertise manager created");
            Log.d(TAG, "periodic scan manager created");
        }
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mNativeInterface = PeriodicScanNativeInterface.getInstance();
    }

    void start() {
        mNativeInterface.init(this);
    }

+0 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ public class DistanceMeasurementManagerTest {
        doReturn(IDENTITY_ADDRESS).when(mAdapterService).getIdentityAddress(IDENTITY_ADDRESS);
        DistanceMeasurementNativeInterface.setInstance(mDistanceMeasurementNativeInterface);
        mDistanceMeasurementManager = new DistanceMeasurementManager(mAdapterService);
        mDistanceMeasurementManager.start();
        mUuid = UUID.randomUUID();
        mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(IDENTITY_ADDRESS);
    }