Merge "[Output Switcher] Remove sysui flag for Output Switcher in U" into udc-dev am: 6ba91bb562

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23107802

Change-Id: I87847d8a0a3cfa8ad85cbddb60bf708a59c45485
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shaowei Shen
2023-05-13 02:55:05 +00:00
committed by Automerger Merge Worker
7 changed files with 180 additions and 527 deletions

View File

@@ -665,15 +665,6 @@ object Flags {
val WARN_ON_BLOCKING_BINDER_TRANSACTIONS = val WARN_ON_BLOCKING_BINDER_TRANSACTIONS =
unreleasedFlag(2400, "warn_on_blocking_binder_transactions") unreleasedFlag(2400, "warn_on_blocking_binder_transactions")
// 2500 - output switcher
// TODO(b/261538825): Tracking Bug
@JvmField
val OUTPUT_SWITCHER_ADVANCED_LAYOUT = releasedFlag(2500, "output_switcher_advanced_layout")
@JvmField
val OUTPUT_SWITCHER_ROUTES_PROCESSING = releasedFlag(2501, "output_switcher_routes_processing")
@JvmField
val OUTPUT_SWITCHER_DEVICE_STATUS = releasedFlag(2502, "output_switcher_device_status")
// 2700 - unfold transitions // 2700 - unfold transitions
// TODO(b/265764985): Tracking Bug // TODO(b/265764985): Tracking Bug
@Keep @Keep

View File

@@ -72,102 +72,67 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
int viewType) { int viewType) {
super.onCreateViewHolder(viewGroup, viewType); super.onCreateViewHolder(viewGroup, viewType);
if (mController.isAdvancedLayoutSupported()) { switch (viewType) {
switch (viewType) { case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER:
case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER: return new MediaGroupDividerViewHolder(mHolderView);
return new MediaGroupDividerViewHolder(mHolderView); case MediaItem.MediaItemType.TYPE_PAIR_NEW_DEVICE:
case MediaItem.MediaItemType.TYPE_PAIR_NEW_DEVICE: case MediaItem.MediaItemType.TYPE_DEVICE:
case MediaItem.MediaItemType.TYPE_DEVICE: default:
default: return new MediaDeviceViewHolder(mHolderView);
return new MediaDeviceViewHolder(mHolderView);
}
} else {
return new MediaDeviceViewHolder(mHolderView);
} }
} }
@Override @Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
if (mController.isAdvancedLayoutSupported()) { if (position >= mMediaItemList.size()) {
if (position >= mMediaItemList.size()) { if (DEBUG) {
if (DEBUG) { Log.d(TAG, "Incorrect position: " + position + " list size: "
Log.d(TAG, "Incorrect position: " + position + " list size: " + mMediaItemList.size());
+ mMediaItemList.size());
}
return;
} }
MediaItem currentMediaItem = mMediaItemList.get(position); return;
switch (currentMediaItem.getMediaItemType()) { }
case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER: MediaItem currentMediaItem = mMediaItemList.get(position);
((MediaGroupDividerViewHolder) viewHolder).onBind(currentMediaItem.getTitle()); switch (currentMediaItem.getMediaItemType()) {
break; case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER:
case MediaItem.MediaItemType.TYPE_PAIR_NEW_DEVICE: ((MediaGroupDividerViewHolder) viewHolder).onBind(currentMediaItem.getTitle());
((MediaDeviceViewHolder) viewHolder).onBind(CUSTOMIZED_ITEM_PAIR_NEW); break;
break; case MediaItem.MediaItemType.TYPE_PAIR_NEW_DEVICE:
case MediaItem.MediaItemType.TYPE_DEVICE:
((MediaDeviceViewHolder) viewHolder).onBind(
currentMediaItem.getMediaDevice().get(),
position);
break;
default:
Log.d(TAG, "Incorrect position: " + position);
}
} else {
final int size = mController.getMediaDevices().size();
if (position == size) {
((MediaDeviceViewHolder) viewHolder).onBind(CUSTOMIZED_ITEM_PAIR_NEW); ((MediaDeviceViewHolder) viewHolder).onBind(CUSTOMIZED_ITEM_PAIR_NEW);
} else if (position < size) { break;
case MediaItem.MediaItemType.TYPE_DEVICE:
((MediaDeviceViewHolder) viewHolder).onBind( ((MediaDeviceViewHolder) viewHolder).onBind(
((List<MediaDevice>) (mController.getMediaDevices())).get(position), currentMediaItem.getMediaDevice().get(),
position); position);
} else if (DEBUG) { break;
default:
Log.d(TAG, "Incorrect position: " + position); Log.d(TAG, "Incorrect position: " + position);
}
} }
} }
@Override @Override
public long getItemId(int position) { public long getItemId(int position) {
if (mController.isAdvancedLayoutSupported()) { if (position >= mMediaItemList.size()) {
if (position >= mMediaItemList.size()) {
Log.d(TAG, "Incorrect position for item id: " + position);
return position;
}
MediaItem currentMediaItem = mMediaItemList.get(position);
return currentMediaItem.getMediaDevice().isPresent()
? currentMediaItem.getMediaDevice().get().getId().hashCode()
: position;
}
final int size = mController.getMediaDevices().size();
if (position == size) {
return -1;
} else if (position < size) {
return ((List<MediaDevice>) (mController.getMediaDevices()))
.get(position).getId().hashCode();
} else if (DEBUG) {
Log.d(TAG, "Incorrect position for item id: " + position); Log.d(TAG, "Incorrect position for item id: " + position);
return position;
} }
return position; MediaItem currentMediaItem = mMediaItemList.get(position);
return currentMediaItem.getMediaDevice().isPresent()
? currentMediaItem.getMediaDevice().get().getId().hashCode()
: position;
} }
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (mController.isAdvancedLayoutSupported() if (position >= mMediaItemList.size()) {
&& position >= mMediaItemList.size()) {
Log.d(TAG, "Incorrect position for item type: " + position); Log.d(TAG, "Incorrect position for item type: " + position);
return MediaItem.MediaItemType.TYPE_GROUP_DIVIDER; return MediaItem.MediaItemType.TYPE_GROUP_DIVIDER;
} }
return mController.isAdvancedLayoutSupported() return mMediaItemList.get(position).getMediaItemType();
? mMediaItemList.get(position).getMediaItemType()
: super.getItemViewType(position);
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
// Add extra one for "pair new" return mMediaItemList.size();
return mController.isAdvancedLayoutSupported()
? mMediaItemList.size()
: mController.getMediaDevices().size() + 1;
} }
class MediaDeviceViewHolder extends MediaDeviceBaseViewHolder { class MediaDeviceViewHolder extends MediaDeviceBaseViewHolder {
@@ -203,17 +168,14 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
// Set different layout for each device // Set different layout for each device
if (device.isMutingExpectedDevice() if (device.isMutingExpectedDevice()
&& !mController.isCurrentConnectedDeviceRemote()) { && !mController.isCurrentConnectedDeviceRemote()) {
if (!mController.isAdvancedLayoutSupported()) { updateTitleIcon(R.drawable.media_output_icon_volume,
updateTitleIcon(R.drawable.media_output_icon_volume, mController.getColorItemContent());
mController.getColorItemContent());
}
mCurrentActivePosition = position; mCurrentActivePosition = position;
updateFullItemClickListener(v -> onItemClick(v, device)); updateFullItemClickListener(v -> onItemClick(v, device));
setSingleLineLayout(getItemTitle(device)); setSingleLineLayout(getItemTitle(device));
initMutingExpectedDevice(); initMutingExpectedDevice();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
&& mController.isSubStatusSupported() && device.hasSubtext()) {
&& mController.isAdvancedLayoutSupported() && device.hasSubtext()) {
boolean isActiveWithOngoingSession = boolean isActiveWithOngoingSession =
(device.hasOngoingSession() && (currentlyConnected || isDeviceIncluded( (device.hasOngoingSession() && (currentlyConnected || isDeviceIncluded(
mController.getSelectedMediaDevice(), device))); mController.getSelectedMediaDevice(), device)));
@@ -284,10 +246,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
// selected device in group // selected device in group
boolean isDeviceDeselectable = isDeviceIncluded( boolean isDeviceDeselectable = isDeviceIncluded(
mController.getDeselectableMediaDevice(), device); mController.getDeselectableMediaDevice(), device);
if (!mController.isAdvancedLayoutSupported()) { updateTitleIcon(R.drawable.media_output_icon_volume,
updateTitleIcon(R.drawable.media_output_icon_volume, mController.getColorItemContent());
mController.getColorItemContent());
}
updateGroupableCheckBox(true, isDeviceDeselectable, device); updateGroupableCheckBox(true, isDeviceDeselectable, device);
updateEndClickArea(device, isDeviceDeselectable); updateEndClickArea(device, isDeviceDeselectable);
setUpContentDescriptionForView(mContainerLayout, false, device); setUpContentDescriptionForView(mContainerLayout, false, device);
@@ -305,8 +265,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
updateFullItemClickListener(v -> cancelMuteAwaitConnection()); updateFullItemClickListener(v -> cancelMuteAwaitConnection());
setSingleLineLayout(getItemTitle(device)); setSingleLineLayout(getItemTitle(device));
} else if (mController.isCurrentConnectedDeviceRemote() } else if (mController.isCurrentConnectedDeviceRemote()
&& !mController.getSelectableMediaDevice().isEmpty() && !mController.getSelectableMediaDevice().isEmpty()) {
&& mController.isAdvancedLayoutSupported()) {
//If device is connected and there's other selectable devices, layout as //If device is connected and there's other selectable devices, layout as
// one of selected devices. // one of selected devices.
updateTitleIcon(R.drawable.media_output_icon_volume, updateTitleIcon(R.drawable.media_output_icon_volume,
@@ -334,36 +293,27 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
//groupable device //groupable device
setUpDeviceIcon(device); setUpDeviceIcon(device);
updateGroupableCheckBox(false, true, device); updateGroupableCheckBox(false, true, device);
if (mController.isAdvancedLayoutSupported()) { updateEndClickArea(device, true);
updateEndClickArea(device, true); updateFullItemClickListener(v -> onItemClick(v, device));
}
updateFullItemClickListener(mController.isAdvancedLayoutSupported()
? v -> onItemClick(v, device)
: v -> onGroupActionTriggered(true, device));
setSingleLineLayout(getItemTitle(device), false /* showSeekBar */, setSingleLineLayout(getItemTitle(device), false /* showSeekBar */,
false /* showProgressBar */, true /* showCheckBox */, false /* showProgressBar */, true /* showCheckBox */,
true /* showEndTouchArea */); true /* showEndTouchArea */);
} else { } else {
setUpDeviceIcon(device); setUpDeviceIcon(device);
setSingleLineLayout(getItemTitle(device)); setSingleLineLayout(getItemTitle(device));
if (mController.isAdvancedLayoutSupported() Drawable deviceStatusIcon =
&& mController.isSubStatusSupported()) { device.hasOngoingSession() ? mContext.getDrawable(
Drawable deviceStatusIcon = R.drawable.ic_sound_bars_anim)
device.hasOngoingSession() ? mContext.getDrawable( : Api34Impl.getDeviceStatusIconBasedOnSelectionBehavior(
R.drawable.ic_sound_bars_anim) device,
: Api34Impl.getDeviceStatusIconBasedOnSelectionBehavior( mContext);
device, if (deviceStatusIcon != null) {
mContext); updateDeviceStatusIcon(deviceStatusIcon);
if (deviceStatusIcon != null) { mStatusIcon.setVisibility(View.VISIBLE);
updateDeviceStatusIcon(deviceStatusIcon);
mStatusIcon.setVisibility(View.VISIBLE);
}
updateSingleLineLayoutContentAlpha(
updateClickActionBasedOnSelectionBehavior(device)
? DEVICE_CONNECTED_ALPHA : DEVICE_DISCONNECTED_ALPHA);
} else {
updateFullItemClickListener(v -> onItemClick(v, device));
} }
updateSingleLineLayoutContentAlpha(
updateClickActionBasedOnSelectionBehavior(device)
? DEVICE_CONNECTED_ALPHA : DEVICE_DISCONNECTED_ALPHA);
} }
} }
} }
@@ -400,10 +350,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
} }
public void updateEndClickAreaColor(int color) { public void updateEndClickAreaColor(int color) {
if (mController.isAdvancedLayoutSupported()) { mEndTouchArea.setBackgroundTintList(
mEndTouchArea.setBackgroundTintList( ColorStateList.valueOf(color));
ColorStateList.valueOf(color));
}
} }
private boolean updateClickActionBasedOnSelectionBehavior(MediaDevice device) { private boolean updateClickActionBasedOnSelectionBehavior(MediaDevice device) {
@@ -440,10 +388,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null); isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null);
mEndTouchArea.setImportantForAccessibility( mEndTouchArea.setImportantForAccessibility(
View.IMPORTANT_FOR_ACCESSIBILITY_YES); View.IMPORTANT_FOR_ACCESSIBILITY_YES);
if (mController.isAdvancedLayoutSupported()) { mEndTouchArea.setBackgroundTintList(
mEndTouchArea.setBackgroundTintList( ColorStateList.valueOf(mController.getColorItemBackground()));
ColorStateList.valueOf(mController.getColorItemBackground()));
}
setUpContentDescriptionForView(mEndTouchArea, true, device); setUpContentDescriptionForView(mEndTouchArea, true, device);
} }
@@ -473,10 +419,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
mTitleIcon.setImageDrawable(addDrawable); mTitleIcon.setImageDrawable(addDrawable);
mTitleIcon.setImageTintList( mTitleIcon.setImageTintList(
ColorStateList.valueOf(mController.getColorItemContent())); ColorStateList.valueOf(mController.getColorItemContent()));
if (mController.isAdvancedLayoutSupported()) { mIconAreaLayout.setBackgroundTintList(
mIconAreaLayout.setBackgroundTintList( ColorStateList.valueOf(mController.getColorItemBackground()));
ColorStateList.valueOf(mController.getColorItemBackground()));
}
mContainerLayout.setOnClickListener(mController::launchBluetoothPairing); mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
} }
} }

