Loading android/app/src/com/android/bluetooth/btservice/CompanionManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ public class CompanionManager { private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); private final Set<BluetoothDevice> mMetadataListeningDevices = new HashSet<>(); CompanionManager(AdapterService service, ServiceFactory factory) { public CompanionManager(AdapterService service, ServiceFactory factory) { mAdapterService = service; mGattConnHighDefault = new int[] { service.getResources().getInteger(R.integer.gatt_high_priority_min_interval), Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -290,6 +290,9 @@ public class AdapterServiceTest { .thenReturn(mBluetoothManager); when(mMockContext.getSystemServiceName(BluetoothManager.class)) .thenReturn(Context.BLUETOOTH_SERVICE); when(mMockContext.getSharedPreferences(anyString(), anyInt())) .thenReturn(InstrumentationRegistry.getTargetContext() .getSharedPreferences("AdapterServiceTestPrefs", Context.MODE_PRIVATE)); when(mMockContext.getAttributionSource()).thenReturn(mAttributionSource); doAnswer(invocation -> { Loading android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.content.AttributionSource; import android.content.Context; import android.content.res.Resources; import android.os.Binder; import android.os.ParcelUuid; import android.os.RemoteException; Loading @@ -54,6 +55,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.CompanionManager; import org.junit.After; import org.junit.Assert; Loading Loading @@ -102,10 +104,12 @@ public class GattServiceTest { private BluetoothAdapter mAdapter; private AttributionSource mAttributionSource; @Mock private Resources mResources; @Mock private AdapterService mAdapterService; @Mock private GattObjectsFactory mFactory; @Mock private GattNativeInterface mNativeInterface; private BluetoothDevice mCurrentDevice; private CompanionManager mBtCompanionManager; @Before public void setUp() throws Exception { Loading @@ -122,6 +126,15 @@ public class GattServiceTest { mAttributionSource = mAdapter.getAttributionSource(); mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(REMOTE_DEVICE_ADDRESS); when(mAdapterService.getResources()).thenReturn(mResources); when(mResources.getInteger(anyInt())).thenReturn(0); when(mAdapterService.getSharedPreferences(anyString(), anyInt())) .thenReturn(InstrumentationRegistry.getTargetContext() .getSharedPreferences("GattServiceTestPrefs", Context.MODE_PRIVATE)); mBtCompanionManager = new CompanionManager(mAdapterService, null); doReturn(mBtCompanionManager).when(mAdapterService).getCompanionManager(); TestUtils.startService(mServiceRule, GattService.class); mService = GattService.getGattService(); Assert.assertNotNull(mService); Loading Loading
android/app/src/com/android/bluetooth/btservice/CompanionManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ public class CompanionManager { private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); private final Set<BluetoothDevice> mMetadataListeningDevices = new HashSet<>(); CompanionManager(AdapterService service, ServiceFactory factory) { public CompanionManager(AdapterService service, ServiceFactory factory) { mAdapterService = service; mGattConnHighDefault = new int[] { service.getResources().getInteger(R.integer.gatt_high_priority_min_interval), Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -290,6 +290,9 @@ public class AdapterServiceTest { .thenReturn(mBluetoothManager); when(mMockContext.getSystemServiceName(BluetoothManager.class)) .thenReturn(Context.BLUETOOTH_SERVICE); when(mMockContext.getSharedPreferences(anyString(), anyInt())) .thenReturn(InstrumentationRegistry.getTargetContext() .getSharedPreferences("AdapterServiceTestPrefs", Context.MODE_PRIVATE)); when(mMockContext.getAttributionSource()).thenReturn(mAttributionSource); doAnswer(invocation -> { Loading
android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.content.AttributionSource; import android.content.Context; import android.content.res.Resources; import android.os.Binder; import android.os.ParcelUuid; import android.os.RemoteException; Loading @@ -54,6 +55,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.CompanionManager; import org.junit.After; import org.junit.Assert; Loading Loading @@ -102,10 +104,12 @@ public class GattServiceTest { private BluetoothAdapter mAdapter; private AttributionSource mAttributionSource; @Mock private Resources mResources; @Mock private AdapterService mAdapterService; @Mock private GattObjectsFactory mFactory; @Mock private GattNativeInterface mNativeInterface; private BluetoothDevice mCurrentDevice; private CompanionManager mBtCompanionManager; @Before public void setUp() throws Exception { Loading @@ -122,6 +126,15 @@ public class GattServiceTest { mAttributionSource = mAdapter.getAttributionSource(); mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(REMOTE_DEVICE_ADDRESS); when(mAdapterService.getResources()).thenReturn(mResources); when(mResources.getInteger(anyInt())).thenReturn(0); when(mAdapterService.getSharedPreferences(anyString(), anyInt())) .thenReturn(InstrumentationRegistry.getTargetContext() .getSharedPreferences("GattServiceTestPrefs", Context.MODE_PRIVATE)); mBtCompanionManager = new CompanionManager(mAdapterService, null); doReturn(mBtCompanionManager).when(mAdapterService).getCompanionManager(); TestUtils.startService(mServiceRule, GattService.class); mService = GattService.getGattService(); Assert.assertNotNull(mService); Loading