From ff43f8b1b52f15aa22f8b100f9053f52be3cbb22 Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Sun, 14 Dec 2025 10:07:46 -0500 Subject: [PATCH] Use sdk provided device name (#457) Use the SDK to get the device name since it handles older Android versions and has a fallback. This should not change the device ID or name if the device was working before this change. Maybe related to #454 --- .../wholphin/services/RefreshRateService.kt | 2 ++ .../wholphin/services/hilt/AppModule.kt | 12 ++----- .../wholphin/ui/detail/DebugPage.kt | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/services/RefreshRateService.kt b/app/src/main/java/com/github/damontecres/wholphin/services/RefreshRateService.kt index 98e2d60a..e34d2fa1 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/services/RefreshRateService.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/services/RefreshRateService.kt @@ -32,6 +32,8 @@ class RefreshRateService private val display = displayManager.getDisplay(Display.DEFAULT_DISPLAY) private val originalMode = display.mode + val displayModes get() = display.supportedModes + private val _refreshRateMode = EqualityMutableLiveData(originalMode) val refreshRateMode: LiveData = _refreshRateMode diff --git a/app/src/main/java/com/github/damontecres/wholphin/services/hilt/AppModule.kt b/app/src/main/java/com/github/damontecres/wholphin/services/hilt/AppModule.kt index 580a53ae..ad778590 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/services/hilt/AppModule.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/services/hilt/AppModule.kt @@ -1,8 +1,6 @@ package com.github.damontecres.wholphin.services.hilt -import android.annotation.SuppressLint import android.content.Context -import android.provider.Settings import androidx.datastore.core.DataStore import com.github.damontecres.wholphin.BuildConfig import com.github.damontecres.wholphin.R @@ -23,6 +21,7 @@ import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import okhttp3.OkHttpClient import org.jellyfin.sdk.Jellyfin +import org.jellyfin.sdk.android.androidDevice import org.jellyfin.sdk.api.client.util.AuthorizationHeaderBuilder import org.jellyfin.sdk.api.okhttp.OkHttpFactory import org.jellyfin.sdk.createJellyfin @@ -60,14 +59,7 @@ object AppModule { @Singleton fun deviceInfo( @ApplicationContext context: Context, - ): DeviceInfo = - DeviceInfo( - id = @SuppressLint("HardwareIds") Settings.Secure.getString( - context.contentResolver, - Settings.Secure.ANDROID_ID, - ), - name = Settings.Global.getString(context.contentResolver, Settings.Global.DEVICE_NAME), - ) + ): DeviceInfo = androidDevice(context) @StandardOkHttpClient @Provides diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/DebugPage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/DebugPage.kt index 5f771ab1..b65f8624 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/DebugPage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/DebugPage.kt @@ -36,6 +36,7 @@ import com.github.damontecres.wholphin.data.ItemPlaybackDao import com.github.damontecres.wholphin.data.ServerRepository import com.github.damontecres.wholphin.data.model.ItemPlayback import com.github.damontecres.wholphin.preferences.UserPreferences +import com.github.damontecres.wholphin.services.RefreshRateService import com.github.damontecres.wholphin.ui.launchIO import com.github.damontecres.wholphin.ui.showToast import com.github.damontecres.wholphin.util.ExceptionHandler @@ -58,6 +59,9 @@ class DebugViewModel constructor( val serverRepository: ServerRepository, val itemPlaybackDao: ItemPlaybackDao, + val refreshRateService: RefreshRateService, + val clientInfo: ClientInfo, + val deviceInfo: DeviceInfo, ) : ViewModel() { val itemPlaybacks = MutableLiveData>(listOf()) val logcat = MutableLiveData>(listOf()) @@ -220,6 +224,7 @@ fun DebugPage( listOf( "Version Name: ${pkgInfo.versionName}", "Version Code: ${pkgInfo.versionCodeLong}", + "ClientInfo: ${viewModel.clientInfo}", "Build type: ${BuildConfig.BUILD_TYPE}", "Debug enabled: ${BuildConfig.DEBUG}", "ABIs: ${Build.SUPPORTED_ABIS.toList()}", @@ -233,6 +238,32 @@ fun DebugPage( } } } + item { + Column( + verticalArrangement = Arrangement.spacedBy(8.dp), + modifier = Modifier.fillMaxWidth(), + ) { + Text( + text = "Device Information", + style = MaterialTheme.typography.displaySmall, + color = MaterialTheme.colorScheme.onSurface, + ) + + listOf( + "DeviceInfo: ${viewModel.deviceInfo}", + "Manufacturer: ${Build.MANUFACTURER}", + "Model: ${Build.MODEL}", + "Display Modes:", + *viewModel.refreshRateService.displayModes, + ).forEach { + Text( + text = it.toString(), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurface, + ) + } + } + } item { Column( verticalArrangement = Arrangement.spacedBy(8.dp),