View File

@@ -89,9 +89,8 @@ public abstract class MediaOutputBaseAdapter extends
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
int viewType) { int viewType) {
mContext = viewGroup.getContext(); mContext = viewGroup.getContext();
mHolderView = LayoutInflater.from(mContext).inflate( mHolderView = LayoutInflater.from(mContext).inflate(MediaItem.getMediaLayoutId(viewType),
mController.isAdvancedLayoutSupported() ? MediaItem.getMediaLayoutId(viewType) viewGroup, false);
: R.layout.media_output_list_item, viewGroup, false);
return null; return null;
} }
@@ -173,15 +172,9 @@ public abstract class MediaOutputBaseAdapter extends
mStatusIcon = view.requireViewById(R.id.media_output_item_status); mStatusIcon = view.requireViewById(R.id.media_output_item_status);
mCheckBox = view.requireViewById(R.id.check_box); mCheckBox = view.requireViewById(R.id.check_box);
mEndTouchArea = view.requireViewById(R.id.end_action_area); mEndTouchArea = view.requireViewById(R.id.end_action_area);
if (mController.isAdvancedLayoutSupported()) { mEndClickIcon = view.requireViewById(R.id.media_output_item_end_click_icon);
mEndClickIcon = view.requireViewById(R.id.media_output_item_end_click_icon); mVolumeValueText = view.requireViewById(R.id.volume_value);
mVolumeValueText = view.requireViewById(R.id.volume_value); mIconAreaLayout = view.requireViewById(R.id.icon_area);
mIconAreaLayout = view.requireViewById(R.id.icon_area);
} else {
mVolumeValueText = null;
mIconAreaLayout = null;
mEndClickIcon = null;
}
initAnimator(); initAnimator();
} }
@@ -197,9 +190,7 @@ public abstract class MediaOutputBaseAdapter extends
mTitleText.setTextColor(mController.getColorItemContent()); mTitleText.setTextColor(mController.getColorItemContent());
mSubTitleText.setTextColor(mController.getColorItemContent()); mSubTitleText.setTextColor(mController.getColorItemContent());
mTwoLineTitleText.setTextColor(mController.getColorItemContent()); mTwoLineTitleText.setTextColor(mController.getColorItemContent());
if (mController.isAdvancedLayoutSupported()) { mVolumeValueText.setTextColor(mController.getColorItemContent());
mVolumeValueText.setTextColor(mController.getColorItemContent());
}
mSeekBar.setProgressTintList( mSeekBar.setProgressTintList(
ColorStateList.valueOf(mController.getColorSeekbarProgress())); ColorStateList.valueOf(mController.getColorSeekbarProgress()));
} }
@@ -230,12 +221,10 @@ public abstract class MediaOutputBaseAdapter extends
mItemLayout.setBackgroundTintList( mItemLayout.setBackgroundTintList(
ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground() ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground()
: mController.getColorItemBackground())); : mController.getColorItemBackground()));
if (mController.isAdvancedLayoutSupported()) { mIconAreaLayout.setBackgroundTintList(
mIconAreaLayout.setBackgroundTintList( ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress()
ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress() : showProgressBar ? mController.getColorConnectedItemBackground()
: showProgressBar ? mController.getColorConnectedItemBackground() : mController.getColorItemBackground()));
: mController.getColorItemBackground()));
}
mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
mSeekBar.setAlpha(1); mSeekBar.setAlpha(1);
mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE); mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
@@ -246,12 +235,10 @@ public abstract class MediaOutputBaseAdapter extends
mTitleText.setVisibility(View.VISIBLE); mTitleText.setVisibility(View.VISIBLE);
mCheckBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE); mCheckBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE);
mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE); mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
if (mController.isAdvancedLayoutSupported()) { ViewGroup.MarginLayoutParams params =
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
(ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams(); params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable() : mController.getItemMarginEndDefault();
: mController.getItemMarginEndDefault();
}
mTitleIcon.setBackgroundTintList( mTitleIcon.setBackgroundTintList(
ColorStateList.valueOf(mController.getColorItemContent())); ColorStateList.valueOf(mController.getColorItemContent()));
} }
@@ -272,36 +259,28 @@ public abstract class MediaOutputBaseAdapter extends
mSeekBar.setAlpha(1); mSeekBar.setAlpha(1);
mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE); mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
final Drawable backgroundDrawable; final Drawable backgroundDrawable;
if (mController.isAdvancedLayoutSupported() && mController.isSubStatusSupported()) { backgroundDrawable = mContext.getDrawable(
backgroundDrawable = mContext.getDrawable( showSeekBar || isFakeActive ? R.drawable.media_output_item_background_active
showSeekBar || isFakeActive ? R.drawable.media_output_item_background_active : R.drawable.media_output_item_background).mutate();
: R.drawable.media_output_item_background).mutate(); mItemLayout.setBackgroundTintList(ColorStateList.valueOf(
mItemLayout.setBackgroundTintList(ColorStateList.valueOf( showSeekBar || isFakeActive ? mController.getColorConnectedItemBackground()
showSeekBar || isFakeActive ? mController.getColorConnectedItemBackground() : mController.getColorItemBackground()
: mController.getColorItemBackground() ));
)); mIconAreaLayout.setBackgroundTintList(
mIconAreaLayout.setBackgroundTintList( ColorStateList.valueOf(showProgressBar || isFakeActive
ColorStateList.valueOf(showProgressBar || isFakeActive ? mController.getColorConnectedItemBackground()
? mController.getColorConnectedItemBackground() : showSeekBar ? mController.getColorSeekbarProgress()
: showSeekBar ? mController.getColorSeekbarProgress() : mController.getColorItemBackground()));
: mController.getColorItemBackground())); if (showSeekBar) {
if (showSeekBar) { updateSeekbarProgressBackground();
updateSeekbarProgressBackground();
}
//update end click area by isActive
mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
mEndClickIcon.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
ViewGroup.MarginLayoutParams params =
(ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
: mController.getItemMarginEndDefault();
} else {
backgroundDrawable = mContext.getDrawable(
R.drawable.media_output_item_background)
.mutate();
mItemLayout.setBackgroundTintList(
ColorStateList.valueOf(mController.getColorItemBackground()));
} }
//update end click area by isActive
mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
mEndClickIcon.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
ViewGroup.MarginLayoutParams params =
(ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
: mController.getItemMarginEndDefault();
mItemLayout.setBackground(backgroundDrawable); mItemLayout.setBackground(backgroundDrawable);
mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE); mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE);
@@ -319,15 +298,11 @@ public abstract class MediaOutputBaseAdapter extends
.findDrawableByLayerId(android.R.id.progress); .findDrawableByLayerId(android.R.id.progress);
final GradientDrawable progressDrawable = final GradientDrawable progressDrawable =
(GradientDrawable) clipDrawable.getDrawable(); (GradientDrawable) clipDrawable.getDrawable();
if (mController.isAdvancedLayoutSupported()) { progressDrawable.setCornerRadii(
progressDrawable.setCornerRadii( new float[]{0, 0, mController.getActiveRadius(),
new float[]{0, 0, mController.getActiveRadius(), mController.getActiveRadius(),
mController.getActiveRadius(), mController.getActiveRadius(),
mController.getActiveRadius(), mController.getActiveRadius(), 0, 0});
mController.getActiveRadius(), 0, 0});
} else {
progressDrawable.setCornerRadius(mController.getActiveRadius());
}
} }
void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) { void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) {
@@ -340,30 +315,23 @@ public abstract class MediaOutputBaseAdapter extends
final int currentVolume = device.getCurrentVolume(); final int currentVolume = device.getCurrentVolume();
if (mSeekBar.getVolume() != currentVolume) { if (mSeekBar.getVolume() != currentVolume) {
if (isCurrentSeekbarInvisible && !mIsInitVolumeFirstTime) { if (isCurrentSeekbarInvisible && !mIsInitVolumeFirstTime) {
if (mController.isAdvancedLayoutSupported()) { updateTitleIcon(currentVolume == 0 ? R.drawable.media_output_icon_volume_off
updateTitleIcon(currentVolume == 0 ? R.drawable.media_output_icon_volume_off : R.drawable.media_output_icon_volume,
: R.drawable.media_output_icon_volume, mController.getColorItemContent());
mController.getColorItemContent());
} else {
animateCornerAndVolume(mSeekBar.getProgress(),
MediaOutputSeekbar.scaleVolumeToProgress(currentVolume));
}
} else { } else {
if (!mVolumeAnimator.isStarted()) { if (!mVolumeAnimator.isStarted()) {
if (mController.isAdvancedLayoutSupported()) { int percentage =
int percentage = (int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE
(int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE / (double) mSeekBar.getMax());
/ (double) mSeekBar.getMax()); if (percentage == 0) {
if (percentage == 0) { updateMutedVolumeIcon();
updateMutedVolumeIcon(); } else {
} else { updateUnmutedVolumeIcon();
updateUnmutedVolumeIcon();
}
} }
mSeekBar.setVolume(currentVolume); mSeekBar.setVolume(currentVolume);
} }
} }
} else if (mController.isAdvancedLayoutSupported() && currentVolume == 0) { } else if (currentVolume == 0) {
mSeekBar.resetVolume(); mSeekBar.resetVolume();
updateMutedVolumeIcon(); updateMutedVolumeIcon();
} }
@@ -378,17 +346,15 @@ public abstract class MediaOutputBaseAdapter extends
} }
int progressToVolume = MediaOutputSeekbar.scaleProgressToVolume(progress); int progressToVolume = MediaOutputSeekbar.scaleProgressToVolume(progress);
int deviceVolume = device.getCurrentVolume(); int deviceVolume = device.getCurrentVolume();
if (mController.isAdvancedLayoutSupported()) { int percentage =
int percentage = (int) ((double) progressToVolume * VOLUME_PERCENTAGE_SCALE_SIZE
(int) ((double) progressToVolume * VOLUME_PERCENTAGE_SCALE_SIZE / (double) seekBar.getMax());
/ (double) seekBar.getMax()); mVolumeValueText.setText(mContext.getResources().getString(
mVolumeValueText.setText(mContext.getResources().getString( R.string.media_output_dialog_volume_percentage, percentage));
R.string.media_output_dialog_volume_percentage, percentage)); mVolumeValueText.setVisibility(View.VISIBLE);
mVolumeValueText.setVisibility(View.VISIBLE);
}
if (progressToVolume != deviceVolume) { if (progressToVolume != deviceVolume) {
mController.adjustVolume(device, progressToVolume); mController.adjustVolume(device, progressToVolume);
if (mController.isAdvancedLayoutSupported() && deviceVolume == 0) { if (deviceVolume == 0) {
updateUnmutedVolumeIcon(); updateUnmutedVolumeIcon();
} }
} }
@@ -396,30 +362,26 @@ public abstract class MediaOutputBaseAdapter extends
@Override @Override
public void onStartTrackingTouch(SeekBar seekBar) { public void onStartTrackingTouch(SeekBar seekBar) {
if (mController.isAdvancedLayoutSupported()) { mTitleIcon.setVisibility(View.INVISIBLE);
mTitleIcon.setVisibility(View.INVISIBLE); mVolumeValueText.setVisibility(View.VISIBLE);
mVolumeValueText.setVisibility(View.VISIBLE);
}
mIsDragging = true; mIsDragging = true;
} }
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
if (mController.isAdvancedLayoutSupported()) { int currentVolume = MediaOutputSeekbar.scaleProgressToVolume(
int currentVolume = MediaOutputSeekbar.scaleProgressToVolume( seekBar.getProgress());
seekBar.getProgress()); int percentage =
int percentage = (int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE
(int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE / (double) seekBar.getMax());
/ (double) seekBar.getMax()); if (percentage == 0) {
if (percentage == 0) { seekBar.setProgress(0);
seekBar.setProgress(0); updateMutedVolumeIcon();
updateMutedVolumeIcon(); } else {
} else { updateUnmutedVolumeIcon();
updateUnmutedVolumeIcon();
}
mTitleIcon.setVisibility(View.VISIBLE);
mVolumeValueText.setVisibility(View.GONE);
} }
mTitleIcon.setVisibility(View.VISIBLE);
mVolumeValueText.setVisibility(View.GONE);
mController.logInteractionAdjustVolume(device); mController.logInteractionAdjustVolume(device);
mIsDragging = false; mIsDragging = false;
} }
@@ -444,10 +406,8 @@ public abstract class MediaOutputBaseAdapter extends
void updateTitleIcon(@DrawableRes int id, int color) { void updateTitleIcon(@DrawableRes int id, int color) {
mTitleIcon.setImageDrawable(mContext.getDrawable(id)); mTitleIcon.setImageDrawable(mContext.getDrawable(id));
mTitleIcon.setImageTintList(ColorStateList.valueOf(color)); mTitleIcon.setImageTintList(ColorStateList.valueOf(color));
if (mController.isAdvancedLayoutSupported()) { mIconAreaLayout.setBackgroundTintList(
mIconAreaLayout.setBackgroundTintList( ColorStateList.valueOf(mController.getColorSeekbarProgress()));
ColorStateList.valueOf(mController.getColorSeekbarProgress()));
}
} }
void updateIconAreaClickListener(View.OnClickListener listener) { void updateIconAreaClickListener(View.OnClickListener listener) {
@@ -475,24 +435,18 @@ public abstract class MediaOutputBaseAdapter extends
(ClipDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable()) (ClipDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable())
.findDrawableByLayerId(android.R.id.progress); .findDrawableByLayerId(android.R.id.progress);
final GradientDrawable targetBackgroundDrawable = final GradientDrawable targetBackgroundDrawable =
(GradientDrawable) (mController.isAdvancedLayoutSupported() (GradientDrawable) (mIconAreaLayout.getBackground());
? mIconAreaLayout.getBackground()
: clipDrawable.getDrawable());
mCornerAnimator.addUpdateListener(animation -> { mCornerAnimator.addUpdateListener(animation -> {
float value = (float) animation.getAnimatedValue(); float value = (float) animation.getAnimatedValue();
layoutBackgroundDrawable.setCornerRadius(value); layoutBackgroundDrawable.setCornerRadius(value);
if (mController.isAdvancedLayoutSupported()) { if (toProgress == 0) {
if (toProgress == 0) {
targetBackgroundDrawable.setCornerRadius(value);
} else {
targetBackgroundDrawable.setCornerRadii(new float[]{
value,
value,
0, 0, 0, 0, value, value
});
}
} else {
targetBackgroundDrawable.setCornerRadius(value); targetBackgroundDrawable.setCornerRadius(value);
} else {
targetBackgroundDrawable.setCornerRadii(new float[]{
value,
value,
0, 0, 0, 0, value, value
});
} }
}); });
mVolumeAnimator.setIntValues(fromProgress, toProgress); mVolumeAnimator.setIntValues(fromProgress, toProgress);
@@ -539,9 +493,7 @@ public abstract class MediaOutputBaseAdapter extends
protected void disableSeekBar() { protected void disableSeekBar() {
mSeekBar.setEnabled(false); mSeekBar.setEnabled(false);
mSeekBar.setOnTouchListener((v, event) -> true); mSeekBar.setOnTouchListener((v, event) -> true);
if (mController.isAdvancedLayoutSupported()) { updateIconAreaClickListener(null);
updateIconAreaClickListener(null);
}
} }
private void enableSeekBar(MediaDevice device) { private void enableSeekBar(MediaDevice device) {

View File

@@ -270,10 +270,8 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
dismiss(); dismiss();
}); });
mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication); mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication);
if (mMediaOutputController.isAdvancedLayoutSupported()) { mMediaMetadataSectionLayout.setOnClickListener(
mMediaMetadataSectionLayout.setOnClickListener( mMediaOutputController::tryToLaunchMediaApplication);
mMediaOutputController::tryToLaunchMediaApplication);
}
} }
@Override @Override

