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

Commit 5d600b86 authored by Kihong Seong's avatar Kihong Seong
Browse files

Merge constructor and start in ScanManager

This helps clean up code inside ScanManager. The start function has only
one reference inside GattService.start(), where it is called right after
the constructor. Therefore, merging the start logic into the constructor
seems reasonable.

Bug: 301345556
Test: atest BluetoothInstrumentationTests
Change-Id: I3a97bde6982038189aa2ba78634a7f6fc2929ed9
parent 84daa526
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.gatt;

import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE;

import static com.android.bluetooth.Utils.callerIsSystemOrActiveOrManagedUser;
import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
@@ -359,7 +360,6 @@ public class GattService extends ProfileService {

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

        mPeriodicScanManager = GattObjectsFactory.getInstance()
                .createPeriodicScanManager(mAdapterService);
+0 −2
Original line number Diff line number Diff line
@@ -179,9 +179,7 @@ public class ScanManager {
        mPriorityMap.put(ScanSettings.SCAN_MODE_BALANCED, 4);
        mPriorityMap.put(ScanSettings.SCAN_MODE_AMBIENT_DISCOVERY, 4);
        mPriorityMap.put(ScanSettings.SCAN_MODE_LOW_LATENCY, 5);
    }

    void start() {
        HandlerThread thread = new HandlerThread("BluetoothScanManager");
        thread.start();
        mHandler = new ClientHandler(thread.getLooper());
+0 −1
Original line number Diff line number Diff line
@@ -182,7 +182,6 @@ public class ScanManagerTest {
        doReturn(mTargetContext.getPackageName()).when(mMockGattService).getPackageName();

        mScanManager = new ScanManager(mMockGattService, mAdapterService, mBluetoothAdapterProxy);
        mScanManager.start();

        mHandler = mScanManager.getClientHandler();
        assertThat(mHandler).isNotNull();