diff --git a/hostinfo/hostinfo.go b/hostinfo/hostinfo.go index 3175a4a0a..9b9eb8959 100644 --- a/hostinfo/hostinfo.go +++ b/hostinfo/hostinfo.go @@ -48,6 +48,9 @@ func getOSVersion() string { } func packageType() string { + if v, _ := packagingType.Load().(string); v != "" { + return v + } switch runtime.GOOS { case "windows": if _, err := os.Stat(`C:\ProgramData\chocolatey\lib\tailscale`); err == nil { @@ -95,6 +98,7 @@ func GetEnvType() EnvType { var ( deviceModelAtomic atomic.Value // of string osVersionAtomic atomic.Value // of string + packagingType atomic.Value // of string ) // SetDeviceModel sets the device model for use in Hostinfo updates. @@ -103,6 +107,11 @@ func SetDeviceModel(model string) { deviceModelAtomic.Store(model) } // SetOSVersion sets the OS version. func SetOSVersion(v string) { osVersionAtomic.Store(v) } +// SetPackage sets the packaging type for the app. +// This is currently (2021-10-05) only used by Android, +// set to "nogoogle" for the F-Droid build. +func SetPackage(v string) { packagingType.Store(v) } + func deviceModel() string { s, _ := deviceModelAtomic.Load().(string) return s diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 914f4d7f2..9b3c6ccc0 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -2277,20 +2277,8 @@ func applyPrefsToHostinfo(hi *tailcfg.Hostinfo, prefs *ipn.Prefs) { } if v := prefs.OSVersion; v != "" && hi.OSVersion == "" { hi.OSVersion = v - - // The Android app annotates when Google Play Services - // aren't available by tacking on a string to the - // OSVersion. Promote that to the Hostinfo.Package - // field instead, rather than adding a new pref, as - // this applyPrefsToHostinfo mechanism is mostly - // abused currently. TODO(bradfitz): instead let - // frontends update Hostinfo, without using Prefs. - if runtime.GOOS == "android" && strings.HasSuffix(v, " [nogoogle]") { - hi.Package = "nogoogle" - hi.OSVersion = strings.TrimSuffix(v, " [nogoogle]") - } } - if m := prefs.DeviceModel; m != "" { + if m := prefs.DeviceModel; m != "" && hi.DeviceModel == "" { hi.DeviceModel = m } hi.RoutableIPs = append(prefs.AdvertiseRoutes[:0:0], prefs.AdvertiseRoutes...)