Loading src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarController.java +10 −4 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.FeatureFlagUtils; import android.util.Log; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; Loading Loading @@ -320,7 +321,12 @@ public class AudioSharingSwitchBarController extends BasePreferenceController } return; } if (mAssistant // FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST is always true in // prod. We can turn off the flag for debug purpose. if (FeatureFlagUtils.isEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST) && mAssistant .getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED}) .isEmpty()) { Loading tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java +19 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Looper; import android.platform.test.flag.junit.SetFlagsRule; import android.util.FeatureFlagUtils; import android.widget.CompoundButton; import androidx.lifecycle.LifecycleOwner; Loading Loading @@ -322,7 +323,9 @@ public class AudioSharingSwitchBarControllerTest { } @Test public void onCheckedChangedToChecked_noConnectedLeaDevices_notStartAudioSharing() { public void onCheckedChangedToChecked_noConnectedLeaDevices_flagOn_notStartAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) Loading @@ -333,8 +336,23 @@ public class AudioSharingSwitchBarControllerTest { verify(mBroadcast, times(0)).startPrivateBroadcast(); } @Test public void onCheckedChangedToChecked_noConnectedLeaDevices_flagOff_startAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) .thenReturn(ImmutableList.of()); doNothing().when(mBroadcast).startPrivateBroadcast(); mController.onCheckedChanged(mBtnView, /* isChecked= */ true); verify(mBroadcast).startPrivateBroadcast(); } @Test public void onCheckedChangedToChecked_notSharing_withConnectedLeaDevices_startAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) Loading Loading
src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarController.java +10 −4 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.FeatureFlagUtils; import android.util.Log; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; Loading Loading @@ -320,7 +321,12 @@ public class AudioSharingSwitchBarController extends BasePreferenceController } return; } if (mAssistant // FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST is always true in // prod. We can turn off the flag for debug purpose. if (FeatureFlagUtils.isEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST) && mAssistant .getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED}) .isEmpty()) { Loading
tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java +19 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Looper; import android.platform.test.flag.junit.SetFlagsRule; import android.util.FeatureFlagUtils; import android.widget.CompoundButton; import androidx.lifecycle.LifecycleOwner; Loading Loading @@ -322,7 +323,9 @@ public class AudioSharingSwitchBarControllerTest { } @Test public void onCheckedChangedToChecked_noConnectedLeaDevices_notStartAudioSharing() { public void onCheckedChangedToChecked_noConnectedLeaDevices_flagOn_notStartAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) Loading @@ -333,8 +336,23 @@ public class AudioSharingSwitchBarControllerTest { verify(mBroadcast, times(0)).startPrivateBroadcast(); } @Test public void onCheckedChangedToChecked_noConnectedLeaDevices_flagOff_startAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, false); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) .thenReturn(ImmutableList.of()); doNothing().when(mBroadcast).startPrivateBroadcast(); mController.onCheckedChanged(mBtnView, /* isChecked= */ true); verify(mBroadcast).startPrivateBroadcast(); } @Test public void onCheckedChangedToChecked_notSharing_withConnectedLeaDevices_startAudioSharing() { FeatureFlagUtils.setEnabled( mContext, FeatureFlagUtils.SETTINGS_NEED_CONNECTED_BLE_DEVICE_FOR_BROADCAST, true); when(mBtnView.isEnabled()).thenReturn(true); when(mAssistant.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED})) Loading