View File

@@ -83,7 +83,6 @@ import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.DialogLaunchAnimator; import com.android.systemui.animation.DialogLaunchAnimator;
import com.android.systemui.broadcast.BroadcastSender; import com.android.systemui.broadcast.BroadcastSender;
import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.media.nearby.NearbyMediaDevicesManager; import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
import com.android.systemui.monet.ColorScheme; import com.android.systemui.monet.ColorScheme;
import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.ActivityStarter;
@@ -132,8 +131,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
private final Object mMediaDevicesLock = new Object(); private final Object mMediaDevicesLock = new Object();
@VisibleForTesting @VisibleForTesting
final List<MediaDevice> mGroupMediaDevices = new CopyOnWriteArrayList<>(); final List<MediaDevice> mGroupMediaDevices = new CopyOnWriteArrayList<>();
@VisibleForTesting
final List<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
final List<MediaDevice> mCachedMediaDevices = new CopyOnWriteArrayList<>(); final List<MediaDevice> mCachedMediaDevices = new CopyOnWriteArrayList<>();
private final List<MediaItem> mMediaItemList = new CopyOnWriteArrayList<>(); private final List<MediaItem> mMediaItemList = new CopyOnWriteArrayList<>();
private final AudioManager mAudioManager; private final AudioManager mAudioManager;
@@ -229,7 +226,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
void start(@NonNull Callback cb) { void start(@NonNull Callback cb) {
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
mCachedMediaDevices.clear(); mCachedMediaDevices.clear();
mMediaDevices.clear();
mMediaItemList.clear(); mMediaItemList.clear();
} }
mNearbyDeviceInfoMap.clear(); mNearbyDeviceInfoMap.clear();
@@ -277,7 +273,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
mLocalMediaManager.stopScan(); mLocalMediaManager.stopScan();
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
mCachedMediaDevices.clear(); mCachedMediaDevices.clear();
mMediaDevices.clear();
mMediaItemList.clear(); mMediaItemList.clear();
} }
if (mNearbyMediaDevicesManager != null) { if (mNearbyMediaDevicesManager != null) {
@@ -308,10 +303,9 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
@Override @Override
public void onDeviceListUpdate(List<MediaDevice> devices) { public void onDeviceListUpdate(List<MediaDevice> devices) {
boolean isListEmpty = boolean isListEmpty = mMediaItemList.isEmpty();
isAdvancedLayoutSupported() ? mMediaItemList.isEmpty() : mMediaDevices.isEmpty();
if (isListEmpty || !mIsRefreshing) { if (isListEmpty || !mIsRefreshing) {
buildMediaDevices(devices); buildMediaItems(devices);
mCallback.onDeviceListChanged(); mCallback.onDeviceListChanged();
} else { } else {
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
@@ -326,11 +320,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
public void onSelectedDeviceStateChanged(MediaDevice device, public void onSelectedDeviceStateChanged(MediaDevice device,
@LocalMediaManager.MediaDeviceState int state) { @LocalMediaManager.MediaDeviceState int state) {
mCallback.onRouteChanged(); mCallback.onRouteChanged();
if (isAdvancedLayoutSupported()) { mMetricLogger.logOutputItemSuccess(device.toString(), new ArrayList<>(mMediaItemList));
mMetricLogger.logOutputItemSuccess(device.toString(), new ArrayList<>(mMediaItemList));
} else {
mMetricLogger.logOutputSuccess(device.toString(), new ArrayList<>(mMediaDevices));
}
} }
@Override @Override
@@ -341,11 +331,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
@Override @Override
public void onRequestFailed(int reason) { public void onRequestFailed(int reason) {
mCallback.onRouteChanged(); mCallback.onRouteChanged();
if (isAdvancedLayoutSupported()) { mMetricLogger.logOutputItemFailure(new ArrayList<>(mMediaItemList), reason);
mMetricLogger.logOutputItemFailure(new ArrayList<>(mMediaItemList), reason);
} else {
mMetricLogger.logOutputFailure(new ArrayList<>(mMediaDevices), reason);
}
} }
/** /**
@@ -364,7 +350,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
} }
try { try {
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
mMediaDevices.removeIf(MediaDevice::isMutingExpectedDevice);
mMediaItemList.removeIf((MediaItem::isMutingExpectedDevice)); mMediaItemList.removeIf((MediaItem::isMutingExpectedDevice));
} }
mAudioManager.cancelMuteAwaitConnection(mAudioManager.getMutingExpectedDevice()); mAudioManager.cancelMuteAwaitConnection(mAudioManager.getMutingExpectedDevice());
@@ -569,7 +554,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
void refreshDataSetIfNeeded() { void refreshDataSetIfNeeded() {
if (mNeedRefresh) { if (mNeedRefresh) {
buildMediaDevices(mCachedMediaDevices); buildMediaItems(mCachedMediaDevices);
mCallback.onDeviceListChanged(); mCallback.onDeviceListChanged();
mNeedRefresh = false; mNeedRefresh = false;
} }
@@ -619,75 +604,9 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
return mItemMarginEndSelectable; return mItemMarginEndSelectable;
} }
private void buildMediaDevices(List<MediaDevice> devices) {
if (isAdvancedLayoutSupported()) {
buildMediaItems(devices);
} else {
buildDefaultMediaDevices(devices);
}
}
private void buildDefaultMediaDevices(List<MediaDevice> devices) {
synchronized (mMediaDevicesLock) {
attachRangeInfo(devices);
Collections.sort(devices, Comparator.naturalOrder());
// For the first time building list, to make sure the top device is the connected
// device.
if (mMediaDevices.isEmpty()) {
boolean needToHandleMutingExpectedDevice =
hasMutingExpectedDevice() && !isCurrentConnectedDeviceRemote();
final MediaDevice connectedMediaDevice =
needToHandleMutingExpectedDevice ? null
: getCurrentConnectedMediaDevice();
if (connectedMediaDevice == null) {
if (DEBUG) {
Log.d(TAG, "No connected media device or muting expected device exist.");
}
if (needToHandleMutingExpectedDevice) {
for (MediaDevice device : devices) {
if (device.isMutingExpectedDevice()) {
mMediaDevices.add(0, device);
} else {
mMediaDevices.add(device);
}
}
} else {
mMediaDevices.addAll(devices);
}
return;
}
for (MediaDevice device : devices) {
if (TextUtils.equals(device.getId(), connectedMediaDevice.getId())) {
mMediaDevices.add(0, device);
} else {
mMediaDevices.add(device);
}
}
return;
}
// To keep the same list order
final List<MediaDevice> targetMediaDevices = new ArrayList<>();
for (MediaDevice originalDevice : mMediaDevices) {
for (MediaDevice newDevice : devices) {
if (TextUtils.equals(originalDevice.getId(), newDevice.getId())) {
targetMediaDevices.add(newDevice);
break;
}
}
}
if (targetMediaDevices.size() != devices.size()) {
devices.removeAll(targetMediaDevices);
targetMediaDevices.addAll(devices);
}
mMediaDevices.clear();
mMediaDevices.addAll(targetMediaDevices);
}
}
private void buildMediaItems(List<MediaDevice> devices) { private void buildMediaItems(List<MediaDevice> devices) {
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
if (!isRouteProcessSupported() || (isRouteProcessSupported() if (!mLocalMediaManager.isPreferenceRouteListingExist()) {
&& !mLocalMediaManager.isPreferenceRouteListingExist())) {
attachRangeInfo(devices); attachRangeInfo(devices);
Collections.sort(devices, Comparator.naturalOrder()); Collections.sort(devices, Comparator.naturalOrder());
} }
@@ -811,18 +730,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
&& (currentConnectedMediaDevice.isHostForOngoingSession()); && (currentConnectedMediaDevice.isHostForOngoingSession());
} }
public boolean isAdvancedLayoutSupported() {
return mFeatureFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT);
}
public boolean isRouteProcessSupported() {
return mFeatureFlags.isEnabled(Flags.OUTPUT_SWITCHER_ROUTES_PROCESSING);
}
public boolean isSubStatusSupported() {
return mFeatureFlags.isEnabled(Flags.OUTPUT_SWITCHER_DEVICE_STATUS);
}
List<MediaDevice> getGroupMediaDevices() { List<MediaDevice> getGroupMediaDevices() {
final List<MediaDevice> selectedDevices = getSelectedMediaDevice(); final List<MediaDevice> selectedDevices = getSelectedMediaDevice();
final List<MediaDevice> selectableDevices = getSelectableMediaDevice(); final List<MediaDevice> selectableDevices = getSelectableMediaDevice();
@@ -867,10 +774,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
}); });
} }
Collection<MediaDevice> getMediaDevices() {
return mMediaDevices;
}
public List<MediaItem> getMediaItemList() { public List<MediaItem> getMediaItemList() {
return mMediaItemList; return mMediaItemList;
} }
@@ -957,19 +860,11 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
boolean isAnyDeviceTransferring() { boolean isAnyDeviceTransferring() {
synchronized (mMediaDevicesLock) { synchronized (mMediaDevicesLock) {
if (isAdvancedLayoutSupported()) { for (MediaItem mediaItem : mMediaItemList) {
for (MediaItem mediaItem : mMediaItemList) { if (mediaItem.getMediaDevice().isPresent()
if (mediaItem.getMediaDevice().isPresent() && mediaItem.getMediaDevice().get().getState()
&& mediaItem.getMediaDevice().get().getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
== LocalMediaManager.MediaDeviceState.STATE_CONNECTING) { return true;
return true;
}
}
} else {
for (MediaDevice device : mMediaDevices) {
if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
return true;
}
} }
} }
} }

View File

@@ -22,6 +22,7 @@ import static android.media.RouteListingPreference.Item.SUBTEXT_SUBSCRIPTION_REQ
import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_GO_TO_APP; import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_GO_TO_APP;
import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_NONE; import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_NONE;
import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECTION_BEHAVIOR_TRANSFER;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -94,10 +95,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Before @Before
public void setUp() { public void setUp() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(false);
when(mMediaOutputController.isSubStatusSupported()).thenReturn(false);
when(mMediaOutputController.getMediaItemList()).thenReturn(mMediaItems); when(mMediaOutputController.getMediaItemList()).thenReturn(mMediaItems);
when(mMediaOutputController.getMediaDevices()).thenReturn(mMediaDevices);
when(mMediaOutputController.hasAdjustVolumeUserRestriction()).thenReturn(false); when(mMediaOutputController.hasAdjustVolumeUserRestriction()).thenReturn(false);
when(mMediaOutputController.isAnyDeviceTransferring()).thenReturn(false); when(mMediaOutputController.isAnyDeviceTransferring()).thenReturn(false);
when(mMediaOutputController.getDeviceIconCompat(mMediaDevice1)).thenReturn(mIconCompat); when(mMediaOutputController.getDeviceIconCompat(mMediaDevice1)).thenReturn(mIconCompat);
@@ -126,85 +124,24 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void getItemCount_containExtraOneForPairNew() { public void getItemCount_returnsMediaItemSize() {
assertThat(mMediaOutputAdapter.getItemCount()).isEqualTo(mMediaDevices.size() + 1);
}
@Test
public void getItemId_validPosition_returnCorrespondingId() {
assertThat(mMediaOutputAdapter.getItemId(0)).isEqualTo(mMediaDevices.get(
0).getId().hashCode());
}
@Test
public void getItemId_invalidPosition_returnPosition() {
int invalidPosition = mMediaDevices.size() + 1;
assertThat(mMediaOutputAdapter.getItemId(invalidPosition)).isEqualTo(invalidPosition);
}
@Test
public void advanced_getItemCount_returnsMediaItemSize() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
assertThat(mMediaOutputAdapter.getItemCount()).isEqualTo(mMediaItems.size()); assertThat(mMediaOutputAdapter.getItemCount()).isEqualTo(mMediaItems.size());
} }
@Test @Test
public void advanced_getItemId_validPosition_returnCorrespondingId() { public void getItemId_validPosition_returnCorrespondingId() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
assertThat(mMediaOutputAdapter.getItemId(0)).isEqualTo(mMediaItems.get( assertThat(mMediaOutputAdapter.getItemId(0)).isEqualTo(mMediaItems.get(
0).getMediaDevice().get().getId().hashCode()); 0).getMediaDevice().get().getId().hashCode());
} }
@Test @Test
public void advanced_getItemId_invalidPosition_returnPosition() { public void getItemId_invalidPosition_returnPosition() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
int invalidPosition = mMediaItems.size() + 1; int invalidPosition = mMediaItems.size() + 1;
assertThat(mMediaOutputAdapter.getItemId(invalidPosition)).isEqualTo(invalidPosition); assertThat(mMediaOutputAdapter.getItemId(invalidPosition)).isEqualTo(invalidPosition);
} }
@Test @Test
public void onBindViewHolder_bindPairNew_verifyView() { public void onBindViewHolder_bindPairNew_verifyView() {
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 2);
assertThat(mViewHolder.mTitleText.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mViewHolder.mTwoLineLayout.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mProgressBar.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mCheckBox.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mTitleText.getText()).isEqualTo(mContext.getText(
R.string.media_output_dialog_pairing_new));
}
@Test
public void onBindViewHolder_bindGroup_withSessionName_verifyView() {
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(mMediaDevices);
when(mMediaOutputController.getSessionName()).thenReturn(TEST_SESSION_NAME);
mMediaOutputAdapter.getItemCount();
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
assertThat(mViewHolder.mSeekBar.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mViewHolder.mTwoLineLayout.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mTitleText.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mViewHolder.mProgressBar.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mCheckBox.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void onBindViewHolder_bindGroup_noSessionName_verifyView() {
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(mMediaDevices);
when(mMediaOutputController.getSessionName()).thenReturn(null);
mMediaOutputAdapter.getItemCount();
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
assertThat(mViewHolder.mSeekBar.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mViewHolder.mTwoLineLayout.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mTitleText.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mViewHolder.mProgressBar.getVisibility()).isEqualTo(View.GONE);
assertThat(mViewHolder.mCheckBox.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void advanced_onBindViewHolder_bindPairNew_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController); mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController);
mMediaOutputAdapter.updateItems(); mMediaOutputAdapter.updateItems();
mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
@@ -222,8 +159,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_bindGroup_withSessionName_verifyView() { public void onBindViewHolder_bindGroup_withSessionName_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn( when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(
mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect( mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect(
Collectors.toList())); Collectors.toList()));
@@ -243,8 +179,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_bindGroup_noSessionName_verifyView() { public void onBindViewHolder_bindGroup_noSessionName_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn( when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(
mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect( mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect(
Collectors.toList())); Collectors.toList()));
@@ -277,8 +212,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_bindNonRemoteConnectedDevice_verifyView() { public void onBindViewHolder_bindNonRemoteConnectedDevice_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.isActiveRemoteDevice(mMediaDevice1)).thenReturn(false); when(mMediaOutputController.isActiveRemoteDevice(mMediaDevice1)).thenReturn(false);
mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
.onCreateViewHolder(new LinearLayout(mContext), 0); .onCreateViewHolder(new LinearLayout(mContext), 0);
@@ -294,8 +228,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_bindConnectedRemoteDevice_verifyView() { public void onBindViewHolder_bindConnectedRemoteDevice_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn( when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(
ImmutableList.of(mMediaDevice2)); ImmutableList.of(mMediaDevice2));
when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(true); when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(true);
@@ -314,8 +247,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_bindSingleConnectedRemoteDevice_verifyView() { public void onBindViewHolder_bindSingleConnectedRemoteDevice_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn( when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(
ImmutableList.of()); ImmutableList.of());
when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(true); when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(true);
@@ -347,8 +279,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onBindViewHolder_isMutingExpectedDevice_verifyView() { public void onBindViewHolder_isMutingExpectedDevice_verifyView() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaDevice1.isMutingExpectedDevice()).thenReturn(true); when(mMediaDevice1.isMutingExpectedDevice()).thenReturn(true);
when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(false); when(mMediaOutputController.isCurrentConnectedDeviceRemote()).thenReturn(false);
when(mMediaOutputController.isActiveRemoteDevice(mMediaDevice1)).thenReturn(false); when(mMediaOutputController.isActiveRemoteDevice(mMediaDevice1)).thenReturn(false);
@@ -449,8 +380,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Test @Test
public void subStatusSupported_onBindViewHolder_bindHostDeviceWithOngoingSession_verifyView() { public void subStatusSupported_onBindViewHolder_bindHostDeviceWithOngoingSession_verifyView() {
when(mMediaOutputController.isSubStatusSupported()).thenReturn(true);
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.isVolumeControlEnabled(mMediaDevice1)).thenReturn(true); when(mMediaOutputController.isVolumeControlEnabled(mMediaDevice1)).thenReturn(true);
when(mMediaDevice1.isHostForOngoingSession()).thenReturn(true); when(mMediaDevice1.isHostForOngoingSession()).thenReturn(true);
when(mMediaDevice1.hasSubtext()).thenReturn(true); when(mMediaDevice1.hasSubtext()).thenReturn(true);
@@ -480,8 +409,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
public void subStatusSupported_onBindViewHolder_bindDeviceRequirePremium_verifyView() { public void subStatusSupported_onBindViewHolder_bindDeviceRequirePremium_verifyView() {
String deviceStatus = (String) mContext.getText( String deviceStatus = (String) mContext.getText(
R.string.media_output_status_require_premium); R.string.media_output_status_require_premium);
when(mMediaOutputController.isSubStatusSupported()).thenReturn(true);
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaDevice2.hasSubtext()).thenReturn(true); when(mMediaDevice2.hasSubtext()).thenReturn(true);
when(mMediaDevice2.getSubtext()).thenReturn(SUBTEXT_SUBSCRIPTION_REQUIRED); when(mMediaDevice2.getSubtext()).thenReturn(SUBTEXT_SUBSCRIPTION_REQUIRED);
when(mMediaDevice2.getSubtextString()).thenReturn(deviceStatus); when(mMediaDevice2.getSubtextString()).thenReturn(deviceStatus);
@@ -506,8 +433,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
public void subStatusSupported_onBindViewHolder_bindDeviceWithAdPlaying_verifyView() { public void subStatusSupported_onBindViewHolder_bindDeviceWithAdPlaying_verifyView() {
String deviceStatus = (String) mContext.getText( String deviceStatus = (String) mContext.getText(
R.string.media_output_status_try_after_ad); R.string.media_output_status_try_after_ad);
when(mMediaOutputController.isSubStatusSupported()).thenReturn(true);
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaDevice2.hasSubtext()).thenReturn(true); when(mMediaDevice2.hasSubtext()).thenReturn(true);
when(mMediaDevice2.getSubtext()).thenReturn(SUBTEXT_AD_ROUTING_DISALLOWED); when(mMediaDevice2.getSubtext()).thenReturn(SUBTEXT_AD_ROUTING_DISALLOWED);
when(mMediaDevice2.getSubtextString()).thenReturn(deviceStatus); when(mMediaDevice2.getSubtextString()).thenReturn(deviceStatus);
@@ -531,8 +456,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Test @Test
public void subStatusSupported_onBindViewHolder_bindDeviceWithOngoingSession_verifyView() { public void subStatusSupported_onBindViewHolder_bindDeviceWithOngoingSession_verifyView() {
when(mMediaOutputController.isSubStatusSupported()).thenReturn(true);
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaDevice1.hasSubtext()).thenReturn(true); when(mMediaDevice1.hasSubtext()).thenReturn(true);
when(mMediaDevice1.getSubtext()).thenReturn(SUBTEXT_CUSTOM); when(mMediaDevice1.getSubtext()).thenReturn(SUBTEXT_CUSTOM);
when(mMediaDevice1.getSubtextString()).thenReturn(TEST_CUSTOM_SUBTEXT); when(mMediaDevice1.getSubtextString()).thenReturn(TEST_CUSTOM_SUBTEXT);
@@ -603,15 +526,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Test @Test
public void onItemClick_clickPairNew_verifyLaunchBluetoothPairing() { public void onItemClick_clickPairNew_verifyLaunchBluetoothPairing() {
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 2);
mViewHolder.mContainerLayout.performClick();
verify(mMediaOutputController).launchBluetoothPairing(mViewHolder.mContainerLayout);
}
@Test
public void advanced_onItemClick_clickPairNew_verifyLaunchBluetoothPairing() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController); mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController);
mMediaOutputAdapter.updateItems(); mMediaOutputAdapter.updateItems();
mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
@@ -629,6 +543,12 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
when(mMediaOutputController.isCurrentOutputDeviceHasSessionOngoing()).thenReturn(false); when(mMediaOutputController.isCurrentOutputDeviceHasSessionOngoing()).thenReturn(false);
assertThat(mMediaDevice2.getState()).isEqualTo( assertThat(mMediaDevice2.getState()).isEqualTo(
LocalMediaManager.MediaDeviceState.STATE_DISCONNECTED); LocalMediaManager.MediaDeviceState.STATE_DISCONNECTED);
when(mMediaDevice2.getSelectionBehavior()).thenReturn(SELECTION_BEHAVIOR_TRANSFER);
mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController);
mMediaOutputAdapter.updateItems();
mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
.onCreateViewHolder(new LinearLayout(mContext), 0);
mMediaOutputAdapter.getItemCount();
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 1); mMediaOutputAdapter.onBindViewHolder(mViewHolder, 1);
mViewHolder.mContainerLayout.performClick(); mViewHolder.mContainerLayout.performClick();
@@ -641,7 +561,13 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
when(mMediaOutputController.isCurrentOutputDeviceHasSessionOngoing()).thenReturn(true); when(mMediaOutputController.isCurrentOutputDeviceHasSessionOngoing()).thenReturn(true);
assertThat(mMediaDevice2.getState()).isEqualTo( assertThat(mMediaDevice2.getState()).isEqualTo(
LocalMediaManager.MediaDeviceState.STATE_DISCONNECTED); LocalMediaManager.MediaDeviceState.STATE_DISCONNECTED);
when(mMediaDevice2.getSelectionBehavior()).thenReturn(SELECTION_BEHAVIOR_TRANSFER);
mMediaOutputAdapter = new MediaOutputAdapter(mMediaOutputController);
mMediaOutputAdapter.updateItems();
mViewHolder = (MediaOutputAdapter.MediaDeviceViewHolder) mMediaOutputAdapter
.onCreateViewHolder(new LinearLayout(mContext), 0);
MediaOutputAdapter.MediaDeviceViewHolder spyMediaDeviceViewHolder = spy(mViewHolder); MediaOutputAdapter.MediaDeviceViewHolder spyMediaDeviceViewHolder = spy(mViewHolder);
mMediaOutputAdapter.getItemCount();
mMediaOutputAdapter.onBindViewHolder(spyMediaDeviceViewHolder, 0); mMediaOutputAdapter.onBindViewHolder(spyMediaDeviceViewHolder, 0);
mMediaOutputAdapter.onBindViewHolder(spyMediaDeviceViewHolder, 1); mMediaOutputAdapter.onBindViewHolder(spyMediaDeviceViewHolder, 1);
@@ -665,20 +591,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void onItemClick_clicksSelectableDevice_triggerGrouping() { public void onGroupActionTriggered_clicksEndAreaOfSelectableDevice_triggerGrouping() {
List<MediaDevice> selectableDevices = new ArrayList<>();
selectableDevices.add(mMediaDevice2);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(selectableDevices);
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 1);
mViewHolder.mContainerLayout.performClick();
verify(mMediaOutputController).addDeviceToPlayMedia(mMediaDevice2);
}
@Test
public void advanced_onGroupActionTriggered_clicksEndAreaOfSelectableDevice_triggerGrouping() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
List<MediaDevice> selectableDevices = new ArrayList<>(); List<MediaDevice> selectableDevices = new ArrayList<>();
selectableDevices.add(mMediaDevice2); selectableDevices.add(mMediaDevice2);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(selectableDevices); when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(selectableDevices);
@@ -692,8 +605,7 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onGroupActionTriggered_clickSelectedRemoteDevice_triggerUngrouping() { public void onGroupActionTriggered_clickSelectedRemoteDevice_triggerUngrouping() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn( when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(
ImmutableList.of(mMediaDevice2)); ImmutableList.of(mMediaDevice2));
when(mMediaOutputController.getDeselectableMediaDevice()).thenReturn( when(mMediaOutputController.getDeselectableMediaDevice()).thenReturn(
@@ -710,21 +622,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Test @Test
public void onItemClick_onGroupActionTriggered_verifySeekbarDisabled() { public void onItemClick_onGroupActionTriggered_verifySeekbarDisabled() {
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(mMediaDevices);
List<MediaDevice> selectableDevices = new ArrayList<>();
selectableDevices.add(mMediaDevice1);
when(mMediaOutputController.getSelectableMediaDevice()).thenReturn(selectableDevices);
when(mMediaOutputController.hasAdjustVolumeUserRestriction()).thenReturn(true);
mMediaOutputAdapter.onBindViewHolder(mViewHolder, 0);
mViewHolder.mContainerLayout.performClick();
assertThat(mViewHolder.mSeekBar.isEnabled()).isFalse();
}
@Test
public void advanced_onItemClick_onGroupActionTriggered_verifySeekbarDisabled() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
when(mMediaOutputController.getSelectedMediaDevice()).thenReturn( when(mMediaOutputController.getSelectedMediaDevice()).thenReturn(
mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect( mMediaItems.stream().map((item) -> item.getMediaDevice().get()).collect(
Collectors.toList())); Collectors.toList()));
@@ -767,7 +664,6 @@ public class MediaOutputAdapterTest extends SysuiTestCase {
@Test @Test
public void updateItems_controllerItemsUpdated_notUpdatesInAdapterUntilUpdateItems() { public void updateItems_controllerItemsUpdated_notUpdatesInAdapterUntilUpdateItems() {
when(mMediaOutputController.isAdvancedLayoutSupported()).thenReturn(true);
mMediaOutputAdapter.updateItems(); mMediaOutputAdapter.updateItems();
List<MediaItem> updatedList = new ArrayList<>(); List<MediaItem> updatedList = new ArrayList<>();
updatedList.add(new MediaItem()); updatedList.add(new MediaItem());

View File

@@ -76,7 +76,6 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.DialogLaunchAnimator; import com.android.systemui.animation.DialogLaunchAnimator;
import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.media.nearby.NearbyMediaDevicesManager; import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.settings.UserTracker; import com.android.systemui.settings.UserTracker;
@@ -200,8 +199,6 @@ public class MediaOutputControllerTest extends SysuiTestCase {
mNotifCollection, mDialogLaunchAnimator, mNotifCollection, mDialogLaunchAnimator,
Optional.of(mNearbyMediaDevicesManager), mAudioManager, mPowerExemptionManager, Optional.of(mNearbyMediaDevicesManager), mAudioManager, mPowerExemptionManager,
mKeyguardManager, mFlags, mUserTracker); mKeyguardManager, mFlags, mUserTracker);
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(false);
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ROUTES_PROCESSING)).thenReturn(false);
mLocalMediaManager = spy(mMediaOutputController.mLocalMediaManager); mLocalMediaManager = spy(mMediaOutputController.mLocalMediaManager);
when(mLocalMediaManager.isPreferenceRouteListingExist()).thenReturn(false); when(mLocalMediaManager.isPreferenceRouteListingExist()).thenReturn(false);
mMediaOutputController.mLocalMediaManager = mLocalMediaManager; mMediaOutputController.mLocalMediaManager = mLocalMediaManager;
@@ -401,25 +398,10 @@ public class MediaOutputControllerTest extends SysuiTestCase {
assertThat(mMediaDevices.get(0).getId()).isEqualTo(TEST_DEVICE_1_ID); assertThat(mMediaDevices.get(0).getId()).isEqualTo(TEST_DEVICE_1_ID);
} }
@Test
public void onDeviceListUpdate_verifyDeviceListCallback() {
mMediaOutputController.start(mCb);
reset(mCb);
mMediaOutputController.onDeviceListUpdate(mMediaDevices);
final List<MediaDevice> devices = new ArrayList<>(mMediaOutputController.getMediaDevices());
assertThat(devices.containsAll(mMediaDevices)).isTrue();
assertThat(devices.size()).isEqualTo(mMediaDevices.size());
verify(mCb).onDeviceListChanged();
}
@Test @Test
public void routeProcessSupport_onDeviceListUpdate_preferenceExist_NotUpdatesRangeInformation() public void routeProcessSupport_onDeviceListUpdate_preferenceExist_NotUpdatesRangeInformation()
throws RemoteException { throws RemoteException {
when(mLocalMediaManager.isPreferenceRouteListingExist()).thenReturn(true); when(mLocalMediaManager.isPreferenceRouteListingExist()).thenReturn(true);
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ROUTES_PROCESSING)).thenReturn(true);
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
mMediaOutputController.start(mCb); mMediaOutputController.start(mCb);
reset(mCb); reset(mCb);
@@ -431,8 +413,7 @@ public class MediaOutputControllerTest extends SysuiTestCase {
} }
@Test @Test
public void advanced_onDeviceListUpdate_verifyDeviceListCallback() { public void onDeviceListUpdate_verifyDeviceListCallback() {
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
mMediaOutputController.start(mCb); mMediaOutputController.start(mCb);
reset(mCb); reset(mCb);
@@ -453,7 +434,6 @@ public class MediaOutputControllerTest extends SysuiTestCase {
@Test @Test
public void advanced_onDeviceListUpdateWithConnectedDeviceRemote_verifyItemSize() { public void advanced_onDeviceListUpdateWithConnectedDeviceRemote_verifyItemSize() {
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
when(mMediaDevice1.getFeatures()).thenReturn( when(mMediaDevice1.getFeatures()).thenReturn(
ImmutableList.of(MediaRoute2Info.FEATURE_REMOTE_PLAYBACK)); ImmutableList.of(MediaRoute2Info.FEATURE_REMOTE_PLAYBACK));
when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mMediaDevice1); when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mMediaDevice1);
@@ -477,7 +457,6 @@ public class MediaOutputControllerTest extends SysuiTestCase {
@Test @Test
public void advanced_categorizeMediaItems_withSuggestedDevice_verifyDeviceListSize() { public void advanced_categorizeMediaItems_withSuggestedDevice_verifyDeviceListSize() {
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
when(mMediaDevice1.isSuggestedDevice()).thenReturn(true); when(mMediaDevice1.isSuggestedDevice()).thenReturn(true);
when(mMediaDevice2.isSuggestedDevice()).thenReturn(false); when(mMediaDevice2.isSuggestedDevice()).thenReturn(false);
@@ -515,7 +494,6 @@ public class MediaOutputControllerTest extends SysuiTestCase {
@Test @Test
public void advanced_onDeviceListUpdate_isRefreshing_updatesNeedRefreshToTrue() { public void advanced_onDeviceListUpdate_isRefreshing_updatesNeedRefreshToTrue() {
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
mMediaOutputController.start(mCb); mMediaOutputController.start(mCb);
reset(mCb); reset(mCb);
mMediaOutputController.mIsRefreshing = true; mMediaOutputController.mIsRefreshing = true;
@@ -717,7 +695,6 @@ public class MediaOutputControllerTest extends SysuiTestCase {
@Test @Test
public void isAnyDeviceTransferring_advancedLayoutSupport() { public void isAnyDeviceTransferring_advancedLayoutSupport() {
when(mFlags.isEnabled(Flags.OUTPUT_SWITCHER_ADVANCED_LAYOUT)).thenReturn(true);
when(mMediaDevice1.getState()).thenReturn( when(mMediaDevice1.getState()).thenReturn(
LocalMediaManager.MediaDeviceState.STATE_CONNECTING); LocalMediaManager.MediaDeviceState.STATE_CONNECTING);
mMediaOutputController.start(mCb); mMediaOutputController.start(mCb);