Skip to content

Commit

Permalink
fix: 换用一个看起来靠谱一点分辨率查询方法
Browse files Browse the repository at this point in the history
fix #257
  • Loading branch information
MistEO committed Jun 13, 2024
1 parent 06c7148 commit f00ea1c
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions source/MaaAdbControlUnit/General/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool DeviceInfo::parse(const json::value& config)
"-s",
"{ADB_SERIAL}",
"shell",
"dumpsys window displays | grep -o -E cur=+[^\\ ]+ | grep -o -E [0-9]+",
"dumpsys window displays | grep DisplayFrames | grep -o -E [0-9]+",
};
static const json::array kDefaultOrientationArgv = {
"{ADB}",
Expand Down Expand Up @@ -68,29 +68,6 @@ std::optional<std::pair<int, int>> DeviceInfo::request_resolution()
std::istringstream iss(output_opt.value());
iss >> width >> height;

auto orientation_opt = request_orientation();
if (!orientation_opt) {
LogWarn << "failed to request_orientation" << VAR(width) << VAR(height);
return std::make_pair(width, height);
}

int orientation = *orientation_opt;
switch (orientation) {
case 0:
case 2:
std::tie(height, width) = std::minmax({ width, height });
LogInfo << "landscape" << VAR(orientation) << VAR(width) << VAR(height);
break;
case 1:
case 3:
std::tie(width, height) = std::minmax({ width, height });
LogInfo << "portrait" << VAR(orientation) << VAR(width) << VAR(height);
break;
default:
LogWarn << "unknown" << VAR(orientation) << VAR(width) << VAR(height);
break;
}

return std::make_pair(width, height);
}

Expand Down

0 comments on commit f00ea1c

Please sign in to comment.