Example #1
0
 /// <summary>
 /// 根据设备状态,判断使用adb还是fastboot执行命令
 /// 当设备处于Fastboot状态时,使用fastboot执行,否则用adb执行
 /// </summary>
 /// <param name="device"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static CommandResult Auto(this IDevice device, string command)
 {
     if (device.State == DeviceState.Fastboot)
     {
         return(device.Fastboot(command));
     }
     else
     {
         return(device.Adb(command));
     }
 }
 /// <summary>
 /// 根据设备状态,判断使用adb还是fastboot执行命令
 /// 当设备处于Fastboot状态时,使用fastboot执行,否则用adb执行
 /// </summary>
 /// <param name="device"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static Tuple <Output, int> Auto(this IDevice device, string command)
 {
     if (device.State == DeviceState.Fastboot)
     {
         return(device.Fastboot(command));
     }
     else
     {
         return(device.Adb(command));
     }
 }
 /// <summary>
 /// 重启设备到9008模式
 /// </summary>
 /// <param name="device"></param>
 public static void Reboot29008(this IDevice device)
 {
     device.ThrowIfNotAlive();
     if (device.State == DeviceState.Fastboot)
     {
         device.Fastboot("oem edl").ThrowIfExitCodeNotEqualsZero();
     }
     else
     {
         device.Adb("reboot edl").ThrowIfExitCodeNotEqualsZero();
     }
 }
 /// <summary>
 /// 重启设备到recovery模式
 /// </summary>
 /// <param name="device"></param>
 public static void Reboot2Recovery(this IDevice device)
 {
     device.ThrowIfNotAlive();
     if (device.State != DeviceState.Fastboot)
     {
         device.Adb("reboot recovery").ThrowIfExitCodeNotEqualsZero();
     }
     else
     {
         throw new Exception("cant restart to fastboot when device on fastboot state");
     }
 }
 /// <summary>
 /// 重启设备到系统
 /// </summary>
 /// <param name="device"></param>
 public static void Reboot2System(this IDevice device)
 {
     device.ThrowIfNotAlive();
     if (device.State == DeviceState.Fastboot)
     {
         using var executor = new HestExecutor(BasicBooter.CommandProcedureManager);
         new FastbootFixedExecutor(device, executor, "reboot")
         {
             Timeout = 1000
         }
         .Execute().ThrowIfExitCodeIsNotZero();
         //device.Fastboot("reboot").ThrowIfExitCodeNotEqualsZero();
     }
     else
     {
         device.Adb("reboot").ThrowIfExitCodeNotEqualsZero();
     }
 }
Example #6
0
 /// <summary>
 /// Pull文件
 /// </summary>
 /// <param name="device"></param>
 /// <param name="fileOnDevice"></param>
 /// <param name="savePath"></param>
 public static void Pull(this IDevice device, string fileOnDevice, string savePath)
 {
     device.Adb($"pull {fileOnDevice} {savePath}")
     .ThrowIfExitCodeNotEqualsZero();
 }