Ejemplo n.º 1
0
        /// <summary>
        /// 异步重启(如果ADB或手机卡到爆,那么这个函数就有作用了)
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="option"></param>
        /// <param name="callback"></param>
        public async static void RebootAsync(DeviceBasicInfo dev, RebootOptions option = RebootOptions.System, Action callback = null)
        {
            await Task.Run(() =>
            {
                Reboot(dev, option);
            });

            callback?.Invoke();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 重启手机
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="option"></param>
        public static void Reboot(DeviceBasicInfo dev, RebootOptions option)
        {
            if (dev.State != DeviceState.Fastboot && (int)dev.State >= 1)
            {
                switch (option)
                {
                case RebootOptions.System:
                    executer.Execute(Command.MakeForAdb(dev.Serial, "reboot"));
                    break;

                case RebootOptions.Recovery:
                    executer.Execute(Command.MakeForAdb(dev.Serial, "reboot recovery"));
                    break;

                case RebootOptions.Fastboot:
                    executer.Execute(Command.MakeForAdb(dev.Serial, "reboot-bootloader"));
                    break;

                case RebootOptions.Snapdragon9008:
                    executer.Execute(Command.MakeForAdb(dev.Serial, "reboot edl"));
                    break;

                case RebootOptions.Sideload:
                    executer.Execute(Command.MakeForAdb(dev.Serial, "reboot sideload"));
                    break;
                }
            }
            else if (dev.State == DeviceState.Fastboot)
            {
                switch (option)
                {
                case RebootOptions.System:
                    executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot"));
                    break;

                case RebootOptions.Fastboot:
                    executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot-bootloader"));
                    break;

                case RebootOptions.Snapdragon9008:
                    executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot-edl"));
                    break;
                }
            }
        }