File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -706,6 +706,13 @@ open class UninitializedApp : Application() {
706706 }
707707
708708 fun getIsClientLoggingEnabled (): Boolean {
709+
710+ // Force client logging to be enabled, when the device is managed by MDM
711+ // Later this could become a dedicated MDMSetting / restriction.
712+ if (MDMSettings .isMDMConfigured) {
713+ return true
714+ }
715+
709716 return getUnencryptedPrefs().getBoolean(IS_CLIENT_LOGGING_ENABLED_KEY , true )
710717 }
711718
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ object MDMSettings {
2222 // MDM restriction keys
2323 const val KEY_HARDWARE_ATTESTATION = " HardwareAttestation"
2424
25+ // We default this to true, so that stricter behavior is used during initialization,
26+ // prior to receiving MDM restrictions.
27+ var isMDMConfigured = true
28+ private set
29+
2530 val forceEnabled = BooleanMDMSetting (" ForceEnabled" , " Force Enabled Connection Toggle" )
2631
2732 // Handled on the backed
@@ -130,6 +135,7 @@ object MDMSettings {
130135 fun loadFrom (preferences : Lazy <SharedPreferences >, restrictionsManager : RestrictionsManager ? ) {
131136 val bundle = restrictionsManager?.applicationRestrictions
132137 allSettings.forEach { it.setFrom(bundle, preferences) }
138+ isMDMConfigured = bundle?.isEmpty == true
133139 }
134140
135141 fun update (app : App , restrictionsManager : RestrictionsManager ? ) {
Original file line number Diff line number Diff line change @@ -16,7 +16,16 @@ class MDMSettingsChangedReceiver : BroadcastReceiver() {
1616 TSLog .d(" syspolicy" , " MDM settings changed" )
1717 val restrictionsManager =
1818 context?.getSystemService(Context .RESTRICTIONS_SERVICE ) as RestrictionsManager
19+
20+ val previouslyIsMDMEnabled = MDMSettings .isMDMConfigured
21+
1922 MDMSettings .update(App .get(), restrictionsManager)
23+
24+ if (MDMSettings .isMDMConfigured && ! previouslyIsMDMEnabled) {
25+ // async MDM settings updated from disabled -> enabled. restart to ensure
26+ // correctly applied (particularly forcing client logs on).
27+ // TODO: actually restart
28+ }
2029 }
2130 }
2231}
Original file line number Diff line number Diff line change @@ -111,8 +111,13 @@ fun SettingsView(
111111 Lists .ItemDivider ()
112112 Setting .Switch (
113113 R .string.client_remote_logging_enabled,
114- subtitle = stringResource(R .string.client_remote_logging_enabled_subtitle),
114+ subtitle =
115+ stringResource(
116+ if (MDMSettings .isMDMConfigured)
117+ R .string.client_remote_logging_enabled_subtitle_mdm
118+ else R .string.client_remote_logging_enabled_subtitle),
115119 isOn = isClientRemoteLoggingEnabled,
120+ enabled = ! MDMSettings .isMDMConfigured,
116121 onToggle = { viewModel.toggleIsClientRemoteLoggingEnabled() })
117122
118123 if (! AndroidTVUtil .isAndroidTV()) {
Original file line number Diff line number Diff line change 356356 <string name =" subnet_routing" >Subnet routing</string >
357357 <string name =" client_remote_logging_enabled" >Remote client logging</string >
358358 <string name =" client_remote_logging_enabled_subtitle" >Whether debug logs are uploaded to Tailscale support. When disabled no support or network flow logs.\nChanges require restarting the app to take effect.</string >
359+ <string name =" client_remote_logging_enabled_subtitle_mdm" >Client logging is always enabled for devices under remote management.</string >
359360 <string name =" specifies_a_device_name_to_be_used_instead_of_the_automatic_default" >Specifies a device name to be used instead of the automatic default.</string >
360361 <string name =" hostname" >Hostname</string >
361362 <string name =" failed_to_save" >Failed to save</string >
You can’t perform that action at this time.
0 commit comments