mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-31 07:09:53 +02:00
Add logs for android auto
This commit is contained in:
parent
03aafafe1c
commit
796d6d79d4
3 changed files with 21 additions and 11 deletions
|
@ -34,6 +34,7 @@ object DeviceManager {
|
||||||
|
|
||||||
val serverConnectionConfigId get() = serverConnectionConfig?.id ?: ""
|
val serverConnectionConfigId get() = serverConnectionConfig?.id ?: ""
|
||||||
val serverConnectionConfigName get() = serverConnectionConfig?.name ?: ""
|
val serverConnectionConfigName get() = serverConnectionConfig?.name ?: ""
|
||||||
|
val serverConnectionConfigString get() = serverConnectionConfig?.name ?: "No server connection"
|
||||||
val serverAddress
|
val serverAddress
|
||||||
get() = serverConnectionConfig?.address ?: ""
|
get() = serverConnectionConfig?.address ?: ""
|
||||||
val serverUserId
|
val serverUserId
|
||||||
|
|
|
@ -136,7 +136,6 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
|
||||||
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()
|
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()
|
||||||
|
|
||||||
if (!DeviceManager.isConnectedToServer || !DeviceManager.checkConnectivity(ctx) || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
|
if (!DeviceManager.isConnectedToServer || !DeviceManager.checkConnectivity(ctx) || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
|
||||||
Log.d(tag, "Reset caches")
|
|
||||||
podcastEpisodeLibraryItemMap = mutableMapOf()
|
podcastEpisodeLibraryItemMap = mutableMapOf()
|
||||||
serverLibraries = listOf()
|
serverLibraries = listOf()
|
||||||
serverLibraryItems = mutableListOf()
|
serverLibraryItems = mutableListOf()
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.audiobookshelf.app.player
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.*
|
import android.app.*
|
||||||
|
import android.bluetooth.BluetoothClass.Device
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
@ -1106,11 +1107,12 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
// No further calls will be made to other media browsing methods.
|
// No further calls will be made to other media browsing methods.
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
Log.d(tag, "Android Auto starting $clientPackageName $clientUid")
|
AbsLogger.info(tag, "onGetRoot: clientPackageName: $clientPackageName, clientUid: $clientUid")
|
||||||
isStarted = true
|
isStarted = true
|
||||||
|
|
||||||
// Reset cache if no longer connected to server or server changed
|
// Reset cache if no longer connected to server or server changed
|
||||||
if (mediaManager.checkResetServerItems()) {
|
if (mediaManager.checkResetServerItems()) {
|
||||||
|
AbsLogger.info(tag, "onGetRoot: Reset Android Auto server items cache (${DeviceManager.serverConnectionConfigString})")
|
||||||
forceReloadingAndroidAuto = true
|
forceReloadingAndroidAuto = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,7 +1137,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
parentMediaId: String,
|
parentMediaId: String,
|
||||||
result: Result<MutableList<MediaBrowserCompat.MediaItem>>
|
result: Result<MutableList<MediaBrowserCompat.MediaItem>>
|
||||||
) {
|
) {
|
||||||
Log.d(tag, "ON LOAD CHILDREN $parentMediaId")
|
AbsLogger.info(tag, "onLoadChildren: parentMediaId: $parentMediaId (${DeviceManager.serverConnectionConfigString})")
|
||||||
|
|
||||||
result.detach()
|
result.detach()
|
||||||
|
|
||||||
|
@ -1146,7 +1148,6 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentMediaId == DOWNLOADS_ROOT) { // Load downloads
|
if (parentMediaId == DOWNLOADS_ROOT) { // Load downloads
|
||||||
|
|
||||||
val localBooks = DeviceManager.dbManager.getLocalLibraryItems("book")
|
val localBooks = DeviceManager.dbManager.getLocalLibraryItems("book")
|
||||||
val localPodcasts = DeviceManager.dbManager.getLocalLibraryItems("podcast")
|
val localPodcasts = DeviceManager.dbManager.getLocalLibraryItems("podcast")
|
||||||
val localBrowseItems: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
val localBrowseItems: MutableList<MediaBrowserCompat.MediaItem> = mutableListOf()
|
||||||
|
@ -1243,8 +1244,10 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
Log.d(tag, "Trying to initialize browseTree.")
|
Log.d(tag, "Trying to initialize browseTree.")
|
||||||
if (!this::browseTree.isInitialized || forceReloadingAndroidAuto) {
|
if (!this::browseTree.isInitialized || forceReloadingAndroidAuto) {
|
||||||
forceReloadingAndroidAuto = false
|
forceReloadingAndroidAuto = false
|
||||||
|
AbsLogger.info(tag, "onLoadChildren: Loading Android Auto items")
|
||||||
mediaManager.loadAndroidAutoItems {
|
mediaManager.loadAndroidAutoItems {
|
||||||
Log.d(tag, "android auto loaded. Starting browseTree initialize")
|
AbsLogger.info(tag, "onLoadChildren: Loaded Android Auto data, initializing browseTree")
|
||||||
|
|
||||||
browseTree =
|
browseTree =
|
||||||
BrowseTree(
|
BrowseTree(
|
||||||
this,
|
this,
|
||||||
|
@ -1260,15 +1263,21 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Log.d(tag, "browseTree initialize and android auto loaded")
|
|
||||||
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
firstLoadDone = true
|
firstLoadDone = true
|
||||||
if (mediaManager.serverLibraries.isNotEmpty()) {
|
if (mediaManager.serverLibraries.isNotEmpty()) {
|
||||||
Log.d(tag, "Starting personalization fetch")
|
AbsLogger.info(tag, "onLoadChildren: Android Auto fetching personalized data for all libraries")
|
||||||
mediaManager.populatePersonalizedDataForAllLibraries { notifyChildrenChanged("/") }
|
mediaManager.populatePersonalizedDataForAllLibraries {
|
||||||
|
AbsLogger.info(tag, "onLoadChildren: Android Auto loaded personalized data for all libraries")
|
||||||
|
notifyChildrenChanged("/")
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(tag, "Initialize inprogress items")
|
AbsLogger.info(tag, "onLoadChildren: Android Auto fetching in progress items")
|
||||||
mediaManager.initializeInProgressItems { notifyChildrenChanged("/") }
|
mediaManager.initializeInProgressItems {
|
||||||
|
AbsLogger.info(tag, "onLoadChildren: Android Auto loaded in progress items")
|
||||||
|
notifyChildrenChanged("/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1288,7 +1297,8 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
||||||
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Log.d(tag, "browseTree initialize and android auto loaded")
|
|
||||||
|
AbsLogger.info(tag, "onLoadChildren: Android auto data loaded")
|
||||||
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
|
||||||
}
|
}
|
||||||
} else if (parentMediaId == LIBRARIES_ROOT || parentMediaId == RECENTLY_ROOT) {
|
} else if (parentMediaId == LIBRARIES_ROOT || parentMediaId == RECENTLY_ROOT) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue