-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
5 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Tailscale Inc & AUTHORS | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
package libtailscale | ||
|
||
import ( | ||
"log" | ||
|
||
"tailscale.com/util/syspolicy" | ||
) | ||
|
||
// 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 { | ||
a *App | ||
} | ||
|
||
func (h androidHandler) ReadString(key string) (string, error) { | ||
if key == "" { | ||
return "", syspolicy.ErrNoSuchKey | ||
} | ||
retVal, err := h.a.appCtx.GetSyspolicyStringValue(key) | ||
if err != nil { | ||
log.Printf("syspolicy: failed to get string value via gomobile: %v", err) | ||
} | ||
return retVal, err | ||
} | ||
|
||
func (h androidHandler) ReadBoolean(key string) (bool, error) { | ||
if key == "" { | ||
return false, syspolicy.ErrNoSuchKey | ||
} | ||
retVal, err := h.a.appCtx.GetSyspolicyBooleanValue(key) | ||
if err != nil { | ||
log.Printf("syspolicy: failed to get bool value via gomobile: %v", err) | ||
} | ||
return retVal, err | ||
} | ||
|
||
func (h androidHandler) ReadUInt64(key string) (uint64, error) { | ||
if key == "" { | ||
return 0, syspolicy.ErrNoSuchKey | ||
} | ||
// TODO(angott): drop ReadUInt64 everywhere. We are not using it. | ||
log.Fatalf("ReadUInt64 is not implemented on Android") | ||
return 0, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters