@@ -10,45 +10,46 @@ import (
1010
1111 "tailscale.com/util/set"
1212 "tailscale.com/util/syspolicy"
13+ "tailscale.com/util/syspolicy/pkey"
1314)
1415
15- // syspolicyHandler is a syspolicy handler for the Android version of the Tailscale client,
16+ // syspolicyStore is a syspolicy Store for the Android version of the Tailscale client,
1617// which lets the main networking code read values set via the Android RestrictionsManager.
17- type syspolicyHandler struct {
18+ type syspolicyStore struct {
1819 a * App
1920 mu sync.RWMutex
2021 cbs set.HandleSet [func ()]
2122}
2223
23- func (h * syspolicyHandler ) ReadString (key string ) (string , error ) {
24+ func (h * syspolicyStore ) ReadString (key pkey. Key ) (string , error ) {
2425 if key == "" {
2526 return "" , syspolicy .ErrNoSuchKey
2627 }
27- retVal , err := h .a .appCtx .GetSyspolicyStringValue (key )
28+ retVal , err := h .a .appCtx .GetSyspolicyStringValue (string ( key ) )
2829 return retVal , translateHandlerError (err )
2930}
3031
31- func (h * syspolicyHandler ) ReadBoolean (key string ) (bool , error ) {
32+ func (h * syspolicyStore ) ReadBoolean (key pkey. Key ) (bool , error ) {
3233 if key == "" {
3334 return false , syspolicy .ErrNoSuchKey
3435 }
35- retVal , err := h .a .appCtx .GetSyspolicyBooleanValue (key )
36+ retVal , err := h .a .appCtx .GetSyspolicyBooleanValue (string ( key ) )
3637 return retVal , translateHandlerError (err )
3738}
3839
39- func (h * syspolicyHandler ) ReadUInt64 (key string ) (uint64 , error ) {
40+ func (h * syspolicyStore ) ReadUInt64 (key pkey. Key ) (uint64 , error ) {
4041 if key == "" {
4142 return 0 , syspolicy .ErrNoSuchKey
4243 }
4344 // We don't have any UInt64 policy settings as of 2024-08-06.
4445 return 0 , errors .New ("ReadUInt64 is not implemented on Android" )
4546}
4647
47- func (h * syspolicyHandler ) ReadStringArray (key string ) ([]string , error ) {
48+ func (h * syspolicyStore ) ReadStringArray (key pkey. Key ) ([]string , error ) {
4849 if key == "" {
4950 return nil , syspolicy .ErrNoSuchKey
5051 }
51- retVal , err := h .a .appCtx .GetSyspolicyStringArrayJSONValue (key )
52+ retVal , err := h .a .appCtx .GetSyspolicyStringArrayJSONValue (string ( key ) )
5253 if err := translateHandlerError (err ); err != nil {
5354 return nil , err
5455 }
@@ -63,7 +64,7 @@ func (h *syspolicyHandler) ReadStringArray(key string) ([]string, error) {
6364 return arr , err
6465}
6566
66- func (h * syspolicyHandler ) RegisterChangeCallback (cb func ()) (unregister func (), err error ) {
67+ func (h * syspolicyStore ) RegisterChangeCallback (cb func ()) (unregister func (), err error ) {
6768 h .mu .Lock ()
6869 handle := h .cbs .Add (cb )
6970 h .mu .Unlock ()
@@ -74,7 +75,7 @@ func (h *syspolicyHandler) RegisterChangeCallback(cb func()) (unregister func(),
7475 }, nil
7576}
7677
77- func (h * syspolicyHandler ) notifyChanged () {
78+ func (h * syspolicyStore ) notifyChanged () {
7879 h .mu .RLock ()
7980 for _ , cb := range h .cbs {
8081 go cb ()
0 commit comments