mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(sidecar): implement ForegroundApp via adb for android
This commit is contained in:
1 parent
09528d84e6
commit
dea39d3bac
2 files changed
+17
No files matched your search
@@ -8,6 +8,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
|
"github.com/priyanshujain/sanderling/internal/android"
|
||||||
"github.com/priyanshujain/sanderling/internal/driver"
|
"github.com/priyanshujain/sanderling/internal/driver"
|
||||||
driverpb "github.com/priyanshujain/sanderling/proto/driverpb"
|
driverpb "github.com/priyanshujain/sanderling/proto/driverpb"
|
||||||
)
|
)
|
||||||
@@ -15,6 +16,21 @@ import (
|
|||||||
type Client struct {
|
type Client struct {
|
||||||
connection *grpc.ClientConn
|
connection *grpc.ClientConn
|
||||||
stub driverpb.DriverClient
|
stub driverpb.DriverClient
|
||||||
|
platform string
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPlatform records the target platform so capability methods (e.g.
|
||||||
|
// ForegroundApp) can pick the right backend. The caller sets this right after
|
||||||
|
// Dial.
|
||||||
|
func (c *Client) SetPlatform(platform string) { c.platform = platform }
|
||||||
|
|
||||||
|
// ForegroundApp reports the foreground package. Only Android is supported (via
|
||||||
|
// adb); other platforms return "" so the runner skips app-scope enforcement.
|
||||||
|
func (c *Client) ForegroundApp(ctx context.Context) (string, error) {
|
||||||
|
if c.platform != "android" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return android.ForegroundPackage(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dial connects to the sidecar gRPC server at the given address.
|
// Dial connects to the sidecar gRPC server at the given address.
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver
|
|||||||
_ = sidecarCommand.Process.Kill()
|
_ = sidecarCommand.Process.Kill()
|
||||||
return nil, nil, fmt.Errorf("dial sidecar: %w", err)
|
return nil, nil, fmt.Errorf("dial sidecar: %w", err)
|
||||||
}
|
}
|
||||||
|
driverClient.SetPlatform(options.Platform)
|
||||||
// WaitForHealth confirms the gRPC sidecar is up. For iOS, the WDA warmup
|
// WaitForHealth confirms the gRPC sidecar is up. For iOS, the WDA warmup
|
||||||
// (absorbing the XCUITest startup race) runs inside IosDriverBackend.init
|
// (absorbing the XCUITest startup race) runs inside IosDriverBackend.init
|
||||||
// in the sidecar - no additional sleep needed here.
|
// in the sidecar - no additional sleep needed here.
|
||||||
|
|||||||
Reference in new issue
Block a user