Loading android/app/src/com/android/bluetooth/gatt/ScanManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -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; Loading android/app/tests/unit/src/com/android/bluetooth/gatt/ScanManagerTest.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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 Loading Loading
android/app/src/com/android/bluetooth/gatt/ScanManager.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -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; Loading
android/app/tests/unit/src/com/android/bluetooth/gatt/ScanManagerTest.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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 Loading