示例#1
0
        static void Main(string[] args)
        {
            ADBClient client = new ADBClient()
            {
                AdbPath    = Path.Combine(Environment.CurrentDirectory, "lib", "adb.exe"),
                AdbTimeout = 1000
            };

            client.StartServer();
            Console.WriteLine("Server up and running!");

            client.Devices().ForEach(x => Console.WriteLine(x));

            Directory.GetFiles("D:\\Google Drive\\Pessoal\\Imagens\\Wallpapers\\Casual Overwatch\\").ToList().ForEach(fileName =>
            {
                client.Push(fileName, "/storage/emulated/0/Pictures/Overwatch/");
            });

            client.KillServer();
            Console.WriteLine("Server' dead and gone!");

            //AdbCmdVersion client = new AdbCmdVersion()
            //{
            //    adbPath = Path.Combine(Environment.CurrentDirectory, "lib", "adb.exe")
            //};

            //client.SendCommandExposed(AdbCmdVersion.commands.StartServer, null);
            //Console.WriteLine("Server up and running!");

            //client.Devices().ForEach(device => Console.WriteLine(device));


            //Directory.GetFiles("D:\\Google Drive\\Pessoal\\Imagens\\Wallpapers\\Casual Overwatch\\").ToList().ForEach(fileName =>
            //{
            //    client.SendCommandExposed(
            //    AdbCmdVersion.commands.Push,
            //    new List<string>()
            //    {
            //        fileName,
            //        "/storage/emulated/0/Pictures/Overwatch/"
            //    });
            //});

            //client.SendCommandExposed(AdbCmdVersion.commands.KillServer, null);
            //Console.WriteLine("Server' dead and gone!");

            //client.Reboot(AdbCmdVersion.bootState.System);

            //AdbPowershellVersion client = new AdbPowershellVersion()
            //{
            //    adbPath = Path.Combine(Environment.CurrentDirectory, "lib", "adb.exe")
            //};

            //client.SendCommand(AdbPowershellVersion.commands.StartServer, null);
            //Console.WriteLine("Server up and running!");

            //Console.WriteLine(client.SendCommand(AdbPowershellVersion.commands.ListDevices, null));

            //Directory.GetFiles("D:\\Google Drive\\Pessoal\\Imagens\\Wallpapers\\Casual Overwatch\\").ToList().ForEach(fileName =>
            //{
            //    client.SendCommand(
            //    AdbPowershellVersion.commands.Push,
            //    new List<string>()
            //    {
            //        fileName,
            //        "/storage/emulated/0/Pictures/Overwatch/"
            //    });
            //    Console.WriteLine($"Sent {fileName} to device!");
            //});

            //client.SendCommand(AdbPowershellVersion.commands.KillServer, null);
            //Console.WriteLine("Server' dead and gone!");

            Console.ReadLine();
        }
 private void Flash_Click(object sender, EventArgs e)
 {
     if (FlashBoot.Checked != true && FlashRecovery.Checked != true)
     {
         MessageBox.Show("Select partition to flash", "Error");
     }
     else
     {
         if (!File.Exists(ImgPath.Text))
         {
             MessageBox.Show("Cannot find the file you have selected", "Error");
         }
         else
         {
             if (!ImgPath.Text.EndsWith(".img"))
             {
                 MessageBox.Show("The file you have selected is not correct format.\nPlease select a .img file", "Error");
             }
             else
             {
                 string filename = Path.GetFileName(ImgPath.Text);
                 FlashOptions.Enabled  = false;
                 RebootOptions.Enabled = false;
                 FlashOutput.Text      = "Flashing started.\nDo not turn off or disconnect device";
                 FlashOutput.Text      = FlashOutput.Text + "\n\nPlease wait..\nSending " + filename + " to device..";
                 Client.Execute("mkdir /sdcard/amltmp", true);
                 Client.Push(ImgPath.Text, "/sdcard/amltmp/");
                 Client.Execute("ls /sdcard/amltmp", true);
                 if (!Client.Output.Contains(filename))
                 {
                     MessageBox.Show("Failed to send file", "Error");
                 }
                 else
                 {
                     FlashOutput.Text = FlashOutput.Text + "\nFile sent";
                     if (FlashBoot.Checked == true)
                     {
                         FlashOutput.Text = FlashOutput.Text + "\n\nFlashing boot..";
                         Client.Execute("dd if=/sdcard/amltmp/" + filename + " of=/dev/block/boot", true);
                         FlashOutput.Text = FlashOutput.Text + "\n" + Client.Output;
                     }
                     else if (FlashRecovery.Checked == true)
                     {
                         FlashOutput.Text = FlashOutput.Text + "\n\nFlashing recovery..";
                         Client.Execute("dd if=/sdcard/amltmp/" + filename + " of=/dev/block/recovery", true);
                         FlashOutput.Text = FlashOutput.Text + "\n" + Client.Output;
                     }
                     else if (FlashCustom.Checked == true)
                     {
                         FlashOutput.Text = FlashOutput.Text + "\n\nFlashing custom block..";
                         Client.Execute("dd if=/sdcard/amltmp/" + filename + " of=" + FlashBlock, true);
                         FlashOutput.Text = FlashOutput.Text + "\n" + Client.Output;
                     }
                     FlashOutput.Text = FlashOutput.Text + "\n\nSUCCESS!";
                 }
                 Client.Execute("rm -rf /sdcard/amltmp", true);
             }
         }
     }
     FlashOptions.Enabled  = true;
     RebootOptions.Enabled = true;
 }