Loading packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterLegacyTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -410,6 +410,7 @@ public class MediaOutputAdapterLegacyTest extends SysuiTestCase { List.of(mMediaDevice1, mMediaDevice2)); List.of(mMediaDevice1, mMediaDevice2)); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn( when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn( List.of(mMediaDevice1, mMediaDevice2)); List.of(mMediaDevice1, mMediaDevice2)); when(mMediaSwitchingController.hasGroupPlayback()).thenReturn(true); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); // Expand the group control. // Expand the group control. Loading Loading @@ -1031,7 +1032,10 @@ public class MediaOutputAdapterLegacyTest extends SysuiTestCase { when(mMediaSwitchingController.getSelectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectedMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectedMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.hasGroupPlayback()).thenReturn(true); mMediaOutputAdapter = new MediaOutputAdapterLegacy(mMediaSwitchingController, mMainExecutor, mBackgroundExecutor); mMediaOutputAdapter.updateItems(); mMediaOutputAdapter.updateItems(); } } } } packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -332,6 +332,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { mMediaSwitchingController.stub { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn false on { isGroupListCollapsed } doReturn false on { isVolumeControlEnabledForSession } doReturn true on { isVolumeControlEnabledForSession } doReturn true on { hasGroupPlayback() } doReturn true } } mMediaSwitchingController.stub { mMediaSwitchingController.stub { on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) Loading Loading @@ -790,6 +791,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { on { selectableMediaDevice } doReturn selectedDevices on { selectableMediaDevice } doReturn selectedDevices on { selectedMediaDevice } doReturn selectedDevices on { selectedMediaDevice } doReturn selectedDevices on { deselectableMediaDevice } doReturn selectedDevices on { deselectableMediaDevice } doReturn selectedDevices on { hasGroupPlayback() } doReturn true } } mMediaOutputAdapter = MediaOutputAdapter(mMediaSwitchingController) mMediaOutputAdapter = MediaOutputAdapter(mMediaSwitchingController) updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : // Avoid grouping broadcast devices because grouped volume control is not available for // Avoid grouping broadcast devices because grouped volume control is not available for // broadcast session. // broadcast session. mGroupSelectedItems = mGroupSelectedItems = mController.selectedMediaDevice.size > 1 && mController.hasGroupPlayback() && (!Flags.enableOutputSwitcherPersonalAudioSharing() || (!Flags.enableOutputSwitcherPersonalAudioSharing() || mController.isVolumeControlEnabledForSession) mController.isVolumeControlEnabledForSession) } } Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapterBase.java +4 −8 Original line number Original line Diff line number Diff line Loading @@ -75,7 +75,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl boolean isCurrentlyConnected(MediaDevice device) { boolean isCurrentlyConnected(MediaDevice device) { return TextUtils.equals(device.getId(), return TextUtils.equals(device.getId(), mController.getCurrentConnectedMediaDevice().getId()) mController.getCurrentConnectedMediaDevice().getId()) || (mController.getSelectedMediaDevice().size() == 1 || (!mController.hasGroupPlayback() && isDeviceIncluded(mController.getSelectedMediaDevice(), device)); && isDeviceIncluded(mController.getSelectedMediaDevice(), device)); } } Loading Loading @@ -105,7 +105,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl mMediaItemList.clear(); mMediaItemList.clear(); mMediaItemList.addAll(mController.getMediaItemList()); mMediaItemList.addAll(mController.getMediaItemList()); if (mShouldGroupSelectedMediaItems) { if (mShouldGroupSelectedMediaItems) { if (mController.getSelectedMediaDevice().size() == 1) { if (!mController.hasGroupPlayback()) { // Don't group devices if initially there isn't more than one selected. // Don't group devices if initially there isn't more than one selected. mShouldGroupSelectedMediaItems = false; mShouldGroupSelectedMediaItems = false; } } Loading Loading @@ -197,7 +197,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl } else if (device.getState() == MediaDeviceState.STATE_GROUPING) { } else if (device.getState() == MediaDeviceState.STATE_GROUPING) { connectionState = ConnectionState.CONNECTING; connectionState = ConnectionState.CONNECTING; } else if (!enableOutputSwitcherRedesign() && mShouldGroupSelectedMediaItems } else if (!enableOutputSwitcherRedesign() && mShouldGroupSelectedMediaItems && hasMultipleSelectedDevices() && mController.hasGroupPlayback() && isSelected) { && isSelected) { if (mediaItem.isFirstDeviceInGroup()) { if (mediaItem.isFirstDeviceInGroup()) { isDeviceGroup = true; isDeviceGroup = true; Loading Loading @@ -263,17 +263,13 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl // A device should either be selectable or, when the device selected, the list should // A device should either be selectable or, when the device selected, the list should // have other selectable or selected devices. // have other selectable or selected devices. boolean selectedWithOtherGroupDevices = boolean selectedWithOtherGroupDevices = isSelected && (hasMultipleSelectedDevices() || hasSelectableDevices()); isSelected && (mController.hasGroupPlayback() || hasSelectableDevices()); if (isSelectable || selectedWithOtherGroupDevices) { if (isSelectable || selectedWithOtherGroupDevices) { return new GroupStatus(isSelected, isDeselectable); return new GroupStatus(isSelected, isDeselectable); } } return null; return null; } } private boolean hasMultipleSelectedDevices() { return mController.getSelectedMediaDevice().size() > 1; } private boolean hasSelectableDevices() { private boolean hasSelectableDevices() { return !mController.getSelectableMediaDevice().isEmpty(); return !mController.getSelectableMediaDevice().isEmpty(); } } Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +6 −20 Original line number Original line Diff line number Diff line Loading @@ -647,17 +647,14 @@ public class MediaSwitchingController mContext.getString(R.string.media_output_group_title_connected_speakers)); mContext.getString(R.string.media_output_group_title_connected_speakers)); } } @Nullable boolean hasGroupPlayback() { MediaItem getConnectNewDeviceItem() { return getSelectedMediaDevice().size() > 1; boolean isSelectedDeviceNotAGroup = getSelectedMediaDevice().size() == 1; if (enableInputRouting()) { // When input routing is enabled, there are expected to be at least 2 total selected // devices: one output device and one input device. isSelectedDeviceNotAGroup = getSelectedMediaDevice().size() <= 2; } } @Nullable MediaItem getConnectNewDeviceItem() { // Attach "Connect a device" item only when current output is not remote and not a group // Attach "Connect a device" item only when current output is not remote and not a group return (!isCurrentConnectedDeviceRemote() && isSelectedDeviceNotAGroup) return (!isCurrentConnectedDeviceRemote() && !hasGroupPlayback()) ? MediaItem.createPairNewDeviceMediaItem() ? MediaItem.createPairNewDeviceMediaItem() : null; : null; } } Loading Loading @@ -779,20 +776,9 @@ public class MediaSwitchingController } } public List<MediaDevice> getSelectedMediaDevice() { public List<MediaDevice> getSelectedMediaDevice() { if (!enableInputRouting()) { return mLocalMediaManager.getSelectedMediaDevice(); return mLocalMediaManager.getSelectedMediaDevice(); } } // Add selected input device if input routing is supported. List<MediaDevice> selectedDevices = new ArrayList<>(mLocalMediaManager.getSelectedMediaDevice()); MediaDevice selectedInputDevice = mInputRouteManager.getSelectedInputDevice(); if (selectedInputDevice != null) { selectedDevices.add(selectedInputDevice); } return selectedDevices; } List<MediaDevice> getDeselectableMediaDevice() { List<MediaDevice> getDeselectableMediaDevice() { return mLocalMediaManager.getDeselectableMediaDevice(); return mLocalMediaManager.getDeselectableMediaDevice(); } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterLegacyTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -410,6 +410,7 @@ public class MediaOutputAdapterLegacyTest extends SysuiTestCase { List.of(mMediaDevice1, mMediaDevice2)); List.of(mMediaDevice1, mMediaDevice2)); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn( when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn( List.of(mMediaDevice1, mMediaDevice2)); List.of(mMediaDevice1, mMediaDevice2)); when(mMediaSwitchingController.hasGroupPlayback()).thenReturn(true); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); // Expand the group control. // Expand the group control. Loading Loading @@ -1031,7 +1032,10 @@ public class MediaOutputAdapterLegacyTest extends SysuiTestCase { when(mMediaSwitchingController.getSelectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectedMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getSelectedMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.getDeselectableMediaDevice()).thenReturn(selectedDevices); when(mMediaSwitchingController.hasGroupPlayback()).thenReturn(true); mMediaOutputAdapter = new MediaOutputAdapterLegacy(mMediaSwitchingController, mMainExecutor, mBackgroundExecutor); mMediaOutputAdapter.updateItems(); mMediaOutputAdapter.updateItems(); } } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -332,6 +332,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { mMediaSwitchingController.stub { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn false on { isGroupListCollapsed } doReturn false on { isVolumeControlEnabledForSession } doReturn true on { isVolumeControlEnabledForSession } doReturn true on { hasGroupPlayback() } doReturn true } } mMediaSwitchingController.stub { mMediaSwitchingController.stub { on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) on { selectedMediaDevice } doReturn listOf(mMediaDevice1, mMediaDevice2) Loading Loading @@ -790,6 +791,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { on { selectableMediaDevice } doReturn selectedDevices on { selectableMediaDevice } doReturn selectedDevices on { selectedMediaDevice } doReturn selectedDevices on { selectedMediaDevice } doReturn selectedDevices on { deselectableMediaDevice } doReturn selectedDevices on { deselectableMediaDevice } doReturn selectedDevices on { hasGroupPlayback() } doReturn true } } mMediaOutputAdapter = MediaOutputAdapter(mMediaSwitchingController) mMediaOutputAdapter = MediaOutputAdapter(mMediaSwitchingController) updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : // Avoid grouping broadcast devices because grouped volume control is not available for // Avoid grouping broadcast devices because grouped volume control is not available for // broadcast session. // broadcast session. mGroupSelectedItems = mGroupSelectedItems = mController.selectedMediaDevice.size > 1 && mController.hasGroupPlayback() && (!Flags.enableOutputSwitcherPersonalAudioSharing() || (!Flags.enableOutputSwitcherPersonalAudioSharing() || mController.isVolumeControlEnabledForSession) mController.isVolumeControlEnabledForSession) } } Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapterBase.java +4 −8 Original line number Original line Diff line number Diff line Loading @@ -75,7 +75,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl boolean isCurrentlyConnected(MediaDevice device) { boolean isCurrentlyConnected(MediaDevice device) { return TextUtils.equals(device.getId(), return TextUtils.equals(device.getId(), mController.getCurrentConnectedMediaDevice().getId()) mController.getCurrentConnectedMediaDevice().getId()) || (mController.getSelectedMediaDevice().size() == 1 || (!mController.hasGroupPlayback() && isDeviceIncluded(mController.getSelectedMediaDevice(), device)); && isDeviceIncluded(mController.getSelectedMediaDevice(), device)); } } Loading Loading @@ -105,7 +105,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl mMediaItemList.clear(); mMediaItemList.clear(); mMediaItemList.addAll(mController.getMediaItemList()); mMediaItemList.addAll(mController.getMediaItemList()); if (mShouldGroupSelectedMediaItems) { if (mShouldGroupSelectedMediaItems) { if (mController.getSelectedMediaDevice().size() == 1) { if (!mController.hasGroupPlayback()) { // Don't group devices if initially there isn't more than one selected. // Don't group devices if initially there isn't more than one selected. mShouldGroupSelectedMediaItems = false; mShouldGroupSelectedMediaItems = false; } } Loading Loading @@ -197,7 +197,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl } else if (device.getState() == MediaDeviceState.STATE_GROUPING) { } else if (device.getState() == MediaDeviceState.STATE_GROUPING) { connectionState = ConnectionState.CONNECTING; connectionState = ConnectionState.CONNECTING; } else if (!enableOutputSwitcherRedesign() && mShouldGroupSelectedMediaItems } else if (!enableOutputSwitcherRedesign() && mShouldGroupSelectedMediaItems && hasMultipleSelectedDevices() && mController.hasGroupPlayback() && isSelected) { && isSelected) { if (mediaItem.isFirstDeviceInGroup()) { if (mediaItem.isFirstDeviceInGroup()) { isDeviceGroup = true; isDeviceGroup = true; Loading Loading @@ -263,17 +263,13 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl // A device should either be selectable or, when the device selected, the list should // A device should either be selectable or, when the device selected, the list should // have other selectable or selected devices. // have other selectable or selected devices. boolean selectedWithOtherGroupDevices = boolean selectedWithOtherGroupDevices = isSelected && (hasMultipleSelectedDevices() || hasSelectableDevices()); isSelected && (mController.hasGroupPlayback() || hasSelectableDevices()); if (isSelectable || selectedWithOtherGroupDevices) { if (isSelectable || selectedWithOtherGroupDevices) { return new GroupStatus(isSelected, isDeselectable); return new GroupStatus(isSelected, isDeselectable); } } return null; return null; } } private boolean hasMultipleSelectedDevices() { return mController.getSelectedMediaDevice().size() > 1; } private boolean hasSelectableDevices() { private boolean hasSelectableDevices() { return !mController.getSelectableMediaDevice().isEmpty(); return !mController.getSelectableMediaDevice().isEmpty(); } } Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +6 −20 Original line number Original line Diff line number Diff line Loading @@ -647,17 +647,14 @@ public class MediaSwitchingController mContext.getString(R.string.media_output_group_title_connected_speakers)); mContext.getString(R.string.media_output_group_title_connected_speakers)); } } @Nullable boolean hasGroupPlayback() { MediaItem getConnectNewDeviceItem() { return getSelectedMediaDevice().size() > 1; boolean isSelectedDeviceNotAGroup = getSelectedMediaDevice().size() == 1; if (enableInputRouting()) { // When input routing is enabled, there are expected to be at least 2 total selected // devices: one output device and one input device. isSelectedDeviceNotAGroup = getSelectedMediaDevice().size() <= 2; } } @Nullable MediaItem getConnectNewDeviceItem() { // Attach "Connect a device" item only when current output is not remote and not a group // Attach "Connect a device" item only when current output is not remote and not a group return (!isCurrentConnectedDeviceRemote() && isSelectedDeviceNotAGroup) return (!isCurrentConnectedDeviceRemote() && !hasGroupPlayback()) ? MediaItem.createPairNewDeviceMediaItem() ? MediaItem.createPairNewDeviceMediaItem() : null; : null; } } Loading Loading @@ -779,20 +776,9 @@ public class MediaSwitchingController } } public List<MediaDevice> getSelectedMediaDevice() { public List<MediaDevice> getSelectedMediaDevice() { if (!enableInputRouting()) { return mLocalMediaManager.getSelectedMediaDevice(); return mLocalMediaManager.getSelectedMediaDevice(); } } // Add selected input device if input routing is supported. List<MediaDevice> selectedDevices = new ArrayList<>(mLocalMediaManager.getSelectedMediaDevice()); MediaDevice selectedInputDevice = mInputRouteManager.getSelectedInputDevice(); if (selectedInputDevice != null) { selectedDevices.add(selectedInputDevice); } return selectedDevices; } List<MediaDevice> getDeselectableMediaDevice() { List<MediaDevice> getDeselectableMediaDevice() { return mLocalMediaManager.getDeselectableMediaDevice(); return mLocalMediaManager.getDeselectableMediaDevice(); } } Loading