Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: port syspolicy handler code to new app #304

Merged
merged 2 commits into from
Apr 10, 2024
Merged

ui: port syspolicy handler code to new app #304

merged 2 commits into from
Apr 10, 2024

Conversation

kari-ts
Copy link
Collaborator

@kari-ts kari-ts commented Apr 10, 2024

port over #199 from cmd/tailscale and legacy_android to libtailscale and android/

fix issue where we were creating MDMSettings every time we were retrieving policy settings

Updates tailscale/corp#18202

Copy link
Member

@barnstar barnstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but @agottardo should take a look as well.

}
}

fun keyExists(key: String): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the one line method here isn't really needed (unless it's called by something else I'm not seeing.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using this in App.getSyspolicyStringValue - MDMSettings has all the MDMSettings we've created, and we want to check to see if there is one with the key we're given

import com.tailscale.ipn.App
import com.tailscale.ipn.ui.util.set
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

abstract class MDMSetting<T>(defaultValue: T, val key: String, val localizedTitle: String) {
// Don't keep track of the key if shouldRegisterKey is false - shouldRegisterKey should be false when creating an MDMSetting for retrieving a setting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that all initializer calls in MDMSettings.kt need to be updated with shouldRegisterKey: false?. The default value here is true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, they should register keys. when we are checking to see if there exists an MDMSetting for a certain key, shouldRegisterKey should be false. I updated the comment to hopefully be a little clearer


// androidHandler is a syspolicy handler for the Android version of the Tailscale client,
// which lets the main networking code read values set via the Android RestrictionsManager.
type androidHandler struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since this isn't in its own package, a more specific name would be good, like syspolicyHandler.

port over #199 from cmd/tailscale and legacy_android to libtailscale and android/

Updates tailscale/corp#18202

Signed-off-by: kari-ts <kari@tailscale.com>
Copy link
Contributor

@oxtoacart oxtoacart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a simpler way to do it.

Updates tailscale/corp#18202

Signed-off-by: Percy Wegmann <percy@tailscale.com>
@kari-ts kari-ts merged commit 6a00880 into main Apr 10, 2024
4 checks passed
@kari-ts kari-ts deleted the kari/syspol branch April 25, 2024 21:43
kari-ts added a commit that referenced this pull request Apr 25, 2024
* ui: port syspolicy handler code to new app

port over #199 from cmd/tailscale and legacy_android to libtailscale and android/

Updates tailscale/corp#18202

Signed-off-by: kari-ts <kari@tailscale.com>

* android: PR suggestions for syspolicyHandler (#308)

Updates tailscale/corp#18202

Signed-off-by: Percy Wegmann <percy@tailscale.com>

---------

Signed-off-by: kari-ts <kari@tailscale.com>
Signed-off-by: Percy Wegmann <percy@tailscale.com>
Co-authored-by: Percy Wegmann <percy@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants