fix: use Override size if existed, otherwise use Physical size

This commit is contained in:
buyuxiang
2023-07-28 13:43:05 +08:00
parent e4f5f8e416
commit c05538a826

View File

@@ -62,14 +62,20 @@ func (ad *adbDriver) WindowSize() (size Size, err error) {
return size, errors.Wrap(err, "get window size failed with adb") return size, errors.Wrap(err, "get window size failed with adb")
} }
// output may contain both Physical and Override size // output may contain both Physical and Override size, use Override if existed
// Physical size: 1080x2340 // Physical size: 1080x2340
// Override size: 1080x2220 // Override size: 1080x2220
matchedSizeType := "Physical"
if strings.Contains(output, "Override") {
matchedSizeType = "Override"
}
var resolution string var resolution string
sizeList := strings.Split(output, "\n") sizeList := strings.Split(output, "\n")
log.Info().Msgf("window size: %v", sizeList) log.Info().Msgf("window size: %v", sizeList)
for _, size := range sizeList { for _, size := range sizeList {
if strings.Contains(size, "Physical") { if strings.Contains(size, matchedSizeType) {
resolution = strings.Split(size, ": ")[1] resolution = strings.Split(size, ": ")[1]
// 1080x2340 // 1080x2340
ss := strings.Split(resolution, "x") ss := strings.Split(resolution, "x")
@@ -392,6 +398,7 @@ func (ad *adbDriver) StopCaptureLog() (result interface{}, err error) {
return "", err return "", err
} }
content := ad.logcat.logBuffer.String() content := ad.logcat.logBuffer.String()
log.Info().Str("logcat content", content).Msg("display logcat content")
return ConvertPoints(content), nil return ConvertPoints(content), nil
} }