Beispiel #1
0
        public static void AssertResolutionIsSupported(EmulatorSize resolution)
        {
            var aspectRatio = GetAspectRatio(resolution);

            if (aspectRatio == null)
            {
                throw new Exception($"不支持的分辨率: {resolution}");
            }
        }
Beispiel #2
0
        public static AspectRatio GetAspectRatio(EmulatorSize resolution)
        {
            var simplified = resolution.Simplify();

            foreach (var ratio in SupportedAspectRatio)
            {
                if (ratio.W == simplified.Item1 && ratio.H == simplified.Item2)
                {
                    return(ratio);
                }
            }
            return(null);
        }
Beispiel #3
0
        private EmulatorSize GetResolutionDirectly()
        {
            var output = AdbShell("wm size");
            var match  = Regex.Match(output, "(\\d+)x(\\d+)");

            if (!match.Success)
            {
                throw new Exception(AheadWithName("获取模拟器分辨率失败"));
            }
            var size = new EmulatorSize(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value));

            return(size);
        }