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

Commit 0eddf9d8 authored by Jayden Kim's avatar Jayden Kim Committed by Gerrit Code Review
Browse files

Merge "ScanManager: Add mock location manager for unit test"

parents 13cbbee9 8ca29d1b
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -166,11 +166,11 @@ public class ScanManager {
        mSuspendedScanClients =
        mSuspendedScanClients =
                Collections.newSetFromMap(new ConcurrentHashMap<ScanClient, Boolean>());
                Collections.newSetFromMap(new ConcurrentHashMap<ScanClient, Boolean>());
        mService = service;
        mService = service;
        mAdapterService = adapterService;
        mScanNative = new ScanNative();
        mScanNative = new ScanNative();
        mDm = mService.getSystemService(DisplayManager.class);
        mDm = mService.getSystemService(DisplayManager.class);
        mActivityManager = mService.getSystemService(ActivityManager.class);
        mActivityManager = mService.getSystemService(ActivityManager.class);
        mLocationManager = mService.getSystemService(LocationManager.class);
        mLocationManager = mAdapterService.getSystemService(LocationManager.class);
        mAdapterService = adapterService;
        mBluetoothAdapterProxy = bluetoothAdapterProxy;
        mBluetoothAdapterProxy = bluetoothAdapterProxy;
        mIsConnecting = false;
        mIsConnecting = false;


+7 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.app.ActivityManager;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanSettings;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
import android.content.Context;
import android.location.LocationManager;
import android.os.Binder;
import android.os.Binder;
import android.os.Handler;
import android.os.Handler;
import android.os.Message;
import android.os.Message;
@@ -90,6 +91,7 @@ public class ScanManagerTest {
    @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule();
    @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule();
    @Mock private AdapterService mAdapterService;
    @Mock private AdapterService mAdapterService;
    @Mock private BluetoothAdapterProxy mBluetoothAdapterProxy;
    @Mock private BluetoothAdapterProxy mBluetoothAdapterProxy;
    @Mock private LocationManager mLocationManager;
    @Mock private GattObjectsFactory mFactory;
    @Mock private GattObjectsFactory mFactory;
    @Mock private GattNativeInterface mNativeInterface;
    @Mock private GattNativeInterface mNativeInterface;
    @Mock private ScanNativeInterface mScanNativeInterface;
    @Mock private ScanNativeInterface mScanNativeInterface;
@@ -109,6 +111,11 @@ public class ScanManagerTest {
                .thenReturn(DEFAULT_NUM_OFFLOAD_SCAN_FILTER);
                .thenReturn(DEFAULT_NUM_OFFLOAD_SCAN_FILTER);
        when(mAdapterService.getOffloadedScanResultStorage())
        when(mAdapterService.getOffloadedScanResultStorage())
                .thenReturn(DEFAULT_BYTES_OFFLOAD_SCAN_RESULT_STORAGE);
                .thenReturn(DEFAULT_BYTES_OFFLOAD_SCAN_RESULT_STORAGE);
        when(mAdapterService.getSystemService(Context.LOCATION_SERVICE))
                .thenReturn(mLocationManager);
        when(mAdapterService.getSystemServiceName(LocationManager.class))
                .thenReturn(Context.LOCATION_SERVICE);
        doReturn(true).when(mLocationManager).isLocationEnabled();


        BluetoothAdapterProxy.setInstanceForTesting(mBluetoothAdapterProxy);
        BluetoothAdapterProxy.setInstanceForTesting(mBluetoothAdapterProxy);
        // Needed to mock Native call/callback when hw offload scan filter is enabled
        // Needed to mock Native call/callback when hw offload scan filter is enabled