Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +25 −4 Original line number Diff line number Diff line Loading @@ -1863,10 +1863,31 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> + " mIsLeAudioProfileConnectedFail=" + mIsLeAudioProfileConnectedFail + " mIsHeadsetProfileConnectedFail=" + mIsHeadsetProfileConnectedFail + " isConnectedSapDevice()=" + isConnectedSapDevice()); return mIsA2dpProfileConnectedFail || mIsHearingAidProfileConnectedFail || (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail) || mIsLeAudioProfileConnectedFail; if (mIsA2dpProfileConnectedFail) { A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile(); if (a2dpProfile != null && a2dpProfile.isEnabled(mDevice)) { return true; } } if (mIsHearingAidProfileConnectedFail) { HearingAidProfile hearingAidProfile = mProfileManager.getHearingAidProfile(); if (hearingAidProfile != null && hearingAidProfile.isEnabled(mDevice)) { return true; } } if (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail) { HeadsetProfile headsetProfile = mProfileManager.getHeadsetProfile(); if (headsetProfile != null && headsetProfile.isEnabled(mDevice)) { return true; } } if (mIsLeAudioProfileConnectedFail) { LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile(); if (leAudioProfile != null && leAudioProfile.isEnabled(mDevice)) { return true; } } return false; } /** Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,8 @@ public class CachedBluetoothDeviceTest { updateProfileStatus(connectingProfile, BluetoothProfile.STATE_CONNECTING); // Set connection policy when(connectingProfile.getConnectionPolicy(mDevice)).thenReturn(connectionPolicy); when(connectingProfile.isEnabled(mDevice)) .thenReturn(connectionPolicy > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); // Act & Assert: // Get the expected connection summary. Loading @@ -191,6 +193,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyAllowed_problem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); String connectTimeoutString = mContext.getString(R.string.profile_connect_timeout_subtext); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, Loading @@ -205,6 +210,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyForbidden_noProblem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null); testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile, Loading @@ -217,6 +225,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyUnknown_noProblem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null); testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile, Loading Loading @@ -1830,6 +1841,10 @@ public class CachedBluetoothDeviceTest { @Test public void getConnectionSummary_profileConnectedFail_showErrorMessage() { final A2dpProfile profile = mock(A2dpProfile.class); when(mProfileManager.getA2dpProfile()).thenReturn(profile); when(profile.getConnectionPolicy(mDevice)) .thenReturn(BluetoothProfile.CONNECTION_POLICY_ALLOWED); when(profile.isEnabled(mDevice)).thenReturn(true); mCachedDevice.onProfileStateChanged(profile, BluetoothProfile.STATE_CONNECTED); mCachedDevice.setProfileConnectedStatus(BluetoothProfile.A2DP, true); Loading @@ -1842,6 +1857,10 @@ public class CachedBluetoothDeviceTest { @Test public void getTvConnectionSummary_profileConnectedFail_showErrorMessage() { final A2dpProfile profile = mock(A2dpProfile.class); when(mProfileManager.getA2dpProfile()).thenReturn(profile); when(profile.getConnectionPolicy(mDevice)) .thenReturn(BluetoothProfile.CONNECTION_POLICY_ALLOWED); when(profile.isEnabled(mDevice)).thenReturn(true); mCachedDevice.onProfileStateChanged(profile, BluetoothProfile.STATE_CONNECTED); mCachedDevice.setProfileConnectedStatus(BluetoothProfile.A2DP, true); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +25 −4 Original line number Diff line number Diff line Loading @@ -1863,10 +1863,31 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> + " mIsLeAudioProfileConnectedFail=" + mIsLeAudioProfileConnectedFail + " mIsHeadsetProfileConnectedFail=" + mIsHeadsetProfileConnectedFail + " isConnectedSapDevice()=" + isConnectedSapDevice()); return mIsA2dpProfileConnectedFail || mIsHearingAidProfileConnectedFail || (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail) || mIsLeAudioProfileConnectedFail; if (mIsA2dpProfileConnectedFail) { A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile(); if (a2dpProfile != null && a2dpProfile.isEnabled(mDevice)) { return true; } } if (mIsHearingAidProfileConnectedFail) { HearingAidProfile hearingAidProfile = mProfileManager.getHearingAidProfile(); if (hearingAidProfile != null && hearingAidProfile.isEnabled(mDevice)) { return true; } } if (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail) { HeadsetProfile headsetProfile = mProfileManager.getHeadsetProfile(); if (headsetProfile != null && headsetProfile.isEnabled(mDevice)) { return true; } } if (mIsLeAudioProfileConnectedFail) { LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile(); if (leAudioProfile != null && leAudioProfile.isEnabled(mDevice)) { return true; } } return false; } /** Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,8 @@ public class CachedBluetoothDeviceTest { updateProfileStatus(connectingProfile, BluetoothProfile.STATE_CONNECTING); // Set connection policy when(connectingProfile.getConnectionPolicy(mDevice)).thenReturn(connectionPolicy); when(connectingProfile.isEnabled(mDevice)) .thenReturn(connectionPolicy > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN); // Act & Assert: // Get the expected connection summary. Loading @@ -191,6 +193,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyAllowed_problem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); String connectTimeoutString = mContext.getString(R.string.profile_connect_timeout_subtext); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, Loading @@ -205,6 +210,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyForbidden_noProblem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null); testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile, Loading @@ -217,6 +225,9 @@ public class CachedBluetoothDeviceTest { @Test public void onProfileStateChanged_testConnectingToDisconnected_policyUnknown_noProblem() { when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile); testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile, BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null); testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile, Loading Loading @@ -1830,6 +1841,10 @@ public class CachedBluetoothDeviceTest { @Test public void getConnectionSummary_profileConnectedFail_showErrorMessage() { final A2dpProfile profile = mock(A2dpProfile.class); when(mProfileManager.getA2dpProfile()).thenReturn(profile); when(profile.getConnectionPolicy(mDevice)) .thenReturn(BluetoothProfile.CONNECTION_POLICY_ALLOWED); when(profile.isEnabled(mDevice)).thenReturn(true); mCachedDevice.onProfileStateChanged(profile, BluetoothProfile.STATE_CONNECTED); mCachedDevice.setProfileConnectedStatus(BluetoothProfile.A2DP, true); Loading @@ -1842,6 +1857,10 @@ public class CachedBluetoothDeviceTest { @Test public void getTvConnectionSummary_profileConnectedFail_showErrorMessage() { final A2dpProfile profile = mock(A2dpProfile.class); when(mProfileManager.getA2dpProfile()).thenReturn(profile); when(profile.getConnectionPolicy(mDevice)) .thenReturn(BluetoothProfile.CONNECTION_POLICY_ALLOWED); when(profile.isEnabled(mDevice)).thenReturn(true); mCachedDevice.onProfileStateChanged(profile, BluetoothProfile.STATE_CONNECTED); mCachedDevice.setProfileConnectedStatus(BluetoothProfile.A2DP, true); Loading