Add logging for swipe and timeout

We weren't logging when the user swiped the carousel away, which makes
it hard to tell in bugreports whether players were set to inactive
because of that or something else.

Bug: 158721393
Bug: 160944177
Test: manual
Change-Id: Ie2205d6c369576f1f83996b2f96d040ddd328e83
This commit is contained in:
Beth Thibodeau
2020-07-23 14:16:39 -04:00
parent 350efb2e0e
commit a0546c7912
2 changed files with 13 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
private const val TAG = "MediaDataFilter" private const val TAG = "MediaDataFilter"
private const val DEBUG = true
/** /**
* Filters data updates from [MediaDataCombineLatest] based on the current user ID, and handles user * Filters data updates from [MediaDataCombineLatest] based on the current user ID, and handles user
@@ -98,7 +99,7 @@ class MediaDataFilter @Inject constructor(
// are up to date // are up to date
mediaEntries.clear() mediaEntries.clear()
keyCopy.forEach { keyCopy.forEach {
Log.d(TAG, "Removing $it after user change") if (DEBUG) Log.d(TAG, "Removing $it after user change")
listenersCopy.forEach { listener -> listenersCopy.forEach { listener ->
listener.onMediaDataRemoved(it) listener.onMediaDataRemoved(it)
} }
@@ -106,7 +107,7 @@ class MediaDataFilter @Inject constructor(
dataSource.getData().forEach { (key, data) -> dataSource.getData().forEach { (key, data) ->
if (lockscreenUserManager.isCurrentProfile(data.userId)) { if (lockscreenUserManager.isCurrentProfile(data.userId)) {
Log.d(TAG, "Re-adding $key after user change") if (DEBUG) Log.d(TAG, "Re-adding $key after user change")
mediaEntries.put(key, data) mediaEntries.put(key, data)
listenersCopy.forEach { listener -> listenersCopy.forEach { listener ->
listener.onMediaDataLoaded(key, null, data) listener.onMediaDataLoaded(key, null, data)
@@ -119,6 +120,7 @@ class MediaDataFilter @Inject constructor(
* Invoked when the user has dismissed the media carousel * Invoked when the user has dismissed the media carousel
*/ */
fun onSwipeToDismiss() { fun onSwipeToDismiss() {
if (DEBUG) Log.d(TAG, "Media carousel swiped away")
val mediaKeys = mediaEntries.keys.toSet() val mediaKeys = mediaEntries.keys.toSet()
mediaKeys.forEach { mediaKeys.forEach {
mediaDataManager.setTimedOut(it, timedOut = true) mediaDataManager.setTimedOut(it, timedOut = true)

View File

@@ -63,6 +63,7 @@ private val ART_URIS = arrayOf(
) )
private const val TAG = "MediaDataManager" private const val TAG = "MediaDataManager"
private const val DEBUG = true
private const val DEFAULT_LUMINOSITY = 0.25f private const val DEFAULT_LUMINOSITY = 0.25f
private const val LUMINOSITY_THRESHOLD = 0.05f private const val LUMINOSITY_THRESHOLD = 0.05f
private const val SATURATION_MULTIPLIER = 0.8f private const val SATURATION_MULTIPLIER = 0.8f
@@ -253,7 +254,7 @@ class MediaDataManager(
fun removeListener(listener: Listener) = listeners.remove(listener) fun removeListener(listener: Listener) = listeners.remove(listener)
/** /**
* Called whenever the player has been paused or stopped for a while. * Called whenever the player has been paused or stopped for a while, or swiped from QQS.
* This will make the player not active anymore, hiding it from QQS and Keyguard. * This will make the player not active anymore, hiding it from QQS and Keyguard.
* @see MediaData.active * @see MediaData.active
*/ */
@@ -263,6 +264,7 @@ class MediaDataManager(
return return
} }
it.active = !timedOut it.active = !timedOut
if (DEBUG) Log.d(TAG, "Updating $token timedOut: $timedOut")
onMediaDataLoaded(token, token, it) onMediaDataLoaded(token, token, it)
} }
} }
@@ -283,7 +285,9 @@ class MediaDataManager(
return return
} }
Log.d(TAG, "adding track for $userId from browser: $desc") if (DEBUG) {
Log.d(TAG, "adding track for $userId from browser: $desc")
}
// Album art // Album art
var artworkBitmap = desc.iconBitmap var artworkBitmap = desc.iconBitmap
@@ -383,7 +387,7 @@ class MediaDataManager(
if (actions != null) { if (actions != null) {
for ((index, action) in actions.withIndex()) { for ((index, action) in actions.withIndex()) {
if (action.getIcon() == null) { if (action.getIcon() == null) {
Log.i(TAG, "No icon for action $index ${action.title}") if (DEBUG) Log.i(TAG, "No icon for action $index ${action.title}")
actionsToShowCollapsed.remove(index) actionsToShowCollapsed.remove(index)
continue continue
} }
@@ -427,7 +431,7 @@ class MediaDataManager(
if (!TextUtils.isEmpty(uriString)) { if (!TextUtils.isEmpty(uriString)) {
val albumArt = loadBitmapFromUri(Uri.parse(uriString)) val albumArt = loadBitmapFromUri(Uri.parse(uriString))
if (albumArt != null) { if (albumArt != null) {
Log.d(TAG, "loaded art from $uri") if (DEBUG) Log.d(TAG, "loaded art from $uri")
return albumArt return albumArt
} }
} }
@@ -514,7 +518,7 @@ class MediaDataManager(
Assert.isMainThread() Assert.isMainThread()
val removed = mediaEntries.remove(key) val removed = mediaEntries.remove(key)
if (useMediaResumption && removed?.resumeAction != null) { if (useMediaResumption && removed?.resumeAction != null) {
Log.d(TAG, "Not removing $key because resumable") if (DEBUG) Log.d(TAG, "Not removing $key because resumable")
// Move to resume key (aka package name) if that key doesn't already exist. // Move to resume key (aka package name) if that key doesn't already exist.
val resumeAction = getResumeMediaAction(removed.resumeAction!!) val resumeAction = getResumeMediaAction(removed.resumeAction!!)
val updated = removed.copy(token = null, actions = listOf(resumeAction), val updated = removed.copy(token = null, actions = listOf(resumeAction),