Amaan Qureshi 2 days ago committed by GitHub
commit b8c6558ca5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -279,7 +279,12 @@ class App : UninitializedApp(), libtailscale.AppContext, ViewModelStoreOwner {
TSLog.d("App", "Set Tile Ready: $ableToStartVPN") 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 val manu = Build.MANUFACTURER
var model = Build.MODEL var model = Build.MODEL
// Strip manufacturer from model. // Strip manufacturer from model.

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

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

Loading…
Cancel
Save