Merge "Add the logging logic to distinguish the SS-reactivated resume media and user-activated one when there is no recommendation card." into tm-dev
This commit is contained in:
commit
c921168aa3
@ -217,17 +217,17 @@ class MediaCarouselController @Inject constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
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
|
// Log card received if a new resumable media card is added
|
||||||
MediaPlayerData.getMediaPlayer(key)?.let {
|
MediaPlayerData.getMediaPlayer(key)?.let {
|
||||||
/* ktlint-disable max-line-length */
|
/* ktlint-disable max-line-length */
|
||||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||||
it.mSmartspaceId,
|
it.mSmartspaceId,
|
||||||
it.mUid,
|
it.mUid,
|
||||||
/* isRecommendationCard */ false,
|
surfaces = intArrayOf(
|
||||||
intArrayOf(
|
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||||
rank = MediaPlayerData.getMediaPlayerIndex(key))
|
rank = MediaPlayerData.getMediaPlayerIndex(key))
|
||||||
@ -250,8 +250,7 @@ class MediaCarouselController @Inject constructor(
|
|||||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||||
it.mSmartspaceId,
|
it.mSmartspaceId,
|
||||||
it.mUid,
|
it.mUid,
|
||||||
/* isRecommendationCard */ false,
|
surfaces = intArrayOf(
|
||||||
intArrayOf(
|
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||||
rank = index,
|
rank = index,
|
||||||
@ -285,12 +284,17 @@ class MediaCarouselController @Inject constructor(
|
|||||||
override fun onSmartspaceMediaDataLoaded(
|
override fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean,
|
shouldPrioritize: Boolean
|
||||||
isSsReactivated: Boolean
|
|
||||||
) {
|
) {
|
||||||
if (DEBUG) Log.d(TAG, "Loading Smartspace media update")
|
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 (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
|
// Log resume card received if resumable media card is reactivated and
|
||||||
// recommendation card is valid and ranked first
|
// recommendation card is valid and ranked first
|
||||||
MediaPlayerData.players().forEachIndexed { index, it ->
|
MediaPlayerData.players().forEachIndexed { index, it ->
|
||||||
@ -302,8 +306,7 @@ class MediaCarouselController @Inject constructor(
|
|||||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||||
it.mSmartspaceId,
|
it.mSmartspaceId,
|
||||||
it.mUid,
|
it.mUid,
|
||||||
/* isRecommendationCard */ false,
|
surfaces = intArrayOf(
|
||||||
intArrayOf(
|
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||||
rank = index,
|
rank = index,
|
||||||
@ -318,8 +321,7 @@ class MediaCarouselController @Inject constructor(
|
|||||||
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
|
||||||
it.mSmartspaceId,
|
it.mSmartspaceId,
|
||||||
it.mUid,
|
it.mUid,
|
||||||
/* isRecommendationCard */ true,
|
surfaces = intArrayOf(
|
||||||
intArrayOf(
|
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE,
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN),
|
||||||
rank = MediaPlayerData.getMediaPlayerIndex(key),
|
rank = MediaPlayerData.getMediaPlayerIndex(key),
|
||||||
@ -417,7 +419,12 @@ class MediaCarouselController @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if new player is added
|
// 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 {
|
||||||
MediaPlayerData.moveIfExists(oldKey, key)
|
MediaPlayerData.moveIfExists(oldKey, key)
|
||||||
val existingPlayer = MediaPlayerData.getMediaPlayer(key)
|
val existingPlayer = MediaPlayerData.getMediaPlayer(key)
|
||||||
val curVisibleMediaKey = MediaPlayerData.playerKeys()
|
val curVisibleMediaKey = MediaPlayerData.playerKeys()
|
||||||
@ -432,12 +439,12 @@ class MediaCarouselController @Inject constructor(
|
|||||||
newPlayer.mediaViewHolder?.player?.setLayoutParams(lp)
|
newPlayer.mediaViewHolder?.player?.setLayoutParams(lp)
|
||||||
newPlayer.bindPlayer(data, key)
|
newPlayer.bindPlayer(data, key)
|
||||||
newPlayer.setListening(currentlyExpanded)
|
newPlayer.setListening(currentlyExpanded)
|
||||||
MediaPlayerData.addMediaPlayer(key, data, newPlayer, systemClock)
|
MediaPlayerData.addMediaPlayer(key, data, newPlayer, systemClock, isSsReactivated)
|
||||||
updatePlayerToState(newPlayer, noAnimation = true)
|
updatePlayerToState(newPlayer, noAnimation = true)
|
||||||
reorderAllPlayers(curVisibleMediaKey)
|
reorderAllPlayers(curVisibleMediaKey)
|
||||||
} else {
|
} else {
|
||||||
existingPlayer.bindPlayer(data, key)
|
existingPlayer.bindPlayer(data, key)
|
||||||
MediaPlayerData.addMediaPlayer(key, data, existingPlayer, systemClock)
|
MediaPlayerData.addMediaPlayer(key, data, existingPlayer, systemClock, isSsReactivated)
|
||||||
if (isReorderingAllowed || shouldScrollToActivePlayer) {
|
if (isReorderingAllowed || shouldScrollToActivePlayer) {
|
||||||
reorderAllPlayers(curVisibleMediaKey)
|
reorderAllPlayers(curVisibleMediaKey)
|
||||||
} else {
|
} else {
|
||||||
@ -531,8 +538,10 @@ class MediaCarouselController @Inject constructor(
|
|||||||
it.targetId, it, MediaPlayerData.shouldPrioritizeSs)
|
it.targetId, it, MediaPlayerData.shouldPrioritizeSs)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
val isSsReactivated = MediaPlayerData.isSsReactivated(key)
|
||||||
removePlayer(key, dismissMediaData = false, dismissRecommendation = false)
|
removePlayer(key, dismissMediaData = false, dismissRecommendation = false)
|
||||||
addOrUpdatePlayer(key = key, oldKey = null, data = data)
|
addOrUpdatePlayer(
|
||||||
|
key = key, oldKey = null, data = data, isSsReactivated = isSsReactivated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -686,7 +695,8 @@ class MediaCarouselController @Inject constructor(
|
|||||||
this.desiredHostState = it
|
this.desiredHostState = it
|
||||||
currentlyExpanded = it.expansion > 0
|
currentlyExpanded = it.expansion > 0
|
||||||
|
|
||||||
val shouldCloseGuts = !currentlyExpanded && !mediaManager.hasActiveMedia() &&
|
val shouldCloseGuts = !currentlyExpanded &&
|
||||||
|
!mediaManager.hasActiveMediaOrRecommendation() &&
|
||||||
desiredHostState.showsOnlyActiveMedia
|
desiredHostState.showsOnlyActiveMedia
|
||||||
|
|
||||||
for (mediaPlayer in MediaPlayerData.players()) {
|
for (mediaPlayer in MediaPlayerData.players()) {
|
||||||
@ -751,7 +761,6 @@ class MediaCarouselController @Inject constructor(
|
|||||||
val mediaControlPanel = MediaPlayerData.players().elementAt(visibleMediaIndex)
|
val mediaControlPanel = MediaPlayerData.players().elementAt(visibleMediaIndex)
|
||||||
val hasActiveMediaOrRecommendationCard =
|
val hasActiveMediaOrRecommendationCard =
|
||||||
MediaPlayerData.hasActiveMediaOrRecommendationCard()
|
MediaPlayerData.hasActiveMediaOrRecommendationCard()
|
||||||
val isRecommendationCard = mediaControlPanel.recommendationViewHolder != null
|
|
||||||
if (!hasActiveMediaOrRecommendationCard && !qsExpanded) {
|
if (!hasActiveMediaOrRecommendationCard && !qsExpanded) {
|
||||||
// Skip logging if on LS or QQS, and there is no active media card
|
// Skip logging if on LS or QQS, and there is no active media card
|
||||||
return
|
return
|
||||||
@ -759,7 +768,6 @@ class MediaCarouselController @Inject constructor(
|
|||||||
logSmartspaceCardReported(800, // SMARTSPACE_CARD_SEEN
|
logSmartspaceCardReported(800, // SMARTSPACE_CARD_SEEN
|
||||||
mediaControlPanel.mSmartspaceId,
|
mediaControlPanel.mSmartspaceId,
|
||||||
mediaControlPanel.mUid,
|
mediaControlPanel.mUid,
|
||||||
isRecommendationCard,
|
|
||||||
intArrayOf(mediaControlPanel.surfaceForSmartspaceLogging))
|
intArrayOf(mediaControlPanel.surfaceForSmartspaceLogging))
|
||||||
mediaControlPanel.mIsImpressed = true
|
mediaControlPanel.mIsImpressed = true
|
||||||
}
|
}
|
||||||
@ -773,7 +781,6 @@ class MediaCarouselController @Inject constructor(
|
|||||||
* @param instanceId id to uniquely identify a card, e.g. each headphone generates a new
|
* @param instanceId id to uniquely identify a card, e.g. each headphone generates a new
|
||||||
* instanceId
|
* instanceId
|
||||||
* @param uid uid for the application that media comes from
|
* @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
|
* @param surfaces list of display surfaces the media card is on (e.g. lockscreen, shade) when
|
||||||
* the event happened
|
* the event happened
|
||||||
* @param interactedSubcardRank the rank for interacted media item for recommendation card, -1
|
* @param interactedSubcardRank the rank for interacted media item for recommendation card, -1
|
||||||
@ -783,21 +790,27 @@ class MediaCarouselController @Inject constructor(
|
|||||||
* @param rank the rank for media card in the media carousel, starting from 0
|
* @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
|
* @param receivedLatencyMillis latency in milliseconds for card received events. E.g. latency
|
||||||
* between headphone connection to sysUI displays media recommendation card
|
* between headphone connection to sysUI displays media recommendation card
|
||||||
|
* @param isSwipeToDismiss whether is to log swipe-to-dismiss event
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
fun logSmartspaceCardReported(
|
fun logSmartspaceCardReported(
|
||||||
eventId: Int,
|
eventId: Int,
|
||||||
instanceId: Int,
|
instanceId: Int,
|
||||||
uid: Int,
|
uid: Int,
|
||||||
isRecommendationCard: Boolean,
|
|
||||||
surfaces: IntArray,
|
surfaces: IntArray,
|
||||||
interactedSubcardRank: Int = 0,
|
interactedSubcardRank: Int = 0,
|
||||||
interactedSubcardCardinality: Int = 0,
|
interactedSubcardCardinality: Int = 0,
|
||||||
rank: Int = mediaCarouselScrollHandler.visibleMediaIndex,
|
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
|
// Only log media resume card when Smartspace data is available
|
||||||
if (!isRecommendationCard &&
|
if (!mediaControlKey.isSsMediaRec &&
|
||||||
!mediaManager.smartspaceMediaData.isActive &&
|
!mediaManager.smartspaceMediaData.isActive &&
|
||||||
MediaPlayerData.smartspaceMediaData == null) {
|
MediaPlayerData.smartspaceMediaData == null) {
|
||||||
return
|
return
|
||||||
@ -813,10 +826,13 @@ class MediaCarouselController @Inject constructor(
|
|||||||
// card type for each new feature.
|
// card type for each new feature.
|
||||||
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__CARD_TYPE__UNKNOWN_CARD,
|
SysUiStatsLog.SMART_SPACE_CARD_REPORTED__CARD_TYPE__UNKNOWN_CARD,
|
||||||
surface,
|
surface,
|
||||||
rank,
|
// Use -1 as rank value to indicate user swipe to dismiss the card
|
||||||
|
if (isSwipeToDismiss) -1 else rank,
|
||||||
cardinality,
|
cardinality,
|
||||||
if (isRecommendationCard)
|
if (mediaControlKey.isSsMediaRec)
|
||||||
15 // MEDIA_RECOMMENDATION
|
15 // MEDIA_RECOMMENDATION
|
||||||
|
else if (mediaControlKey.isSsReactivated)
|
||||||
|
43 // MEDIA_RESUME_SS_ACTIVATED
|
||||||
else
|
else
|
||||||
31, // MEDIA_RESUME
|
31, // MEDIA_RESUME
|
||||||
uid,
|
uid,
|
||||||
@ -828,7 +844,9 @@ class MediaCarouselController @Inject constructor(
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Log Smartspace card event id: $eventId instance id: $instanceId" +
|
Log.d(TAG, "Log Smartspace card event id: $eventId instance id: $instanceId" +
|
||||||
" surface: $surface rank: $rank cardinality: $cardinality " +
|
" surface: $surface rank: $rank cardinality: $cardinality " +
|
||||||
"isRecommendationCard: $isRecommendationCard uid: $uid " +
|
"isRecommendationCard: ${mediaControlKey.isSsMediaRec} " +
|
||||||
|
"isSsReactivated: ${mediaControlKey.isSsReactivated}" +
|
||||||
|
"uid: $uid " +
|
||||||
"interactedSubcardRank: $interactedSubcardRank " +
|
"interactedSubcardRank: $interactedSubcardRank " +
|
||||||
"interactedSubcardCardinality: $interactedSubcardCardinality " +
|
"interactedSubcardCardinality: $interactedSubcardCardinality " +
|
||||||
"received_latency_millis: $receivedLatencyMillis")
|
"received_latency_millis: $receivedLatencyMillis")
|
||||||
@ -843,10 +861,9 @@ class MediaCarouselController @Inject constructor(
|
|||||||
logSmartspaceCardReported(SMARTSPACE_CARD_DISMISS_EVENT,
|
logSmartspaceCardReported(SMARTSPACE_CARD_DISMISS_EVENT,
|
||||||
it.mSmartspaceId,
|
it.mSmartspaceId,
|
||||||
it.mUid,
|
it.mUid,
|
||||||
it.recommendationViewHolder != null,
|
|
||||||
intArrayOf(it.surfaceForSmartspaceLogging),
|
intArrayOf(it.surfaceForSmartspaceLogging),
|
||||||
// Use -1 as rank value to indicate user swipe to dismiss the card
|
rank = index,
|
||||||
rank = -1)
|
isSwipeToDismiss = true)
|
||||||
// Reset card impressed state when swipe to dismissed
|
// Reset card impressed state when swipe to dismissed
|
||||||
it.mIsImpressed = false
|
it.mIsImpressed = false
|
||||||
}
|
}
|
||||||
@ -897,29 +914,37 @@ internal object MediaPlayerData {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
data class MediaSortKey(
|
data class MediaSortKey(
|
||||||
// Whether the item represents a Smartspace media recommendation.
|
val isSsMediaRec: Boolean, // Whether the item represents a Smartspace media recommendation.
|
||||||
val isSsMediaRec: Boolean,
|
|
||||||
val data: MediaData,
|
val data: MediaData,
|
||||||
val updateTime: Long = 0
|
val updateTime: Long = 0,
|
||||||
|
val isSsReactivated: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
private val comparator =
|
private val comparator =
|
||||||
compareByDescending<MediaSortKey> { it.data.isPlaying == true &&
|
compareByDescending<MediaSortKey> { it.data.isPlaying == true &&
|
||||||
it.data.playbackLocation == MediaData.PLAYBACK_LOCAL }
|
it.data.playbackLocation == MediaData.PLAYBACK_LOCAL }
|
||||||
.thenByDescending { it.data.isPlaying == true &&
|
.thenByDescending { it.data.isPlaying == true &&
|
||||||
it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL }
|
it.data.playbackLocation == MediaData.PLAYBACK_CAST_LOCAL
|
||||||
.thenByDescending { if (shouldPrioritizeSs) it.isSsMediaRec else !it.isSsMediaRec }
|
}
|
||||||
.thenByDescending { !it.data.resumption }
|
.thenByDescending { if (shouldPrioritizeSs) it.isSsMediaRec else !it.isSsMediaRec }
|
||||||
.thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
|
.thenByDescending { !it.data.resumption }
|
||||||
.thenByDescending { it.updateTime }
|
.thenByDescending { it.data.playbackLocation != MediaData.PLAYBACK_CAST_REMOTE }
|
||||||
.thenByDescending { it.data.notificationKey }
|
.thenByDescending { it.updateTime }
|
||||||
|
.thenByDescending { it.data.notificationKey }
|
||||||
|
|
||||||
private val mediaPlayers = TreeMap<MediaSortKey, MediaControlPanel>(comparator)
|
private val mediaPlayers = TreeMap<MediaSortKey, MediaControlPanel>(comparator)
|
||||||
private val mediaData: MutableMap<String, MediaSortKey> = mutableMapOf()
|
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)
|
removeMediaPlayer(key)
|
||||||
val sortKey = MediaSortKey(isSsMediaRec = false, data, clock.currentTimeMillis())
|
val sortKey = MediaSortKey(isSsMediaRec = false,
|
||||||
|
data, clock.currentTimeMillis(), isSsReactivated = isSsReactivated)
|
||||||
mediaData.put(key, sortKey)
|
mediaData.put(key, sortKey)
|
||||||
mediaPlayers.put(sortKey, player)
|
mediaPlayers.put(sortKey, player)
|
||||||
}
|
}
|
||||||
@ -933,8 +958,8 @@ internal object MediaPlayerData {
|
|||||||
) {
|
) {
|
||||||
shouldPrioritizeSs = shouldPrioritize
|
shouldPrioritizeSs = shouldPrioritize
|
||||||
removeMediaPlayer(key)
|
removeMediaPlayer(key)
|
||||||
val sortKey = MediaSortKey(/* isSsMediaRec= */ true,
|
val sortKey = MediaSortKey(isSsMediaRec = true,
|
||||||
EMPTY.copy(isPlaying = false), clock.currentTimeMillis())
|
EMPTY.copy(isPlaying = false), clock.currentTimeMillis(), isSsReactivated = true)
|
||||||
mediaData.put(key, sortKey)
|
mediaData.put(key, sortKey)
|
||||||
mediaPlayers.put(sortKey, player)
|
mediaPlayers.put(sortKey, player)
|
||||||
smartspaceMediaData = data
|
smartspaceMediaData = data
|
||||||
@ -1014,4 +1039,8 @@ internal object MediaPlayerData {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isSsReactivated(key: String): Boolean = mediaData.get(key)?.let {
|
||||||
|
it.isSsReactivated
|
||||||
|
} ?: false
|
||||||
}
|
}
|
@ -178,8 +178,7 @@ public class MediaControlPanel {
|
|||||||
if (mPackageName != null && mInstanceId != null) {
|
if (mPackageName != null && mInstanceId != null) {
|
||||||
mLogger.logSeek(mUid, mPackageName, mInstanceId);
|
mLogger.logSeek(mUid, mPackageName, mInstanceId);
|
||||||
}
|
}
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT,
|
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT);
|
||||||
/* isRecommendationCard */ false);
|
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -335,8 +334,7 @@ public class MediaControlPanel {
|
|||||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||||
if (mMediaViewController.isGutsVisible()) return;
|
if (mMediaViewController.isGutsVisible()) return;
|
||||||
|
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT,
|
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT);
|
||||||
/* isRecommendationCard */ false);
|
|
||||||
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
|
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
|
||||||
buildLaunchAnimatorController(mMediaViewHolder.getPlayer()));
|
buildLaunchAnimatorController(mMediaViewHolder.getPlayer()));
|
||||||
});
|
});
|
||||||
@ -440,9 +438,7 @@ public class MediaControlPanel {
|
|||||||
mMediaViewHolder.getDismiss().setEnabled(isDismissible);
|
mMediaViewHolder.getDismiss().setEnabled(isDismissible);
|
||||||
mMediaViewHolder.getDismiss().setOnClickListener(v -> {
|
mMediaViewHolder.getDismiss().setOnClickListener(v -> {
|
||||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||||
|
logSmartspaceCardReported(SMARTSPACE_CARD_DISMISS_EVENT);
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_DISMISS_EVENT,
|
|
||||||
/* isRecommendationCard */ false);
|
|
||||||
mLogger.logLongPressDismiss(mUid, mPackageName, mInstanceId);
|
mLogger.logLongPressDismiss(mUid, mPackageName, mInstanceId);
|
||||||
|
|
||||||
if (mKey != null) {
|
if (mKey != null) {
|
||||||
@ -683,8 +679,7 @@ public class MediaControlPanel {
|
|||||||
button.setOnClickListener(v -> {
|
button.setOnClickListener(v -> {
|
||||||
if (!mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
if (!mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||||
mLogger.logTapAction(button.getId(), mUid, mPackageName, mInstanceId);
|
mLogger.logTapAction(button.getId(), mUid, mPackageName, mInstanceId);
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT,
|
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT);
|
||||||
/* isRecommendationCard */ false);
|
|
||||||
action.run();
|
action.run();
|
||||||
|
|
||||||
if (icon instanceof Animatable) {
|
if (icon instanceof Animatable) {
|
||||||
@ -932,8 +927,9 @@ public class MediaControlPanel {
|
|||||||
mRecommendationViewHolder.getDismiss().setOnClickListener(v -> {
|
mRecommendationViewHolder.getDismiss().setOnClickListener(v -> {
|
||||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||||
|
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_DISMISS_EVENT,
|
logSmartspaceCardReported(
|
||||||
/* isRecommendationCard */ true);
|
761 // SMARTSPACE_CARD_DISMISS
|
||||||
|
);
|
||||||
closeGuts();
|
closeGuts();
|
||||||
mMediaDataManagerLazy.get().dismissSmartspaceRecommendation(
|
mMediaDataManagerLazy.get().dismissSmartspaceRecommendation(
|
||||||
data.getTargetId(), MediaViewController.GUTS_ANIMATION_DURATION + 100L);
|
data.getTargetId(), MediaViewController.GUTS_ANIMATION_DURATION + 100L);
|
||||||
@ -1068,7 +1064,6 @@ public class MediaControlPanel {
|
|||||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||||
|
|
||||||
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT,
|
logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT,
|
||||||
/* isRecommendationCard */ true,
|
|
||||||
interactedSubcardRank,
|
interactedSubcardRank,
|
||||||
getSmartspaceSubCardCardinality());
|
getSmartspaceSubCardCardinality());
|
||||||
|
|
||||||
@ -1138,18 +1133,17 @@ public class MediaControlPanel {
|
|||||||
return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__DEFAULT_SURFACE;
|
return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__DEFAULT_SURFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logSmartspaceCardReported(int eventId, boolean isRecommendationCard) {
|
private void logSmartspaceCardReported(int eventId) {
|
||||||
logSmartspaceCardReported(eventId, isRecommendationCard,
|
logSmartspaceCardReported(eventId,
|
||||||
/* interactedSubcardRank */ 0,
|
/* interactedSubcardRank */ 0,
|
||||||
/* interactedSubcardCardinality */ 0);
|
/* interactedSubcardCardinality */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logSmartspaceCardReported(int eventId, boolean isRecommendationCard,
|
private void logSmartspaceCardReported(int eventId,
|
||||||
int interactedSubcardRank, int interactedSubcardCardinality) {
|
int interactedSubcardRank, int interactedSubcardCardinality) {
|
||||||
mMediaCarouselController.logSmartspaceCardReported(eventId,
|
mMediaCarouselController.logSmartspaceCardReported(eventId,
|
||||||
mSmartspaceId,
|
mSmartspaceId,
|
||||||
mUid,
|
mUid,
|
||||||
isRecommendationCard,
|
|
||||||
new int[]{getSurfaceForSmartspaceLogging()},
|
new int[]{getSurfaceForSmartspaceLogging()},
|
||||||
interactedSubcardRank,
|
interactedSubcardRank,
|
||||||
interactedSubcardCardinality);
|
interactedSubcardCardinality);
|
||||||
|
@ -32,7 +32,8 @@ class MediaDataCombineLatest @Inject constructor() : MediaDataManager.Listener,
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
if (oldKey != null && oldKey != key && entries.contains(oldKey)) {
|
if (oldKey != null && oldKey != key && entries.contains(oldKey)) {
|
||||||
entries[key] = data to entries.remove(oldKey)?.second
|
entries[key] = data to entries.remove(oldKey)?.second
|
||||||
@ -46,8 +47,7 @@ class MediaDataCombineLatest @Inject constructor() : MediaDataManager.Listener,
|
|||||||
override fun onSmartspaceMediaDataLoaded(
|
override fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean,
|
shouldPrioritize: Boolean
|
||||||
isSsReactivated: Boolean
|
|
||||||
) {
|
) {
|
||||||
listeners.toSet().forEach { it.onSmartspaceMediaDataLoaded(key, data) }
|
listeners.toSet().forEach { it.onSmartspaceMediaDataLoaded(key, data) }
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,8 @@ class MediaDataFilter @Inject constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
if (oldKey != null && oldKey != key) {
|
if (oldKey != null && oldKey != key) {
|
||||||
allEntries.remove(oldKey)
|
allEntries.remove(oldKey)
|
||||||
@ -114,8 +115,7 @@ class MediaDataFilter @Inject constructor(
|
|||||||
override fun onSmartspaceMediaDataLoaded(
|
override fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean,
|
shouldPrioritize: Boolean
|
||||||
isSsReactivated: Boolean
|
|
||||||
) {
|
) {
|
||||||
if (!data.isActive) {
|
if (!data.isActive) {
|
||||||
Log.d(TAG, "Inactive recommendation data. Skip triggering.")
|
Log.d(TAG, "Inactive recommendation data. Skip triggering.")
|
||||||
@ -140,13 +140,12 @@ class MediaDataFilter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val activeMedia = userEntries.filter { (key, value) -> value.active }
|
val shouldReactivate = !hasActiveMedia() && hasAnyMedia()
|
||||||
var isSsReactivatedMutable = activeMedia.isEmpty() && userEntries.isNotEmpty()
|
|
||||||
|
|
||||||
if (timeSinceActive < smartspaceMaxAgeMillis) {
|
if (timeSinceActive < smartspaceMaxAgeMillis) {
|
||||||
// It could happen there are existing active media resume cards, then we don't need to
|
// It could happen there are existing active media resume cards, then we don't need to
|
||||||
// reactivate.
|
// reactivate.
|
||||||
if (isSsReactivatedMutable) {
|
if (shouldReactivate) {
|
||||||
val lastActiveKey = sorted.lastKey() // most recently active
|
val lastActiveKey = sorted.lastKey() // most recently active
|
||||||
// Notify listeners to consider this media active
|
// Notify listeners to consider this media active
|
||||||
Log.d(TAG, "reactivating $lastActiveKey instead of smartspace")
|
Log.d(TAG, "reactivating $lastActiveKey instead of smartspace")
|
||||||
@ -156,7 +155,7 @@ class MediaDataFilter @Inject constructor(
|
|||||||
it.onMediaDataLoaded(lastActiveKey, lastActiveKey, mediaData,
|
it.onMediaDataLoaded(lastActiveKey, lastActiveKey, mediaData,
|
||||||
receivedSmartspaceCardLatency =
|
receivedSmartspaceCardLatency =
|
||||||
(systemClock.currentTimeMillis() - data.headphoneConnectionTimeMillis)
|
(systemClock.currentTimeMillis() - data.headphoneConnectionTimeMillis)
|
||||||
.toInt())
|
.toInt(), isSsReactivated = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -168,8 +167,7 @@ class MediaDataFilter @Inject constructor(
|
|||||||
Log.d(TAG, "Invalid recommendation data. Skip showing the rec card")
|
Log.d(TAG, "Invalid recommendation data. Skip showing the rec card")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
listeners.forEach { it.onSmartspaceMediaDataLoaded(key, data, shouldPrioritizeMutable,
|
listeners.forEach { it.onSmartspaceMediaDataLoaded(key, data, shouldPrioritizeMutable) }
|
||||||
isSsReactivatedMutable) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMediaDataRemoved(key: String) {
|
override fun onMediaDataRemoved(key: String) {
|
||||||
@ -260,14 +258,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?
|
* 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
|
* Add a listener for filtered [MediaData] changes
|
||||||
|
@ -1079,15 +1079,27 @@ class MediaDataManager(
|
|||||||
fun onSwipeToDismiss() = mediaDataFilter.onSwipeToDismiss()
|
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()
|
fun hasActiveMedia() = mediaDataFilter.hasActiveMedia()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are there any media entries we should display?
|
* Are there any resume media notifications active, excluding the recommendations?
|
||||||
* If resumption is enabled, this will include inactive players
|
* If resumption is enabled, this will include inactive players
|
||||||
* If resumption is disabled, we only want to show active players
|
* If resumption is disabled, we only want to show active players
|
||||||
*/
|
*/
|
||||||
fun hasAnyMedia() = mediaDataFilter.hasAnyMedia()
|
fun hasAnyMedia() = mediaDataFilter.hasAnyMedia()
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
@ -1106,13 +1118,17 @@ class MediaDataManager(
|
|||||||
* @param receivedSmartspaceCardLatency is the latency between headphone connects and sysUI
|
* @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
|
* displays Smartspace media targets. Will be 0 if the data is not activated by Smartspace
|
||||||
* signal.
|
* signal.
|
||||||
|
*
|
||||||
|
* @param isSsReactivated indicates resume media card is reactivated by Smartspace
|
||||||
|
* recommendation signal
|
||||||
*/
|
*/
|
||||||
fun onMediaDataLoaded(
|
fun onMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean = true,
|
immediately: Boolean = true,
|
||||||
receivedSmartspaceCardLatency: Int = 0
|
receivedSmartspaceCardLatency: Int = 0,
|
||||||
|
isSsReactivated: Boolean = false
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1121,15 +1137,11 @@ class MediaDataManager(
|
|||||||
* @param shouldPrioritize indicates the sorting priority of the Smartspace card. If true,
|
* @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
|
* it will be prioritized as the first card. Otherwise, it will show up as the last card as
|
||||||
* default.
|
* default.
|
||||||
*
|
|
||||||
* @param isSsReactivated indicates resume media card is reactivated by Smartspace
|
|
||||||
* recommendation signal
|
|
||||||
*/
|
*/
|
||||||
fun onSmartspaceMediaDataLoaded(
|
fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean = false,
|
shouldPrioritize: Boolean = false
|
||||||
isSsReactivated: Boolean = false
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/** Called whenever a previously existing Media notification was removed. */
|
/** Called whenever a previously existing Media notification was removed. */
|
||||||
|
@ -72,7 +72,8 @@ class MediaDeviceManager @Inject constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
if (oldKey != null && oldKey != key) {
|
if (oldKey != null && oldKey != key) {
|
||||||
val oldEntry = entries.remove(oldKey)
|
val oldEntry = entries.remove(oldKey)
|
||||||
|
@ -68,7 +68,8 @@ class MediaHost constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
if (immediately) {
|
if (immediately) {
|
||||||
updateViewVisibility()
|
updateViewVisibility()
|
||||||
@ -78,8 +79,7 @@ class MediaHost constructor(
|
|||||||
override fun onSmartspaceMediaDataLoaded(
|
override fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean,
|
shouldPrioritize: Boolean
|
||||||
isSsReactivated: Boolean
|
|
||||||
) {
|
) {
|
||||||
updateViewVisibility()
|
updateViewVisibility()
|
||||||
}
|
}
|
||||||
@ -169,9 +169,9 @@ class MediaHost constructor(
|
|||||||
|
|
||||||
private fun updateViewVisibility() {
|
private fun updateViewVisibility() {
|
||||||
state.visible = if (showsOnlyActiveMedia) {
|
state.visible = if (showsOnlyActiveMedia) {
|
||||||
mediaDataManager.hasActiveMedia()
|
mediaDataManager.hasActiveMediaOrRecommendation()
|
||||||
} else {
|
} else {
|
||||||
mediaDataManager.hasAnyMedia()
|
mediaDataManager.hasAnyMediaOrRecommendation()
|
||||||
}
|
}
|
||||||
val newVisibility = if (visible) View.VISIBLE else View.GONE
|
val newVisibility = if (visible) View.VISIBLE else View.GONE
|
||||||
if (newVisibility != hostView.visibility) {
|
if (newVisibility != hostView.visibility) {
|
||||||
|
@ -184,7 +184,8 @@ class MediaResumeListener @Inject constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
if (useMediaResumption) {
|
if (useMediaResumption) {
|
||||||
// If this had been started from a resume state, disconnect now that it's live
|
// 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?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
backgroundExecutor.execute {
|
backgroundExecutor.execute {
|
||||||
data.token?.let {
|
data.token?.let {
|
||||||
@ -143,8 +144,7 @@ class MediaSessionBasedFilter @Inject constructor(
|
|||||||
override fun onSmartspaceMediaDataLoaded(
|
override fun onSmartspaceMediaDataLoaded(
|
||||||
key: String,
|
key: String,
|
||||||
data: SmartspaceMediaData,
|
data: SmartspaceMediaData,
|
||||||
shouldPrioritize: Boolean,
|
shouldPrioritize: Boolean
|
||||||
isSsReactivated: Boolean
|
|
||||||
) {
|
) {
|
||||||
backgroundExecutor.execute {
|
backgroundExecutor.execute {
|
||||||
dispatchSmartspaceMediaDataLoaded(key, data)
|
dispatchSmartspaceMediaDataLoaded(key, data)
|
||||||
|
@ -63,7 +63,8 @@ class MediaTimeoutListener @Inject constructor(
|
|||||||
oldKey: String?,
|
oldKey: String?,
|
||||||
data: MediaData,
|
data: MediaData,
|
||||||
immediately: Boolean,
|
immediately: Boolean,
|
||||||
receivedSmartspaceCardLatency: Int
|
receivedSmartspaceCardLatency: Int,
|
||||||
|
isSsReactivated: Boolean
|
||||||
) {
|
) {
|
||||||
var reusedListener: PlaybackStateListener? = null
|
var reusedListener: PlaybackStateListener? = null
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@ public class MediaDreamSentinel extends CoreStartable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
||||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize,
|
@NonNull SmartspaceMediaData data, boolean shouldPrioritize) {
|
||||||
boolean isSsReactivated) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaDataLoaded(@NonNull String key, @Nullable String oldKey,
|
public void onMediaDataLoaded(@NonNull String key, @Nullable String oldKey,
|
||||||
@NonNull MediaData data, boolean immediately, int receivedSmartspaceCardLatency) {
|
@NonNull MediaData data, boolean immediately, int receivedSmartspaceCardLatency,
|
||||||
|
boolean isSsReactivated) {
|
||||||
if (mAdded) {
|
if (mAdded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -245,13 +245,12 @@ public class NotificationMediaManager implements Dumpable {
|
|||||||
@Override
|
@Override
|
||||||
public void onMediaDataLoaded(@NonNull String key,
|
public void onMediaDataLoaded(@NonNull String key,
|
||||||
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
||||||
int receivedSmartspaceCardLatency) {
|
int receivedSmartspaceCardLatency, boolean isSsReactivated) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
||||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize,
|
@NonNull SmartspaceMediaData data, boolean shouldPrioritize) {
|
||||||
boolean isSsReactivated) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -320,13 +319,12 @@ public class NotificationMediaManager implements Dumpable {
|
|||||||
@Override
|
@Override
|
||||||
public void onMediaDataLoaded(@NonNull String key,
|
public void onMediaDataLoaded(@NonNull String key,
|
||||||
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
@Nullable String oldKey, @NonNull MediaData data, boolean immediately,
|
||||||
int receivedSmartspaceCardLatency) {
|
int receivedSmartspaceCardLatency, boolean isSsReactivated) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
public void onSmartspaceMediaDataLoaded(@NonNull String key,
|
||||||
@NonNull SmartspaceMediaData data, boolean shouldPrioritize,
|
@NonNull SmartspaceMediaData data, boolean shouldPrioritize) {
|
||||||
boolean isSsReactivated) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,9 +1355,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard;
|
int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard;
|
||||||
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
||||||
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||||
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
.getVisibleNotificationCount() != 0
|
||||||
|
|| mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||||
boolean splitShadeWithActiveMedia =
|
boolean splitShadeWithActiveMedia =
|
||||||
mShouldUseSplitNotificationShade && mMediaDataManager.hasActiveMedia();
|
mShouldUseSplitNotificationShade
|
||||||
|
&& mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||||
boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange();
|
boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange();
|
||||||
if ((hasVisibleNotifications && !mShouldUseSplitNotificationShade)
|
if ((hasVisibleNotifications && !mShouldUseSplitNotificationShade)
|
||||||
|| (splitShadeWithActiveMedia && !mDozing)) {
|
|| (splitShadeWithActiveMedia && !mDozing)) {
|
||||||
@ -1424,7 +1426,8 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
|
|
||||||
private void updateKeyguardStatusViewAlignment(boolean animate) {
|
private void updateKeyguardStatusViewAlignment(boolean animate) {
|
||||||
boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||||
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
.getVisibleNotificationCount() != 0
|
||||||
|
|| mMediaDataManager.hasActiveMediaOrRecommendation();
|
||||||
boolean shouldBeCentered = !mShouldUseSplitNotificationShade || !hasVisibleNotifications
|
boolean shouldBeCentered = !mShouldUseSplitNotificationShade || !hasVisibleNotifications
|
||||||
|| mDozing;
|
|| mDozing;
|
||||||
if (mStatusViewCentered != shouldBeCentered) {
|
if (mStatusViewCentered != shouldBeCentered) {
|
||||||
@ -2622,7 +2625,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
float endPosition = 0;
|
float endPosition = 0;
|
||||||
if (pxAmount > 0.0f) {
|
if (pxAmount > 0.0f) {
|
||||||
if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0
|
if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0
|
||||||
&& !mMediaDataManager.hasActiveMedia()) {
|
&& !mMediaDataManager.hasActiveMediaOrRecommendation()) {
|
||||||
// No notifications are visible, let's animate to the height of qs instead
|
// No notifications are visible, let's animate to the height of qs instead
|
||||||
if (mQs != null) {
|
if (mQs != null) {
|
||||||
// Let's interpolate to the header height instead of the top padding,
|
// Let's interpolate to the header height instead of the top padding,
|
||||||
|
@ -142,7 +142,7 @@ class MediaCarouselControllerTest : SysuiTestCase() {
|
|||||||
expected.forEach {
|
expected.forEach {
|
||||||
clock.setCurrentTimeMillis(it.third)
|
clock.setCurrentTimeMillis(it.third)
|
||||||
MediaPlayerData.addMediaPlayer(it.first, it.second.copy(notificationKey = it.first),
|
MediaPlayerData.addMediaPlayer(it.first, it.second.copy(notificationKey = it.first),
|
||||||
panel, clock)
|
panel, clock, isSsReactivated = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
for ((index, key) in MediaPlayerData.playerKeys().withIndex()) {
|
for ((index, key) in MediaPlayerData.playerKeys().withIndex()) {
|
||||||
|
@ -87,10 +87,10 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void eventNotEmittedWithoutDevice() {
|
public void eventNotEmittedWithoutDevice() {
|
||||||
// WHEN data source emits an event without device data
|
// WHEN data source emits an event without device data
|
||||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
// THEN an event isn't emitted
|
// THEN an event isn't emitted
|
||||||
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -99,7 +99,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||||
// THEN an event isn't emitted
|
// THEN an event isn't emitted
|
||||||
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
verify(mListener, never()).onMediaDataLoaded(eq(KEY), any(), any(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -108,11 +108,11 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||||
// WHEN media event is received
|
// WHEN media event is received
|
||||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
// THEN the listener receives a combined event
|
// THEN the listener receives a combined event
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,13 +120,13 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void emitEventAfterMediaFirst() {
|
public void emitEventAfterMediaFirst() {
|
||||||
// GIVEN that media event has already been received
|
// GIVEN that media event has already been received
|
||||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
// WHEN device event is received
|
// WHEN device event is received
|
||||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||||
// THEN the listener receives a combined event
|
// THEN the listener receives a combined event
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), any(), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,16 +134,16 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void migrateKeyMediaFirst() {
|
public void migrateKeyMediaFirst() {
|
||||||
// GIVEN that media and device info has already been received
|
// GIVEN that media and device info has already been received
|
||||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||||
reset(mListener);
|
reset(mListener);
|
||||||
// WHEN a key migration event is received
|
// WHEN a key migration event is received
|
||||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
// THEN the listener receives a combined event
|
// THEN the listener receives a combined event
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void migrateKeyDeviceFirst() {
|
public void migrateKeyDeviceFirst() {
|
||||||
// GIVEN that media and device info has already been received
|
// GIVEN that media and device info has already been received
|
||||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||||
reset(mListener);
|
reset(mListener);
|
||||||
// WHEN a key migration event is received
|
// WHEN a key migration event is received
|
||||||
@ -159,7 +159,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
// THEN the listener receives a combined event
|
// THEN the listener receives a combined event
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), eq(OLD_KEY), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,17 +167,17 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void migrateKeyMediaAfter() {
|
public void migrateKeyMediaAfter() {
|
||||||
// GIVEN that media and device info has already been received
|
// GIVEN that media and device info has already been received
|
||||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||||
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
||||||
reset(mListener);
|
reset(mListener);
|
||||||
// WHEN a second key migration event is received for media
|
// WHEN a second key migration event is received for media
|
||||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
// THEN the key has already been migrated
|
// THEN the key has already been migrated
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,17 +185,17 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void migrateKeyDeviceAfter() {
|
public void migrateKeyDeviceAfter() {
|
||||||
// GIVEN that media and device info has already been received
|
// GIVEN that media and device info has already been received
|
||||||
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(OLD_KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(OLD_KEY, null, mDeviceData);
|
||||||
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, OLD_KEY, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
reset(mListener);
|
reset(mListener);
|
||||||
// WHEN a second key migration event is received for the device
|
// WHEN a second key migration event is received for the device
|
||||||
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, OLD_KEY, mDeviceData);
|
||||||
// THEN the key has already be migrated
|
// THEN the key has already be migrated
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
verify(mListener).onMediaDataLoaded(eq(KEY), eq(KEY), captor.capture(), anyBoolean(),
|
||||||
anyInt());
|
anyInt(), anyBoolean());
|
||||||
assertThat(captor.getValue().getDevice()).isNotNull();
|
assertThat(captor.getValue().getDevice()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void mediaDataRemovedAfterMediaEvent() {
|
public void mediaDataRemovedAfterMediaEvent() {
|
||||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDataRemoved(KEY);
|
mManager.onMediaDataRemoved(KEY);
|
||||||
verify(mListener).onMediaDataRemoved(eq(KEY));
|
verify(mListener).onMediaDataRemoved(eq(KEY));
|
||||||
}
|
}
|
||||||
@ -226,14 +226,14 @@ public class MediaDataCombineLatestTest extends SysuiTestCase {
|
|||||||
public void mediaDataKeyUpdated() {
|
public void mediaDataKeyUpdated() {
|
||||||
// GIVEN that device and media events have already been received
|
// GIVEN that device and media events have already been received
|
||||||
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
mManager.onMediaDataLoaded(KEY, null, mMediaData, true /* immediately */,
|
||||||
0 /* receivedSmartspaceCardLatency */);
|
0 /* receivedSmartspaceCardLatency */, false /* isSsReactivated */);
|
||||||
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
mManager.onMediaDeviceChanged(KEY, null, mDeviceData);
|
||||||
// WHEN the key is changed
|
// WHEN the key is changed
|
||||||
mManager.onMediaDataLoaded("NEW_KEY", KEY, mMediaData, true /* immediately */,
|
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
|
// THEN the listener gets a load event with the correct keys
|
||||||
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
ArgumentCaptor<MediaData> captor = ArgumentCaptor.forClass(MediaData.class);
|
||||||
verify(mListener).onMediaDataLoaded(
|
verify(mListener).onMediaDataLoaded(
|
||||||
eq("NEW_KEY"), any(), captor.capture(), anyBoolean(), anyInt());
|
eq("NEW_KEY"), any(), captor.capture(), anyBoolean(), anyInt(), anyBoolean());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// THEN we should tell the listener
|
// THEN we should tell the listener
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataMain), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataMain), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -124,7 +124,8 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataGuest)
|
mediaDataFilter.onMediaDataLoaded(KEY, null, dataGuest)
|
||||||
|
|
||||||
// THEN we should NOT tell the listener
|
// 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
|
@Test
|
||||||
@ -171,51 +172,56 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// THEN we should add back the guest user media
|
// THEN we should add back the guest user media
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY_ALT), eq(null), eq(dataGuest), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY_ALT), eq(null), eq(dataGuest), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
// but not the main user's
|
// but not the main user's
|
||||||
verify(listener, never()).onMediaDataLoaded(eq(KEY), any(), eq(dataMain), anyBoolean(),
|
verify(listener, never()).onMediaDataLoaded(eq(KEY), any(), eq(dataMain), anyBoolean(),
|
||||||
anyInt())
|
anyInt(), anyBoolean())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHasAnyMedia() {
|
fun testHasAnyMediaOrRecommendation() {
|
||||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||||
|
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
||||||
|
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isTrue()
|
||||||
assertThat(mediaDataFilter.hasAnyMedia()).isTrue()
|
assertThat(mediaDataFilter.hasAnyMedia()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHasActiveMedia() {
|
fun testHasActiveMediaOrRecommendation() {
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
val data = dataMain.copy(active = true)
|
val data = dataMain.copy(active = true)
|
||||||
|
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
||||||
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHasAnyMedia_onlyCurrentUser() {
|
fun testHasAnyMediaOrRecommendation_onlyCurrentUser() {
|
||||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||||
|
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataGuest)
|
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataGuest)
|
||||||
|
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHasActiveMedia_onlyCurrentUser() {
|
fun testHasActiveMediaOrRecommendation_onlyCurrentUser() {
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
val data = dataGuest.copy(active = true)
|
val data = dataGuest.copy(active = true)
|
||||||
|
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = data)
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
|
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOnNotificationRemoved_doesntHaveMedia() {
|
fun testOnNotificationRemoved_doesntHaveMedia() {
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
mediaDataFilter.onMediaDataLoaded(KEY, oldKey = null, data = dataMain)
|
||||||
mediaDataFilter.onMediaDataRemoved(KEY)
|
mediaDataFilter.onMediaDataRemoved(KEY)
|
||||||
|
assertThat(mediaDataFilter.hasAnyMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
assertThat(mediaDataFilter.hasAnyMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +238,9 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true),
|
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true))
|
||||||
eq(false))
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -243,9 +249,10 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
|
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(), anyInt())
|
verify(listener, never()).onMediaDataLoaded(any(), any(), any(), anyBoolean(),
|
||||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
anyInt(), anyBoolean())
|
||||||
anyBoolean())
|
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||||
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,9 +264,9 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true),
|
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(true))
|
||||||
eq(true))
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -271,8 +278,8 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
clock.advanceTime(SMARTSPACE_MAX_AGE + 100)
|
clock.advanceTime(SMARTSPACE_MAX_AGE + 100)
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||||
anyBoolean())
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,16 +291,16 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
// AND we get a smartspace signal
|
// AND we get a smartspace signal
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
// THEN we should tell listeners to treat the media as not active instead
|
// THEN we should tell listeners to treat the media as not active instead
|
||||||
verify(listener, never()).onMediaDataLoaded(eq(KEY), eq(KEY), any(), anyBoolean(),
|
verify(listener, never()).onMediaDataLoaded(eq(KEY), eq(KEY), any(), anyBoolean(),
|
||||||
anyInt())
|
anyInt(), anyBoolean())
|
||||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||||
anyBoolean())
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +312,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
// AND we get a smartspace signal
|
// AND we get a smartspace signal
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
@ -313,11 +320,10 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
// THEN we should tell listeners to treat the media as active instead
|
// THEN we should tell listeners to treat the media as active instead
|
||||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||||
eq(100))
|
eq(100), eq(true))
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
// Smartspace update shouldn't be propagated for the empty rec list.
|
// Smartspace update shouldn't be propagated for the empty rec list.
|
||||||
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean(),
|
verify(listener, never()).onSmartspaceMediaDataLoaded(any(), any(), anyBoolean())
|
||||||
anyBoolean())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -326,7 +332,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
// AND we get a smartspace signal
|
// AND we get a smartspace signal
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
@ -334,12 +340,11 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
// THEN we should tell listeners to treat the media as active instead
|
// THEN we should tell listeners to treat the media as active instead
|
||||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||||
eq(100))
|
eq(100), eq(true))
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isTrue()
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isTrue()
|
||||||
// Smartspace update should also be propagated but not prioritized.
|
// Smartspace update should also be propagated but not prioritized.
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(false),
|
.onSmartspaceMediaDataLoaded(eq(SMARTSPACE_KEY), eq(smartspaceData), eq(false))
|
||||||
eq(true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -348,6 +353,7 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||||
|
|
||||||
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||||
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,17 +362,18 @@ class MediaDataFilterTest : SysuiTestCase() {
|
|||||||
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
val dataCurrent = dataMain.copy(active = false, lastActive = clock.elapsedRealtime())
|
||||||
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
mediaDataFilter.onMediaDataLoaded(KEY, null, dataCurrent)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), eq(dataCurrent), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
mediaDataFilter.onSmartspaceMediaDataLoaded(SMARTSPACE_KEY, smartspaceData)
|
||||||
|
|
||||||
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
val dataCurrentAndActive = dataCurrent.copy(active = true)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), eq(dataCurrentAndActive), eq(true),
|
||||||
eq(100))
|
eq(100), eq(true))
|
||||||
|
|
||||||
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
mediaDataFilter.onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||||
|
|
||||||
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
verify(listener).onSmartspaceMediaDataRemoved(SMARTSPACE_KEY)
|
||||||
|
assertThat(mediaDataFilter.hasActiveMediaOrRecommendation()).isFalse()
|
||||||
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
assertThat(mediaDataFilter.hasActiveMedia()).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
backgroundExecutor.runAllReady()
|
backgroundExecutor.runAllReady()
|
||||||
foregroundExecutor.runAllReady()
|
foregroundExecutor.runAllReady()
|
||||||
verify(listener).onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor),
|
verify(listener).onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor),
|
||||||
eq(true), eq(0))
|
eq(true), eq(0), eq(false))
|
||||||
|
|
||||||
mediaDataManager.setTimedOut(PACKAGE_NAME, timedOut = true)
|
mediaDataManager.setTimedOut(PACKAGE_NAME, timedOut = true)
|
||||||
verify(logger).logMediaTimeout(anyInt(), eq(PACKAGE_NAME),
|
verify(logger).logMediaTimeout(anyInt(), eq(PACKAGE_NAME),
|
||||||
@ -244,7 +244,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value!!.active).isTrue()
|
assertThat(mediaDataCaptor.value!!.active).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value!!.playbackLocation).isEqualTo(
|
assertThat(mediaDataCaptor.value!!.playbackLocation).isEqualTo(
|
||||||
MediaData.PLAYBACK_CAST_REMOTE)
|
MediaData.PLAYBACK_CAST_REMOTE)
|
||||||
verify(logger).logActiveMediaAdded(anyInt(), eq(SYSTEM_PACKAGE_NAME),
|
verify(logger).logActiveMediaAdded(anyInt(), eq(SYSTEM_PACKAGE_NAME),
|
||||||
@ -295,7 +295,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
// THEN the media data indicates that it is for resumption
|
// THEN the media data indicates that it is for resumption
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||||
assertThat(mediaDataCaptor.value.isPlaying).isFalse()
|
assertThat(mediaDataCaptor.value.isPlaying).isFalse()
|
||||||
verify(logger).logActiveConvertedToResume(anyInt(), eq(PACKAGE_NAME), eq(data.instanceId))
|
verify(logger).logActiveConvertedToResume(anyInt(), eq(PACKAGE_NAME), eq(data.instanceId))
|
||||||
@ -311,7 +311,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(2)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(2)
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
val data = mediaDataCaptor.value
|
val data = mediaDataCaptor.value
|
||||||
assertThat(data.resumption).isFalse()
|
assertThat(data.resumption).isFalse()
|
||||||
val resumableData = data.copy(resumeAction = Runnable {})
|
val resumableData = data.copy(resumeAction = Runnable {})
|
||||||
@ -323,7 +323,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
// THEN the data is for resumption and the key is migrated to the package name
|
// THEN the data is for resumption and the key is migrated to the package name
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||||
verify(listener, never()).onMediaDataRemoved(eq(KEY))
|
verify(listener, never()).onMediaDataRemoved(eq(KEY))
|
||||||
// WHEN the second is removed
|
// WHEN the second is removed
|
||||||
@ -332,7 +332,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(
|
.onMediaDataLoaded(
|
||||||
eq(PACKAGE_NAME), eq(PACKAGE_NAME), capture(mediaDataCaptor), eq(true),
|
eq(PACKAGE_NAME), eq(PACKAGE_NAME), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||||
verify(listener).onMediaDataRemoved(eq(KEY_2))
|
verify(listener).onMediaDataRemoved(eq(KEY_2))
|
||||||
}
|
}
|
||||||
@ -373,7 +373,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
// THEN the media data indicates that it is for resumption
|
// THEN the media data indicates that it is for resumption
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
val data = mediaDataCaptor.value
|
val data = mediaDataCaptor.value
|
||||||
assertThat(data.resumption).isTrue()
|
assertThat(data.resumption).isTrue()
|
||||||
assertThat(data.song).isEqualTo(SESSION_TITLE)
|
assertThat(data.song).isEqualTo(SESSION_TITLE)
|
||||||
@ -396,7 +396,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener).onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor),
|
verify(listener).onMediaDataLoaded(eq(PACKAGE_NAME), eq(null), capture(mediaDataCaptor),
|
||||||
eq(true), eq(0))
|
eq(true), eq(0), eq(false))
|
||||||
val data = mediaDataCaptor.value
|
val data = mediaDataCaptor.value
|
||||||
mediaDataManager.setMediaResumptionEnabled(false)
|
mediaDataManager.setMediaResumptionEnabled(false)
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -456,7 +456,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
eq(SmartspaceMediaData(KEY_MEDIA_SMARTSPACE, true /* isActive */, true /*isValid */,
|
eq(SmartspaceMediaData(KEY_MEDIA_SMARTSPACE, true /* isActive */, true /*isValid */,
|
||||||
PACKAGE_NAME, mediaSmartspaceBaseAction, listOf(mediaRecommendationItem),
|
PACKAGE_NAME, mediaSmartspaceBaseAction, listOf(mediaRecommendationItem),
|
||||||
DISMISS_INTENT, 0, 1234L)),
|
DISMISS_INTENT, 0, 1234L)),
|
||||||
eq(false), eq(false))
|
eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -469,7 +469,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
||||||
isValid = false, dismissIntent = DISMISS_INTENT,
|
isValid = false, dismissIntent = DISMISS_INTENT,
|
||||||
headphoneConnectionTimeMillis = 1234L)),
|
headphoneConnectionTimeMillis = 1234L)),
|
||||||
eq(false), eq(false))
|
eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -489,14 +489,14 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
eq(EMPTY_SMARTSPACE_MEDIA_DATA
|
eq(EMPTY_SMARTSPACE_MEDIA_DATA
|
||||||
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
.copy(targetId = KEY_MEDIA_SMARTSPACE, isActive = true,
|
||||||
isValid = false, dismissIntent = null, headphoneConnectionTimeMillis = 1234L)),
|
isValid = false, dismissIntent = null, headphoneConnectionTimeMillis = 1234L)),
|
||||||
eq(false), eq(false))
|
eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOnSmartspaceMediaDataLoaded_hasNoneMediaTarget_notCallsListener() {
|
fun testOnSmartspaceMediaDataLoaded_hasNoneMediaTarget_notCallsListener() {
|
||||||
smartspaceMediaDataProvider.onTargetsAvailable(listOf())
|
smartspaceMediaDataProvider.onTargetsAvailable(listOf())
|
||||||
verify(listener, never())
|
verify(listener, never())
|
||||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean(), anyBoolean())
|
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -520,7 +520,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// THEN smartspace signal is ignored
|
// THEN smartspace signal is ignored
|
||||||
verify(listener, never())
|
verify(listener, never())
|
||||||
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean(), anyBoolean())
|
.onSmartspaceMediaDataLoaded(anyObject(), anyObject(), anyBoolean())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -528,7 +528,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
// GIVEN a media recommendation card is present
|
// GIVEN a media recommendation card is present
|
||||||
smartspaceMediaDataProvider.onTargetsAvailable(listOf(mediaSmartspaceTarget))
|
smartspaceMediaDataProvider.onTargetsAvailable(listOf(mediaSmartspaceTarget))
|
||||||
verify(listener).onSmartspaceMediaDataLoaded(eq(KEY_MEDIA_SMARTSPACE), anyObject(),
|
verify(listener).onSmartspaceMediaDataLoaded(eq(KEY_MEDIA_SMARTSPACE), anyObject(),
|
||||||
anyBoolean(), anyBoolean())
|
anyBoolean())
|
||||||
|
|
||||||
// WHEN the media recommendation setting is turned off
|
// WHEN the media recommendation setting is turned off
|
||||||
Settings.Secure.putInt(context.contentResolver,
|
Settings.Secure.putInt(context.contentResolver,
|
||||||
@ -562,7 +562,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// THEN the last active time is not changed
|
// THEN the last active time is not changed
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
// THEN the last active time is not changed
|
// THEN the last active time is not changed
|
||||||
verify(listener)
|
verify(listener)
|
||||||
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
.onMediaDataLoaded(eq(PACKAGE_NAME), eq(KEY), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
assertThat(mediaDataCaptor.value.resumption).isTrue()
|
||||||
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
assertThat(mediaDataCaptor.value.lastActive).isLessThan(currentTime)
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// THEN only the first MAX_COMPACT_ACTIONS are actually set
|
// THEN only the first MAX_COMPACT_ACTIONS are actually set
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
assertThat(mediaDataCaptor.value.actionsToShowInCompact.size).isEqualTo(
|
assertThat(mediaDataCaptor.value.actionsToShowInCompact.size).isEqualTo(
|
||||||
MediaDataManager.MAX_COMPACT_ACTIONS)
|
MediaDataManager.MAX_COMPACT_ACTIONS)
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
|
|
||||||
assertThat(mediaDataCaptor.value!!.semanticActions).isNull()
|
assertThat(mediaDataCaptor.value!!.semanticActions).isNull()
|
||||||
assertThat(mediaDataCaptor.value!!.actions).hasSize(1)
|
assertThat(mediaDataCaptor.value!!.actions).hasSize(1)
|
||||||
@ -803,6 +803,6 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(backgroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
assertThat(foregroundExecutor.runAllReady()).isEqualTo(1)
|
||||||
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
verify(listener).onMediaDataLoaded(eq(KEY), eq(null), capture(mediaDataCaptor), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,10 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
|||||||
val playerIsRemote = mock(MediaControlPanel::class.java)
|
val playerIsRemote = mock(MediaControlPanel::class.java)
|
||||||
val dataIsRemote = createMediaData("app2", PLAYING, REMOTE, !RESUMPTION)
|
val dataIsRemote = createMediaData("app2", PLAYING, REMOTE, !RESUMPTION)
|
||||||
|
|
||||||
MediaPlayerData.addMediaPlayer("2", dataIsRemote, playerIsRemote, systemClock)
|
MediaPlayerData.addMediaPlayer("2", dataIsRemote, playerIsRemote, systemClock,
|
||||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock)
|
isSsReactivated = false)
|
||||||
|
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
|
|
||||||
val players = MediaPlayerData.players()
|
val players = MediaPlayerData.players()
|
||||||
assertThat(players).hasSize(2)
|
assertThat(players).hasSize(2)
|
||||||
@ -77,18 +79,22 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
|||||||
val playerIsPlaying2 = mock(MediaControlPanel::class.java)
|
val playerIsPlaying2 = mock(MediaControlPanel::class.java)
|
||||||
var dataIsPlaying2 = createMediaData("app2", !PLAYING, LOCAL, !RESUMPTION)
|
var dataIsPlaying2 = createMediaData("app2", !PLAYING, LOCAL, !RESUMPTION)
|
||||||
|
|
||||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock)
|
MediaPlayerData.addMediaPlayer("1", dataIsPlaying1, playerIsPlaying1, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
systemClock.advanceTime(1)
|
systemClock.advanceTime(1)
|
||||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock)
|
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
systemClock.advanceTime(1)
|
systemClock.advanceTime(1)
|
||||||
|
|
||||||
dataIsPlaying1 = createMediaData("app1", !PLAYING, LOCAL, !RESUMPTION)
|
dataIsPlaying1 = createMediaData("app1", !PLAYING, LOCAL, !RESUMPTION)
|
||||||
dataIsPlaying2 = createMediaData("app2", 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)
|
systemClock.advanceTime(1)
|
||||||
|
|
||||||
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock)
|
MediaPlayerData.addMediaPlayer("2", dataIsPlaying2, playerIsPlaying2, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
systemClock.advanceTime(1)
|
systemClock.advanceTime(1)
|
||||||
|
|
||||||
val players = MediaPlayerData.players()
|
val players = MediaPlayerData.players()
|
||||||
@ -116,14 +122,20 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
|||||||
val dataUndetermined = createMediaData("app6", UNDETERMINED, LOCAL, RESUMPTION)
|
val dataUndetermined = createMediaData("app6", UNDETERMINED, LOCAL, RESUMPTION)
|
||||||
|
|
||||||
MediaPlayerData.addMediaPlayer(
|
MediaPlayerData.addMediaPlayer(
|
||||||
"3", dataIsStoppedAndLocal, playerIsStoppedAndLocal, systemClock)
|
"3", dataIsStoppedAndLocal, playerIsStoppedAndLocal, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
MediaPlayerData.addMediaPlayer(
|
MediaPlayerData.addMediaPlayer(
|
||||||
"5", dataIsStoppedAndRemote, playerIsStoppedAndRemote, systemClock)
|
"5", dataIsStoppedAndRemote, playerIsStoppedAndRemote, systemClock,
|
||||||
MediaPlayerData.addMediaPlayer("4", dataCanResume, playerCanResume, systemClock)
|
isSsReactivated = false)
|
||||||
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock)
|
MediaPlayerData.addMediaPlayer("4", dataCanResume, playerCanResume, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
|
MediaPlayerData.addMediaPlayer("1", dataIsPlaying, playerIsPlaying, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
MediaPlayerData.addMediaPlayer(
|
MediaPlayerData.addMediaPlayer(
|
||||||
"2", dataIsPlayingAndRemote, playerIsPlayingAndRemote, systemClock)
|
"2", dataIsPlayingAndRemote, playerIsPlayingAndRemote, systemClock,
|
||||||
MediaPlayerData.addMediaPlayer("6", dataUndetermined, playerUndetermined, systemClock)
|
isSsReactivated = false)
|
||||||
|
MediaPlayerData.addMediaPlayer("6", dataUndetermined, playerUndetermined, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
|
|
||||||
val players = MediaPlayerData.players()
|
val players = MediaPlayerData.players()
|
||||||
assertThat(players).hasSize(6)
|
assertThat(players).hasSize(6)
|
||||||
@ -141,11 +153,13 @@ public class MediaPlayerDataTest : SysuiTestCase() {
|
|||||||
|
|
||||||
assertThat(MediaPlayerData.players()).hasSize(0)
|
assertThat(MediaPlayerData.players()).hasSize(0)
|
||||||
|
|
||||||
MediaPlayerData.addMediaPlayer(keyA, data, playerIsPlaying, systemClock)
|
MediaPlayerData.addMediaPlayer(keyA, data, playerIsPlaying, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
systemClock.advanceTime(1)
|
systemClock.advanceTime(1)
|
||||||
|
|
||||||
assertThat(MediaPlayerData.players()).hasSize(1)
|
assertThat(MediaPlayerData.players()).hasSize(1)
|
||||||
MediaPlayerData.addMediaPlayer(keyB, data, playerIsPlaying, systemClock)
|
MediaPlayerData.addMediaPlayer(keyB, data, playerIsPlaying, systemClock,
|
||||||
|
isSsReactivated = false)
|
||||||
systemClock.advanceTime(1)
|
systemClock.advanceTime(1)
|
||||||
|
|
||||||
assertThat(MediaPlayerData.players()).hasSize(2)
|
assertThat(MediaPlayerData.players()).hasSize(2)
|
||||||
|
@ -162,7 +162,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -185,7 +185,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -215,7 +215,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -231,14 +231,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
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
|
// WHEN a loaded event is received that matches the local session
|
||||||
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is filtered
|
// THEN the event is filtered
|
||||||
verify(mediaListener, never()).onMediaDataLoaded(
|
verify(mediaListener, never()).onMediaDataLoaded(
|
||||||
eq(KEY), eq(null), eq(mediaData2), anyBoolean(), anyInt())
|
eq(KEY), eq(null), eq(mediaData2), anyBoolean(), anyInt(), anyBoolean())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -255,7 +255,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
// THEN the event is not filtered because there isn't a notification for the remote
|
// THEN the event is not filtered because there isn't a notification for the remote
|
||||||
// session.
|
// session.
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -273,14 +273,15 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(key1), eq(null), eq(mediaData1), eq(true),
|
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
|
// WHEN a loaded event is received that matches the local session
|
||||||
filter.onMediaDataLoaded(key2, null, mediaData2)
|
filter.onMediaDataLoaded(key2, null, mediaData2)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is filtered
|
// THEN the event is filtered
|
||||||
verify(mediaListener, never())
|
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
|
// AND there should be a removed event for key2
|
||||||
verify(mediaListener).onMediaDataRemoved(eq(key2))
|
verify(mediaListener).onMediaDataRemoved(eq(key2))
|
||||||
}
|
}
|
||||||
@ -300,14 +301,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(key1), eq(null), eq(mediaData1), eq(true),
|
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
|
// WHEN a loaded event is received that matches the remote session
|
||||||
filter.onMediaDataLoaded(key2, null, mediaData2)
|
filter.onMediaDataLoaded(key2, null, mediaData2)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData2), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -324,14 +325,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
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
|
// WHEN a loaded event is received that matches the local session
|
||||||
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
filter.onMediaDataLoaded(KEY, null, mediaData2)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData2), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData2), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -350,7 +351,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the event is not filtered
|
// THEN the event is not filtered
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(KEY), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -373,7 +374,7 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the key migration event is fired
|
// THEN the key migration event is fired
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(key1), eq(mediaData2), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(key1), eq(mediaData2), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -403,13 +404,14 @@ public class MediaSessionBasedFilterTest : SysuiTestCase() {
|
|||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the key migration event is filtered
|
// THEN the key migration event is filtered
|
||||||
verify(mediaListener, never())
|
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
|
// WHEN a loaded event is received that matches the remote session
|
||||||
filter.onMediaDataLoaded(key2, null, mediaData1)
|
filter.onMediaDataLoaded(key2, null, mediaData1)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
fgExecutor.runAllReady()
|
fgExecutor.runAllReady()
|
||||||
// THEN the key migration event is fired
|
// THEN the key migration event is fired
|
||||||
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData1), eq(true),
|
verify(mediaListener).onMediaDataLoaded(eq(key2), eq(null), eq(mediaData1), eq(true),
|
||||||
eq(0))
|
eq(0), eq(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,11 +75,13 @@ public class MediaDreamSentinelTest extends SysuiTestCase {
|
|||||||
final MediaDataManager.Listener listener = listenerCaptor.getValue();
|
final MediaDataManager.Listener listener = listenerCaptor.getValue();
|
||||||
|
|
||||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
|
when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
|
||||||
listener.onMediaDataLoaded(mKey, mOldKey, mData, true, 0);
|
listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */ true,
|
||||||
|
/* receivedSmartspaceCardLatency= */ 0, /* isSsReactived= */ false);
|
||||||
verify(mDreamOverlayStateController, never()).addComplication(any());
|
verify(mDreamOverlayStateController, never()).addComplication(any());
|
||||||
|
|
||||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
||||||
listener.onMediaDataLoaded(mKey, mOldKey, mData, true, 0);
|
listener.onMediaDataLoaded(mKey, mOldKey, mData, /* immediately= */true,
|
||||||
|
/* receivedSmartspaceCardLatency= */0, /* isSsReactived= */ false);
|
||||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||||
|
|
||||||
listener.onMediaDataRemoved(mKey);
|
listener.onMediaDataRemoved(mKey);
|
||||||
|
@ -876,7 +876,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
|||||||
public void testSwitchesToBigClockInSplitShadeOnAod() {
|
public void testSwitchesToBigClockInSplitShadeOnAod() {
|
||||||
mStatusBarStateController.setState(KEYGUARD);
|
mStatusBarStateController.setState(KEYGUARD);
|
||||||
enableSplitShade(/* enabled= */ true);
|
enableSplitShade(/* enabled= */ true);
|
||||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
|
||||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
|
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2);
|
||||||
clearInvocations(mKeyguardStatusViewController);
|
clearInvocations(mKeyguardStatusViewController);
|
||||||
|
|
||||||
@ -904,7 +904,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
|||||||
mStatusBarStateController.setState(KEYGUARD);
|
mStatusBarStateController.setState(KEYGUARD);
|
||||||
enableSplitShade(/* enabled= */ true);
|
enableSplitShade(/* enabled= */ true);
|
||||||
clearInvocations(mKeyguardStatusViewController);
|
clearInvocations(mKeyguardStatusViewController);
|
||||||
when(mMediaDataManager.hasActiveMedia()).thenReturn(true);
|
when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true);
|
||||||
|
|
||||||
// one notification + media player visible
|
// one notification + media player visible
|
||||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(1);
|
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user