fix: use the user-set device name before falling back to the device model

Signed-off-by: Amaan Qureshi <git@amaanq.com>
pull/716/head
Amaan Qureshi 2 weeks ago
parent 6f3d1881a8
commit 00c38f899b
No known key found for this signature in database

@ -279,7 +279,12 @@ class App : UninitializedApp(), libtailscale.AppContext, ViewModelStoreOwner {
TSLog.d("App", "Set Tile Ready: $ableToStartVPN")
}
override fun getModelName(): String {
override fun getDeviceName(): String {
// Try user-defined device name first
android.provider.Settings.Global.getString(contentResolver, android.provider.Settings.Global.DEVICE_NAME)
?.let { return it }
// Otherwise fallback to manufacturer + model
val manu = Build.MANUFACTURER
var model = Build.MODEL
// Strip manufacturer from model.

@ -36,8 +36,8 @@ type AppContext interface {
// GetOSVersion gets the Android version.
GetOSVersion() (string, error)
// GetModelName gets the Android device's model name.
GetModelName() (string, error)
// GetDeviceName gets the Android device's user-set name, or hardware model name as a fallback.
GetDeviceName() (string, error)
// GetInstallSource gets information about how the app was installed or updated.
GetInstallSource() string

@ -91,7 +91,7 @@ func (a *App) osVersion() string {
// modelName return the MANUFACTURER + MODEL from
// android.os.Build.
func (a *App) modelName() string {
model, err := a.appCtx.GetModelName()
model, err := a.appCtx.GetDeviceName()
if err != nil {
panic(err)
}

Loading…
Cancel
Save