[DO NOT MERGE] Add the logging logic to distinguish the SS-reactivated resume media and user-activated one when there is no recommendation card.
Fixes: 213379423 Test: atest com.android.systemui.media Change-Id: Ic5164ef5372654be9a049085aeea7ed559f3edd4
This commit is contained in:
@@ -209,17 +209,17 @@ class MediaCarouselController @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (addOrUpdatePlayer(key, oldKey, data)) {
|
||||
if (addOrUpdatePlayer(key, oldKey, data, isSsReactivated)) {
|
||||
// Log card received if a new resumable media card is added
|
||||
MediaPlayerData.getMediaPlayer(key)?.let {
|
||||
/* ktlint-disable max-line-length */
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
it.mUid,
|
||||
/* isRecommendationCard */ false,
|
||||
intArrayOf(
|
||||
surfaces = intArrayOf(
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||
rank = MediaPlayerData.getMediaPlayerIndex(key))
|
||||
@@ -242,8 +242,7 @@ class MediaCarouselController @Inject constructor(
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
it.mUid,
|
||||
/* isRecommendationCard */ false,
|
||||
intArrayOf(
|
||||
surfaces = intArrayOf(
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||
rank = index,
|
||||
@@ -277,12 +276,17 @@ class MediaCarouselController @Inject constructor(
|
||||
override fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean,
|
||||
isSsReactivated: Boolean
|
||||
shouldPrioritize: Boolean
|
||||
) {
|
||||
if (DEBUG) Log.d(TAG, "Loading Smartspace media update")
|
||||
// Log the case where the hidden media carousel with the existed inactive resume
|
||||
// media is shown by the Smartspace signal.
|
||||
if (data.isActive) {
|
||||
if (isSsReactivated && shouldPrioritize) {
|
||||
val hasActivatedExistedResumeMedia =
|
||||
!mediaManager.hasActiveMedia() &&
|
||||
mediaManager.hasAnyMedia() &&
|
||||
shouldPrioritize
|
||||
if (hasActivatedExistedResumeMedia) {
|
||||
// Log resume card received if resumable media card is reactivated and
|
||||
// recommendation card is valid and ranked first
|
||||
MediaPlayerData.players().forEachIndexed { index, it ->
|
||||
@@ -294,8 +298,7 @@ class MediaCarouselController @Inject constructor(
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
it.mUid,
|
||||
/* isRecommendationCard */ false,
|
||||
intArrayOf(
|
||||
surfaces = intArrayOf(
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||
rank = index,
|
||||
@@ -310,8 +313,7 @@ class MediaCarouselController @Inject constructor(
|
||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||
it.mInstanceId,
|
||||
it.mUid,
|
||||
/* isRecommendationCard */ true,
|
||||
intArrayOf(
|
||||
surfaces = intArrayOf(
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||
rank = MediaPlayerData.getMediaPlayerIndex(key),
|
||||
@@ -408,7 +410,12 @@ class MediaCarouselController @Inject constructor(
|
||||
}
|
||||
|
||||
// Returns true if new player is added
|
||||
private fun addOrUpdatePlayer(key: String, oldKey: String?, data: MediaData): Boolean {
|
||||
private fun addOrUpdatePlayer(
|
||||
key: String,
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
isSsReactivated: Boolean
|
||||
): Boolean {
|
||||
val dataCopy = data.copy(backgroundColor = bgColor)
|
||||
MediaPlayerData.moveIfExists(oldKey, key)
|
||||
val existingPlayer = MediaPlayerData.getMediaPlayer(key)
|
||||
@@ -424,12 +431,13 @@ class MediaCarouselController @Inject constructor(
|
||||
newPlayer.playerViewHolder?.player?.setLayoutParams(lp)
|
||||
newPlayer.bindPlayer(dataCopy, key)
|
||||
newPlayer.setListening(currentlyExpanded)
|
||||
MediaPlayerData.addMediaPlayer(key, dataCopy, newPlayer, systemClock)
|
||||
MediaPlayerData.addMediaPlayer(key, dataCopy, newPlayer, systemClock, isSsReactivated)
|
||||
updatePlayerToState(newPlayer, noAnimation = true)
|
||||
reorderAllPlayers(curVisibleMediaKey)
|
||||
} else {
|
||||
existingPlayer.bindPlayer(dataCopy, key)
|
||||
MediaPlayerData.addMediaPlayer(key, dataCopy, existingPlayer, systemClock)
|
||||
MediaPlayerData.addMediaPlayer(key, dataCopy, existingPlayer, systemClock,
|
||||
isSsReactivated)
|
||||
if (visualStabilityManager.isReorderingAllowed || shouldScrollToActivePlayer) {
|
||||
reorderAllPlayers(curVisibleMediaKey)
|
||||
} else {
|
||||
@@ -523,8 +531,10 @@ class MediaCarouselController @Inject constructor(
|
||||
it.targetId, it, MediaPlayerData.shouldPrioritizeSs)
|
||||
}
|
||||
} else {
|
||||
val isSsReactivated = MediaPlayerData.isSsReactivated(key)
|
||||
removePlayer(key, dismissMediaData = false, dismissRecommendation = false)
|
||||
addOrUpdatePlayer(key = key, oldKey = null, data = data)
|
||||
addOrUpdatePlayer(
|
||||
key = key, oldKey = null, data = data, isSsReactivated = isSsReactivated)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -682,7 +692,8 @@ class MediaCarouselController @Inject constructor(
|
||||
this.desiredHostState = it
|
||||
currentlyExpanded = it.expansion > 0
|
||||
|
||||
val shouldCloseGuts = !currentlyExpanded && !mediaManager.hasActiveMedia() &&
|
||||
val shouldCloseGuts = !currentlyExpanded &&
|
||||
!mediaManager.hasActiveMediaOrRecommendation() &&
|
||||
desiredHostState.showsOnlyActiveMedia
|
||||
|
||||
for (mediaPlayer in MediaPlayerData.players()) {
|
||||
@@ -747,7 +758,6 @@ class MediaCarouselController @Inject constructor(
|
||||
val mediaControlPanel = MediaPlayerData.players().elementAt(visibleMediaIndex)
|
||||
val hasActiveMediaOrRecommendationCard =
|
||||
MediaPlayerData.hasActiveMediaOrRecommendationCard()
|
||||
val isRecommendationCard = mediaControlPanel.recommendationViewHolder != null
|
||||
if (!hasActiveMediaOrRecommendationCard && !qsExpanded) {
|
||||
// Skip logging if on LS or QQS, and there is no active media card
|
||||
return
|
||||
@@ -755,7 +765,6 @@ class MediaCarouselController @Inject constructor(
|
||||
logSmartspaceCardReported(800, // SMARTSPACE_CARD_SEEN
|
||||
mediaControlPanel.mInstanceId,
|
||||
mediaControlPanel.mUid,
|
||||
isRecommendationCard,
|
||||
intArrayOf(mediaControlPanel.surfaceForSmartspaceLogging))
|
||||
mediaControlPanel.mIsImpressed = true
|
||||
}
|
||||
@@ -769,7 +778,6 @@ class MediaCarouselController @Inject constructor(
|
||||
* @param instanceId id to uniquely identify a card, e.g. each headphone generates a new
|
||||
* instanceId
|
||||
* @param uid uid for the application that media comes from
|
||||
* @param isRecommendationCard whether the card is media recommendation
|
||||
* @param surfaces list of display surfaces the media card is on (e.g. lockscreen, shade) when
|
||||
* the event happened
|
||||
* @param interactedSubcardRank the rank for interacted media item for recommendation card, -1
|
||||
@@ -779,21 +787,27 @@ class MediaCarouselController @Inject constructor(
|
||||
* @param rank the rank for media card in the media carousel, starting from 0
|
||||
* @param receivedLatencyMillis latency in milliseconds for card received events. E.g. latency
|
||||
* between headphone connection to sysUI displays media recommendation card
|
||||
* @param isSwipeToDismiss whether is to log swipe-to-dismiss event
|
||||
*
|
||||
*/
|
||||
fun logSmartspaceCardReported(
|
||||
eventId: Int,
|
||||
instanceId: Int,
|
||||
uid: Int,
|
||||
isRecommendationCard: Boolean,
|
||||
surfaces: IntArray,
|
||||
interactedSubcardRank: Int = 0,
|
||||
interactedSubcardCardinality: Int = 0,
|
||||
rank: Int = mediaCarouselScrollHandler.visibleMediaIndex,
|
||||
receivedLatencyMillis: Int = 0
|
||||
receivedLatencyMillis: Int = 0,
|
||||
isSwipeToDismiss: Boolean = false
|
||||
) {
|
||||
if (MediaPlayerData.players().size <= rank) {
|
||||
return
|
||||
}
|
||||
|
||||
val mediaControlKey = MediaPlayerData.playerKeys().elementAt(rank)
|
||||
// Only log media resume card when Smartspace data is available
|
||||
if (!isRecommendationCard &&
|
||||
if (!mediaControlKey.isSsMediaRec &&
|
||||
!mediaManager.smartspaceMediaData.isActive &&
|
||||
MediaPlayerData.smartspaceMediaData == null) {
|
||||
return
|
||||
@@ -809,10 +823,13 @@ class MediaCarouselController @Inject constructor(
|
||||
// card type for each new feature.
|
||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__CARD_TYPE__UNKNOWN_CARD,
|
||||
surface,
|
||||
rank,
|
||||
// Use -1 as rank value to indicate user swipe to dismiss the card
|
||||
if (isSwipeToDismiss) -1 else rank,
|
||||
cardinality,
|
||||
if (isRecommendationCard)
|
||||
if (mediaControlKey.isSsMediaRec)
|
||||
15 // MEDIA_RECOMMENDATION
|
||||
else if (mediaControlKey.isSsReactivated)
|
||||
43 // MEDIA_RESUME_SS_ACTIVATED
|
||||
else
|
||||
31, // MEDIA_RESUME
|
||||
uid,
|
||||
@@ -824,7 +841,9 @@ class MediaCarouselController @Inject constructor(
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Log Smartspace card event id: $eventId instance id: $instanceId" +
|
||||
" surface: $surface rank: $rank cardinality: $cardinality " +
|
||||
"isRecommendationCard: $isRecommendationCard uid: $uid " +
|
||||
"isRecommendationCard: ${mediaControlKey.isSsMediaRec} " +
|
||||
"isSsReactivated: ${mediaControlKey.isSsReactivated}" +
|
||||
"uid: $uid " +
|
||||
"interactedSubcardRank: $interactedSubcardRank " +
|
||||
"interactedSubcardCardinality: $interactedSubcardCardinality " +
|
||||
"received_latency_millis: $receivedLatencyMillis")
|
||||
@@ -839,10 +858,9 @@ class MediaCarouselController @Inject constructor(
|
||||
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
|
||||
it.mInstanceId,
|
||||
it.mUid,
|
||||
it.recommendationViewHolder != null,
|
||||
intArrayOf(it.surfaceForSmartspaceLogging),
|
||||
// Use -1 as rank value to indicate user swipe to dismiss the card
|
||||
rank = -1)
|
||||
rank = index,
|
||||
isSwipeToDismiss = true)
|
||||
// Reset card impressed state when swipe to dismissed
|
||||
it.mIsImpressed = false
|
||||
}
|
||||
@@ -871,29 +889,37 @@ internal object MediaPlayerData {
|
||||
private set
|
||||
|
||||
data class MediaSortKey(
|
||||
// Whether the item represents a Smartspace media recommendation.
|
||||
val isSsMediaRec: Boolean,
|
||||
val isSsMediaRec: Boolean, // Whether the item represents a Smartspace media recommendation.
|
||||
val data: MediaData,
|
||||
val updateTime: Long = 0
|
||||
val updateTime: Long = 0,
|
||||
val isSsReactivated: Boolean = false
|
||||
)
|
||||
|
||||
private val comparator =
|
||||
compareByDescending<MediaSortKey> { it.data.isPlaying == true &&
|
||||
it.data.playbackLocation == MediaData.PLAYBACK_LOCAL }
|
||||
.thenByDescending { it.data.isPlaying == true &&
|
||||
it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL }
|
||||
.thenByDescending { if (shouldPrioritizeSs) it.isSsMediaRec else !it.isSsMediaRec }
|
||||
.thenByDescending { !it.data.resumption }
|
||||
.thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
|
||||
.thenByDescending { it.updateTime }
|
||||
.thenByDescending { it.data.notificationKey }
|
||||
.thenByDescending { it.data.isPlaying == true &&
|
||||
it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL
|
||||
}
|
||||
.thenByDescending { if (shouldPrioritizeSs) it.isSsMediaRec else !it.isSsMediaRec }
|
||||
.thenByDescending { !it.data.resumption }
|
||||
.thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
|
||||
.thenByDescending { it.updateTime }
|
||||
.thenByDescending { it.data.notificationKey }
|
||||
|
||||
private val mediaPlayers = TreeMap<MediaSortKey, MediaControlPanel>(comparator)
|
||||
private val mediaData: MutableMap<String, MediaSortKey> = mutableMapOf()
|
||||
|
||||
fun addMediaPlayer(key: String, data: MediaData, player: MediaControlPanel, clock: SystemClock) {
|
||||
fun addMediaPlayer(
|
||||
key: String,
|
||||
data: MediaData,
|
||||
player: MediaControlPanel,
|
||||
clock: SystemClock,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
removeMediaPlayer(key)
|
||||
val sortKey = MediaSortKey(isSsMediaRec = false, data, clock.currentTimeMillis())
|
||||
val sortKey = MediaSortKey(isSsMediaRec = false,
|
||||
data, clock.currentTimeMillis(), isSsReactivated = isSsReactivated)
|
||||
mediaData.put(key, sortKey)
|
||||
mediaPlayers.put(sortKey, player)
|
||||
}
|
||||
@@ -907,8 +933,8 @@ internal object MediaPlayerData {
|
||||
) {
|
||||
shouldPrioritizeSs = shouldPrioritize
|
||||
removeMediaPlayer(key)
|
||||
val sortKey = MediaSortKey(/* isSsMediaRec= */ true,
|
||||
EMPTY.copy(isPlaying = false), clock.currentTimeMillis())
|
||||
val sortKey = MediaSortKey(isSsMediaRec = true,
|
||||
EMPTY.copy(isPlaying = false), clock.currentTimeMillis(), isSsReactivated = true)
|
||||
mediaData.put(key, sortKey)
|
||||
mediaPlayers.put(sortKey, player)
|
||||
smartspaceMediaData = data
|
||||
@@ -988,4 +1014,8 @@ internal object MediaPlayerData {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun isSsReactivated(key: String): Boolean = mediaData.get(key)?.let {
|
||||
it.isSsReactivated
|
||||
} ?: false
|
||||
}
|
||||
@@ -155,8 +155,8 @@ public class MediaControlPanel {
|
||||
|
||||
mSeekBarViewModel.setLogSmartspaceClick(() -> {
|
||||
logSmartspaceCardReported(
|
||||
760, // SMARTSPACE_CARD_CLICK
|
||||
/* isRecommendationCard */ false);
|
||||
760 // SMARTSPACE_CARD_CLICK
|
||||
);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
@@ -323,8 +323,9 @@ public class MediaControlPanel {
|
||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||
if (mMediaViewController.isGutsVisible()) return;
|
||||
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
/* isRecommendationCard */ false);
|
||||
logSmartspaceCardReported(
|
||||
760 // SMARTSPACE_CARD_CLICK
|
||||
);
|
||||
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
|
||||
buildLaunchAnimatorController(mPlayerViewHolder.getPlayer()));
|
||||
});
|
||||
@@ -444,8 +445,9 @@ public class MediaControlPanel {
|
||||
button.setEnabled(true);
|
||||
button.setOnClickListener(v -> {
|
||||
if (!mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
/* isRecommendationCard */ false);
|
||||
logSmartspaceCardReported(
|
||||
760 // SMARTSPACE_CARD_CLICK
|
||||
);
|
||||
action.run();
|
||||
}
|
||||
});
|
||||
@@ -481,8 +483,9 @@ public class MediaControlPanel {
|
||||
mPlayerViewHolder.getDismiss().setOnClickListener(v -> {
|
||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||
|
||||
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
|
||||
/* isRecommendationCard */ false);
|
||||
logSmartspaceCardReported(
|
||||
761 // SMARTSPACE_CARD_DISMISS
|
||||
);
|
||||
|
||||
if (mKey != null) {
|
||||
closeGuts();
|
||||
@@ -665,8 +668,9 @@ public class MediaControlPanel {
|
||||
mRecommendationViewHolder.getDismiss().setOnClickListener(v -> {
|
||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||
|
||||
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
|
||||
/* isRecommendationCard */ true);
|
||||
logSmartspaceCardReported(
|
||||
761 // SMARTSPACE_CARD_DISMISS
|
||||
);
|
||||
closeGuts();
|
||||
mMediaDataManagerLazy.get().dismissSmartspaceRecommendation(
|
||||
data.getTargetId(), MediaViewController.GUTS_ANIMATION_DURATION + 100L);
|
||||
@@ -823,7 +827,6 @@ public class MediaControlPanel {
|
||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||
|
||||
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
|
||||
/* isRecommendationCard */ true,
|
||||
interactedSubcardRank,
|
||||
getSmartspaceSubCardCardinality());
|
||||
|
||||
@@ -882,18 +885,17 @@ public class MediaControlPanel {
|
||||
return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__DEFAULT_SURFACE;
|
||||
}
|
||||
|
||||
private void logSmartspaceCardReported(int eventId, boolean isRecommendationCard) {
|
||||
logSmartspaceCardReported(eventId, isRecommendationCard,
|
||||
private void logSmartspaceCardReported(int eventId) {
|
||||
logSmartspaceCardReported(eventId,
|
||||
/* interactedSubcardRank */ 0,
|
||||
/* interactedSubcardCardinality */ 0);
|
||||
}
|
||||
|
||||
private void logSmartspaceCardReported(int eventId, boolean isRecommendationCard,
|
||||
private void logSmartspaceCardReported(int eventId,
|
||||
int interactedSubcardRank, int interactedSubcardCardinality) {
|
||||
mMediaCarouselController.logSmartspaceCardReported(eventId,
|
||||
mInstanceId,
|
||||
mUid,
|
||||
isRecommendationCard,
|
||||
new int[]{getSurfaceForSmartspaceLogging()},
|
||||
interactedSubcardRank,
|
||||
interactedSubcardCardinality);
|
||||
|
||||
@@ -32,7 +32,8 @@ class MediaDataCombineLatest @Inject constructor() : MediaDataManager.Listener,
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (oldKey != null && oldKey != key && entries.contains(oldKey)) {
|
||||
entries[key] = data to entries.remove(oldKey)?.second
|
||||
@@ -46,8 +47,7 @@ class MediaDataCombineLatest @Inject constructor() : MediaDataManager.Listener,
|
||||
override fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean,
|
||||
isSsReactivated: Boolean
|
||||
shouldPrioritize: Boolean
|
||||
) {
|
||||
listeners.toSet().forEach { it.onSmartspaceMediaDataLoaded(key, data) }
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ class MediaDataFilter @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (oldKey != null && oldKey != key) {
|
||||
allEntries.remove(oldKey)
|
||||
@@ -112,8 +113,7 @@ class MediaDataFilter @Inject constructor(
|
||||
override fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean,
|
||||
isSsReactivated: Boolean
|
||||
shouldPrioritize: Boolean
|
||||
) {
|
||||
if (!data.isActive) {
|
||||
Log.d(TAG, "Inactive recommendation data. Skip triggering.")
|
||||
@@ -138,13 +138,12 @@ class MediaDataFilter @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val activeMedia = userEntries.filter { (key, value) -> value.active }
|
||||
var isSsReactivatedMutable = activeMedia.isEmpty() && userEntries.isNotEmpty()
|
||||
val shouldReactivate = !hasActiveMedia() && hasAnyMedia()
|
||||
|
||||
if (timeSinceActive < smartspaceMaxAgeMillis) {
|
||||
// It could happen there are existing active media resume cards, then we don't need to
|
||||
// reactivate.
|
||||
if (isSsReactivatedMutable) {
|
||||
if (shouldReactivate) {
|
||||
val lastActiveKey = sorted.lastKey() // most recently active
|
||||
// Notify listeners to consider this media active
|
||||
Log.d(TAG, "reactivating $lastActiveKey instead of smartspace")
|
||||
@@ -154,7 +153,7 @@ class MediaDataFilter @Inject constructor(
|
||||
it.onMediaDataLoaded(lastActiveKey, lastActiveKey, mediaData,
|
||||
receivedSmartspaceCardLatency =
|
||||
(systemClock.currentTimeMillis() - data.headphoneConnectionTimeMillis)
|
||||
.toInt())
|
||||
.toInt(), isSsReactivated = true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -166,8 +165,7 @@ class MediaDataFilter @Inject constructor(
|
||||
Log.d(TAG, "Invalid recommendation data. Skip showing the rec card")
|
||||
return
|
||||
}
|
||||
listeners.forEach { it.onSmartspaceMediaDataLoaded(key, data, shouldPrioritizeMutable,
|
||||
isSsReactivatedMutable) }
|
||||
listeners.forEach { it.onSmartspaceMediaDataLoaded(key, data, shouldPrioritizeMutable) }
|
||||
}
|
||||
|
||||
override fun onMediaDataRemoved(key: String) {
|
||||
@@ -258,14 +256,27 @@ class MediaDataFilter @Inject constructor(
|
||||
}
|
||||
|
||||
/**
|
||||
* Are there any media notifications active?
|
||||
* Are there any media notifications active, including the recommendation?
|
||||
*/
|
||||
fun hasActiveMedia() = userEntries.any { it.value.active } || smartspaceMediaData.isActive
|
||||
fun hasActiveMediaOrRecommendation() =
|
||||
userEntries.any { it.value.active } ||
|
||||
(smartspaceMediaData.isActive && smartspaceMediaData.isValid)
|
||||
|
||||
/**
|
||||
* Are there any media entries we should display?
|
||||
*/
|
||||
fun hasAnyMedia() = userEntries.isNotEmpty() || smartspaceMediaData.isActive
|
||||
fun hasAnyMediaOrRecommendation() = userEntries.isNotEmpty() ||
|
||||
(smartspaceMediaData.isActive && smartspaceMediaData.isValid)
|
||||
|
||||
/**
|
||||
* Are there any media notifications active (excluding the recommendation)?
|
||||
*/
|
||||
fun hasActiveMedia() = userEntries.any { it.value.active }
|
||||
|
||||
/**
|
||||
* Are there any media entries we should display (excluding the recommendation)?
|
||||
*/
|
||||
fun hasAnyMedia() = userEntries.isNotEmpty()
|
||||
|
||||
/**
|
||||
* Add a listener for filtered [MediaData] changes
|
||||
|
||||
@@ -828,15 +828,27 @@ class MediaDataManager(
|
||||
fun onSwipeToDismiss() = mediaDataFilter.onSwipeToDismiss()
|
||||
|
||||
/**
|
||||
* Are there any media notifications active?
|
||||
* Are there any media notifications active, including the recommendations?
|
||||
*/
|
||||
fun hasActiveMediaOrRecommendation() = mediaDataFilter.hasActiveMediaOrRecommendation()
|
||||
|
||||
/**
|
||||
* Are there any media entries we should display, including the recommendations?
|
||||
* If resumption is enabled, this will include inactive players
|
||||
* If resumption is disabled, we only want to show active players
|
||||
*/
|
||||
fun hasAnyMediaOrRecommendation() = mediaDataFilter.hasAnyMediaOrRecommendation()
|
||||
|
||||
/**
|
||||
* Are there any resume media notifications active, excluding the recommendations?
|
||||
*/
|
||||
fun hasActiveMedia() = mediaDataFilter.hasActiveMedia()
|
||||
|
||||
/**
|
||||
* Are there any media entries we should display?
|
||||
* If resumption is enabled, this will include inactive players
|
||||
* If resumption is disabled, we only want to show active players
|
||||
*/
|
||||
* Are there any resume media notifications active, excluding the recommendations?
|
||||
* If resumption is enabled, this will include inactive players
|
||||
* If resumption is disabled, we only want to show active players
|
||||
*/
|
||||
fun hasAnyMedia() = mediaDataFilter.hasAnyMedia()
|
||||
|
||||
interface Listener {
|
||||
@@ -855,13 +867,17 @@ class MediaDataManager(
|
||||
* @param receivedSmartspaceCardLatency is the latency between headphone connects and sysUI
|
||||
* displays Smartspace media targets. Will be 0 if the data is not activated by Smartspace
|
||||
* signal.
|
||||
*
|
||||
* @param isSsReactivated indicates resume media card is reactivated by Smartspace
|
||||
* recommendation signal
|
||||
*/
|
||||
fun onMediaDataLoaded(
|
||||
key: String,
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean = true,
|
||||
receivedSmartspaceCardLatency: Int = 0
|
||||
receivedSmartspaceCardLatency: Int = 0,
|
||||
isSsReactivated: Boolean = false
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -870,15 +886,11 @@ class MediaDataManager(
|
||||
* @param shouldPrioritize indicates the sorting priority of the Smartspace card. If true,
|
||||
* it will be prioritized as the first card. Otherwise, it will show up as the last card as
|
||||
* default.
|
||||
*
|
||||
* @param isSsReactivated indicates resume media card is reactivated by Smartspace
|
||||
* recommendation signal
|
||||
*/
|
||||
fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean = false,
|
||||
isSsReactivated: Boolean = false
|
||||
shouldPrioritize: Boolean = false
|
||||
) {}
|
||||
|
||||
/** Called whenever a previously existing Media notification was removed. */
|
||||
|
||||
@@ -68,7 +68,8 @@ class MediaDeviceManager @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (oldKey != null && oldKey != key) {
|
||||
val oldEntry = entries.remove(oldKey)
|
||||
|
||||
@@ -61,7 +61,8 @@ class MediaHost constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (immediately) {
|
||||
updateViewVisibility()
|
||||
@@ -71,8 +72,7 @@ class MediaHost constructor(
|
||||
override fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean,
|
||||
isSsReactivated: Boolean
|
||||
shouldPrioritize: Boolean
|
||||
) {
|
||||
updateViewVisibility()
|
||||
}
|
||||
@@ -162,9 +162,9 @@ class MediaHost constructor(
|
||||
|
||||
private fun updateViewVisibility() {
|
||||
state.visible = if (showsOnlyActiveMedia) {
|
||||
mediaDataManager.hasActiveMedia()
|
||||
mediaDataManager.hasActiveMediaOrRecommendation()
|
||||
} else {
|
||||
mediaDataManager.hasAnyMedia()
|
||||
mediaDataManager.hasAnyMediaOrRecommendation()
|
||||
}
|
||||
val newVisibility = if (visible) View.VISIBLE else View.GONE
|
||||
if (newVisibility != hostView.visibility) {
|
||||
|
||||
@@ -184,7 +184,8 @@ class MediaResumeListener @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
if (useMediaResumption) {
|
||||
// If this had been started from a resume state, disconnect now that it's live
|
||||
|
||||
@@ -96,7 +96,8 @@ class MediaSessionBasedFilter @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
backgroundExecutor.execute {
|
||||
data.token?.let {
|
||||
@@ -143,8 +144,7 @@ class MediaSessionBasedFilter @Inject constructor(
|
||||
override fun onSmartspaceMediaDataLoaded(
|
||||
key: String,
|
||||
data: SmartspaceMediaData,
|
||||
shouldPrioritize: Boolean,
|
||||
isSsReactivated: Boolean
|
||||
shouldPrioritize: Boolean
|
||||
) {
|
||||
backgroundExecutor.execute {
|
||||
dispatchSmartspaceMediaDataLoaded(key, data)
|
||||
|
||||
@@ -63,7 +63,8 @@ class MediaTimeoutListener @Inject constructor(
|
||||
oldKey: String?,
|
||||
data: MediaData,
|
||||
immediately: Boolean,
|
||||
receivedSmartspaceCardLatency: Int
|
||||
receivedSmartspaceCardLatency: Int,
|
||||
isSsReactivated: Boolean
|
||||
) {
|
||||
var reusedListener: PlaybackStateListener? = null
|
||||
|
||||
|
||||
@@ -242,13 +242,12 @@ public class NotificationMediaManager implements Dumpable {
|
||||
@Override
|
||||
public void onMediaDataLoaded(@NonNull String key,
|
||||
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
||||
int receivedSmartspaceCardLatency) {
|
||||
int receivedSmartspaceCardLatency, boolean isSsReactivated) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize,
|
||||
boolean isSsReactivated) {
|
||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,13 +316,12 @@ public class NotificationMediaManager implements Dumpable {
|
||||
@Override
|
||||
public void onMediaDataLoaded(@NonNull String key,
|
||||
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
||||
int receivedSmartspaceCardLatency) {
|
||||
int receivedSmartspaceCardLatency, boolean isSsReactivated) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize,
|
||||
boolean isSsReactivated) {
|
||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1293,9 +1293,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard;
|
||||
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
||||
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
||||
.getVisibleNotificationCount() != 0
|
||||
|| mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||
boolean splitShadeWithActiveMedia =
|
||||
mShouldUseSplitNotificationShade && mMediaDataManager.hasActiveMedia();
|
||||
mShouldUseSplitNotificationShade
|
||||
&& mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||
if ((hasVisibleNotifications && !mShouldUseSplitNotificationShade)
|
||||
|| (splitShadeWithActiveMedia && !mDozing)) {
|
||||
mKeyguardStatusViewController.displayClock(SMALL);
|
||||
@@ -1361,7 +1363,8 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
|
||||
private void updateKeyguardStatusViewAlignment(boolean animate) {
|
||||
boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
||||
.getVisibleNotificationCount() != 0
|
||||
|| mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||
boolean shouldBeCentered =
|
||||
!mShouldUseSplitNotificationShade || !hasVisibleNotifications || mDozing;
|
||||
if (mStatusViewCentered != shouldBeCentered) {
|
||||
@@ -2576,7 +2579,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
float endPosition = 0;
|
||||
if (pxAmount > 0.0f) {
|
||||
if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0
|
||||
&& !mMediaDataManager.hasActiveMedia()) {
|
||||
&& !mMediaDataManager.hasActiveMediaOrRecommendation()) {
|
||||
// No notifications are visible, let's animate to the height of qs instead
|
||||
if (mQs != null) {
|
||||
// Let's interpolate to the header height instead of the top padding,
|
||||
|
||||
@@ -156,7 +156,7 @@ class MediaCarouselControllerTest : SysuiTestCase() {
|
||||
expected.forEach {
|
||||
clock.setCurrentTimeMillis(it.third)
|
||||
MediaPlayerData.addMediaPlayer(it.first, it.second.copy(notificationKey = it.first),
|
||||
panel, clock)
|
||||
panel, clock, isSsReactivated = false)
|
||||
}
|
||||
|
||||
for ((index, key) in MediaPlayerData.playerKeys().withIndex()) {
|
||||
|
||||
@@ -84,10 +84,10 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void eventNotEmittedWithoutDevice() {
|
||||
// WHEN data source emits an event without device data
|
||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// THEN an event isn't emitted
|
||||
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +96,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||
// THEN an event isn't emitted
|
||||
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,11 +105,11 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||
// WHEN media event is received
|
||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// THEN the listener receives a combined event
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void emitEventAfterMediaFirst() {
|
||||
// GIVEN that media event has already been received
|
||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// WHEN device event is received
|
||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||
// THEN the listener receives a combined event
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -131,16 +131,16 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void migrateKeyMediaFirst() {
|
||||
// GIVEN that media and device info has already been received
|
||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||
reset(mListener);
|
||||
// WHEN a key migration event is received
|
||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// THEN the listener receives a combined event
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void migrateKeyDeviceFirst() {
|
||||
// GIVEN that media and device info has already been received
|
||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||
reset(mListener);
|
||||
// WHEN a key migration event is received
|
||||
@@ -156,7 +156,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
// THEN the listener receives a combined event
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -164,17 +164,17 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void migrateKeyMediaAfter() {
|
||||
// GIVEN that media and device info has already been received
|
||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
||||
reset(mListener);
|
||||
// WHEN a second key migration event is received for media
|
||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// THEN the key has already been migrated
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -182,17 +182,17 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void migrateKeyDeviceAfter() {
|
||||
// GIVEN that media and device info has already been received
|
||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
reset(mListener);
|
||||
// WHEN a second key migration event is received for the device
|
||||
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
||||
// THEN the key has already be migrated
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
||||
anyInt());
|
||||
anyInt(), anyBoolean());
|
||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void mediaDataRemovedAfterMediaEvent() {
|
||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDataRemoved(KEY);
|
||||
verify(mListener).onMediaDataRemoved(eq(KEY));
|
||||
}
|
||||
@@ -223,14 +223,14 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
||||
public void mediaDataKeyUpdated() {
|
||||
// GIVEN that device and media events have already been received
|
||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||
// WHEN the key is changed
|
||||
mManager.onMediaDataLoaded("NEW_KEY", KEY, mMediaData, true /* immediately */,
|
||||
0 /* receivedSmartspaceCardLatency */);
|
||||
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||
// THEN the listener gets a load event with the correct keys
|
||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||
verify(mListener).onMediaDataLoaded(
|
||||
eq("NEW_KEY"), any(), captor.capture(), anyBoolean(), anyInt());
|
||||
eq("NEW_KEY"), any(), captor.capture(), anyBoolean(), anyInt(), anyBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
|
||||
// THEN we should tell the listener
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataMain), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +133,8 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataGuest)
|
||||
|
||||
// THEN we should NOT tell the listener
|
||||
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(), anyInt())
|
||||
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(),
|
||||
anyInt(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,51 +181,56 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
|
||||
// THEN we should add back the guest user media
|
||||
verify(listener).onMediaDataLoaded(eq(KEY_ALT), eq(null), eq(dataGuest), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
|
||||
// but not the main user's
|
||||
verify(listener, never()).onMediaDataLoaded(eq(KEY), any(), eq(dataMain), anyBoolean(),
|
||||
anyInt())
|
||||
anyInt(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHasAnyMedia() {
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||
fun testHasAnyMediaOrRecommendation() {
|
||||
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
||||
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isTrue()
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHasActiveMedia() {
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
fun testHasActiveMediaOrRecommendation() {
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
val data = dataMain.copy(active = true)
|
||||
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHasAnyMedia_onlyCurrentUser() {
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||
fun testHasAnyMediaOrRecommendation_onlyCurrentUser() {
|
||||
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataGuest)
|
||||
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHasActiveMedia_onlyCurrentUser() {
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
fun testHasActiveMediaOrRecommendation_onlyCurrentUser() {
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
val data = dataGuest.copy(active = true)
|
||||
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnNotificationRemoved_doesntHaveMedia() {
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
||||
mediaDataFilter.onMediaDataRemoved(KEY)
|
||||
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||
}
|
||||
|
||||
@@ -241,9 +247,9 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
verify(listener)
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true),
|
||||
eq(false))
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true))
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -252,9 +258,10 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(), anyInt())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
||||
anyBoolean())
|
||||
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(),
|
||||
anyInt(), anyBoolean())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@@ -266,9 +273,9 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
verify(listener)
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true),
|
||||
eq(true))
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true))
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -280,8 +287,8 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
clock.advanceTime(SMARTSPACE_MAX_AGE + 100)
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
||||
anyBoolean())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@@ -293,16 +300,16 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
|
||||
// AND we get a smartspace signal
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
// THEN we should tell listeners to treat the media as not active instead
|
||||
verify(listener, never()).onMediaDataLoaded(eq(KEY), eq(KEY), any(), anyBoolean(),
|
||||
anyInt())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
||||
anyBoolean())
|
||||
anyInt(), anyBoolean())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@@ -314,7 +321,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
|
||||
// AND we get a smartspace signal
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
@@ -322,11 +329,10 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
// THEN we should tell listeners to treat the media as active instead
|
||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||
eq(100))
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||
eq(100), eq(true))
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
// Smartspace update shouldn't be propagated for the empty rec list.
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
||||
anyBoolean())
|
||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,7 +341,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
|
||||
// AND we get a smartspace signal
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
@@ -343,12 +349,11 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
// THEN we should tell listeners to treat the media as active instead
|
||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||
eq(100))
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||
eq(100), eq(true))
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||
// Smartspace update should also be propagated but not prioritized.
|
||||
verify(listener)
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(false),
|
||||
eq(true))
|
||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -357,6 +362,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||
|
||||
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
|
||||
@@ -365,17 +371,18 @@ class MediaDataFilterTest : SysuiTestCase() {
|
||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
|
||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||
|
||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||
eq(100))
|
||||
eq(100), eq(true))
|
||||
|
||||
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||
|
||||
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
mediaDataManager.onNotificationAdded(KEY, mediaNotification)
|
||||
mediaDataManager.onMediaDataLoaded(KEY, oldKey = null, data = mock(MediaData::class.java))
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), anyObject(), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,7 +226,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value!!.active).isTrue()
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value!!.playbackLocation).isEqualTo(
|
||||
MediaData.PLAYBACK_CAST_REMOTE)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
val data = mediaDataCaptor.value
|
||||
assertThat(data.resumption).isFalse()
|
||||
mediaDataManager.onMediaDataLoaded(KEY, null, data.copy(resumeAction = Runnable {}))
|
||||
@@ -279,7 +279,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
// THEN the media data indicates that it is for resumption
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||
assertThat(mediaDataCaptor.value.isPlaying).isFalse()
|
||||
}
|
||||
@@ -294,7 +294,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(2)
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
val data = mediaDataCaptor.value
|
||||
assertThat(data.resumption).isFalse()
|
||||
val resumableData = data.copy(resumeAction = Runnable {})
|
||||
@@ -306,7 +306,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
// THEN the data is for resumption and the key is migrated to the package name
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||
verify(listener, never()).onMediaDataRemoved(eq(KEY))
|
||||
// WHEN the second is removed
|
||||
@@ -315,7 +315,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(
|
||||
eq(PACKAGE_NAME), eq(PACKAGE_NAME), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||
verify(listener).onMediaDataRemoved(eq(KEY_2))
|
||||
}
|
||||
@@ -330,7 +330,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
val data = mediaDataCaptor.value
|
||||
val dataRemoteWithResume = data.copy(resumeAction = Runnable {},
|
||||
playbackLocation = MediaData.PLAYBACK_CAST_LOCAL)
|
||||
@@ -358,7 +358,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
// THEN the media data indicates that it is for resumption
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
val data = mediaDataCaptor.value
|
||||
assertThat(data.resumption).isTrue()
|
||||
assertThat(data.song).isEqualTo(SESSION_TITLE)
|
||||
@@ -406,7 +406,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -417,7 +417,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
eq(SmartspaceMediaData(KEY_MEDIA_SMARTSPACE, true /* isActive */, true /*isValid */,
|
||||
PACKAGE_NAME, mediaSmartspaceBaseAction, listOf(mediaRecommendationItem),
|
||||
DISMISS_INTENT, 0, 1234L)),
|
||||
eq(false), eq(false))
|
||||
eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -430,7 +430,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
||||
isValid = false, dismissIntent = DISMISS_INTENT,
|
||||
headphoneConnectionTimeMillis = 1234L)),
|
||||
eq(false), eq(false))
|
||||
eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -450,14 +450,14 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
eq(EMPTY_SMARTSPACE_MEDIA_DATA
|
||||
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
||||
isValid = false, dismissIntent = null, headphoneConnectionTimeMillis = 1234L)),
|
||||
eq(false), eq(false))
|
||||
eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnSmartspaceMediaDataLoaded_hasNoneMediaTarget_notCallsListener() {
|
||||
smartspaceMediaDataProvider.onTargetsAvailable(listOf())
|
||||
verify(listener, never())
|
||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean(), anyBoolean())
|
||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -481,7 +481,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
|
||||
// THEN smartspace signal is ignored
|
||||
verify(listener, never())
|
||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean(), anyBoolean())
|
||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -489,7 +489,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
// GIVEN a media recommendation card is present
|
||||
smartspaceMediaDataProvider.onTargetsAvailable(listOf(mediaSmartspaceTarget))
|
||||
verify(listener).onSmartspaceMediaDataLoaded(eq(KEY_MEDIA_SMARTSPACE), anyObject(),
|
||||
anyBoolean(), anyBoolean())
|
||||
anyBoolean())
|
||||
|
||||
// WHEN the media recommendation setting is turned off
|
||||
Settings.Secure.putInt(context.contentResolver,
|
||||
@@ -509,7 +509,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value!!.lastActive).isAtLeast(currentTime)
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
|
||||
// THEN the last active time is not changed
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
val data = mediaDataCaptor.value
|
||||
assertThat(data.resumption).isFalse()
|
||||
mediaDataManager.onMediaDataLoaded(KEY, null, data.copy(resumeAction = Runnable {}))
|
||||
@@ -552,7 +552,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
// THEN the last active time is not changed
|
||||
verify(listener)
|
||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
||||
}
|
||||
@@ -579,7 +579,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
||||
|
||||
// THEN only the first MAX_COMPACT_ACTIONS are actually set
|
||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
assertThat(mediaDataCaptor.value.actionsToShowInCompact.size).isEqualTo(
|
||||
MediaDataManager.MAX_COMPACT_ACTIONS)
|
||||
}
|
||||
|
||||
@@ -61,8 +61,10 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
||||
val playerIsRemote = mock(MediaControlPanel::class.java)
|
||||
val dataIsRemote = createMediaData("app2", PLAYING, REMOTE, !RESUMPTION)
|
||||
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsRemote, playerIsRemote, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsRemote, playerIsRemote, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock,
|
||||
isSsReactivated = false)
|
||||
|
||||
val players = MediaPlayerData.players()
|
||||
assertThat(players).hasSize(2)
|
||||
@@ -77,18 +79,22 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
||||
val playerIsPlaying2 = mock(MediaControlPanel::class.java)
|
||||
var dataIsPlaying2 = createMediaData("app2", !PLAYING, LOCAL, !RESUMPTION)
|
||||
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
|
||||
dataIsPlaying1 = createMediaData("app1", !PLAYING, LOCAL, !RESUMPTION)
|
||||
dataIsPlaying2 = createMediaData("app2", PLAYING, LOCAL, !RESUMPTION)
|
||||
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
|
||||
val players = MediaPlayerData.players()
|
||||
@@ -116,14 +122,20 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
||||
val dataUndetermined = createMediaData("app6", UNDETERMINED, LOCAL, RESUMPTION)
|
||||
|
||||
MediaPlayerData.addMediaPlayer(
|
||||
"3", dataIsStoppedAndLocal, playerIsStoppedAndLocal, systemClock)
|
||||
"3", dataIsStoppedAndLocal, playerIsStoppedAndLocal, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer(
|
||||
"5", dataIsStoppedAndRemote, playerIsStoppedAndRemote, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("4", dataCanResume, playerCanResume, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock)
|
||||
"5", dataIsStoppedAndRemote, playerIsStoppedAndRemote, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer("4", dataCanResume, playerCanResume, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer(
|
||||
"2", dataIsPlayingAndRemote, playerIsPlayingAndRemote, systemClock)
|
||||
MediaPlayerData.addMediaPlayer("6", dataUndetermined, playerUndetermined, systemClock)
|
||||
"2", dataIsPlayingAndRemote, playerIsPlayingAndRemote, systemClock,
|
||||
isSsReactivated = false)
|
||||
MediaPlayerData.addMediaPlayer("6", dataUndetermined, playerUndetermined, systemClock,
|
||||
isSsReactivated = false)
|
||||
|
||||
val players = MediaPlayerData.players()
|
||||
assertThat(players).hasSize(6)
|
||||
@@ -141,11 +153,13 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
||||
|
||||
assertThat(MediaPlayerData.players()).hasSize(0)
|
||||
|
||||
MediaPlayerData.addMediaPlayer(keyA, data, playerIsPlaying, systemClock)
|
||||
MediaPlayerData.addMediaPlayer(keyA, data, playerIsPlaying, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
|
||||
assertThat(MediaPlayerData.players()).hasSize(1)
|
||||
MediaPlayerData.addMediaPlayer(keyB, data, playerIsPlaying, systemClock)
|
||||
MediaPlayerData.addMediaPlayer(keyB, data, playerIsPlaying, systemClock,
|
||||
isSsReactivated = false)
|
||||
systemClock.advanceTime(1)
|
||||
|
||||
assertThat(MediaPlayerData.players()).hasSize(2)
|
||||
|
||||
@@ -187,7 +187,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -210,7 +210,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,7 +240,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,14 +256,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
// WHEN a loaded event is received that matches the local session
|
||||
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is filtered
|
||||
verify(mediaListener, never()).onMediaDataLoaded(
|
||||
eq(KEY), eq(null), eq(mediaData2), anyBoolean(), anyInt())
|
||||
eq(KEY), eq(null), eq(mediaData2), anyBoolean(), anyInt(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -280,7 +280,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
// THEN the event is not filtered because there isn't a notification for the remote
|
||||
// session.
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -298,14 +298,15 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(key1), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
// WHEN a loaded event is received that matches the local session
|
||||
filter.onMediaDataLoaded(key2, null, mediaData2)
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is filtered
|
||||
verify(mediaListener, never())
|
||||
.onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), anyBoolean(), anyInt())
|
||||
.onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), anyBoolean(),
|
||||
anyInt(), anyBoolean())
|
||||
// AND there should be a removed event for key2
|
||||
verify(mediaListener).onMediaDataRemoved(eq(key2))
|
||||
}
|
||||
@@ -325,14 +326,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(key1), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
// WHEN a loaded event is received that matches the remote session
|
||||
filter.onMediaDataLoaded(key2, null, mediaData2)
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -349,14 +350,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
// WHEN a loaded event is received that matches the local session
|
||||
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData2), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,7 +376,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the event is not filtered
|
||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -398,7 +399,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the key migration event is fired
|
||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(key1), eq(mediaData2), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -428,13 +429,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the key migration event is filtered
|
||||
verify(mediaListener, never())
|
||||
.onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), anyBoolean(), anyInt())
|
||||
.onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), anyBoolean(),
|
||||
anyInt(), anyBoolean())
|
||||
// WHEN a loaded event is received that matches the remote session
|
||||
filter.onMediaDataLoaded(key2, null, mediaData1)
|
||||
bgExecutor.runAllReady()
|
||||
fgExecutor.runAllReady()
|
||||
// THEN the key migration event is fired
|
||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData1), eq(true),
|
||||
eq(0))
|
||||
eq(0), eq(false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||
public void testSwitchesToBigClockInSplitShadeOnAod() {
|
||||
mStatusBarStateController.setState(KEYGUARD);
|
||||
enableSplitShade(/* enabled= */ true);
|
||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
||||
when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
|
||||
|
||||
mNotificationPanelViewController.setDozing(true, false, null);
|
||||
@@ -836,7 +836,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||
public void testDisplaysSmallClockOnLockscreenInSplitShadeWhenMediaIsPlaying() {
|
||||
mStatusBarStateController.setState(KEYGUARD);
|
||||
enableSplitShade(/* enabled= */ true);
|
||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
||||
when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
|
||||
|
||||
// one notification + media player visible
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(1);
|
||||
|
||||
Reference in New Issue
Block a user