Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion android/src/main/java/com/tailscale/ipn/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions libtailscale/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libtailscale/tailscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down