diff --git a/android/app/src/main/java/com/audiobookshelf/app/media/MediaProgressSyncer.kt b/android/app/src/main/java/com/audiobookshelf/app/media/MediaProgressSyncer.kt index d8b9baad5..369fd18c8 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/media/MediaProgressSyncer.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/media/MediaProgressSyncer.kt @@ -238,6 +238,8 @@ class MediaProgressSyncer(val playerNotificationService: PlayerNotificationServi saveLocalProgress(it) lastSyncTime = System.currentTimeMillis() + Log.d(tag, "Sync local device current serverConnectionConfigId=${DeviceManager.serverConnectionConfig?.id}") + // Local library item is linked to a server library item // Send sync to server also if connected to this server and local item belongs to this server if (hasNetworkConnection && shouldSyncServer && !it.libraryItemId.isNullOrEmpty() && it.serverConnectionConfigId != null && DeviceManager.serverConnectionConfig?.id == it.serverConnectionConfigId) { diff --git a/android/app/src/main/java/com/audiobookshelf/app/server/ApiHandler.kt b/android/app/src/main/java/com/audiobookshelf/app/server/ApiHandler.kt index de0805515..15941ac7a 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/server/ApiHandler.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/server/ApiHandler.kt @@ -1,6 +1,9 @@ package com.audiobookshelf.app.server +import android.annotation.SuppressLint import android.content.Context +import android.os.Build +import android.provider.Settings import android.util.Log import com.audiobookshelf.app.data.* import com.audiobookshelf.app.device.DeviceManager @@ -31,7 +34,7 @@ class ApiHandler(var ctx:Context) { private var pingClient = OkHttpClient.Builder().callTimeout(3, TimeUnit.SECONDS).build() private var jacksonMapper = jacksonObjectMapper().enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()) - data class LocalSessionsSyncRequestPayload(val sessions:List) + data class LocalSessionsSyncRequestPayload(val sessions:List, val deviceInfo:DeviceInfo) @JsonIgnoreProperties(ignoreUnknown = true) data class LocalSessionSyncResult(val id:String, val success:Boolean, val progressSynced:Boolean?, val error:String?) data class LocalSessionsSyncResponsePayload(val results:List) @@ -322,7 +325,11 @@ class ApiHandler(var ctx:Context) { } fun sendSyncLocalSessions(playbackSessions:List, cb: (Boolean, String?) -> Unit) { - val payload = JSObject(jacksonMapper.writeValueAsString(LocalSessionsSyncRequestPayload(playbackSessions))) + @SuppressLint("HardwareIds") + val deviceId = Settings.Secure.getString(ctx.contentResolver, Settings.Secure.ANDROID_ID) + val deviceInfo = DeviceInfo(deviceId, Build.MANUFACTURER, Build.MODEL, Build.VERSION.SDK_INT, Build.VERSION.RELEASE) + + val payload = JSObject(jacksonMapper.writeValueAsString(LocalSessionsSyncRequestPayload(playbackSessions, deviceInfo))) Log.d(tag, "Sending ${playbackSessions.size} saved local playback sessions to server") postRequest("/api/session/local-all", payload, null) { if (!it.getString("error").isNullOrEmpty()) { diff --git a/pages/item/_id/index.vue b/pages/item/_id/index.vue index 54901d0b5..6031fcbe5 100644 --- a/pages/item/_id/index.vue +++ b/pages/item/_id/index.vue @@ -191,7 +191,6 @@ export default { // Filter by downloaded when redirecting from the local copy queryParams.set('episodefilter', 'downloaded') } - console.log('Redirecting to server library item page with queryparams', queryParams.toString()) return redirect(`/item/${libraryItem.libraryItemId}?${queryParams.toString()}`) } } else if (!store.state.user.serverConnectionConfig) {