Skip to content

Commit 00c38f8

Browse files
committed
fix: use the user-set device name before falling back to the device model
Signed-off-by: Amaan Qureshi <[email protected]>
1 parent 6f3d188 commit 00c38f8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

android/src/main/java/com/tailscale/ipn/App.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,12 @@ class App : UninitializedApp(), libtailscale.AppContext, ViewModelStoreOwner {
279279
TSLog.d("App", "Set Tile Ready: $ableToStartVPN")
280280
}
281281

282-
override fun getModelName(): String {
282+
override fun getDeviceName(): String {
283+
// Try user-defined device name first
284+
android.provider.Settings.Global.getString(contentResolver, android.provider.Settings.Global.DEVICE_NAME)
285+
?.let { return it }
286+
287+
// Otherwise fallback to manufacturer + model
283288
val manu = Build.MANUFACTURER
284289
var model = Build.MODEL
285290
// Strip manufacturer from model.

libtailscale/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ type AppContext interface {
3636
// GetOSVersion gets the Android version.
3737
GetOSVersion() (string, error)
3838

39-
// GetModelName gets the Android device's model name.
40-
GetModelName() (string, error)
39+
// GetDeviceName gets the Android device's user-set name, or hardware model name as a fallback.
40+
GetDeviceName() (string, error)
4141

4242
// GetInstallSource gets information about how the app was installed or updated.
4343
GetInstallSource() string

libtailscale/tailscale.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (a *App) osVersion() string {
9191
// modelName return the MANUFACTURER + MODEL from
9292
// android.os.Build.
9393
func (a *App) modelName() string {
94-
model, err := a.appCtx.GetModelName()
94+
model, err := a.appCtx.GetDeviceName()
9595
if err != nil {
9696
panic(err)
9797
}

0 commit comments

Comments
 (0)