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
This commit is contained in:
damontecres 2025-12-14 10:07:46 -05:00 committed by GitHub
parent 43703436c5
commit ff43f8b1b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 10 deletions

View file

@ -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<Display.Mode>(originalMode)
val refreshRateMode: LiveData<Display.Mode> = _refreshRateMode

View file

@ -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

View file

@ -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<List<ItemPlayback>>(listOf())
val logcat = MutableLiveData<List<LogcatLine>>(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),