diff options
5 files changed, 66 insertions, 57 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java index 684a9aaf36aa..c9e831256cf4 100644 --- a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java @@ -31,7 +31,6 @@ import static android.media.MediaRoute2Info.TYPE_USB_DEVICE; import static android.media.MediaRoute2Info.TYPE_USB_HEADSET; import static android.media.MediaRoute2Info.TYPE_WIRED_HEADPHONES; import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET; -import static android.media.MediaRoute2ProviderService.REASON_UNKNOWN_ERROR; import static com.android.settingslib.media.LocalMediaManager.MediaDeviceState.STATE_SELECTED; @@ -621,9 +620,11 @@ public class InfoMediaManager extends MediaManager { dispatchConnectedDeviceChanged(id); } + /** + * Ignore callback here since we'll also receive {@link onRequestFailed} with reason code. + */ @Override public void onTransferFailed(RoutingSessionInfo session, MediaRoute2Info route) { - dispatchOnRequestFailed(REASON_UNKNOWN_ERROR); } @Override diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java index f63c06adbea2..270fda89c212 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java @@ -30,6 +30,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -799,12 +800,12 @@ public class InfoMediaManagerTest { } @Test - public void onTransferFailed_shouldDispatchOnRequestFailed() { + public void onTransferFailed_notDispatchOnRequestFailed() { mInfoMediaManager.registerCallback(mCallback); mInfoMediaManager.mMediaRouterCallback.onTransferFailed(null, null); - verify(mCallback).onRequestFailed(REASON_UNKNOWN_ERROR); + verify(mCallback, never()).onRequestFailed(REASON_UNKNOWN_ERROR); } @Test diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java index 00e9a79a3213..d037f0941ec7 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java @@ -25,8 +25,6 @@ import static android.media.RouteListingPreference.Item.SUBTEXT_SUBSCRIPTION_REQ import android.content.Context; import android.content.res.ColorStateList; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; @@ -296,6 +294,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { && mController.isAdvancedLayoutSupported()) { //If device is connected and there's other selectable devices, layout as // one of selected devices. + updateTitleIcon(R.drawable.media_output_icon_volume, + mController.getColorItemContent()); boolean isDeviceDeselectable = isDeviceIncluded( mController.getDeselectableMediaDevice(), device); updateGroupableCheckBox(true, isDeviceDeselectable, device); @@ -371,7 +371,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { mEndClickIcon.setOnClickListener(null); mEndTouchArea.setOnClickListener(null); updateEndClickAreaColor(mController.getColorSeekbarProgress()); - mEndClickIcon.setColorFilter(mController.getColorItemContent()); + mEndClickIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); mEndClickIcon.setOnClickListener( v -> mController.tryToLaunchInAppRoutingIntent(device.getId(), v)); mEndTouchArea.setOnClickListener(v -> mCheckBox.performClick()); @@ -379,8 +380,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { public void updateEndClickAreaColor(int color) { if (mController.isAdvancedLayoutSupported()) { - mEndTouchArea.getBackground().setColorFilter( - new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); + mEndTouchArea.setBackgroundTintList( + ColorStateList.valueOf(color)); } } @@ -394,22 +395,22 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { private void updateConnectionFailedStatusIcon() { mStatusIcon.setImageDrawable( mContext.getDrawable(R.drawable.media_output_status_failed)); - mStatusIcon.setColorFilter(mController.getColorItemContent()); + mStatusIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); } private void updateDeviceStatusIcon(Drawable drawable) { mStatusIcon.setImageDrawable(drawable); - mStatusIcon.setColorFilter(mController.getColorItemContent()); + mStatusIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); if (drawable instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable) drawable).start(); } } private void updateProgressBarColor() { - mProgressBar.getIndeterminateDrawable().setColorFilter( - new PorterDuffColorFilter( - mController.getColorItemContent(), - PorterDuff.Mode.SRC_IN)); + mProgressBar.getIndeterminateDrawable().setTintList( + ColorStateList.valueOf(mController.getColorItemContent())); } public void updateEndClickArea(MediaDevice device, boolean isDeviceDeselectable) { @@ -419,9 +420,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { mEndTouchArea.setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES); if (mController.isAdvancedLayoutSupported()) { - mEndTouchArea.getBackground().setColorFilter( - new PorterDuffColorFilter(mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + mEndTouchArea.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorItemBackground())); } setUpContentDescriptionForView(mEndTouchArea, true, device); } @@ -450,11 +450,11 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new)); final Drawable addDrawable = mContext.getDrawable(R.drawable.ic_add); mTitleIcon.setImageDrawable(addDrawable); - mTitleIcon.setColorFilter(mController.getColorItemContent()); + mTitleIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); if (mController.isAdvancedLayoutSupported()) { - mIconAreaLayout.getBackground().setColorFilter( - new PorterDuffColorFilter(mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorItemBackground())); } mContainerLayout.setOnClickListener(mController::launchBluetoothPairing); } diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index 2a2cf63464ce..f76f049abf97 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -23,8 +23,7 @@ import android.animation.ValueAnimator; import android.annotation.DrawableRes; import android.app.WallpaperColors; import android.content.Context; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; +import android.content.res.ColorStateList; import android.graphics.Typeface; import android.graphics.drawable.ClipDrawable; import android.graphics.drawable.Drawable; @@ -196,9 +195,8 @@ public abstract class MediaOutputBaseAdapter extends mIconAreaLayout.setOnClickListener(null); mVolumeValueText.setTextColor(mController.getColorItemContent()); } - mSeekBar.getProgressDrawable().setColorFilter( - new PorterDuffColorFilter(mController.getColorSeekbarProgress(), - PorterDuff.Mode.SRC_IN)); + mSeekBar.setProgressTintList( + ColorStateList.valueOf(mController.getColorSeekbarProgress())); } abstract void onBind(int customizedItem); @@ -224,16 +222,14 @@ public abstract class MediaOutputBaseAdapter extends updateSeekbarProgressBackground(); } } - mItemLayout.getBackground().setColorFilter(new PorterDuffColorFilter( - isActive ? mController.getColorConnectedItemBackground() - : mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + mItemLayout.setBackgroundTintList( + ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground() + : mController.getColorItemBackground())); if (mController.isAdvancedLayoutSupported()) { - mIconAreaLayout.getBackground().setColorFilter(new PorterDuffColorFilter( - showSeekBar ? mController.getColorSeekbarProgress() + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress() : showProgressBar ? mController.getColorConnectedItemBackground() - : mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + : mController.getColorItemBackground())); } mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mSeekBar.setAlpha(1); @@ -251,7 +247,8 @@ public abstract class MediaOutputBaseAdapter extends params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable() : mController.getItemMarginEndDefault(); } - mTitleIcon.setColorFilter(mController.getColorItemContent()); + mTitleIcon.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorItemContent())); } void setTwoLineLayout(MediaDevice device, boolean bFocused, boolean showSeekBar, @@ -274,15 +271,14 @@ public abstract class MediaOutputBaseAdapter extends backgroundDrawable = mContext.getDrawable( showSeekBar ? R.drawable.media_output_item_background_active : R.drawable.media_output_item_background).mutate(); - backgroundDrawable.setColorFilter(new PorterDuffColorFilter( + backgroundDrawable.setTint( showSeekBar ? mController.getColorConnectedItemBackground() - : mController.getColorItemBackground(), PorterDuff.Mode.SRC_IN)); - mIconAreaLayout.getBackground().setColorFilter(new PorterDuffColorFilter( - showProgressBar || isFakeActive + : mController.getColorItemBackground()); + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(showProgressBar || isFakeActive ? mController.getColorConnectedItemBackground() : showSeekBar ? mController.getColorSeekbarProgress() - : mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + : mController.getColorItemBackground())); if (showSeekBar) { updateSeekbarProgressBackground(); } @@ -297,9 +293,7 @@ public abstract class MediaOutputBaseAdapter extends backgroundDrawable = mContext.getDrawable( R.drawable.media_output_item_background) .mutate(); - backgroundDrawable.setColorFilter(new PorterDuffColorFilter( - mController.getColorItemBackground(), - PorterDuff.Mode.SRC_IN)); + backgroundDrawable.setTint(mController.getColorItemBackground()); } mItemLayout.setBackground(backgroundDrawable); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); @@ -442,11 +436,10 @@ public abstract class MediaOutputBaseAdapter extends void updateTitleIcon(@DrawableRes int id, int color) { mTitleIcon.setImageDrawable(mContext.getDrawable(id)); - mTitleIcon.setColorFilter(color); + mTitleIcon.setImageTintList(ColorStateList.valueOf(color)); if (mController.isAdvancedLayoutSupported()) { - mIconAreaLayout.getBackground().setColorFilter( - new PorterDuffColorFilter(mController.getColorSeekbarProgress(), - PorterDuff.Mode.SRC_IN)); + mIconAreaLayout.setBackgroundTintList( + ColorStateList.valueOf(mController.getColorSeekbarProgress())); } } @@ -462,9 +455,7 @@ public abstract class MediaOutputBaseAdapter extends final Drawable backgroundDrawable = mContext.getDrawable( R.drawable.media_output_item_background_active) .mutate(); - backgroundDrawable.setColorFilter( - new PorterDuffColorFilter(mController.getColorConnectedItemBackground(), - PorterDuff.Mode.SRC_IN)); + backgroundDrawable.setTint(mController.getColorConnectedItemBackground()); mItemLayout.setBackground(backgroundDrawable); } @@ -539,10 +530,8 @@ public abstract class MediaOutputBaseAdapter extends Drawable getSpeakerDrawable() { final Drawable drawable = mContext.getDrawable(R.drawable.ic_speaker_group_black_24dp) .mutate(); - drawable.setColorFilter( - new PorterDuffColorFilter(Utils.getColorStateListDefaultColor(mContext, - R.color.media_dialog_item_main_content), - PorterDuff.Mode.SRC_IN)); + drawable.setTint(Utils.getColorStateListDefaultColor(mContext, + R.color.media_dialog_item_main_content)); return drawable; } @@ -574,7 +563,9 @@ public abstract class MediaOutputBaseAdapter extends return; } mTitleIcon.setImageIcon(icon); - mTitleIcon.setColorFilter(mController.getColorItemContent()); + icon.setTint(mController.getColorItemContent()); + mTitleIcon.setImageTintList( + ColorStateList.valueOf(mController.getColorItemContent())); }); }); } diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java index 2250d72d8658..39d4e6e8d68a 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputMetricLogger.java @@ -80,6 +80,10 @@ public class MediaOutputMetricLogger { Log.d(TAG, "logOutputSuccess - selected device: " + selectedDeviceType); } + if (mSourceDevice == null && mTargetDevice == null) { + return; + } + updateLoggingDeviceCount(deviceList); SysUiStatsLog.write( @@ -105,6 +109,10 @@ public class MediaOutputMetricLogger { Log.d(TAG, "logOutputSuccess - selected device: " + selectedDeviceType); } + if (mSourceDevice == null && mTargetDevice == null) { + return; + } + updateLoggingMediaItemCount(deviceItemList); SysUiStatsLog.write( @@ -176,6 +184,10 @@ public class MediaOutputMetricLogger { Log.e(TAG, "logRequestFailed - " + reason); } + if (mSourceDevice == null && mTargetDevice == null) { + return; + } + updateLoggingDeviceCount(deviceList); SysUiStatsLog.write( @@ -201,6 +213,10 @@ public class MediaOutputMetricLogger { Log.e(TAG, "logRequestFailed - " + reason); } + if (mSourceDevice == null && mTargetDevice == null) { + return; + } + updateLoggingMediaItemCount(deviceItemList); SysUiStatsLog.write( |