Fix after dis/reconnect HA, DUT will request to re-pair one side of HA
Root Cause: Another side of HA jumps to connecting state after pair-other-ear dialog appears. Solution: Listen to onDeviceAttributesChanged() callback to know when the sub device gets connected, then to dismiss dialog. Bug: 236782832 Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidUtilsTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidPairingDialogFragmentTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=AvailableMediaDeviceGroupControllerTest Change-Id: I8dafefbb05e7cf1cadf37a7acbb2c5d66f2d0a78
This commit is contained in:
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -50,6 +51,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.BluetoothCallback;
|
||||
import com.android.settingslib.bluetooth.BluetoothEventManager;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.HearingAidProfile;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
|
||||
@@ -70,6 +72,7 @@ import org.robolectric.annotation.Config;
|
||||
ShadowBluetoothUtils.class})
|
||||
public class AvailableMediaDeviceGroupControllerTest {
|
||||
|
||||
private static final String TEST_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
|
||||
private static final String PREFERENCE_KEY_1 = "pref_key_1";
|
||||
|
||||
@Mock
|
||||
@@ -85,7 +88,9 @@ public class AvailableMediaDeviceGroupControllerTest {
|
||||
@Mock
|
||||
private BluetoothEventManager mEventManager;
|
||||
@Mock
|
||||
private LocalBluetoothManager mLocalManager;
|
||||
private LocalBluetoothManager mLocalBluetoothManager;
|
||||
@Mock
|
||||
private CachedBluetoothDeviceManager mCachedDeviceManager;
|
||||
@Mock
|
||||
private CachedBluetoothDevice mCachedBluetoothDevice;
|
||||
|
||||
@@ -93,7 +98,6 @@ public class AvailableMediaDeviceGroupControllerTest {
|
||||
private Context mContext;
|
||||
private Preference mPreference;
|
||||
private AvailableMediaDeviceGroupController mAvailableMediaDeviceGroupController;
|
||||
private LocalBluetoothManager mLocalBluetoothManager;
|
||||
private AudioManager mAudioManager;
|
||||
|
||||
@Before
|
||||
@@ -112,10 +116,14 @@ public class AvailableMediaDeviceGroupControllerTest {
|
||||
when(mDashboardFragment.getParentFragmentManager()).thenReturn(
|
||||
mActivity.getSupportFragmentManager());
|
||||
|
||||
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
|
||||
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
|
||||
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
|
||||
mAudioManager = mContext.getSystemService(AudioManager.class);
|
||||
doReturn(mEventManager).when(mLocalBluetoothManager).getEventManager();
|
||||
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
|
||||
when(mCachedDeviceManager.findDevice(any(BluetoothDevice.class))).thenReturn(
|
||||
mCachedBluetoothDevice);
|
||||
when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS);
|
||||
|
||||
mAvailableMediaDeviceGroupController = spy(
|
||||
new AvailableMediaDeviceGroupController(mContext));
|
||||
|
Reference in New Issue
Block a user